diff options
author | Colin Guthrie <colin@mageia.org> | 2013-10-28 23:35:35 +0000 |
---|---|---|
committer | Colin Guthrie <colin@mageia.org> | 2013-10-29 20:29:08 +0000 |
commit | 33a891128a5ac6fa2c581ef4106fe569f47eb867 (patch) | |
tree | 7cbc7f1ba8f9674b5244010bf2fde0b1db2645c6 | |
parent | 065557f6287bd87a4e52bea28db5a0b9c4a98b76 (diff) | |
download | drakx-33a891128a5ac6fa2c581ef4106fe569f47eb867.tar drakx-33a891128a5ac6fa2c581ef4106fe569f47eb867.tar.gz drakx-33a891128a5ac6fa2c581ef4106fe569f47eb867.tar.bz2 drakx-33a891128a5ac6fa2c581ef4106fe569f47eb867.tar.xz drakx-33a891128a5ac6fa2c581ef4106fe569f47eb867.zip |
stage1: Switch to a new mode of knowing when to re-exec init.
Now that dracut runs stage1 earlier, we need to store it's exit code
for later reuse. In this, the separate dracut module will just write a
flag file in /run/drakx/ to indicate that we want to re-exec /sbin/init
(after doing some symlinks and /usr bind mount) rather than run the install.
As a result there is no need to return 0x35 ('procced') so just return
0 and keep 0x35 return code for when we really do need to restart stage1
(e.g. on a fatal error). The dracut module should loop if 0x35 is
ever returned.
-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 } |