summaryrefslogtreecommitdiffstats
path: root/init
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2014-04-27 22:04:33 -0400
committerRusty Russell <rusty@rustcorp.com.au>2014-04-27 22:18:34 -0400
commit51e158c12aca3c9ac63988611a97c05109b14dc9 (patch)
tree579ef4259a17200a77ec111c6a6ca082d43a368d /init
parent2ee41e62ba5b952e9d9fcba6f7079a0c608bb849 (diff)
param: hand arguments after -- straight to init
The kernel passes any args it doesn't need through to init, except it assumes anything containing '.' belongs to the kernel (for a module). This change means all users can clearly distinguish which arguments are for init. For example, the kernel uses debug ("dee-bug") to mean log everything to the console, where systemd uses the debug from the Scandinavian "day-boog" meaning "fail to boot". If a future versions uses argv[] instead of reading /proc/cmdline, this confusion will be avoided. eg: test 'FOO="this is --foo"' -- 'systemd.debug="true true true"' Gives: argv[0] = '/debug-init' argv[1] = 'test' argv[2] = 'systemd.debug=true true true' envp[0] = 'HOME=/' envp[1] = 'TERM=linux' envp[2] = 'FOO=this is --foo' Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'init')
-rw-r--r--init/main.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/init/main.c b/init/main.c
index 9c7fd4c9249f..e9d458b5d77b 100644
--- a/init/main.c
+++ b/init/main.c
@@ -252,6 +252,27 @@ static int __init repair_env_string(char *param, char *val, const char *unused)
252 return 0; 252 return 0;
253} 253}
254 254
255/* Anything after -- gets handed straight to init. */
256static int __init set_init_arg(char *param, char *val, const char *unused)
257{
258 unsigned int i;
259
260 if (panic_later)
261 return 0;
262
263 repair_env_string(param, val, unused);
264
265 for (i = 0; argv_init[i]; i++) {
266 if (i == MAX_INIT_ARGS) {
267 panic_later = "init";
268 panic_param = param;
269 return 0;
270 }
271 }
272 argv_init[i] = param;
273 return 0;
274}
275
255/* 276/*
256 * Unknown boot options get handed to init, unless they look like 277 * Unknown boot options get handed to init, unless they look like
257 * unused parameters (modprobe will find them in /proc/cmdline). 278 * unused parameters (modprobe will find them in /proc/cmdline).
@@ -478,7 +499,7 @@ static void __init mm_init(void)
478 499
479asmlinkage void __init start_kernel(void) 500asmlinkage void __init start_kernel(void)
480{ 501{
481 char * command_line; 502 char * command_line, *after_dashes;
482 extern const struct kernel_param __start___param[], __stop___param[]; 503 extern const struct kernel_param __start___param[], __stop___param[];
483 504
484 /* 505 /*
@@ -519,9 +540,13 @@ asmlinkage void __init start_kernel(void)
519 540
520 pr_notice("Kernel command line: %s\n", boot_command_line); 541 pr_notice("Kernel command line: %s\n", boot_command_line);
521 parse_early_param(); 542 parse_early_param();
522 parse_args("Booting kernel", static_command_line, __start___param, 543 after_dashes = parse_args("Booting kernel",
523 __stop___param - __start___param, 544 static_command_line, __start___param,
524 -1, -1, &unknown_bootoption); 545 __stop___param - __start___param,
546 -1, -1, &unknown_bootoption);
547 if (after_dashes)
548 parse_args("Setting init args", after_dashes, NULL, 0, -1, -1,
549 set_init_arg);
525 550
526 jump_label_init(); 551 jump_label_init();
527 552