Cleanup magiskinit code

This commit is contained in:
topjohnwu
2021-10-26 00:35:55 -07:00
parent 2e299b3814
commit 50710c72ad
6 changed files with 124 additions and 135 deletions
+10 -10
View File
@@ -56,7 +56,7 @@ static int dump_manager(const char *path, mode_t mode) {
class RecoveryInit : public BaseInit {
public:
RecoveryInit(char *argv[], cmdline *cmd) : BaseInit(argv, cmd) {}
RecoveryInit(char *argv[], BootConfig *cmd) : BaseInit(argv, cmd) {}
void start() override {
LOGD("Ramdisk is recovery, abort\n");
rename("/.backup/init", "/init");
@@ -141,25 +141,25 @@ int main(int argc, char *argv[]) {
return 1;
BaseInit *init;
cmdline cmd{};
BootConfig config{};
if (argc > 1 && argv[1] == "selinux_setup"sv) {
setup_klog();
init = new SecondStageInit(argv);
} else {
// This will also mount /sys and /proc
load_kernel_info(&cmd);
load_kernel_info(&config);
if (cmd.skip_initramfs)
init = new SARInit(argv, &cmd);
else if (cmd.force_normal_boot)
init = new FirstStageInit(argv, &cmd);
if (config.skip_initramfs)
init = new SARInit(argv, &config);
else 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, &cmd);
init = new RecoveryInit(argv, &config);
else if (check_two_stage())
init = new FirstStageInit(argv, &cmd);
init = new FirstStageInit(argv, &config);
else
init = new RootFSInit(argv, &cmd);
init = new RootFSInit(argv, &config);
}
// Run the main routine