Merge changes I82b7d77b,I6b77690c am: ad7d1d13a4 am: 85d6c1cff5
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1526995 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I3865a6659fdc430e9573e9fe5e8a522520b76438
This commit is contained in:
commit
3526a48e87
3 changed files with 46 additions and 21 deletions
|
|
@ -286,7 +286,11 @@ int FirstStageMain(int argc, char** argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (want_console == FirstStageConsoleParam::CONSOLE_ON_FAILURE) {
|
if (want_console == FirstStageConsoleParam::CONSOLE_ON_FAILURE) {
|
||||||
|
if (!DoCreateDevices()) {
|
||||||
|
LOG(ERROR) << "Failed to create device nodes early";
|
||||||
|
}
|
||||||
StartConsole(cmdline);
|
StartConsole(cmdline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -327,7 +331,7 @@ int FirstStageMain(int argc, char** argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DoFirstStageMount()) {
|
if (!DoFirstStageMount(want_console != FirstStageConsoleParam::CONSOLE_ON_FAILURE)) {
|
||||||
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,6 +245,28 @@ std::unique_ptr<FirstStageMount> FirstStageMount::Create() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FirstStageMount::DoCreateDevices() {
|
||||||
|
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;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool FirstStageMount::DoFirstStageMount() {
|
bool FirstStageMount::DoFirstStageMount() {
|
||||||
if (!IsDmLinearEnabled() && fstab_.empty()) {
|
if (!IsDmLinearEnabled() && fstab_.empty()) {
|
||||||
// Nothing to mount.
|
// Nothing to mount.
|
||||||
|
|
@ -251,8 +274,6 @@ bool FirstStageMount::DoFirstStageMount() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!InitDevices()) return false;
|
|
||||||
|
|
||||||
if (!MountPartitions()) return false;
|
if (!MountPartitions()) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -505,22 +526,6 @@ bool FirstStageMount::TrySwitchSystemAsRoot() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FirstStageMount::MountPartitions() {
|
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 (!TrySwitchSystemAsRoot()) return false;
|
||||||
|
|
||||||
if (!SkipMountingPartitions(&fstab_)) return false;
|
if (!SkipMountingPartitions(&fstab_)) return false;
|
||||||
|
|
@ -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