Mark the new kernel invalid when starting an update.
Before we overwrite the new kernel, mark it as unbootable by setting the GPT
flags "successful" and "tries" to 0. This is good, but not critical as a
general behavior because it prevents the firmware from even trying a kernel
we think will be bad.
It's more useful, because it gives us a definitive way to know if the other
kernel is expected to be valid for purposes of things like rollback. There
will be a future CL to use it for preventing rollback to a known invalid
installation.
Also adds a MockHardware implementation backed by the FakeHardware
implementation, and switches MockSystemState to use it.
BUG=chromium:280816
TEST=Manual watching of flags, and multiple updates.
CQ-DEPEND=CL:176177
Change-Id: Idb083279cd1438a555c5165c69b25c351207e382
Reviewed-on: https://chromium-review.googlesource.com/176169
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Tested-by: Don Garrett <dgarrett@chromium.org>
Reviewed-by: David Zeuthen <zeuthen@chromium.org>
Commit-Queue: Don Garrett <dgarrett@chromium.org>
diff --git a/hardware_interface.h b/hardware_interface.h
index 8909058..29baec4 100644
--- a/hardware_interface.h
+++ b/hardware_interface.h
@@ -17,11 +17,22 @@
// unit testing.
class HardwareInterface {
public:
- // Returns the currently booted device. "/dev/sda3", for example.
- // This will not interpret LABEL= or UUID=. You'll need to use findfs
- // or something with equivalent funcionality to interpret those.
+ // Returns the currently booted kernel partition. "/dev/sda2", for example.
+ virtual const std::string BootKernelDevice() = 0;
+
+ // Returns the currently booted rootfs partition. "/dev/sda3", for example.
virtual const std::string BootDevice() = 0;
+ // Is the specified kernel partition currently bootable, based on GPT flags?
+ // Returns success.
+ virtual bool IsKernelBootable(const std::string& kernel_device,
+ bool* bootable) = 0;
+
+ // Mark the specified kernel partition unbootable in GPT flags. We mark
+ // the other kernel as bootable inside postinst, not inside the UE.
+ // Returns success.
+ virtual bool MarkKernelUnbootable(const std::string& kernel_device) = 0;
+
// Returns true if this is an official Chrome OS build, false otherwise.
virtual bool IsOfficialBuild() = 0;