Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bc53c842 authored by David Anderson's avatar David Anderson Committed by Gerrit Code Review
Browse files

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

parents 7f34035f 935420f9
Loading
Loading
Loading
Loading
+1 −10
Original line number Diff line number Diff line
@@ -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;
+0 −9
Original line number Diff line number Diff line
@@ -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);

+0 −1
Original line number Diff line number Diff line
@@ -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