summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fs_mgr/liblp/builder.cpp22
-rw-r--r--fs_mgr/liblp/include/liblp/builder.h3
2 files changed, 18 insertions, 7 deletions
diff --git a/fs_mgr/liblp/builder.cpp b/fs_mgr/liblp/builder.cpp
index 33ea8c5927..e789524f5f 100644
--- a/fs_mgr/liblp/builder.cpp
+++ b/fs_mgr/liblp/builder.cpp
@@ -140,7 +140,7 @@ std::unique_ptr<MetadataBuilder> MetadataBuilder::New(const LpMetadata& metadata
}
if (opener) {
for (size_t i = 0; i < builder->block_devices_.size(); i++) {
- std::string partition_name = GetBlockDevicePartitionName(builder->block_devices_[i]);
+ std::string partition_name = builder->GetBlockDevicePartitionName(i);
BlockDeviceInfo device_info;
if (opener->GetInfo(partition_name, &device_info)) {
builder->UpdateBlockDeviceInfo(i, device_info);
@@ -164,7 +164,7 @@ std::unique_ptr<MetadataBuilder> MetadataBuilder::NewForUpdate(const IPartitionO
// name and system properties.
// See comments for UpdateMetadataForOtherSuper.
auto super_device = GetMetadataSuperBlockDevice(*metadata.get());
- if (GetBlockDevicePartitionName(*super_device) != "super" &&
+ if (android::fs_mgr::GetBlockDevicePartitionName(*super_device) != "super" &&
IsRetrofitDynamicPartitionsDevice()) {
if (!UpdateMetadataForOtherSuper(metadata.get(), source_slot_number, target_slot_number)) {
return nullptr;
@@ -192,7 +192,8 @@ bool MetadataBuilder::UpdateMetadataForOtherSuper(LpMetadata* metadata, uint32_t
// Translate block devices.
auto source_block_devices = std::move(metadata->block_devices);
for (const auto& source_block_device : source_block_devices) {
- std::string partition_name = GetBlockDevicePartitionName(source_block_device);
+ std::string partition_name =
+ android::fs_mgr::GetBlockDevicePartitionName(source_block_device);
std::string slot_suffix = GetPartitionSlotSuffix(partition_name);
if (slot_suffix.empty() || slot_suffix != source_slot_suffix) {
// This should never happen. It means that the source metadata
@@ -375,7 +376,7 @@ bool MetadataBuilder::Init(const std::vector<BlockDeviceInfo>& block_devices,
block_devices_.emplace_back(out);
}
}
- if (GetBlockDevicePartitionName(block_devices_[0]) != super_partition) {
+ if (GetBlockDevicePartitionName(0) != super_partition) {
LERROR << "No super partition was specified.";
return false;
}
@@ -849,7 +850,7 @@ uint64_t MetadataBuilder::AlignSector(const LpMetadataBlockDevice& block_device,
bool MetadataBuilder::FindBlockDeviceByName(const std::string& partition_name,
uint32_t* index) const {
for (size_t i = 0; i < block_devices_.size(); i++) {
- if (GetBlockDevicePartitionName(block_devices_[i]) == partition_name) {
+ if (GetBlockDevicePartitionName(i) == partition_name) {
*index = i;
return true;
}
@@ -974,7 +975,8 @@ static bool CompareBlockDevices(const LpMetadataBlockDevice& first,
// Note: we don't compare alignment, since it's a performance thing and
// won't affect whether old extents continue to work.
return first.first_logical_sector == second.first_logical_sector && first.size == second.size &&
- GetBlockDevicePartitionName(first) == GetBlockDevicePartitionName(second);
+ android::fs_mgr::GetBlockDevicePartitionName(first) ==
+ android::fs_mgr::GetBlockDevicePartitionName(second);
}
bool MetadataBuilder::ImportPartitions(const LpMetadata& metadata,
@@ -1057,7 +1059,7 @@ bool MetadataBuilder::IsRetrofitDynamicPartitionsDevice() {
}
bool MetadataBuilder::IsRetrofitMetadata() const {
- return GetBlockDevicePartitionName(block_devices_[0]) != LP_METADATA_DEFAULT_PARTITION_NAME;
+ return GetBlockDevicePartitionName(0) != LP_METADATA_DEFAULT_PARTITION_NAME;
}
bool MetadataBuilder::AddLinearExtent(Partition* partition, const std::string& block_device,
@@ -1121,5 +1123,11 @@ bool MetadataBuilder::ChangeGroupSize(const std::string& group_name, uint64_t ma
return true;
}
+std::string MetadataBuilder::GetBlockDevicePartitionName(uint64_t index) const {
+ return index < block_devices_.size()
+ ? android::fs_mgr::GetBlockDevicePartitionName(block_devices_[index])
+ : "";
+}
+
} // namespace fs_mgr
} // namespace android
diff --git a/fs_mgr/liblp/include/liblp/builder.h b/fs_mgr/liblp/include/liblp/builder.h
index d2a206be46..1f7029ece4 100644
--- a/fs_mgr/liblp/include/liblp/builder.h
+++ b/fs_mgr/liblp/include/liblp/builder.h
@@ -287,6 +287,9 @@ class MetadataBuilder {
// Return true if a block device is found, else false.
bool HasBlockDevice(const std::string& partition_name) const;
+ // Return the name of the block device at |index|.
+ std::string GetBlockDevicePartitionName(uint64_t index) const;
+
private:
MetadataBuilder();
MetadataBuilder(const MetadataBuilder&) = delete;