From 2b2914cc04a93ca362e4eb3663061c3039aa4049 Mon Sep 17 00:00:00 2001 From: Guillaume Cottenceau Date: Tue, 12 Dec 2000 21:05:30 +0000 Subject: - add pci probing feature - add listing of available modules and insmod'ing on user request - make rescue-stage2 working --- mdk-stage1/init.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) (limited to 'mdk-stage1/init.c') diff --git a/mdk-stage1/init.c b/mdk-stage1/init.c index 3783bc8c7..22a381e6e 100644 --- a/mdk-stage1/init.c +++ b/mdk-stage1/init.c @@ -54,6 +54,7 @@ char * env[] = { */ int testing; +int klog_pid; void fatal_error(char *msg) @@ -107,12 +108,11 @@ void doklog() return; } - if (fork()) { + if ((klog_pid = fork())) { /* parent */ close(in); close(out); close(log); - sleep(1); return; } @@ -364,6 +364,17 @@ void disable_swap(void) } } +int is_rescue() +{ + int fd, size; + char buf[512]; + if ((fd = open("/proc/cmdline", O_RDONLY, 0)) == -1) + fatal_error("could not open /proc/cmdline"); + size = read(fd, buf, sizeof(buf)); + buf[size-1] = 0; + close(fd); + return (strstr(buf, "rescue") != NULL); +} int main(int argc, char **argv) { @@ -372,7 +383,7 @@ int main(int argc, char **argv) int fd; int abnormal_termination = 0; int end_stage2 = 0; - + /* getpid() != 1 should work, by linuxrc tends to get a larger pid */ testing = (getpid() > 50); @@ -452,8 +463,8 @@ int main(int argc, char **argv) printf("execing: %s\n", child_argv[0]); execve(child_argv[0], child_argv, env); - - exit(0); + printf("error in exec of stage1 :-(\n"); + return 0; } while (!end_stage2) { @@ -468,12 +479,16 @@ int main(int argc, char **argv) printf("-- received signal %d", WTERMSIG(wait_status)); printf("\n"); abnormal_termination = 1; - } - else - printf("back to stage1-initializer control -- install exited normally\n"); + } else if (is_rescue()) { + kill(klog_pid, 9); + printf("exiting stage1-initializer -- giving hand to rescue\n"); + return 0; + } + + printf("back to stage1-initializer control -- install exited normally\n"); if (testing) - exit(0); + return 0; sync(); sync(); @@ -501,6 +516,5 @@ int main(int argc, char **argv) while (1); } - exit(0); return 0; } -- cgit v1.2.1