patch-1.3.43 linux/init/main.c

Next file: linux/init/version.c
Previous file: linux/include/linux/tty.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.42/linux/init/main.c linux/init/main.c
@@ -120,6 +120,7 @@
 
 int ramdisk_size;
 int root_mountflags = MS_RDONLY;
+char *execute_command = 0;
 
 #ifdef CONFIG_ROOT_NFS
 char nfs_root_name[256] = { 0, };
@@ -421,6 +422,11 @@
 			console_loglevel = 10;
 			continue;
 		}
+		if (!strncmp(line,"init=",5)) {
+			line += 5;
+			execute_command = line;
+			continue;
+		}
 		if (checksetup(line))
 			continue;
 		/*
@@ -651,17 +657,22 @@
 	(void) dup(0);
 	(void) dup(0);
 
-	execve("/etc/init",argv_init,envp_init);
-	execve("/bin/init",argv_init,envp_init);
-	execve("/sbin/init",argv_init,envp_init);
-	/* if this fails, fall through to original stuff */
-
-	pid = kernel_thread(do_rc, "/etc/rc", SIGCHLD);
-	if (pid>0)
-		while (pid != wait(&i))
-			/* nothing */;
+	if (!execute_command) {
+		execve("/etc/init",argv_init,envp_init);
+		execve("/bin/init",argv_init,envp_init);
+		execve("/sbin/init",argv_init,envp_init);
+		/* if this fails, fall through to original stuff */
+
+		pid = kernel_thread(do_rc, "/etc/rc", SIGCHLD);
+		if (pid>0)
+			while (pid != wait(&i))
+				/* nothing */;
+		}
+
 	while (1) {
-		pid = kernel_thread(do_shell, "/bin/sh", SIGCHLD);
+		pid = kernel_thread(do_shell,
+			execute_command ? execute_command : "/bin/sh",
+			SIGCHLD);
 		if (pid < 0) {
 			printf("Fork failed in init\n\r");
 			continue;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this