diff options
author | Andy Whitcroft <apw@canonical.com> | 2010-06-17 10:46:47 +0100 |
---|---|---|
committer | John Rigby <john.rigby@linaro.org> | 2012-06-20 20:13:59 -0600 |
commit | 51014b5e53f66341d9e12fdedc2bf5a9210502c4 (patch) | |
tree | e9345aeaf92dbefbc65845697c6c03e0cc2b1a04 /init | |
parent | a117b05ea98282cf07300fcb84212250bf02e033 (diff) |
UBUNTU: SAUCE: add option to hand off all kernel parameters to init
BugLink: http://bugs.launchpad.net/bugs/586386
Some init packages such as upstart find having all of the kernel parameters
passed in useful. Currently they have to open up /proc/cmdline and
reparse that to obtain this information. Add a kernel configuration
option to enable passing of all options.
Note, enabling this option will reduce the chances that a fallback from
/sbin/init to /bin/bash or /bin/sh will succeed. Though it should be
noted that there are commonly unknown options present which would already
break this fallback. init=/bin/foo provides explicit control over options
which is unaffected by this change.
Signed-off-by: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Leann Ogasawara <leann.ogasawara@canonical.com>
Diffstat (limited to 'init')
-rw-r--r-- | init/Kconfig | 7 | ||||
-rw-r--r-- | init/main.c | 33 |
2 files changed, 33 insertions, 7 deletions
diff --git a/init/Kconfig b/init/Kconfig index b32ca50d4e7..0a6702a9680 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -76,6 +76,13 @@ config INIT_ENV_ARG_LIMIT Maximum of each of the number of arguments and environment variables passed to init from the kernel command line. +config INIT_PASS_ALL_PARAMS + bool "Pass all (known and unknown) kernel parameters to init" + default n + help + Pass all kernel command line parameters to init, this includes + those consumed by kernel modules. This is useful for upstart + based systems. If in doubt say N. config CROSS_COMPILE string "Cross-compiler tool prefix" diff --git a/init/main.c b/init/main.c index de1c75fd5a9..89895a7dcf7 100644 --- a/init/main.c +++ b/init/main.c @@ -112,6 +112,11 @@ EXPORT_SYMBOL(system_state); */ #define MAX_INIT_ARGS CONFIG_INIT_ENV_ARG_LIMIT #define MAX_INIT_ENVS CONFIG_INIT_ENV_ARG_LIMIT +#ifdef CONFIG_INIT_PASS_ALL_PARAMS +#define INIT_PASS_FUNCTION pass_all_bootoptions +#else +#define INIT_PASS_FUNCTION pass_unknown_bootoptions +#endif extern void time_init(void); /* Default late time init is NULL. archs can override this later. */ @@ -243,19 +248,20 @@ static int __init repair_env_string(char *param, char *val) } /* - * Unknown boot options get handed to init, unless they look like - * unused parameters (modprobe will find them in /proc/cmdline). + * Select boot options to hand to init. If all is set hand off them all + * otherwise only hand off unused ones which do not apply to modules + * (modprobe will find them in /proc/cmdline). */ -static int __init unknown_bootoption(char *param, char *val) +static int __init pass_bootoption(char *param, char *val, int all) { repair_env_string(param, val); /* Handle obsolete-style parameters */ - if (obsolete_checksetup(param)) + if (obsolete_checksetup(param) && !all) return 0; /* Unused module parameter. */ - if (strchr(param, '.') && (!val || strchr(param, '.') < val)) + if (!all && strchr(param, '.') && (!val || strchr(param, '.') < val)) return 0; if (panic_later) @@ -286,6 +292,16 @@ static int __init unknown_bootoption(char *param, char *val) } return 0; } +static int __init pass_unknown_bootoptions(char *param, char *val, int known) +{ + if (known) + return 0; + return pass_bootoption(param, val, 0); +} +static int __init pass_all_bootoptions(char *param, char *val, int known) +{ + return pass_bootoption(param, val, 1); +} static int __init init_setup(char *str) { @@ -385,10 +401,13 @@ static noinline void __init_refok rest_init(void) } /* Check for early params. */ -static int __init do_early_param(char *param, char *val) +static int __init do_early_param(char *param, char *val, int known) { const struct obs_kernel_param *p; + if (known) + return 0; + for (p = __setup_start; p < __setup_end; p++) { if ((p->early && parameq(param, p->str)) || (strcmp(param, "console") == 0 && @@ -508,7 +527,7 @@ asmlinkage void __init start_kernel(void) parse_early_param(); parse_args("Booting kernel", static_command_line, __start___param, __stop___param - __start___param, - 0, 0, &unknown_bootoption); + 0, 0, &INIT_PASS_FUNCTION); jump_label_init(); |