diff options
-rw-r--r-- | Android.mk | 4 | ||||
-rw-r--r-- | bootloader_message/bootloader_message.cpp | 5 | ||||
-rw-r--r-- | bootloader_message/include/bootloader_message/bootloader_message.h | 5 | ||||
-rw-r--r-- | updater/install.cpp | 3 |
4 files changed, 12 insertions, 5 deletions
diff --git a/Android.mk b/Android.mk index 8189ffae3..d6a318ba5 100644 --- a/Android.mk +++ b/Android.mk @@ -602,10 +602,6 @@ ifeq ($(AB_OTA_UPDATER),true) LOCAL_CFLAGS += -DAB_OTA_UPDATER=1 endif -ifneq ($(BOARD_RECOVERY_BLDRMSG_OFFSET),) - LOCAL_CFLAGS += -DBOARD_RECOVERY_BLDRMSG_OFFSET=$(BOARD_RECOVERY_BLDRMSG_OFFSET) -endif - include $(BUILD_SHARED_LIBRARY) # All the APIs for testing diff --git a/bootloader_message/bootloader_message.cpp b/bootloader_message/bootloader_message.cpp index 4d1ce5bb4..449f40e11 100644 --- a/bootloader_message/bootloader_message.cpp +++ b/bootloader_message/bootloader_message.cpp @@ -159,7 +159,10 @@ static bool write_misc_partition(const void* p, size_t size, size_t offset, std: *err = "no misc device set"; return false; } - int fd = (open(misc_blk_device.c_str(), O_WRONLY | O_SYNC)); + int open_flags = O_WRONLY | O_SYNC; + if (offset > 0) + open_flags = O_RDWR | O_APPEND | O_SYNC; + int fd = (open(misc_blk_device.c_str(), open_flags)); if (fd == -1) { *err = "failed to open " + misc_blk_device + ": "; *err += strerror(errno); diff --git a/bootloader_message/include/bootloader_message/bootloader_message.h b/bootloader_message/include/bootloader_message/bootloader_message.h index 52d733105..e0fc2cd8a 100644 --- a/bootloader_message/include/bootloader_message/bootloader_message.h +++ b/bootloader_message/include/bootloader_message/bootloader_message.h @@ -25,8 +25,13 @@ // 16K - 64K Used by uncrypt and recovery to store wipe_package for A/B devices // Note that these offsets are admitted by bootloader,recovery and uncrypt, so they // are not configurable without changing all of them. +#ifdef BOARD_RECOVERY_BLDRMSG_OFFSET +static const size_t BOOTLOADER_MESSAGE_OFFSET_IN_MISC = BOARD_RECOVERY_BLDRMSG_OFFSET; +static const size_t WIPE_PACKAGE_OFFSET_IN_MISC = 16 * 1024 + BOOTLOADER_MESSAGE_OFFSET_IN_MISC; +#else static const size_t BOOTLOADER_MESSAGE_OFFSET_IN_MISC = 0; static const size_t WIPE_PACKAGE_OFFSET_IN_MISC = 16 * 1024; +#endif /* Bootloader Message * diff --git a/updater/install.cpp b/updater/install.cpp index b17c34fb2..d4ae64ee5 100644 --- a/updater/install.cpp +++ b/updater/install.cpp @@ -1456,6 +1456,7 @@ Value* RebootNowFn(const char* name, State* state, int argc, Expr* argv[]) { memset(buffer, 0, sizeof(((struct bootloader_message*)0)->command)); FILE* f = fopen(filename, "r+b"); fseek(f, offsetof(struct bootloader_message, command), SEEK_SET); + fseek(f, BOOTLOADER_MESSAGE_OFFSET_IN_MISC, SEEK_CUR); ota_fwrite(buffer, sizeof(((struct bootloader_message*)0)->command), 1, f); fclose(f); free(filename); @@ -1498,6 +1499,7 @@ Value* SetStageFn(const char* name, State* state, int argc, Expr* argv[]) { // package installation. FILE* f = fopen(filename, "r+b"); fseek(f, offsetof(struct bootloader_message, stage), SEEK_SET); + fseek(f, BOOTLOADER_MESSAGE_OFFSET_IN_MISC, SEEK_CUR); int to_write = strlen(stagestr)+1; int max_size = sizeof(((struct bootloader_message*)0)->stage); if (to_write > max_size) { @@ -1524,6 +1526,7 @@ Value* GetStageFn(const char* name, State* state, int argc, Expr* argv[]) { char buffer[sizeof(((struct bootloader_message*)0)->stage)]; FILE* f = fopen(filename, "rb"); fseek(f, offsetof(struct bootloader_message, stage), SEEK_SET); + fseek(f, BOOTLOADER_MESSAGE_OFFSET_IN_MISC, SEEK_CUR); ota_fread(buffer, sizeof(buffer), 1, f); fclose(f); buffer[sizeof(buffer)-1] = '\0'; |