diff options
author | Alessandro Astone <ales.astone@gmail.com> | 2019-05-04 20:06:48 +0200 |
---|---|---|
committer | Rashed Abdel-Tawab <rashedabdeltawab@gmail.com> | 2019-06-25 01:57:26 +0200 |
commit | 8ce449552742f34b26bacf86b53dd180749729cd (patch) | |
tree | f25f9ea9babcbbd92a6cf5d87a749f0e3866aa85 | |
parent | 5d5abd863e8758447eb7e68baff022df1332b3cf (diff) | |
download | android_bootable_recovery-8ce449552742f34b26bacf86b53dd180749729cd.tar.gz android_bootable_recovery-8ce449552742f34b26bacf86b53dd180749729cd.tar.bz2 android_bootable_recovery-8ce449552742f34b26bacf86b53dd180749729cd.zip |
recovery: wipe bootloader message from index 0 when using custom offsets
* We may use a custom offset to:
a) preserve data that oem wrote to the first bytes of misc
b) skip recovery flags written by the bootloader (e.g. --wipe_data)
For case a) one should set the offset 'x' to be at least greater than
the size of bootloader_message struct (2048 bytes). If this is the case,
then we zero out bytes x ~ x + 2047
For case b) one should set the offset to be strictly smaller than
the size of bootloader_message struct. If this is the case, then we
zero out bytes 0 ~ 2047.
This allows to clear any additional flag set by the bootloader,
that would otherwise be forgotten in misc.
This also guarantees that we do not involountarily wipe any data that
the oem may have written starting at byte 2048 (coff coff LG)
Change-Id: I2d4e0702a2d8cbbef6274a87ce9499b0f69310dd
-rw-r--r-- | bootloader_message/bootloader_message.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/bootloader_message/bootloader_message.cpp b/bootloader_message/bootloader_message.cpp index 7ebd86a5..1dd37ac1 100644 --- a/bootloader_message/bootloader_message.cpp +++ b/bootloader_message/bootloader_message.cpp @@ -164,6 +164,11 @@ bool write_bootloader_message(const bootloader_message& boot, std::string* err) bool clear_bootloader_message(std::string* err) { bootloader_message boot = {}; + if (BOOTLOADER_MESSAGE_OFFSET_IN_MISC < sizeof(bootloader_message)) { + std::string misc_blk_device = get_misc_blk_device(err); + if (misc_blk_device.empty()) return false; + return write_misc_partition(&boot, sizeof(boot), misc_blk_device, 0 /* offset */, err); + } return write_bootloader_message(boot, err); } |