summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/init.c
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2000-12-12 21:05:30 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2000-12-12 21:05:30 +0000
commit2b2914cc04a93ca362e4eb3663061c3039aa4049 (patch)
tree3f8dbeae1bc114e58f3246cd76b9b0156392b720 /mdk-stage1/init.c
parent7852f76ee05551c05a4f833f9a55bec15f44f85d (diff)
downloaddrakx-backup-do-not-use-2b2914cc04a93ca362e4eb3663061c3039aa4049.tar
drakx-backup-do-not-use-2b2914cc04a93ca362e4eb3663061c3039aa4049.tar.gz
drakx-backup-do-not-use-2b2914cc04a93ca362e4eb3663061c3039aa4049.tar.bz2
drakx-backup-do-not-use-2b2914cc04a93ca362e4eb3663061c3039aa4049.tar.xz
drakx-backup-do-not-use-2b2914cc04a93ca362e4eb3663061c3039aa4049.zip
- add pci probing feature
- add listing of available modules and insmod'ing on user request - make rescue-stage2 working
Diffstat (limited to 'mdk-stage1/init.c')
-rw-r--r--mdk-stage1/init.c34
1 files changed, 24 insertions, 10 deletions
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;
}