[klibc] [patch] kinit cmdline handling change

Aaron Griffin aaronmgriffin at gmail.com
Wed May 10 09:20:15 PDT 2006


Following mail advice from maximilian attems (thanks).

The following patch changes 2 parts of kinit's command line parameter handling.
1) Parse command line parameters passed to kinit *before*
/proc/cmdline, in order to allow overrides
2) Pass this resultant command line to the init program, rather than
forcing the kinit caller to pass all /proc/cmdline parameters to the
kinit call.

Signed-off-by: Aaron Griffin <aaron at archlinux.org>

--- a/usr/kinit/kinit.c	2006-05-08 12:59:42.000000000 -0500
+++ b/usr/kinit/kinit.c	2006-05-10 11:06:53.000000000 -0500
@@ -76,6 +76,12 @@
 	if ( cmdv )
 		cmdv[0] = argv[0];

+	for (a = 1; a < argc && v < vmax; a++) {
+		if ( cmdv )
+			cmdv[v] = argv[a];
+		v++;
+	}
+
 	while (i && *i && v < vmax) {
 		if ((*i == ' ' || *i == '\t') && !was_space) {
 			if ( cmdv )
@@ -90,12 +96,6 @@
 		i++;
 	}

-	for (a = 1; a < argc && v < vmax; a++) {
-		if ( cmdv )
-			cmdv[v] = argv[a];
-		v++;
-	}
-
 	if ( cmdv )
 		cmdv[v] = NULL;

@@ -252,11 +252,6 @@
 	gettimeofday(&now, NULL);
 	srand48(now.tv_usec ^ (now.tv_sec << 24));

-	/* Default parameters for anything init-like we execute */
-	init_argc = argc;
-	init_argv = alloca((argc+1)*sizeof(char *));
-	memcpy(init_argv, argv, (argc+1)*sizeof(char *));
-
 	if ((fd = open("/dev/console", O_RDWR)) != -1) {
 		dup2(fd, STDIN_FILENO);
 		dup2(fd, STDOUT_FILENO);
@@ -293,6 +288,11 @@
 		goto bail;
 	}

+	/* Default parameters for anything init-like we execute */
+	init_argc = cmdc;
+	init_argv = alloca((cmdc+1)*sizeof(char *));
+	memcpy(init_cmdv, cmdv, (cmdc+1)*sizeof(char *));
+
 	/* Resume from suspend-to-disk, if appropriate */
 	/* If successful, does not return */
 	do_resume(cmdc, cmdv);



More information about the klibc mailing list