diff options
-rw-r--r-- | mdk-stage1/init.c | 57 | ||||
-rw-r--r-- | mdk-stage1/stage1.c | 4 |
2 files changed, 30 insertions, 31 deletions
diff --git a/mdk-stage1/init.c b/mdk-stage1/init.c index f774484d7..b5fb6115b 100644 --- a/mdk-stage1/init.c +++ b/mdk-stage1/init.c @@ -521,46 +521,45 @@ int main(int argc, char **argv) fatal_error("Unable to bind mount /usr filesystem from rescue or installer stage2"); - do { - printf("proceeding, please wait...\n"); - - if (!(installpid = fork())) { - /* child */ - char * child_argv[2]; - child_argv[0] = BINARY_STAGE2; - child_argv[1] = NULL; - - execve(child_argv[0], child_argv, env); - printf("error in exec of %s :-( [%d]\n", child_argv[0], errno); - return 0; - } - - do { - childpid = wait4(-1, &wait_status, 0, NULL); - } while (childpid != installpid); - } while (WIFEXITED(wait_status) && WEXITSTATUS(wait_status) == exit_value_restart); + if (access("/run/drakx/run-init", R_OK) == 0) { + /* This is typically used in rescue mode */ + char * child_argv[2] = { "/sbin/init", NULL }; - /* allow Ctrl Alt Del to reboot */ - reboot(LINUX_REBOOT_CMD_CAD_ON); - - if (in_reboot()) { - // any exitcode is valid if we're in_reboot - } else if (WIFEXITED(wait_status) && WEXITSTATUS(wait_status) == exit_value_proceed) { kill(klog_pid, 9); printf("proceeding, please wait...\n"); + execve(child_argv[0], child_argv, env); + fatal_error("failed to exec /sbin/init"); + } + + /* This is installer mode */ + do { + printf("proceeding, please wait...\n"); - { - char * child_argv[2] = { "/sbin/init", NULL }; + if (!(installpid = fork())) { + /* child */ + char * child_argv[2] = { BINARY_STAGE2, NULL }; execve(child_argv[0], child_argv, env); + printf("error in exec of %s :-( [%d]\n", child_argv[0], errno); + return 0; } - fatal_error("failed to exec /sbin/init"); - } else if (!WIFEXITED(wait_status) || WEXITSTATUS(wait_status) != 0) { + + do { + childpid = wait4(-1, &wait_status, 0, NULL); + } while (childpid != installpid); + } while (WIFEXITED(wait_status) && WEXITSTATUS(wait_status) == exit_value_restart); + + /* allow Ctrl Alt Del to reboot */ + reboot(LINUX_REBOOT_CMD_CAD_ON); + + if (in_reboot()) { + // any exitcode is valid if we're in_reboot + } else if (!WIFEXITED(wait_status) || WEXITSTATUS(wait_status) != 0) { printf("exited abnormally :-( "); if (WIFSIGNALED(wait_status)) printf("-- received signal %d", WTERMSIG(wait_status)); printf("\n"); abnormal_termination = 1; - } + } if (!abnormal_termination) { int i; diff --git a/mdk-stage1/stage1.c b/mdk-stage1/stage1.c index 4439b7d37..94bb1e0df 100644 --- a/mdk-stage1/stage1.c +++ b/mdk-stage1/stage1.c @@ -437,7 +437,7 @@ int main(int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)) if (IS_RESCUE) return 66; /* ask init to exec new init */ - else - return 0x35; /* ask init to run stage2 binary */ + + return 0; #endif } |