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

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

Merge "liblp: Add API for adding predetermined linear extents to partitions"

parents b815e6cc 18972708
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -983,5 +983,18 @@ bool MetadataBuilder::IsRetrofitDevice() const {
    return GetBlockDevicePartitionName(block_devices_[0]) != LP_METADATA_DEFAULT_PARTITION_NAME;
}

bool MetadataBuilder::AddLinearExtent(Partition* partition, const std::string& block_device,
                                      uint64_t num_sectors, uint64_t physical_sector) {
    uint32_t device_index;
    if (!FindBlockDeviceByName(block_device, &device_index)) {
        LERROR << "Could not find backing block device for extent: " << block_device;
        return false;
    }

    auto extent = std::make_unique<LinearExtent>(num_sectors, device_index, physical_sector);
    partition->AddExtent(std::move(extent));
    return true;
}

}  // namespace fs_mgr
}  // namespace android
+4 −0
Original line number Diff line number Diff line
@@ -219,6 +219,10 @@ class MetadataBuilder {
    // Find a group by name. If no group is found, nullptr is returned.
    PartitionGroup* FindGroup(const std::string& name);

    // Add a predetermined extent to a partition.
    bool AddLinearExtent(Partition* partition, const std::string& block_device,
                         uint64_t num_sectors, uint64_t physical_sector);

    // Grow or shrink a partition to the requested size. This size will be
    // rounded UP to the nearest block (512 bytes).
    //