Create service files to remove read-write UBI volumes
Perform the opposite operations in reverse order as the
ubimount service file. Create two service files to remove
the rw UBI volumes:
A template service file that takes the version id and
removes the pnor-rw-<versionid> volumes. This can be
used by the Object.Delete interface implementation
to remove a software version.
A service file that removes the single pnor-prsv volume.
This and the template service file can be called by
the FactoryReset interface implementation to remove
all read-write volumes.
Closes openbmc/openbmc#1615
Change-Id: I079eb0fdb7e444434f57abf0421f55864dfb9703
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager.bb b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager.bb
index 3201c69..1b426d0 100644
--- a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager.bb
+++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager.bb
@@ -28,6 +28,8 @@
SYSTEMD_SERVICE_${PN} += " \
obmc-flash-bios-ubiattach.service \
obmc-flash-bios-ubimount@.service \
+ obmc-flash-bios-ubiumount-prsv.service \
+ obmc-flash-bios-ubiumount-rw@.service \
obmc-flash-bios-squashfsmount@.service \
"
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-ubiumount-prsv.service b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-ubiumount-prsv.service
new file mode 100644
index 0000000..7dcf1b2
--- /dev/null
+++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-ubiumount-prsv.service
@@ -0,0 +1,15 @@
+[Unit]
+Description=Remove UBIFS volume pnor-prsv
+Wants=obmc-flash-bios-ubiattach.service
+After=obmc-flash-bios-ubiattach.service
+
+[Service]
+Type=oneshot
+RemainAfterExit=no
+ExecStart=/bin/sh -c 'if grep -q pnor-prsv /proc/mounts; then \
+ umount /media/pnor-prsv; fi; \
+ prsv_ubi=`ubinfo -d 0 -a | grep pnor-prsv`; \
+ if [ ! -z "$prsv_ubi" ]; then \
+ {sbindir}/ubirmvol /dev/ubi0 -N pnor-prsv; fi; \
+ if [ -d "/media/pnor-prsv" ]; then \
+ rm -r /media/pnor-prsv; fi;'
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-ubiumount-rw@.service b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-ubiumount-rw@.service
new file mode 100644
index 0000000..b272402
--- /dev/null
+++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-ubiumount-rw@.service
@@ -0,0 +1,16 @@
+[Unit]
+Description=Remove UBIFS volume pnor-rw-%I
+Wants=obmc-flash-bios-ubiattach.service
+After=obmc-flash-bios-ubiattach.service
+
+[Service]
+Type=oneshot
+RemainAfterExit=no
+ExecStart=/bin/sh -c 'rw=pnor-rw-%i; \
+ if grep -q $rw /proc/mounts; then \
+ umount /media/$rw; fi; \
+ rw_ubi=`ubinfo -d 0 -a | grep $rw`; \
+ if [ ! -z "$rw_ubi" ]; then \
+ {sbindir}/ubirmvol /dev/ubi0 -N $rw; fi; \
+ if [ -d "/media/$rw" ]; then \
+ rm -r /media/$rw; fi;'