Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init: support 2SI devices with skip_initramfs #8337

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion native/src/init/getinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,9 @@ kv_pairs load_partition_map() {
}

bool check_two_stage() {
if (access("/apex", F_OK) == 0)
if (access("/first_stage_ramdisk", F_OK) == 0)
return true;
if (access("/second_stage_resources", F_OK) == 0)
return true;
if (access("/system/bin/init", F_OK) == 0)
return true;
Expand Down
14 changes: 8 additions & 6 deletions native/src/init/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,17 @@ int main(int argc, char *argv[]) {
} else {
// This will also mount /sys and /proc
load_kernel_info(&config);
bool recovery = access("/sbin/recovery", F_OK) == 0 ||
access("/system/bin/recovery", F_OK) == 0;

if (config.skip_initramfs)
init = new LegacySARInit(argv, &config);
else if (config.force_normal_boot)
if (config.force_normal_boot)
init = new FirstStageInit(argv, &config);
else if (access("/sbin/recovery", F_OK) == 0 || access("/system/bin/recovery", F_OK) == 0)
init = new RecoveryInit(argv, &config);
else if (check_two_stage())
else if (!recovery && check_two_stage())
init = new FirstStageInit(argv, &config);
else if (config.skip_initramfs)
init = new LegacySARInit(argv, &config);
else if (recovery)
init = new RecoveryInit(argv, &config);
else
init = new RootFSInit(argv, &config);
}
Expand Down
3 changes: 1 addition & 2 deletions native/src/init/mount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,7 @@ bool LegacySARInit::mount_system_root() {
xmount("tmpfs", "/dev", "tmpfs", 0, "mode=755");
mount_list.emplace_back("/dev");

// Use the apex folder to determine whether 2SI (Android 10+)
bool is_two_stage = access("/apex", F_OK) == 0;
bool is_two_stage = access("/system/bin/init", F_OK) == 0;
LOGD("is_two_stage: [%d]\n", is_two_stage);

// For API 28 AVD, it uses legacy SAR setup that requires
Expand Down