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

Commit a619f22e authored by Elliot Berman's avatar Elliot Berman
Browse files

first_stage_mount: Move CreateLogicalPartitions to DoFirstStageMount



In preparation for later commit:
   first_stage_mount: Create snapshot devices before launching
first_stage_console

Bug: 173732805
Bug: 174685384
Change-Id: I6b77690c7cf68f6235c99bf4ff897b0ee41c4d0e
Signed-off-by: default avatarElliot Berman <eberman@quicinc.com>
parent 81bf17ce
Loading
Loading
Loading
Loading
+16 −16
Original line number Diff line number Diff line
@@ -253,6 +253,22 @@ bool FirstStageMount::DoFirstStageMount() {

    if (!InitDevices()) return false;

    // Mount /metadata before creating logical partitions, since we need to
    // know whether a snapshot merge is in progress.
    auto metadata_partition = std::find_if(fstab_.begin(), fstab_.end(), [](const auto& entry) {
        return entry.mount_point == "/metadata";
    });
    if (metadata_partition != fstab_.end()) {
        if (MountPartition(metadata_partition, true /* erase_same_mounts */)) {
            // Copies DSU AVB keys from the ramdisk to /metadata.
            // Must be done before the following TrySwitchSystemAsRoot().
            // Otherwise, ramdisk will be inaccessible after switching root.
            CopyDsuAvbKeys();
        }
    }

    if (!CreateLogicalPartitions()) return false;

    if (!MountPartitions()) return false;

    return true;
@@ -505,22 +521,6 @@ bool FirstStageMount::TrySwitchSystemAsRoot() {
}

bool FirstStageMount::MountPartitions() {
    // Mount /metadata before creating logical partitions, since we need to
    // know whether a snapshot merge is in progress.
    auto metadata_partition = std::find_if(fstab_.begin(), fstab_.end(), [](const auto& entry) {
        return entry.mount_point == "/metadata";
    });
    if (metadata_partition != fstab_.end()) {
        if (MountPartition(metadata_partition, true /* erase_same_mounts */)) {
            // Copies DSU AVB keys from the ramdisk to /metadata.
            // Must be done before the following TrySwitchSystemAsRoot().
            // Otherwise, ramdisk will be inaccessible after switching root.
            CopyDsuAvbKeys();
        }
    }

    if (!CreateLogicalPartitions()) return false;

    if (!TrySwitchSystemAsRoot()) return false;

    if (!SkipMountingPartitions(&fstab_)) return false;