Merge "fs_mgr: Add a helper for creating one-off dynamic partitions."
This commit is contained in:
commit
6eec7f031e
2 changed files with 21 additions and 8 deletions
|
@ -168,6 +168,19 @@ bool CreateLogicalPartitions(const LpMetadata& metadata, const std::string& supe
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CreateLogicalPartition(const std::string& block_device, const LpMetadata& metadata,
|
||||
const std::string& partition_name, bool force_writable,
|
||||
const std::chrono::milliseconds& timeout_ms, std::string* path) {
|
||||
for (const auto& partition : metadata.partitions) {
|
||||
if (GetPartitionName(partition) == partition_name) {
|
||||
return CreateLogicalPartition(metadata, partition, force_writable, timeout_ms,
|
||||
block_device, path);
|
||||
}
|
||||
}
|
||||
LERROR << "Could not find any partition with name: " << partition_name;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CreateLogicalPartition(const std::string& block_device, uint32_t metadata_slot,
|
||||
const std::string& partition_name, bool force_writable,
|
||||
const std::chrono::milliseconds& timeout_ms, std::string* path) {
|
||||
|
@ -176,14 +189,8 @@ bool CreateLogicalPartition(const std::string& block_device, uint32_t metadata_s
|
|||
LOG(ERROR) << "Could not read partition table.";
|
||||
return true;
|
||||
}
|
||||
for (const auto& partition : metadata->partitions) {
|
||||
if (GetPartitionName(partition) == partition_name) {
|
||||
return CreateLogicalPartition(*metadata.get(), partition, force_writable, timeout_ms,
|
||||
block_device, path);
|
||||
}
|
||||
}
|
||||
LERROR << "Could not find any partition with name: " << partition_name;
|
||||
return false;
|
||||
return CreateLogicalPartition(block_device, *metadata.get(), partition_name, force_writable,
|
||||
timeout_ms, path);
|
||||
}
|
||||
|
||||
bool DestroyLogicalPartition(const std::string& name, const std::chrono::milliseconds& timeout_ms) {
|
||||
|
|
|
@ -60,6 +60,12 @@ bool CreateLogicalPartition(const std::string& block_device, uint32_t metadata_s
|
|||
const std::string& partition_name, bool force_writable,
|
||||
const std::chrono::milliseconds& timeout_ms, std::string* path);
|
||||
|
||||
// Same as above, but with a given metadata object. Care should be taken that
|
||||
// the metadata represents a valid partition layout.
|
||||
bool CreateLogicalPartition(const std::string& block_device, const LpMetadata& metadata,
|
||||
const std::string& partition_name, bool force_writable,
|
||||
const std::chrono::milliseconds& timeout_ms, std::string* path);
|
||||
|
||||
// Destroy the block device for a logical partition, by name. If |timeout_ms|
|
||||
// is non-zero, then this will block until the device path has been unlinked.
|
||||
bool DestroyLogicalPartition(const std::string& name, const std::chrono::milliseconds& timeout_ms);
|
||||
|
|
Loading…
Reference in a new issue