Merge "liblp: Add API for adding predetermined linear extents to partitions"
This commit is contained in:
commit
c80c6ac9dd
2 changed files with 17 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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).
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue