Merge "first_stage_mount: Create snapshot devices before launching first_stage_console" am: 0c931aa993
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1565166 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I6d92b22489e5bae7acbe7ae7e0ecbf3f738ba719
This commit is contained in:
commit
c30a2b00ca
3 changed files with 39 additions and 10 deletions
|
|
@ -298,7 +298,15 @@ int FirstStageMain(int argc, char** argv) {
|
||||||
<< module_elapse_time.count() << " ms";
|
<< module_elapse_time.count() << " ms";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool created_devices = false;
|
||||||
if (want_console == FirstStageConsoleParam::CONSOLE_ON_FAILURE) {
|
if (want_console == FirstStageConsoleParam::CONSOLE_ON_FAILURE) {
|
||||||
|
if (!IsRecoveryMode()) {
|
||||||
|
created_devices = DoCreateDevices();
|
||||||
|
if (!created_devices){
|
||||||
|
LOG(ERROR) << "Failed to create device nodes early";
|
||||||
|
}
|
||||||
|
}
|
||||||
StartConsole(cmdline);
|
StartConsole(cmdline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -339,7 +347,7 @@ int FirstStageMain(int argc, char** argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DoFirstStageMount()) {
|
if (!DoFirstStageMount(!created_devices)) {
|
||||||
LOG(FATAL) << "Failed to mount required partitions early ...";
|
LOG(FATAL) << "Failed to mount required partitions early ...";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,7 @@ class FirstStageMount {
|
||||||
// The factory method to create either FirstStageMountVBootV1 or FirstStageMountVBootV2
|
// The factory method to create either FirstStageMountVBootV1 or FirstStageMountVBootV2
|
||||||
// based on device tree configurations.
|
// based on device tree configurations.
|
||||||
static std::unique_ptr<FirstStageMount> Create();
|
static std::unique_ptr<FirstStageMount> Create();
|
||||||
|
bool DoCreateDevices(); // Creates devices and logical partitions from storage devices
|
||||||
bool DoFirstStageMount(); // Mounts fstab entries read from device tree.
|
bool DoFirstStageMount(); // Mounts fstab entries read from device tree.
|
||||||
bool InitDevices();
|
bool InitDevices();
|
||||||
|
|
||||||
|
|
@ -244,13 +245,7 @@ std::unique_ptr<FirstStageMount> FirstStageMount::Create() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FirstStageMount::DoFirstStageMount() {
|
bool FirstStageMount::DoCreateDevices() {
|
||||||
if (!IsDmLinearEnabled() && fstab_.empty()) {
|
|
||||||
// Nothing to mount.
|
|
||||||
LOG(INFO) << "First stage mount skipped (missing/incompatible/empty fstab in device tree)";
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!InitDevices()) return false;
|
if (!InitDevices()) return false;
|
||||||
|
|
||||||
// Mount /metadata before creating logical partitions, since we need to
|
// Mount /metadata before creating logical partitions, since we need to
|
||||||
|
|
@ -269,6 +264,16 @@ bool FirstStageMount::DoFirstStageMount() {
|
||||||
|
|
||||||
if (!CreateLogicalPartitions()) return false;
|
if (!CreateLogicalPartitions()) return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FirstStageMount::DoFirstStageMount() {
|
||||||
|
if (!IsDmLinearEnabled() && fstab_.empty()) {
|
||||||
|
// Nothing to mount.
|
||||||
|
LOG(INFO) << "First stage mount skipped (missing/incompatible/empty fstab in device tree)";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!MountPartitions()) return false;
|
if (!MountPartitions()) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -829,8 +834,18 @@ bool FirstStageMountVBootV2::InitAvbHandle() {
|
||||||
|
|
||||||
// Public functions
|
// Public functions
|
||||||
// ----------------
|
// ----------------
|
||||||
|
// Creates devices and logical partitions from storage devices
|
||||||
|
bool DoCreateDevices() {
|
||||||
|
std::unique_ptr<FirstStageMount> handle = FirstStageMount::Create();
|
||||||
|
if (!handle) {
|
||||||
|
LOG(ERROR) << "Failed to create FirstStageMount";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return handle->DoCreateDevices();
|
||||||
|
}
|
||||||
|
|
||||||
// Mounts partitions specified by fstab in device tree.
|
// Mounts partitions specified by fstab in device tree.
|
||||||
bool DoFirstStageMount() {
|
bool DoFirstStageMount(bool create_devices) {
|
||||||
// Skips first stage mount if we're in recovery mode.
|
// Skips first stage mount if we're in recovery mode.
|
||||||
if (IsRecoveryMode()) {
|
if (IsRecoveryMode()) {
|
||||||
LOG(INFO) << "First stage mount skipped (recovery mode)";
|
LOG(INFO) << "First stage mount skipped (recovery mode)";
|
||||||
|
|
@ -842,6 +857,11 @@ bool DoFirstStageMount() {
|
||||||
LOG(ERROR) << "Failed to create FirstStageMount";
|
LOG(ERROR) << "Failed to create FirstStageMount";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (create_devices) {
|
||||||
|
if (!handle->DoCreateDevices()) return false;
|
||||||
|
}
|
||||||
|
|
||||||
return handle->DoFirstStageMount();
|
return handle->DoFirstStageMount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,8 @@
|
||||||
namespace android {
|
namespace android {
|
||||||
namespace init {
|
namespace init {
|
||||||
|
|
||||||
bool DoFirstStageMount();
|
bool DoCreateDevices();
|
||||||
|
bool DoFirstStageMount(bool create_devices);
|
||||||
void SetInitAvbVersionInRecovery();
|
void SetInitAvbVersionInRecovery();
|
||||||
|
|
||||||
} // namespace init
|
} // namespace init
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue