Loading fastboot/fastboot.cpp +5 −12 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ #include "fastboot.h" #include <ctype.h> #include <errno.h> #include <fcntl.h> #include <getopt.h> Loading @@ -44,12 +43,10 @@ #include <unistd.h> #include <chrono> #include <fstream> #include <functional> #include <iostream> #include <memory> #include <regex> #include <sstream> #include <string> #include <thread> #include <utility> Loading Loading @@ -79,7 +76,6 @@ #include "fastboot_driver_interface.h" #include "fs.h" #include "storage.h" #include "super_flash_helper.h" #include "task.h" #include "tcp.h" #include "transport.h" Loading @@ -93,7 +89,6 @@ using android::base::ReadFully; using android::base::Split; using android::base::Trim; using android::base::unique_fd; using namespace std::string_literals; using namespace std::placeholders; #define FASTBOOT_INFO_VERSION 1 Loading Loading @@ -350,8 +345,7 @@ Result<NetworkSerial, FastbootError> ParseNetworkSerial(const std::string& seria // // The returned Transport is a singleton, so multiple calls to this function will return the same // object, and the caller should not attempt to delete the returned Transport. static std::unique_ptr<Transport> open_device(const char* local_serial, bool wait_for_device = true, static std::unique_ptr<Transport> open_device(const char* local_serial, bool wait_for_device = true, bool announce = true) { const Result<NetworkSerial, FastbootError> network_serial = ParseNetworkSerial(local_serial); Loading Loading @@ -1883,13 +1877,12 @@ std::vector<std::unique_ptr<Task>> FlashAllTool::CollectTasksFromImageList() { // partitions (otherwise they would not mount on first boot). To enforce // this, we delete any logical partitions for the "other" slot. if (is_retrofit_device(fp_->fb)) { std::string partition_name = image->part_name + "_"s + slot; std::string partition_name = image->part_name + "_" + slot; if (image->IsSecondary() && should_flash_in_userspace(partition_name)) { fp_->fb->DeletePartition(partition_name); } tasks.emplace_back(std::make_unique<DeleteTask>(fp_, partition_name)); } } } AddFlashTasks(os_images_, tasks); Loading Loading @@ -2136,7 +2129,7 @@ static bool wipe_super(const android::fs_mgr::LpMetadata& metadata, const std::s if (metadata.block_devices.size() > 1) { ok = WriteSplitImageFiles(temp_dir.path, metadata, block_size, {}, true); } else { auto image_path = temp_dir.path + "/"s + super_bdev_name + ".img"; auto image_path = std::string(temp_dir.path) + "/" + std::string(super_bdev_name) + ".img"; ok = WriteToImageFile(image_path, metadata, block_size, {}, true); } if (!ok) { Loading @@ -2155,7 +2148,7 @@ static bool wipe_super(const android::fs_mgr::LpMetadata& metadata, const std::s image_name = partition + ".img"; } auto image_path = temp_dir.path + "/"s + image_name; auto image_path = std::string(temp_dir.path) + "/" + image_name; auto flash = [&](const std::string& partition_name) { do_flash(partition_name.c_str(), image_path.c_str(), false, fp); }; Loading fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_test.cpp +6 −2 Original line number Diff line number Diff line Loading @@ -714,10 +714,12 @@ TEST_F(SnapuserdTest, Snapshot_MERGE_IO_TEST) { } ASSERT_NO_FATAL_FAILURE(SetupDefault()); // Issue I/O before merge begins auto read_future = std::async(std::launch::async, &SnapuserdTest::ReadSnapshotDeviceAndValidate, this); // Start the merge ASSERT_TRUE(Merge()); ValidateMerge(); read_future.wait(); } TEST_F(SnapuserdTest, Snapshot_MERGE_IO_TEST_1) { Loading @@ -728,9 +730,11 @@ TEST_F(SnapuserdTest, Snapshot_MERGE_IO_TEST_1) { // Start the merge ASSERT_TRUE(StartMerge()); // Issue I/O in parallel when merge is in-progress auto read_future = std::async(std::launch::async, &SnapuserdTest::ReadSnapshotDeviceAndValidate, this); CheckMergeCompletion(); ValidateMerge(); read_future.wait(); } TEST_F(SnapuserdTest, Snapshot_Merge_Resume) { Loading init/first_stage_init.cpp +6 −2 Original line number Diff line number Diff line Loading @@ -239,8 +239,12 @@ bool LoadKernelModules(BootMode boot_mode, bool want_console, bool want_parallel module_dirs.emplace_back(entry->d_name); break; } // Ignore _16k/_64k module dirs on 4K kernels if (GetPageSizeSuffix(entry->d_name) != page_size_suffix) { // Is a directory does not have page size suffix, it does not mean this directory is for 4K // kernels. Certain 16K kernel builds put all modules in /lib/modules/`uname -r` without any // suffix. Therefore, only ignore a directory if it has _16k/_64k suffix and the suffix does // not match system page size. const auto dir_page_size_suffix = GetPageSizeSuffix(entry->d_name); if (!dir_page_size_suffix.empty() && dir_page_size_suffix != page_size_suffix) { continue; } int dir_major = 0, dir_minor = 0; Loading libcutils/ashmem-dev.cpp +6 −51 Original line number Diff line number Diff line Loading @@ -44,13 +44,6 @@ #include <android-base/strings.h> #include <android-base/unique_fd.h> /* * The minimum vendor API level at and after which it is safe to use memfd. * This is to facilitate deprecation of ashmem. */ #define MIN_MEMFD_VENDOR_API_LEVEL 29 #define MIN_MEMFD_VENDOR_API_LEVEL_CHAR 'Q' /* ashmem identity */ static dev_t __ashmem_rdev; /* Loading Loading @@ -88,55 +81,17 @@ static bool pin_deprecation_warn = true; /* Log the pin deprecation warning only /* Determine if vendor processes would be ok with memfd in the system: * * If VNDK is using older libcutils, don't use memfd. This is so that the * same shared memory mechanism is used across binder transactions between * vendor partition processes and system partition processes. * Previously this function checked if memfd is supported by checking if * vendor VNDK version is greater than Q. As we can assume all treblelized * device using this code is up to date enough to use memfd, memfd is allowed * if the device is treblelized. */ static bool check_vendor_memfd_allowed() { std::string vndk_version = android::base::GetProperty("ro.vndk.version", ""); if (vndk_version == "") { ALOGE("memfd: ro.vndk.version not defined or invalid (%s), this is mandated since P.\n", vndk_version.c_str()); return false; } static bool is_treblelized = android::base::GetBoolProperty("ro.treble.enabled", false); /* No issues if vendor is targetting current Dessert */ if (vndk_version == "current") { return false; } /* Check if VNDK version is a number and act on it */ char* p; long int vers = strtol(vndk_version.c_str(), &p, 10); if (*p == 0) { if (vers < MIN_MEMFD_VENDOR_API_LEVEL) { ALOGI("memfd: device VNDK version (%s) is < Q so using ashmem.\n", vndk_version.c_str()); return false; return is_treblelized; } return true; } // Non-numeric should be a single ASCII character. Characters after the // first are ignored. if (tolower(vndk_version[0]) < 'a' || tolower(vndk_version[0]) > 'z') { ALOGE("memfd: ro.vndk.version not defined or invalid (%s), this is mandated since P.\n", vndk_version.c_str()); return false; } if (tolower(vndk_version[0]) < tolower(MIN_MEMFD_VENDOR_API_LEVEL_CHAR)) { ALOGI("memfd: device is using VNDK version (%s) which is less than Q. Use ashmem only.\n", vndk_version.c_str()); return false; } return true; } /* Determine if memfd can be supported. This is just one-time hardwork * which will be cached by the caller. */ Loading libcutils/fs_config.cpp +2 −6 Original line number Diff line number Diff line Loading @@ -41,10 +41,6 @@ #include "fs_config.h" #ifndef O_BINARY #define O_BINARY 0 #endif using android::base::EndsWith; using android::base::StartsWith; Loading Loading @@ -257,12 +253,12 @@ static int fs_config_open(int dir, int which, const char* target_out_path) { len = strip(target_out_path, len, "/"); len = strip(target_out_path, len, "/system"); if (asprintf(&name, "%.*s%s", (int)len, target_out_path, conf[which][dir]) != -1) { fd = TEMP_FAILURE_RETRY(open(name, O_RDONLY | O_BINARY)); fd = TEMP_FAILURE_RETRY(open(name, O_RDONLY)); free(name); } } if (fd < 0) { fd = TEMP_FAILURE_RETRY(open(conf[which][dir], O_RDONLY | O_BINARY)); fd = TEMP_FAILURE_RETRY(open(conf[which][dir], O_RDONLY)); } return fd; } Loading Loading
fastboot/fastboot.cpp +5 −12 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ #include "fastboot.h" #include <ctype.h> #include <errno.h> #include <fcntl.h> #include <getopt.h> Loading @@ -44,12 +43,10 @@ #include <unistd.h> #include <chrono> #include <fstream> #include <functional> #include <iostream> #include <memory> #include <regex> #include <sstream> #include <string> #include <thread> #include <utility> Loading Loading @@ -79,7 +76,6 @@ #include "fastboot_driver_interface.h" #include "fs.h" #include "storage.h" #include "super_flash_helper.h" #include "task.h" #include "tcp.h" #include "transport.h" Loading @@ -93,7 +89,6 @@ using android::base::ReadFully; using android::base::Split; using android::base::Trim; using android::base::unique_fd; using namespace std::string_literals; using namespace std::placeholders; #define FASTBOOT_INFO_VERSION 1 Loading Loading @@ -350,8 +345,7 @@ Result<NetworkSerial, FastbootError> ParseNetworkSerial(const std::string& seria // // The returned Transport is a singleton, so multiple calls to this function will return the same // object, and the caller should not attempt to delete the returned Transport. static std::unique_ptr<Transport> open_device(const char* local_serial, bool wait_for_device = true, static std::unique_ptr<Transport> open_device(const char* local_serial, bool wait_for_device = true, bool announce = true) { const Result<NetworkSerial, FastbootError> network_serial = ParseNetworkSerial(local_serial); Loading Loading @@ -1883,13 +1877,12 @@ std::vector<std::unique_ptr<Task>> FlashAllTool::CollectTasksFromImageList() { // partitions (otherwise they would not mount on first boot). To enforce // this, we delete any logical partitions for the "other" slot. if (is_retrofit_device(fp_->fb)) { std::string partition_name = image->part_name + "_"s + slot; std::string partition_name = image->part_name + "_" + slot; if (image->IsSecondary() && should_flash_in_userspace(partition_name)) { fp_->fb->DeletePartition(partition_name); } tasks.emplace_back(std::make_unique<DeleteTask>(fp_, partition_name)); } } } AddFlashTasks(os_images_, tasks); Loading Loading @@ -2136,7 +2129,7 @@ static bool wipe_super(const android::fs_mgr::LpMetadata& metadata, const std::s if (metadata.block_devices.size() > 1) { ok = WriteSplitImageFiles(temp_dir.path, metadata, block_size, {}, true); } else { auto image_path = temp_dir.path + "/"s + super_bdev_name + ".img"; auto image_path = std::string(temp_dir.path) + "/" + std::string(super_bdev_name) + ".img"; ok = WriteToImageFile(image_path, metadata, block_size, {}, true); } if (!ok) { Loading @@ -2155,7 +2148,7 @@ static bool wipe_super(const android::fs_mgr::LpMetadata& metadata, const std::s image_name = partition + ".img"; } auto image_path = temp_dir.path + "/"s + image_name; auto image_path = std::string(temp_dir.path) + "/" + image_name; auto flash = [&](const std::string& partition_name) { do_flash(partition_name.c_str(), image_path.c_str(), false, fp); }; Loading
fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_test.cpp +6 −2 Original line number Diff line number Diff line Loading @@ -714,10 +714,12 @@ TEST_F(SnapuserdTest, Snapshot_MERGE_IO_TEST) { } ASSERT_NO_FATAL_FAILURE(SetupDefault()); // Issue I/O before merge begins auto read_future = std::async(std::launch::async, &SnapuserdTest::ReadSnapshotDeviceAndValidate, this); // Start the merge ASSERT_TRUE(Merge()); ValidateMerge(); read_future.wait(); } TEST_F(SnapuserdTest, Snapshot_MERGE_IO_TEST_1) { Loading @@ -728,9 +730,11 @@ TEST_F(SnapuserdTest, Snapshot_MERGE_IO_TEST_1) { // Start the merge ASSERT_TRUE(StartMerge()); // Issue I/O in parallel when merge is in-progress auto read_future = std::async(std::launch::async, &SnapuserdTest::ReadSnapshotDeviceAndValidate, this); CheckMergeCompletion(); ValidateMerge(); read_future.wait(); } TEST_F(SnapuserdTest, Snapshot_Merge_Resume) { Loading
init/first_stage_init.cpp +6 −2 Original line number Diff line number Diff line Loading @@ -239,8 +239,12 @@ bool LoadKernelModules(BootMode boot_mode, bool want_console, bool want_parallel module_dirs.emplace_back(entry->d_name); break; } // Ignore _16k/_64k module dirs on 4K kernels if (GetPageSizeSuffix(entry->d_name) != page_size_suffix) { // Is a directory does not have page size suffix, it does not mean this directory is for 4K // kernels. Certain 16K kernel builds put all modules in /lib/modules/`uname -r` without any // suffix. Therefore, only ignore a directory if it has _16k/_64k suffix and the suffix does // not match system page size. const auto dir_page_size_suffix = GetPageSizeSuffix(entry->d_name); if (!dir_page_size_suffix.empty() && dir_page_size_suffix != page_size_suffix) { continue; } int dir_major = 0, dir_minor = 0; Loading
libcutils/ashmem-dev.cpp +6 −51 Original line number Diff line number Diff line Loading @@ -44,13 +44,6 @@ #include <android-base/strings.h> #include <android-base/unique_fd.h> /* * The minimum vendor API level at and after which it is safe to use memfd. * This is to facilitate deprecation of ashmem. */ #define MIN_MEMFD_VENDOR_API_LEVEL 29 #define MIN_MEMFD_VENDOR_API_LEVEL_CHAR 'Q' /* ashmem identity */ static dev_t __ashmem_rdev; /* Loading Loading @@ -88,55 +81,17 @@ static bool pin_deprecation_warn = true; /* Log the pin deprecation warning only /* Determine if vendor processes would be ok with memfd in the system: * * If VNDK is using older libcutils, don't use memfd. This is so that the * same shared memory mechanism is used across binder transactions between * vendor partition processes and system partition processes. * Previously this function checked if memfd is supported by checking if * vendor VNDK version is greater than Q. As we can assume all treblelized * device using this code is up to date enough to use memfd, memfd is allowed * if the device is treblelized. */ static bool check_vendor_memfd_allowed() { std::string vndk_version = android::base::GetProperty("ro.vndk.version", ""); if (vndk_version == "") { ALOGE("memfd: ro.vndk.version not defined or invalid (%s), this is mandated since P.\n", vndk_version.c_str()); return false; } static bool is_treblelized = android::base::GetBoolProperty("ro.treble.enabled", false); /* No issues if vendor is targetting current Dessert */ if (vndk_version == "current") { return false; } /* Check if VNDK version is a number and act on it */ char* p; long int vers = strtol(vndk_version.c_str(), &p, 10); if (*p == 0) { if (vers < MIN_MEMFD_VENDOR_API_LEVEL) { ALOGI("memfd: device VNDK version (%s) is < Q so using ashmem.\n", vndk_version.c_str()); return false; return is_treblelized; } return true; } // Non-numeric should be a single ASCII character. Characters after the // first are ignored. if (tolower(vndk_version[0]) < 'a' || tolower(vndk_version[0]) > 'z') { ALOGE("memfd: ro.vndk.version not defined or invalid (%s), this is mandated since P.\n", vndk_version.c_str()); return false; } if (tolower(vndk_version[0]) < tolower(MIN_MEMFD_VENDOR_API_LEVEL_CHAR)) { ALOGI("memfd: device is using VNDK version (%s) which is less than Q. Use ashmem only.\n", vndk_version.c_str()); return false; } return true; } /* Determine if memfd can be supported. This is just one-time hardwork * which will be cached by the caller. */ Loading
libcutils/fs_config.cpp +2 −6 Original line number Diff line number Diff line Loading @@ -41,10 +41,6 @@ #include "fs_config.h" #ifndef O_BINARY #define O_BINARY 0 #endif using android::base::EndsWith; using android::base::StartsWith; Loading Loading @@ -257,12 +253,12 @@ static int fs_config_open(int dir, int which, const char* target_out_path) { len = strip(target_out_path, len, "/"); len = strip(target_out_path, len, "/system"); if (asprintf(&name, "%.*s%s", (int)len, target_out_path, conf[which][dir]) != -1) { fd = TEMP_FAILURE_RETRY(open(name, O_RDONLY | O_BINARY)); fd = TEMP_FAILURE_RETRY(open(name, O_RDONLY)); free(name); } } if (fd < 0) { fd = TEMP_FAILURE_RETRY(open(conf[which][dir], O_RDONLY | O_BINARY)); fd = TEMP_FAILURE_RETRY(open(conf[which][dir], O_RDONLY)); } return fd; } Loading