Merge "liblp: Add partitions to the correct group when writing LpMetadata."

This commit is contained in:
Treehugger Robot 2018-10-17 01:54:09 +00:00 committed by Gerrit Code Review
commit 4bc53d20af

View file

@ -505,6 +505,7 @@ std::unique_ptr<LpMetadata> MetadataBuilder::Export() {
strncpy(out.name, group->name().c_str(), sizeof(out.name));
out.maximum_size = group->maximum_size();
group_indices[group->name()] = metadata->groups.size();
metadata->groups.push_back(out);
}
@ -528,6 +529,14 @@ std::unique_ptr<LpMetadata> MetadataBuilder::Export() {
part.num_extents = static_cast<uint32_t>(partition->extents().size());
part.attributes = partition->attributes();
auto iter = group_indices.find(partition->group_name());
if (iter == group_indices.end()) {
LERROR << "Partition " << partition->name() << " is a member of unknown group "
<< partition->group_name();
return nullptr;
}
part.group_index = iter->second;
for (const auto& extent : partition->extents()) {
extent->AddTo(metadata.get());
}