Host reset: Change deletes to clears
This commit changes the behavior of the host factory reset to
clear affected read-write and preserved volumes, rather than
deleting them.
Resolves openbmc/openbmc#2322
Change-Id: Ib08f6ef039e32034ce18d80ce82e8a75021f81c2
Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
diff --git a/item_updater.cpp b/item_updater.cpp
index 7692293..5ef6bd0 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -318,28 +318,43 @@
bus.call_noreply(method);
}
-void ItemUpdater::removePreservedPartition()
+void ItemUpdater::reset()
{
- // Remove the preserved partition.
+ for (const auto& it : activations)
+ {
+ auto serviceFile = "obmc-flash-bios-ubiclear@pnor-rw-" + it.first +
+ ".service";
+
+ // Clear the read-write partitions.
+ auto method = bus.new_method_call(
+ SYSTEMD_BUSNAME,
+ SYSTEMD_PATH,
+ SYSTEMD_INTERFACE,
+ "StartUnit");
+ method.append(serviceFile, "replace");
+ auto reply = bus.call(method);
+
+ if (reply.is_method_error())
+ {
+ elog<InternalFailure>();
+ }
+
+ removeFile(it.first);
+ }
+ // Clear the preserved partition.
auto method = bus.new_method_call(
SYSTEMD_BUSNAME,
SYSTEMD_PATH,
SYSTEMD_INTERFACE,
"StartUnit");
- method.append("obmc-flash-bios-ubiumount-prsv.service", "replace");
- bus.call_noreply(method);
+ method.append("obmc-flash-bios-ubiclear@pnor-prsv.service", "replace");
+ auto reply = bus.call(method);
- return;
-}
-
-void ItemUpdater::reset()
-{
- for (const auto& it : activations)
+ if (reply.is_method_error())
{
- removeReadWritePartition(it.first);
- removeFile(it.first);
+ elog<InternalFailure>();
}
- removePreservedPartition();
+
return;
}