r1387 - trunk/initramfs

jhuntwork at linuxfromscratch.org jhuntwork at linuxfromscratch.org
Sun Jan 29 18:42:04 PST 2006


Author: jhuntwork
Date: 2006-01-29 19:42:03 -0700 (Sun, 29 Jan 2006)
New Revision: 1387

Modified:
   trunk/initramfs/init.c
Log:
Ajdust init.c - should fix a hang after 'Starting init...' on some systems. Thanks Brian.

Modified: trunk/initramfs/init.c
===================================================================
--- trunk/initramfs/init.c	2006-01-29 20:14:19 UTC (rev 1386)
+++ trunk/initramfs/init.c	2006-01-30 02:42:03 UTC (rev 1387)
@@ -25,6 +25,7 @@
 
 int main(int argc, char * argv[], char * envp[])
 {
+	char **cmd = malloc( sizeof(char *) * (argc+1) );
 	int i, fd, ffd;
 	struct loop_info loopinfo;
 	
@@ -147,10 +148,15 @@
 	/* We're done! Pass control to sysvinit. */
 
 	printf("Starting init...\n");
-	i = execve("/sbin/init", argv, envp);
-	if (i<0)
-		printf("Failed to start init: %s :(\n", strerror(errno));
+	cmd[0] = malloc( sizeof(char) * 11);
+	cmd[0] = strncpy(cmd[0], "/sbin/init", 11);
 
+        for (i=1; i <= argc; i++) {
+                cmd[i] = argv[i];
+        }
+        i = execve(cmd[0], cmd, envp);
+	printf("Failed to start init: %s :(\n", strerror(errno));
+
 	return(0);
 }
 




More information about the livecd mailing list