aboutsummaryrefslogtreecommitdiffstats
path: root/init/main.c
diff options
context:
space:
mode:
authorChris Metcalf <cmetcalf@tilera.com>2012-04-06 12:53:50 -0400
committerChris Metcalf <cmetcalf@tilera.com>2012-04-25 11:47:29 -0400
commita99cd1125189aaf31a7ee505d6208143482119eb (patch)
treea950082dce0d04b0448210f590d5bbb2c357cf55 /init/main.c
parent66f75a5d028beaf67c931435fdc3e7823125730c (diff)
init: fix bug where environment vars can't be passed via boot args
Commit 026cee0086f had the side-effect of dropping the '=' from the unknown boot arguments that are passed to init as environment variables. This is because parse_args() puts a NUL in the string where the '=' was when it passes the "param" and "val" pointers to the parsing subfunctions. Previously, unknown_bootoption() was the last parse_args() subfunction to run, and it carefully put back the '=' character. Now the ignore_unknown_bootoption() is the last one to run, and it wasn't doing the necessary repair, so the envp params ended up with the embedded NUL and were no longer seen as valid environment variables by init. Tested-by: Woody Suwalski <terraluna977@gmail.com> Acked-by: Pawel Moll <pawel.moll@arm.com> Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
Diffstat (limited to 'init/main.c')
-rw-r--r--init/main.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/init/main.c b/init/main.c
index 9d454f09f3b1..44b2433334c7 100644
--- a/init/main.c
+++ b/init/main.c
@@ -225,13 +225,9 @@ static int __init loglevel(char *str)
225 225
226early_param("loglevel", loglevel); 226early_param("loglevel", loglevel);
227 227
228/* 228/* Change NUL term back to "=", to make "param" the whole string. */
229 * Unknown boot options get handed to init, unless they look like 229static int __init repair_env_string(char *param, char *val)
230 * unused parameters (modprobe will find them in /proc/cmdline).
231 */
232static int __init unknown_bootoption(char *param, char *val)
233{ 230{
234 /* Change NUL term back to "=", to make "param" the whole string. */
235 if (val) { 231 if (val) {
236 /* param=val or param="val"? */ 232 /* param=val or param="val"? */
237 if (val == param+strlen(param)+1) 233 if (val == param+strlen(param)+1)
@@ -243,6 +239,16 @@ static int __init unknown_bootoption(char *param, char *val)
243 } else 239 } else
244 BUG(); 240 BUG();
245 } 241 }
242 return 0;
243}
244
245/*
246 * Unknown boot options get handed to init, unless they look like
247 * unused parameters (modprobe will find them in /proc/cmdline).
248 */
249static int __init unknown_bootoption(char *param, char *val)
250{
251 repair_env_string(param, val);
246 252
247 /* Handle obsolete-style parameters */ 253 /* Handle obsolete-style parameters */
248 if (obsolete_checksetup(param)) 254 if (obsolete_checksetup(param))
@@ -732,11 +738,6 @@ static char *initcall_level_names[] __initdata = {
732 "late parameters", 738 "late parameters",
733}; 739};
734 740
735static int __init ignore_unknown_bootoption(char *param, char *val)
736{
737 return 0;
738}
739
740static void __init do_initcall_level(int level) 741static void __init do_initcall_level(int level)
741{ 742{
742 extern const struct kernel_param __start___param[], __stop___param[]; 743 extern const struct kernel_param __start___param[], __stop___param[];
@@ -747,7 +748,7 @@ static void __init do_initcall_level(int level)
747 static_command_line, __start___param, 748 static_command_line, __start___param,
748 __stop___param - __start___param, 749 __stop___param - __start___param,
749 level, level, 750 level, level,
750 ignore_unknown_bootoption); 751 repair_env_string);
751 752
752 for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) 753 for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
753 do_one_initcall(*fn); 754 do_one_initcall(*fn);