Don't rollback if the other partition isn't valid.
Before we start a rollback to the other OS slot, validate the GPT flags show
it as bootable. This should prevent us from attempting a rollback if an
update has been attempted and failed, or is currently in progress. Such
a rollback would always fail, since the other partition would be left in
a partially modified state.
Piggyback:
Move sanity test in hardware that was added to the wrong method.
Undid some unittest changes that were decided against after the fact.
BUG=chromium:267054
TEST=Unittests
Manual Update Rollbacks (with/without flags on other partition)
Change-Id: Ide6b0673855ba2e4b05a0db93413a1a9f2ece2a9
Reviewed-on: https://chromium-review.googlesource.com/176755
Reviewed-by: David Zeuthen <zeuthen@chromium.org>
Commit-Queue: Don Garrett <dgarrett@chromium.org>
Tested-by: Don Garrett <dgarrett@chromium.org>
diff --git a/hardware.cc b/hardware.cc
index d547c2d..6213739 100644
--- a/hardware.cc
+++ b/hardware.cc
@@ -51,12 +51,6 @@
bool Hardware::IsKernelBootable(const std::string& kernel_device,
bool* bootable) {
-
- if (kernel_device == BootKernelDevice()) {
- LOG(ERROR) << "Refusing to mark current kernel as unbootable.";
- return false;
- }
-
CgptAddParams params;
memset(¶ms, '\0', sizeof(params));
@@ -78,6 +72,11 @@
bool Hardware::MarkKernelUnbootable(const std::string& kernel_device) {
LOG(INFO) << "MarkPartitionUnbootable: " << kernel_device;
+ if (kernel_device == BootKernelDevice()) {
+ LOG(ERROR) << "Refusing to mark current kernel as unbootable.";
+ return false;
+ }
+
string root_dev = utils::RootDevice(kernel_device);
string partition_number_str = utils::PartitionNumber(kernel_device);
uint32_t partition_number = atoi(partition_number_str.c_str());