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

Commit 5283ae4a authored by David Anderson's avatar David Anderson
Browse files

libsnapshot: Only mount snapshots in MapAllSnapshots().

By accident, this was mounting partitions as well, which caused
conflicts in partial updates where some partitions don't have snapshots.

Test: update_device.py with partial OTA
Change-Id: I2db0e6269f0a02cbe8164fa2a72b887c352f56d8
parent 71ab9dbe
Loading
Loading
Loading
Loading
+35 −3
Original line number Original line Diff line number Diff line
@@ -2172,12 +2172,44 @@ bool SnapshotManager::MapAllSnapshots(const std::chrono::milliseconds& timeout_m
        return false;
        return false;
    }
    }


    if (!UnmapAllSnapshots(lock.get())) {
    std::vector<std::string> snapshots;
    if (!ListSnapshots(lock.get(), &snapshots)) {
        return false;
    }

    const auto& opener = device_->GetPartitionOpener();
    auto slot_suffix = device_->GetOtherSlotSuffix();
    auto slot_number = SlotNumberForSlotSuffix(slot_suffix);
    auto super_device = device_->GetSuperDevice(slot_number);
    auto metadata = android::fs_mgr::ReadMetadata(opener, super_device, slot_number);
    if (!metadata) {
        LOG(ERROR) << "MapAllSnapshots could not read dynamic partition metadata for device: "
                   << super_device;
        return false;
    }

    for (const auto& snapshot : snapshots) {
        if (!UnmapPartitionWithSnapshot(lock.get(), snapshot)) {
            LOG(ERROR) << "MapAllSnapshots could not unmap snapshot: " << snapshot;
            return false;
        }

        CreateLogicalPartitionParams params = {
                .block_device = super_device,
                .metadata = metadata.get(),
                .partition_name = snapshot,
                .partition_opener = &opener,
                .timeout_ms = timeout_ms,
        };
        if (!MapPartitionWithSnapshot(lock.get(), std::move(params), SnapshotContext::Mount,
                                      nullptr)) {
            LOG(ERROR) << "MapAllSnapshots failed to map: " << snapshot;
            return false;
            return false;
        }
        }
    }


    uint32_t slot = SlotNumberForSlotSuffix(device_->GetOtherSlotSuffix());
    LOG(INFO) << "MapAllSnapshots succeeded.";
    return MapAllPartitions(lock.get(), device_->GetSuperDevice(slot), slot, timeout_ms);
    return true;
}
}


bool SnapshotManager::UnmapAllSnapshots() {
bool SnapshotManager::UnmapAllSnapshots() {