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

The group_indices variable was intended to facilitate this, but I forgot
to actually use it.

Bug: 116817738
Test: lpmake, lpdump super_empty.img
Change-Id: Ia0da50b56b6c09e277324ec9d7aea6ce48fdc10a
This commit is contained in:
David Anderson 2018-10-16 15:27:56 -07:00
parent 79e5b550ce
commit 875434618f

View file

@ -523,6 +523,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);
}
@ -546,6 +547,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());
}