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: Elliot Berman <eberman@quicinc.com>
diff --git a/init/first_stage_mount.cpp b/init/first_stage_mount.cpp
index 7c46281..7307237 100644
--- a/init/first_stage_mount.cpp
+++ b/init/first_stage_mount.cpp
@@ -253,6 +253,22 @@
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::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;