Merge "liblp: Remove the slot-suffix requirement in MetadataBuilder."

This commit is contained in:
David Anderson 2019-06-17 22:58:20 +00:00 committed by Gerrit Code Review
commit bc53c842e9
3 changed files with 1 additions and 20 deletions

View File

@ -214,7 +214,7 @@ void MetadataBuilder::OverrideABForTesting(bool ab_device) {
sABOverrideValue = ab_device;
}
MetadataBuilder::MetadataBuilder() : auto_slot_suffixing_(false), ignore_slot_suffixing_(false) {
MetadataBuilder::MetadataBuilder() : auto_slot_suffixing_(false) {
memset(&geometry_, 0, sizeof(geometry_));
geometry_.magic = LP_METADATA_GEOMETRY_MAGIC;
geometry_.struct_size = sizeof(geometry_);
@ -443,11 +443,6 @@ Partition* MetadataBuilder::AddPartition(const std::string& name, const std::str
LERROR << "Could not find partition group: " << group_name;
return nullptr;
}
if (IsABDevice() && !auto_slot_suffixing_ && name != "scratch" && !ignore_slot_suffixing_ &&
GetPartitionSlotSuffix(name).empty()) {
LERROR << "Unsuffixed partition not allowed on A/B device: " << name;
return nullptr;
}
partitions_.push_back(std::make_unique<Partition>(name, group_name, attributes));
return partitions_.back().get();
}
@ -1049,10 +1044,6 @@ void MetadataBuilder::SetAutoSlotSuffixing() {
auto_slot_suffixing_ = true;
}
void MetadataBuilder::IgnoreSlotSuffixing() {
ignore_slot_suffixing_ = true;
}
bool MetadataBuilder::IsABDevice() const {
if (sABOverrideSet) {
return sABOverrideValue;

View File

@ -772,15 +772,6 @@ TEST_F(BuilderTest, ImportPartitionsFail) {
EXPECT_FALSE(builder->ImportPartitions(*exported.get(), {"system"}));
}
TEST_F(BuilderTest, UnsuffixedPartitions) {
MetadataBuilder::OverrideABForTesting(true);
unique_ptr<MetadataBuilder> builder = MetadataBuilder::New(1024 * 1024, 1024, 2);
ASSERT_NE(builder, nullptr);
ASSERT_EQ(builder->AddPartition("system", 0), nullptr);
ASSERT_NE(builder->AddPartition("system_a", 0), nullptr);
}
TEST_F(BuilderTest, ABExtents) {
BlockDeviceInfo device_info("super", 10_GiB, 768 * 1024, 0, 4096);

View File

@ -345,7 +345,6 @@ class MetadataBuilder {
std::vector<std::unique_ptr<PartitionGroup>> groups_;
std::vector<LpMetadataBlockDevice> block_devices_;
bool auto_slot_suffixing_;
bool ignore_slot_suffixing_;
};
// Read BlockDeviceInfo for a given block device. This always returns false