diff options
author | Tianjie Xu <xunchang@google.com> | 2019-11-13 23:24:19 +0100 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-11-13 23:24:19 +0100 |
commit | 423f0d109b98de73c7aa3c5229bc06212b647f9f (patch) | |
tree | 67b6e14fe3be9bd8e7ba844d733d8079ab113b97 /bootloader_message/bootloader_message.cpp | |
parent | Merge "Fixed typo during stopping fastboot" (diff) | |
parent | Consolidate the vendor space misc usage for Pixels (diff) | |
download | android_bootable_recovery-423f0d109b98de73c7aa3c5229bc06212b647f9f.tar android_bootable_recovery-423f0d109b98de73c7aa3c5229bc06212b647f9f.tar.gz android_bootable_recovery-423f0d109b98de73c7aa3c5229bc06212b647f9f.tar.bz2 android_bootable_recovery-423f0d109b98de73c7aa3c5229bc06212b647f9f.tar.lz android_bootable_recovery-423f0d109b98de73c7aa3c5229bc06212b647f9f.tar.xz android_bootable_recovery-423f0d109b98de73c7aa3c5229bc06212b647f9f.tar.zst android_bootable_recovery-423f0d109b98de73c7aa3c5229bc06212b647f9f.zip |
Diffstat (limited to 'bootloader_message/bootloader_message.cpp')
-rw-r--r-- | bootloader_message/bootloader_message.cpp | 37 |
1 files changed, 3 insertions, 34 deletions
diff --git a/bootloader_message/bootloader_message.cpp b/bootloader_message/bootloader_message.cpp index 4f7085db9..b70d54e5c 100644 --- a/bootloader_message/bootloader_message.cpp +++ b/bootloader_message/bootloader_message.cpp @@ -45,7 +45,7 @@ void SetMiscBlockDeviceForTest(std::string_view misc_device) { g_misc_device_for_test = misc_device; } -static std::string get_misc_blk_device(std::string* err) { +std::string get_misc_blk_device(std::string* err) { if (g_misc_device_for_test.has_value() && !g_misc_device_for_test->empty()) { return *g_misc_device_for_test; } @@ -111,8 +111,8 @@ static bool read_misc_partition(void* p, size_t size, const std::string& misc_bl return true; } -static bool write_misc_partition(const void* p, size_t size, const std::string& misc_blk_device, - size_t offset, std::string* err) { +bool write_misc_partition(const void* p, size_t size, const std::string& misc_blk_device, + size_t offset, std::string* err) { android::base::unique_fd fd(open(misc_blk_device.c_str(), O_WRONLY)); if (fd == -1) { *err = android::base::StringPrintf("failed to open %s: %s", misc_blk_device.c_str(), @@ -261,37 +261,6 @@ bool write_wipe_package(const std::string& package_data, std::string* err) { WIPE_PACKAGE_OFFSET_IN_MISC, err); } -static bool OffsetAndSizeInVendorSpace(size_t offset, size_t size) { - auto total_size = WIPE_PACKAGE_OFFSET_IN_MISC - VENDOR_SPACE_OFFSET_IN_MISC; - return size <= total_size && offset <= total_size - size; -} - -bool ReadMiscPartitionVendorSpace(void* data, size_t size, size_t offset, std::string* err) { - if (!OffsetAndSizeInVendorSpace(offset, size)) { - *err = android::base::StringPrintf("Out of bound read (offset %zu size %zu)", offset, size); - return false; - } - auto misc_blk_device = get_misc_blk_device(err); - if (misc_blk_device.empty()) { - return false; - } - return read_misc_partition(data, size, misc_blk_device, VENDOR_SPACE_OFFSET_IN_MISC + offset, - err); -} - -bool WriteMiscPartitionVendorSpace(const void* data, size_t size, size_t offset, std::string* err) { - if (!OffsetAndSizeInVendorSpace(offset, size)) { - *err = android::base::StringPrintf("Out of bound write (offset %zu size %zu)", offset, size); - return false; - } - auto misc_blk_device = get_misc_blk_device(err); - if (misc_blk_device.empty()) { - return false; - } - return write_misc_partition(data, size, misc_blk_device, VENDOR_SPACE_OFFSET_IN_MISC + offset, - err); -} - static bool ValidateSystemSpaceRegion(size_t offset, size_t size, std::string* err) { if (size <= SYSTEM_SPACE_SIZE_IN_MISC && offset <= (SYSTEM_SPACE_SIZE_IN_MISC - size)) { return true; |