init: use '/system' as the system mount point for force_normal_boot
We need to keep the right mount points in the fstab for other processes to access (/ for system-as-root or /system otherwise). Force_normal_boot devices are defacto not system-as-root, since they're booting through the recovery ramdisk and therefore must use /system as the system mount point. Bug: 114062208 Test: boot pixel from recovery with force_normal_boot Change-Id: Ib0e4e4f8a29299ecdcd35e8f1415551c4c9745ad
This commit is contained in:
parent
3da42a6c05
commit
c382957789
|
@ -120,14 +120,18 @@ static inline bool IsDtVbmetaCompatible() {
|
|||
return is_android_dt_value_expected("vbmeta/compatible", "android,vbmeta");
|
||||
}
|
||||
|
||||
static bool IsRecoveryMode() {
|
||||
static bool ForceNormalBoot() {
|
||||
static bool force_normal_boot = []() {
|
||||
std::string cmdline;
|
||||
android::base::ReadFileToString("/proc/cmdline", &cmdline);
|
||||
return cmdline.find("androidboot.force_normal_boot=1") != std::string::npos;
|
||||
}();
|
||||
|
||||
return !force_normal_boot && access("/system/bin/recovery", F_OK) == 0;
|
||||
return force_normal_boot;
|
||||
}
|
||||
|
||||
static bool IsRecoveryMode() {
|
||||
return !ForceNormalBoot() && access("/system/bin/recovery", F_OK) == 0;
|
||||
}
|
||||
|
||||
static inline bool IsDmLinearEnabled() {
|
||||
|
@ -368,11 +372,15 @@ bool FirstStageMount::MountPartitions() {
|
|||
// this case, we mount system first then pivot to it. From that point on,
|
||||
// we are effectively identical to a system-as-root device.
|
||||
auto system_partition =
|
||||
std::find_if(mount_fstab_recs_.begin(), mount_fstab_recs_.end(), [](const auto& rec) {
|
||||
return rec->mount_point == "/system"s ||
|
||||
rec->mount_point == "/system_recovery_mount"s;
|
||||
});
|
||||
std::find_if(mount_fstab_recs_.begin(), mount_fstab_recs_.end(),
|
||||
[](const auto& rec) { return rec->mount_point == "/system"s; });
|
||||
|
||||
if (system_partition != mount_fstab_recs_.end()) {
|
||||
if (ForceNormalBoot()) {
|
||||
free((*system_partition)->mount_point);
|
||||
(*system_partition)->mount_point = strdup("/system_recovery_mount");
|
||||
}
|
||||
|
||||
if (!MountPartition(*system_partition)) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue