From 06ed613e7363bd0b67aa7899f1c813c1a098d15f Mon Sep 17 00:00:00 2001 From: Bowgo Tsai Date: Thu, 8 Jun 2017 10:43:41 +0800 Subject: [PATCH] first stage mount: removing the restriction of mount points Current first stage mount only allows three mount points: system, vendor and/or odm. This was introduced by project Treble to mount those verified partitions early. However, there might be some other custom partitions needs to be mounted early as well. This CL removes the restriction and does first stage mount for whatever specified in fstab-dt. Bug: 62423887 Test: first stage mount /vendor with vboot 1.0 Test: first stage mount /vendor with vboot 2.0 (AVB) Change-Id: I6c146c64e673c35c2823523ccbde193590430c48 --- fs_mgr/fs_mgr_fstab.cpp | 12 ++---------- init/init_first_stage.cpp | 15 ++++++--------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/fs_mgr/fs_mgr_fstab.cpp b/fs_mgr/fs_mgr_fstab.cpp index 70cd60878..7a41b147d 100644 --- a/fs_mgr/fs_mgr_fstab.cpp +++ b/fs_mgr/fs_mgr_fstab.cpp @@ -337,16 +337,8 @@ static std::string read_fstab_from_dt() { dirent* dp; while ((dp = readdir(fstabdir.get())) != NULL) { - // skip over name and compatible - if (dp->d_type != DT_DIR) { - continue; - } - - // skip if its not 'vendor', 'odm' or 'system' - if (strcmp(dp->d_name, "odm") && strcmp(dp->d_name, "system") && - strcmp(dp->d_name, "vendor")) { - continue; - } + // skip over name, compatible and . + if (dp->d_type != DT_DIR || dp->d_name[0] == '.') continue; // create \n std::vector fstab_entry; diff --git a/init/init_first_stage.cpp b/init/init_first_stage.cpp index 8a7d9a2bc..0f2b1f3d4 100644 --- a/init/init_first_stage.cpp +++ b/init/init_first_stage.cpp @@ -60,9 +60,8 @@ class FirstStageMount { virtual bool SetUpDmVerity(fstab_rec* fstab_rec) = 0; bool need_dm_verity_; - // Device tree fstab entries. + std::unique_ptr device_tree_fstab_; - // Eligible first stage mount candidates, only allow /system, /vendor and/or /odm. std::vector mount_fstab_recs_; std::set required_devices_partition_names_; DeviceHandler device_handler_; @@ -115,12 +114,10 @@ FirstStageMount::FirstStageMount() LOG(ERROR) << "Failed to read fstab from device tree"; return; } - for (auto mount_point : {"/system", "/vendor", "/odm"}) { - fstab_rec* fstab_rec = - fs_mgr_get_entry_for_mount_point(device_tree_fstab_.get(), mount_point); - if (fstab_rec != nullptr) { - mount_fstab_recs_.push_back(fstab_rec); - } + // Stores device_tree_fstab_->recs[] into mount_fstab_recs_ (vector) + // for easier manipulation later, e.g., range-base for loop. + for (int i = 0; i < device_tree_fstab_->num_entries; i++) { + mount_fstab_recs_.push_back(&device_tree_fstab_->recs[i]); } } @@ -420,7 +417,7 @@ bool FirstStageMountVBootV2::InitAvbHandle() { // Public functions // ---------------- -// Mounts /system, /vendor, and/or /odm if they are present in the fstab provided by device tree. +// Mounts partitions specified by fstab in device tree. bool DoFirstStageMount() { // Skips first stage mount if we're in recovery mode. if (IsRecoveryMode()) {