Commit ffdfc40976dda18d923cd001d44bf0ee55da1af4
Committed by
Linus Torvalds
1 parent
2b579beec2
Exists in
master
and in
4 other branches
[PATCH] Add rdinit parameter to pick early userspace init
Since early userspace was added, there's no way to override which init to run from it. Some people tack on an extra cpio archive with a link from /init depending on what they want to run, but that's sometimes impractical. Changing the "init=" to also override the early userspace isn't feasible, since it is still used to indicate what init to run from disk when early userspace has completed doing whatever it's doing (i.e. load filesystem modules and drivers). Instead, introduce "rdinit=" and make it override the default "/init" if specified. Signed-off-by: Olof Johansson <olof@lixom.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Showing 2 changed files with 32 additions and 4 deletions Side-by-side Diff
Documentation/kernel-parameters.txt
... | ... | @@ -1174,6 +1174,11 @@ |
1174 | 1174 | New name for the ramdisk parameter. |
1175 | 1175 | See Documentation/ramdisk.txt. |
1176 | 1176 | |
1177 | + rdinit= [KNL] | |
1178 | + Format: <full_path> | |
1179 | + Run specified binary instead of /init from the ramdisk, | |
1180 | + used for early userspace startup. See initrd. | |
1181 | + | |
1177 | 1182 | reboot= [BUGS=IA-32,BUGS=ARM,BUGS=IA-64] Rebooting mode |
1178 | 1183 | Format: <reboot_mode>[,<reboot_mode2>[,...]] |
1179 | 1184 | See arch/*/kernel/reboot.c. |
init/main.c
... | ... | @@ -123,6 +123,7 @@ |
123 | 123 | char saved_command_line[COMMAND_LINE_SIZE]; |
124 | 124 | |
125 | 125 | static char *execute_command; |
126 | +static char *ramdisk_execute_command; | |
126 | 127 | |
127 | 128 | /* Setup configured maximum number of CPUs to activate */ |
128 | 129 | static unsigned int max_cpus = NR_CPUS; |
... | ... | @@ -297,6 +298,18 @@ |
297 | 298 | } |
298 | 299 | __setup("init=", init_setup); |
299 | 300 | |
301 | +static int __init rdinit_setup(char *str) | |
302 | +{ | |
303 | + unsigned int i; | |
304 | + | |
305 | + ramdisk_execute_command = str; | |
306 | + /* See "auto" comment in init_setup */ | |
307 | + for (i = 1; i < MAX_INIT_ARGS; i++) | |
308 | + argv_init[i] = NULL; | |
309 | + return 1; | |
310 | +} | |
311 | +__setup("rdinit=", rdinit_setup); | |
312 | + | |
300 | 313 | extern void setup_arch(char **); |
301 | 314 | |
302 | 315 | #ifndef CONFIG_SMP |
303 | 316 | |
... | ... | @@ -681,10 +694,14 @@ |
681 | 694 | * check if there is an early userspace init. If yes, let it do all |
682 | 695 | * the work |
683 | 696 | */ |
684 | - if (sys_access((const char __user *) "/init", 0) == 0) | |
685 | - execute_command = "/init"; | |
686 | - else | |
697 | + | |
698 | + if (!ramdisk_execute_command) | |
699 | + ramdisk_execute_command = "/init"; | |
700 | + | |
701 | + if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) { | |
702 | + ramdisk_execute_command = NULL; | |
687 | 703 | prepare_namespace(); |
704 | + } | |
688 | 705 | |
689 | 706 | /* |
690 | 707 | * Ok, we have completed the initial bootup, and |
... | ... | @@ -701,7 +718,13 @@ |
701 | 718 | |
702 | 719 | (void) sys_dup(0); |
703 | 720 | (void) sys_dup(0); |
704 | - | |
721 | + | |
722 | + if (ramdisk_execute_command) { | |
723 | + run_init_process(ramdisk_execute_command); | |
724 | + printk(KERN_WARNING "Failed to execute %s\n", | |
725 | + ramdisk_execute_command); | |
726 | + } | |
727 | + | |
705 | 728 | /* |
706 | 729 | * We try each of these until one succeeds. |
707 | 730 | * |