Implement Rollback to previously booted partitions.
This CL implements rollback to whatever partition we ran from before.
We expose this functionality via dbus under AttemptRollback and expose
a new command-line option to update_engine_client that a developer can
use.
BUG=chromium:242665
TEST=Unittests, full update, update + rollback and verified.
Change-Id: Ie59f90b9a0b777dc1329592449090c70892236bf
Reviewed-on: https://gerrit.chromium.org/gerrit/58427
Commit-Queue: Chris Sosa <[email protected]>
Reviewed-by: Chris Sosa <[email protected]>
Tested-by: Chris Sosa <[email protected]>
diff --git a/utils.cc b/utils.cc
index d24a61f..62581f4 100644
--- a/utils.cc
+++ b/utils.cc
@@ -1021,6 +1021,17 @@
return result;
}
+bool GetInstallDev(const std::string& boot_dev, std::string* install_dev) {
+ TEST_AND_RETURN_FALSE(StringHasPrefix(boot_dev, "/dev/"));
+ string ret(boot_dev);
+ string::reverse_iterator it = ret.rbegin(); // last character in string
+ // Right now, we just switch '3' and '5' partition numbers.
+ TEST_AND_RETURN_FALSE((*it == '3') || (*it == '5'));
+ *it = (*it == '3') ? '5' : '3';
+ *install_dev = ret;
+ return true;
+}
+
} // namespace utils
} // namespace chromeos_update_engine