diff --git a/init/first_stage_mount.cpp b/init/first_stage_mount.cpp index 10a07a1cc..ada5a4752 100644 --- a/init/first_stage_mount.cpp +++ b/init/first_stage_mount.cpp @@ -81,8 +81,7 @@ class FirstStageMount { FirstStageMount(Fstab fstab); virtual ~FirstStageMount() = default; - // The factory method to create either FirstStageMountVBootV1 or FirstStageMountVBootV2 - // based on device tree configurations. + // The factory method to create a FirstStageMountVBootV2 instance. static Result> Create(); bool DoCreateDevices(); // Creates devices and logical partitions from storage devices bool DoFirstStageMount(); // Mounts fstab entries read from device tree. @@ -125,16 +124,6 @@ class FirstStageMount { std::map> preload_avb_key_blobs_; }; -class FirstStageMountVBootV1 : public FirstStageMount { - public: - FirstStageMountVBootV1(Fstab fstab) : FirstStageMount(std::move(fstab)) {} - ~FirstStageMountVBootV1() override = default; - - protected: - bool GetDmVerityDevices(std::set* devices) override; - bool SetUpDmVerity(FstabEntry* fstab_entry) override; -}; - class FirstStageMountVBootV2 : public FirstStageMount { public: friend void SetInitAvbVersionInRecovery(); @@ -243,11 +232,7 @@ Result> FirstStageMount::Create() { return fstab.error(); } - if (IsDtVbmetaCompatible(*fstab)) { - return std::make_unique(std::move(*fstab)); - } else { - return std::make_unique(std::move(*fstab)); - } + return std::make_unique(std::move(*fstab)); } bool FirstStageMount::DoCreateDevices() { @@ -679,56 +664,6 @@ void FirstStageMount::UseDsuIfPresent() { TransformFstabForDsu(&fstab_, active_dsu, dsu_partitions); } -bool FirstStageMountVBootV1::GetDmVerityDevices(std::set* devices) { - need_dm_verity_ = false; - - for (const auto& fstab_entry : fstab_) { - // Don't allow verifyatboot in the first stage. - if (fstab_entry.fs_mgr_flags.verify_at_boot) { - LOG(ERROR) << "Partitions can't be verified at boot"; - return false; - } - // Checks for verified partitions. - if (fstab_entry.fs_mgr_flags.verify) { - need_dm_verity_ = true; - } - } - - // Includes the partition names of fstab records. - // Notes that fstab_rec->blk_device has A/B suffix updated by fs_mgr when A/B is used. - for (const auto& fstab_entry : fstab_) { - // Skip pseudo filesystems. - if (fstab_entry.fs_type == "overlay") { - continue; - } - if (!fstab_entry.fs_mgr_flags.logical) { - devices->emplace(basename(fstab_entry.blk_device.c_str())); - } - } - - return true; -} - -bool FirstStageMountVBootV1::SetUpDmVerity(FstabEntry* fstab_entry) { - if (fstab_entry->fs_mgr_flags.verify) { - int ret = fs_mgr_setup_verity(fstab_entry, false /* wait_for_verity_dev */); - switch (ret) { - case FS_MGR_SETUP_VERITY_SKIPPED: - case FS_MGR_SETUP_VERITY_DISABLED: - LOG(INFO) << "Verity disabled/skipped for '" << fstab_entry->mount_point << "'"; - return true; - case FS_MGR_SETUP_VERITY_SUCCESS: - // The exact block device name (fstab_rec->blk_device) is changed to - // "/dev/block/dm-XX". Needs to create it because ueventd isn't started in init - // first stage. - return block_dev_init_.InitDmDevice(fstab_entry->blk_device); - default: - return false; - } - } - return true; // Returns true to mount the partition. -} - // First retrieve any vbmeta partitions from device tree (legacy) then read through the fstab // for any further vbmeta partitions. FirstStageMountVBootV2::FirstStageMountVBootV2(Fstab fstab)