Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c5b3c88f authored by David Anderson's avatar David Anderson Committed by Gerrit Code Review
Browse files

Merge "liblp: Support sdcards in PartitionOpener."

parents afe45ab5 251ec05f
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -41,7 +41,21 @@ std::string GetPartitionAbsolutePath(const std::string& path) {
    if (android::base::StartsWith(path, "/")) {
        return path;
    }
    return "/dev/block/by-name/" + path;

    auto by_name = "/dev/block/by-name/" + path;
    if (access(by_name.c_str(), F_OK) != 0) {
        // If the by-name symlink doesn't exist, as a special case we allow
        // certain devices to be used as partition names. This can happen if a
        // Dynamic System Update is installed to an sdcard, which won't be in
        // the boot device list.
        //
        // We whitelist because most devices in /dev/block are not valid for
        // storing fiemaps.
        if (android::base::StartsWith(path, "mmcblk")) {
            return "/dev/block/" + path;
        }
    }
    return by_name;
}

bool GetBlockDeviceInfo(const std::string& block_device, BlockDeviceInfo* device_info) {
+4 −12
Original line number Diff line number Diff line
@@ -602,19 +602,11 @@ void FirstStageMount::UseGsiIfPresent() {
        return;
    }

    // Find the name of the super partition for the GSI. It will either be
    // "userdata", or a block device such as an sdcard. There are no by-name
    // partitions other than userdata that we support installing GSIs to.
    // Find the super name. PartitionOpener will ensure this translates to the
    // correct block device path.
    auto super = GetMetadataSuperBlockDevice(*metadata.get());
    std::string super_name = android::fs_mgr::GetBlockDevicePartitionName(*super);
    std::string super_path;
    if (super_name == "userdata") {
        super_path = "/dev/block/by-name/" + super_name;
    } else {
        super_path = "/dev/block/" + super_name;
    }

    if (!android::fs_mgr::CreateLogicalPartitions(*metadata.get(), super_path)) {
    auto super_name = android::fs_mgr::GetBlockDevicePartitionName(*super);
    if (!android::fs_mgr::CreateLogicalPartitions(*metadata.get(), super_name)) {
        LOG(ERROR) << "GSI partition layout could not be instantiated";
        return;
    }