Make non-volatile directory platform-specific.
update_engine daemon needs to persist files (such as the progress of
the update) in a non-volatile storage and also used to store a
marker file on a volatile storage to detect when update_engine is
restarted, likelly due to a crash.
This patch moves the non-volatile directory configuration to the
Hardware interface, making it platform-specific. It also replaces the
system rebooted detection using the boot_id provided by the kernel
instead of storing a file under /tmp. This implementation works both
on Chrome OS and Android.
Bug: 24074252
Test: FEATURES=test emerge-link update_engine; `mma`; deployed and tested manually on brillo.
Change-Id: I921d767982adebfd04eb12e08d8a157d9102d1e3
diff --git a/utils.cc b/utils.cc
index 2baa087..cf7913c 100644
--- a/utils.cc
+++ b/utils.cc
@@ -85,6 +85,9 @@
// in GetFileFormat.
const int kGetFileFormatMaxHeaderSize = 32;
+// The path to the kernel's boot_id.
+const char kBootIdPath[] = "/proc/sys/kernel/random/boot_id";
+
// Return true if |disk_name| is an MTD or a UBI device. Note that this test is
// simply based on the name of the device.
bool IsMtdDeviceName(const string& disk_name) {
@@ -1609,6 +1612,13 @@
return true;
}
+bool GetBootId(string* boot_id) {
+ TEST_AND_RETURN_FALSE(
+ base::ReadFileToString(base::FilePath(kBootIdPath), boot_id));
+ base::TrimWhitespaceASCII(*boot_id, base::TRIM_TRAILING, boot_id);
+ return true;
+}
+
} // namespace utils
} // namespace chromeos_update_engine