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

Commit 565577f9 authored by David Anderson's avatar David Anderson
Browse files

Add support for compressed snapshot merges in fastboot.

SnapshotManager::New() is now preferred in recovery. Previously we used
NewForFirstStageMount(), which is technically incorrect as that enables
code paths specifically for first-stage init.

We also explicitly label the snapuserd context, since rootfs in recovery
has unlabelled files.

Finally, we add a timeout to internal calls to
CreateSnapshotsAndLogicalPartitions. Without this, WaitForDevice() calls
will terminate immediately, which breaks VABC given the more complex
device stacking that is created.

Bug: 168258606
Test: fastboot snapshot-update merge
Change-Id: I3a663b95c0b1eabaf14e6fde409c6902653c3c5e
parent cfb743e4
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -659,7 +659,7 @@ bool SnapshotUpdateHandler(FastbootDevice* device, const std::vector<std::string
            return device->WriteFail("No snapshot merge is in progress");
            return device->WriteFail("No snapshot merge is in progress");
        }
        }


        auto sm = SnapshotManager::NewForFirstStageMount();
        auto sm = SnapshotManager::New();
        if (!sm) {
        if (!sm) {
            return device->WriteFail("Unable to create SnapshotManager");
            return device->WriteFail("Unable to create SnapshotManager");
        }
        }
+8 −4
Original line number Original line Diff line number Diff line
@@ -94,7 +94,11 @@ std::unique_ptr<SnapshotManager> SnapshotManager::New(IDeviceInfo* info) {
    if (!info) {
    if (!info) {
        info = new DeviceInfo();
        info = new DeviceInfo();
    }
    }
    return std::unique_ptr<SnapshotManager>(new SnapshotManager(info));
    auto sm = std::unique_ptr<SnapshotManager>(new SnapshotManager(info));
    if (info->IsRecovery()) {
        sm->ForceLocalImageManager();
    }
    return sm;
}
}


std::unique_ptr<SnapshotManager> SnapshotManager::NewForFirstStageMount(IDeviceInfo* info) {
std::unique_ptr<SnapshotManager> SnapshotManager::NewForFirstStageMount(IDeviceInfo* info) {
@@ -3169,7 +3173,7 @@ bool SnapshotManager::HandleImminentDataWipe(const std::function<void()>& callba


    auto slot_number = SlotNumberForSlotSuffix(device_->GetSlotSuffix());
    auto slot_number = SlotNumberForSlotSuffix(device_->GetSlotSuffix());
    auto super_path = device_->GetSuperDevice(slot_number);
    auto super_path = device_->GetSuperDevice(slot_number);
    if (!CreateLogicalAndSnapshotPartitions(super_path)) {
    if (!CreateLogicalAndSnapshotPartitions(super_path, 20s)) {
        LOG(ERROR) << "Unable to map partitions to complete merge.";
        LOG(ERROR) << "Unable to map partitions to complete merge.";
        return false;
        return false;
    }
    }
@@ -3209,7 +3213,7 @@ bool SnapshotManager::FinishMergeInRecovery() {


    auto slot_number = SlotNumberForSlotSuffix(device_->GetSlotSuffix());
    auto slot_number = SlotNumberForSlotSuffix(device_->GetSlotSuffix());
    auto super_path = device_->GetSuperDevice(slot_number);
    auto super_path = device_->GetSuperDevice(slot_number);
    if (!CreateLogicalAndSnapshotPartitions(super_path)) {
    if (!CreateLogicalAndSnapshotPartitions(super_path, 20s)) {
        LOG(ERROR) << "Unable to map partitions to complete merge.";
        LOG(ERROR) << "Unable to map partitions to complete merge.";
        return false;
        return false;
    }
    }
@@ -3355,7 +3359,7 @@ CreateResult SnapshotManager::RecoveryCreateSnapshotDevices(
    auto slot_suffix = device_->GetOtherSlotSuffix();
    auto slot_suffix = device_->GetOtherSlotSuffix();
    auto slot_number = SlotNumberForSlotSuffix(slot_suffix);
    auto slot_number = SlotNumberForSlotSuffix(slot_suffix);
    auto super_path = device_->GetSuperDevice(slot_number);
    auto super_path = device_->GetSuperDevice(slot_number);
    if (!CreateLogicalAndSnapshotPartitions(super_path)) {
    if (!CreateLogicalAndSnapshotPartitions(super_path, 20s)) {
        LOG(ERROR) << "Unable to map partitions.";
        LOG(ERROR) << "Unable to map partitions.";
        return CreateResult::ERROR;
        return CreateResult::ERROR;
    }
    }
+1 −0
Original line number Original line Diff line number Diff line
@@ -4,3 +4,4 @@ service snapuserd /system/bin/snapuserd
    disabled
    disabled
    user root
    user root
    group root system
    group root system
    seclabel u:r:snapuserd:s0