Merge tag 'android-10.0.0_r25' into aosp10-4
Android 10.0.0 release 25
This commit is contained in:
@@ -21,12 +21,23 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/stringprintf.h>
|
||||
#include <android-base/unique_fd.h>
|
||||
#include <fs_mgr.h>
|
||||
#include <fstab/fstab.h>
|
||||
|
||||
using android::fs_mgr::Fstab;
|
||||
using android::fs_mgr::ReadDefaultFstab;
|
||||
|
||||
static std::string g_misc_device_for_test;
|
||||
|
||||
// Exposed for test purpose.
|
||||
void SetMiscBlockDeviceForTest(std::string_view misc_device) {
|
||||
g_misc_device_for_test = misc_device;
|
||||
}
|
||||
|
||||
#ifdef USE_OLD_BOOTLOADER_MESSAGE
|
||||
#include <sys/system_properties.h>
|
||||
@@ -49,6 +60,7 @@ static struct fstab* read_fstab(std::string* err) {
|
||||
#endif
|
||||
|
||||
static std::string get_misc_blk_device(std::string* err) {
|
||||
<<<<<<< HEAD
|
||||
#ifdef USE_OLD_BOOTLOADER_MESSAGE
|
||||
struct fstab* fstab = read_fstab(err);
|
||||
#else
|
||||
@@ -67,8 +79,24 @@ static std::string get_misc_blk_device(std::string* err) {
|
||||
if (record == nullptr) {
|
||||
*err = "failed to find /misc partition";
|
||||
return "";
|
||||
=======
|
||||
if (!g_misc_device_for_test.empty()) {
|
||||
return g_misc_device_for_test;
|
||||
}
|
||||
return record->blk_device;
|
||||
Fstab fstab;
|
||||
if (!ReadDefaultFstab(&fstab)) {
|
||||
*err = "failed to read default fstab";
|
||||
return "";
|
||||
}
|
||||
for (const auto& entry : fstab) {
|
||||
if (entry.mount_point == "/misc") {
|
||||
return entry.blk_device;
|
||||
}
|
||||
>>>>>>> android-10.0.0_r25
|
||||
}
|
||||
|
||||
*err = "failed to find /misc partition";
|
||||
return "";
|
||||
}
|
||||
|
||||
// In recovery mode, recovery can get started and try to access the misc
|
||||
@@ -251,6 +279,37 @@ 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);
|
||||
}
|
||||
|
||||
extern "C" bool write_reboot_bootloader(void) {
|
||||
std::string err;
|
||||
return write_reboot_bootloader(&err);
|
||||
|
||||
Reference in New Issue
Block a user