From 95f4b9ccb7c31d7c76e42e57e37a4a4b3fea592a Mon Sep 17 00:00:00 2001 From: Oleg Matcovschi Date: Fri, 20 Aug 2021 00:43:31 -0700 Subject: [PATCH] bootctrl: enforce synchronous write operation Bug: 197104397 Signed-off-by: Oleg Matcovschi Change-Id: Ifbc612fc40847395ccb751463b1bb15bd3f20657 --- interfaces/boot/1.2/BootControl.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/interfaces/boot/1.2/BootControl.cpp b/interfaces/boot/1.2/BootControl.cpp index 70b95940..a28be05a 100644 --- a/interfaces/boot/1.2/BootControl.cpp +++ b/interfaces/boot/1.2/BootControl.cpp @@ -162,7 +162,7 @@ static bool DevInfoSync() { return false; } - android::base::unique_fd fd(open(DEVINFO_PATH, O_WRONLY)); + android::base::unique_fd fd(open(DEVINFO_PATH, O_WRONLY | O_DSYNC)); return android::base::WriteFully(fd, &devinfo, sizeof devinfo); } @@ -270,13 +270,13 @@ Return BootControl::setActiveBootSlot(uint32_t slot, setActiveBootSlot_cb std::string boot_lun_path = std::string("/sys/devices/platform/") + boot_dev + "/pixel/boot_lun_enabled"; - int fd = open(boot_lun_path.c_str(), O_RDWR); + int fd = open(boot_lun_path.c_str(), O_RDWR | O_DSYNC); if (fd < 0) { // Try old path for kernels < 5.4 // TODO: remove once kernel 4.19 support is deprecated std::string boot_lun_path = std::string("/sys/devices/platform/") + boot_dev + "/attributes/boot_lun_enabled"; - fd = open(boot_lun_path.c_str(), O_RDWR); + fd = open(boot_lun_path.c_str(), O_RDWR | O_DSYNC); if (fd < 0) { _hidl_cb({false, "failed to open ufs attr boot_lun_enabled"}); return Void();