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

Commit 769522da authored by David Anderson's avatar David Anderson
Browse files

liblp: Remove unused slot-suffixing code.

Bug: 406251416
Test: th
Change-Id: I4f2b30377eb9878431e58b5daa37ee43919c4dc2
parent 9ccbab0d
Loading
Loading
Loading
Loading
+7 −19
Original line number Diff line number Diff line
@@ -84,8 +84,7 @@ std::string SerializeMetadata(const LpMetadata& input) {
// Perform checks so we don't accidentally overwrite valid metadata with
// potentially invalid metadata, or random partition data with metadata.
static bool ValidateAndSerializeMetadata([[maybe_unused]] const IPartitionOpener& opener,
                                         const LpMetadata& metadata, const std::string& slot_suffix,
                                         std::string* blob) {
                                         const LpMetadata& metadata, std::string* blob) {
    const LpMetadataGeometry& geometry = metadata.geometry;

    *blob = SerializeMetadata(metadata);
@@ -116,13 +115,9 @@ static bool ValidateAndSerializeMetadata([[maybe_unused]] const IPartitionOpener
    for (const auto& block_device : metadata.block_devices) {
        std::string partition_name = GetBlockDevicePartitionName(block_device);
        if (block_device.flags & LP_BLOCK_DEVICE_SLOT_SUFFIXED) {
            if (slot_suffix.empty()) {
                LERROR << "Block device " << partition_name << " requires a slot suffix,"
                       << " which could not be derived from the super partition name.";
            LERROR << "Slot-suffixed super is no longer supported.";
            return false;
        }
            partition_name += slot_suffix;
        }

        if ((block_device.first_logical_sector + 1) * LP_SECTOR_SIZE > block_device.size) {
            LERROR << "Block device " << partition_name << " has invalid first sector "
@@ -253,16 +248,11 @@ bool FlashPartitionTable(const IPartitionOpener& opener, const std::string& supe
        return false;
    }

    // This is only used in update_engine and fastbootd, where the super
    // partition should be specified as a name (or by-name link), and
    // therefore, we should be able to extract a slot suffix.
    std::string slot_suffix = GetPartitionSlotSuffix(super_partition);

    // Before writing geometry and/or logical partition tables, perform some
    // basic checks that the geometry and tables are coherent, and will fit
    // on the given block device.
    std::string metadata_blob;
    if (!ValidateAndSerializeMetadata(opener, metadata, slot_suffix, &metadata_blob)) {
    if (!ValidateAndSerializeMetadata(opener, metadata, &metadata_blob)) {
        return false;
    }

@@ -328,13 +318,11 @@ bool UpdatePartitionTable(const IPartitionOpener& opener, const std::string& sup
        return false;
    }

    std::string slot_suffix = SlotSuffixForSlotNumber(slot_number);

    // Before writing geometry and/or logical partition tables, perform some
    // basic checks that the geometry and tables are coherent, and will fit
    // on the given block device.
    std::string blob;
    if (!ValidateAndSerializeMetadata(opener, metadata, slot_suffix, &blob)) {
    if (!ValidateAndSerializeMetadata(opener, metadata, &blob)) {
        return false;
    }

@@ -366,7 +354,7 @@ bool UpdatePartitionTable(const IPartitionOpener& opener, const std::string& sup
        // synchronize the backup copy. This guarantees that a partial write
        // still leaves one copy intact.
        std::string old_blob;
        if (!ValidateAndSerializeMetadata(opener, *primary.get(), slot_suffix, &old_blob)) {
        if (!ValidateAndSerializeMetadata(opener, *primary.get(), &old_blob)) {
            LERROR << "Error serializing primary metadata to repair corrupted backup";
            return false;
        }
@@ -378,7 +366,7 @@ bool UpdatePartitionTable(const IPartitionOpener& opener, const std::string& sup
        // The backup copy is coherent, and the primary is not. Sync it for
        // safety.
        std::string old_blob;
        if (!ValidateAndSerializeMetadata(opener, *backup.get(), slot_suffix, &old_blob)) {
        if (!ValidateAndSerializeMetadata(opener, *backup.get(), &old_blob)) {
            LERROR << "Error serializing backup metadata to repair corrupted primary";
            return false;
        }