diff options
author | David Anderson | 2018-05-01 15:57:14 -0500 |
---|---|---|
committer | David Anderson | 2018-05-02 14:23:15 -0500 |
commit | 29954f6062e59beb645109e2585afa4eb71e7992 (patch) | |
tree | 8475ddfd86a0e9ac04ff3da1e0dff9a1d6fbada7 /init | |
parent | 78393951de05ef60456f23d959400125684d7f7a (diff) | |
download | platform-system-core-29954f6062e59beb645109e2585afa4eb71e7992.tar.gz platform-system-core-29954f6062e59beb645109e2585afa4eb71e7992.tar.xz platform-system-core-29954f6062e59beb645109e2585afa4eb71e7992.zip |
init: refactor first stage to not require fstab
In order to support dm-linear devices, we need an additional first-stage
step to ensure that required devices are created. This must happen before
setting up dm-verity or mounting any first-stage partitions.
This patch refactors FirstStageMount so that having a compatible fstab
is optional. This will let us use InitRequiredDevices on systems that
would not otherwise perform first-stage mounts.
Bug: 78914864
Test: non-AVB devices still boot
Change-Id: I11265375a9900d983da8cabcc77d32c503ded02e
Diffstat (limited to 'init')
-rw-r--r-- | init/init_first_stage.cpp | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/init/init_first_stage.cpp b/init/init_first_stage.cpp index 45d3d4499..1b6e97ec7 100644 --- a/init/init_first_stage.cpp +++ b/init/init_first_stage.cpp | |||
@@ -118,14 +118,14 @@ static bool inline IsRecoveryMode() { | |||
118 | // ----------------- | 118 | // ----------------- |
119 | FirstStageMount::FirstStageMount() | 119 | FirstStageMount::FirstStageMount() |
120 | : need_dm_verity_(false), device_tree_fstab_(fs_mgr_read_fstab_dt(), fs_mgr_free_fstab) { | 120 | : need_dm_verity_(false), device_tree_fstab_(fs_mgr_read_fstab_dt(), fs_mgr_free_fstab) { |
121 | if (!device_tree_fstab_) { | 121 | if (device_tree_fstab_) { |
122 | // Stores device_tree_fstab_->recs[] into mount_fstab_recs_ (vector<fstab_rec*>) | ||
123 | // for easier manipulation later, e.g., range-base for loop. | ||
124 | for (int i = 0; i < device_tree_fstab_->num_entries; i++) { | ||
125 | mount_fstab_recs_.push_back(&device_tree_fstab_->recs[i]); | ||
126 | } | ||
127 | } else { | ||
122 | LOG(INFO) << "Failed to read fstab from device tree"; | 128 | LOG(INFO) << "Failed to read fstab from device tree"; |
123 | return; | ||
124 | } | ||
125 | // Stores device_tree_fstab_->recs[] into mount_fstab_recs_ (vector<fstab_rec*>) | ||
126 | // for easier manipulation later, e.g., range-base for loop. | ||
127 | for (int i = 0; i < device_tree_fstab_->num_entries; i++) { | ||
128 | mount_fstab_recs_.push_back(&device_tree_fstab_->recs[i]); | ||
129 | } | 129 | } |
130 | } | 130 | } |
131 | 131 | ||
@@ -138,8 +138,11 @@ std::unique_ptr<FirstStageMount> FirstStageMount::Create() { | |||
138 | } | 138 | } |
139 | 139 | ||
140 | bool FirstStageMount::DoFirstStageMount() { | 140 | bool FirstStageMount::DoFirstStageMount() { |
141 | // Nothing to mount. | 141 | if (mount_fstab_recs_.empty()) { |
142 | if (mount_fstab_recs_.empty()) return true; | 142 | // Nothing to mount. |
143 | LOG(INFO) << "First stage mount skipped (missing/incompatible/empty fstab in device tree)"; | ||
144 | return true; | ||
145 | } | ||
143 | 146 | ||
144 | if (!InitDevices()) return false; | 147 | if (!InitDevices()) return false; |
145 | 148 | ||
@@ -479,12 +482,6 @@ bool DoFirstStageMount() { | |||
479 | return true; | 482 | return true; |
480 | } | 483 | } |
481 | 484 | ||
482 | // Firstly checks if device tree fstab entries are compatible. | ||
483 | if (!is_android_dt_value_expected("fstab/compatible", "android,fstab")) { | ||
484 | LOG(INFO) << "First stage mount skipped (missing/incompatible fstab in device tree)"; | ||
485 | return true; | ||
486 | } | ||
487 | |||
488 | std::unique_ptr<FirstStageMount> handle = FirstStageMount::Create(); | 485 | std::unique_ptr<FirstStageMount> handle = FirstStageMount::Create(); |
489 | if (!handle) { | 486 | if (!handle) { |
490 | LOG(ERROR) << "Failed to create FirstStageMount"; | 487 | LOG(ERROR) << "Failed to create FirstStageMount"; |