Service files for factory reset change - clear instead of delete
This commit adds a new service file to the build which will clear the
contents of a specified UBI volume. It's intended as the backend for the
host factory reset.
Additionally, the service file obmc-flash-bios-ubiumount-prsv.service is
removed. This file removes the volume pnor-prsv. Its only use case - the
factory reset - is changing in this issue, openbmc/openbmc#2322, to
clear that volume instead of deleting it, so there's no reason to keep
the service file around anymore.
Change-Id: I577291e3511bf5234ffb87084a082255dac3dbae
Signed-off-by: Michael Tritz <mtritz@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 ce1fbb3..4d2c4b8 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
@@ -45,10 +45,10 @@
SYSTEMD_SERVICE_${PN} += " \
obmc-flash-bios-ubiattach.service \
obmc-flash-bios-ubimount@.service \
- obmc-flash-bios-ubiumount-prsv.service \
obmc-flash-bios-ubiumount-ro@.service \
obmc-flash-bios-ubiumount-rw@.service \
obmc-flash-bios-ubipatch.service \
obmc-flash-bios-ubiremount.service \
obmc-flash-bios-updatesymlinks.service \
+ obmc-flash-bios-ubiclear@.service \
"
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios
index f82e6fb..948c6ec 100644
--- a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios
+++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios
@@ -263,6 +263,13 @@
fi
}
+clear_ubi() {
+ mountdir="/media/${name}"
+ if is_mounted "${name}"; then
+ rm -rf $mountdir/..?* $mountdir/.[!.]* $mountdir/*
+ fi
+}
+
case "$1" in
ubiattach)
attach_ubi
@@ -286,6 +293,10 @@
updatesymlinks)
update_symlinks
;;
+ ubiclear)
+ name="$2"
+ clear_ubi
+ ;;
*)
echo "Invalid argument"
exit 1
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-ubiclear@.service b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-ubiclear@.service
new file mode 100644
index 0000000..b84035f
--- /dev/null
+++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-ubiclear@.service
@@ -0,0 +1,8 @@
+[Unit]
+Description=Clear UBIFS volume %i
+
+[Service]
+Type=oneshot
+RemainAfterExit=no
+ExecStart=/usr/bin/env obmc-flash-bios ubiclear %i
+SyslogIdentifier=obmc-flash-bios
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
deleted file mode 100644
index 1c3939e..0000000
--- a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-ubiumount-prsv.service
+++ /dev/null
@@ -1,10 +0,0 @@
-[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=/usr/bin/env obmc-flash-bios ubiumount pnor-prsv
-SyslogIdentifier=obmc-flash-bios