Move MarkBootSuccessful to BootControlInterface.
Updating the boot flags to mark the current boot as successful is
platform-specific and part of the BootControlInterface's job. This
patch moves this to a new async method in this interface.
Bug: 24077637
Test: FEATURES=test emerge-link update_engine; cros flash in Chrome OS; tested on a dragonboard.
Change-Id: I23c3ed915dd8d2588a90d84b212bb04977957975
diff --git a/boot_control_chromeos.cc b/boot_control_chromeos.cc
index 03e1c26..5f8f74e 100644
--- a/boot_control_chromeos.cc
+++ b/boot_control_chromeos.cc
@@ -18,6 +18,7 @@
#include <string>
+#include <base/bind.h>
#include <base/files/file_path.h>
#include <base/files/file_util.h>
#include <base/strings/string_util.h>
@@ -29,6 +30,7 @@
}
#include "update_engine/boot_control.h"
+#include "update_engine/subprocess.h"
#include "update_engine/utils.h"
using std::string;
@@ -57,6 +59,15 @@
return boot_path;
}
+// ExecCallback called when the execution of setgoodkernel finishes. Notifies
+// the caller of MarkBootSuccessfullAsync() by calling |callback| with the
+// result.
+void OnMarkBootSuccessfulDone(base::Callback<void(bool)> callback,
+ int return_code,
+ const string& output) {
+ callback.Run(return_code == 0);
+}
+
} // namespace
namespace chromeos_update_engine {
@@ -194,6 +205,13 @@
return true;
}
+bool BootControlChromeOS::MarkBootSuccessfulAsync(
+ base::Callback<void(bool)> callback) {
+ return Subprocess::Get().Exec(
+ {"/usr/sbin/chromeos-setgoodkernel"},
+ base::Bind(&OnMarkBootSuccessfulDone, callback)) != 0;
+}
+
// static
string BootControlChromeOS::SysfsBlockDevice(const string& device) {
base::FilePath device_path(device);