From c0dd3f3a3b25e4d91084613e104592b789f1cefe Mon Sep 17 00:00:00 2001 From: Andy Whitcroft Date: Thu, 17 Jun 2010 10:46:47 +0100 Subject: 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 Signed-off-by: Leann Ogasawara --- kernel/params.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'kernel') diff --git a/kernel/params.c b/kernel/params.c index ed35345be53..8b8b3144793 100644 --- a/kernel/params.c +++ b/kernel/params.c @@ -90,8 +90,8 @@ static int parse_one(char *param, unsigned num_params, s16 min_level, s16 max_level, - int (*handle_unknown)(char *param, char *val, - const char *doing)) + int (*handle_arg)(char *param, char *val, + const char *doing, int known)) { unsigned int i; int err; @@ -106,6 +106,14 @@ static int parse_one(char *param, if (!val && params[i].ops->set != param_set_bool && params[i].ops->set != param_set_bint) return -EINVAL; + if (handle_arg) { + int ret; + pr_debug("Valid argument: calling %p\n", + handle_arg); + ret = handle_arg(param, val, doing, 1); + if (ret) + return ret; + } pr_debug("handling %s with %p\n", param, params[i].ops->set); mutex_lock(¶m_lock); @@ -115,9 +123,9 @@ static int parse_one(char *param, } } - if (handle_unknown) { + if (handle_arg) { pr_debug("doing %s: %s='%s'\n", doing, param, val); - return handle_unknown(param, val, doing); + return handle_arg(param, val, doing, 0); } pr_debug("Unknown argument '%s'\n", param); @@ -183,7 +191,7 @@ int parse_args(const char *doing, unsigned num, s16 min_level, s16 max_level, - int (*unknown)(char *param, char *val, const char *doing)) + int (*handle_arg)(char *param, char *val, const char *doing, int arg)) { char *param, *val; @@ -200,7 +208,7 @@ int parse_args(const char *doing, args = next_arg(args, ¶m, &val); irq_was_disabled = irqs_disabled(); ret = parse_one(param, val, doing, params, num, - min_level, max_level, unknown); + min_level, max_level, handle_arg); if (irq_was_disabled && !irqs_disabled()) pr_warn("%s: option '%s' enabled irq's!\n", doing, param); -- cgit v1.2.3