1 From: Imre Kaloz <kaloz@openwrt.org>
2 Subject: init: add CONFIG_MANGLE_BOOTARGS and disable it by default
4 Enabling this option renames the bootloader supplied root=
5 and rootfstype= variables, which might have to be know but
6 would break the automatisms OpenWrt uses.
8 Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
10 init/Kconfig | 9 +++++++++
11 init/main.c | 24 ++++++++++++++++++++++++
12 2 files changed, 33 insertions(+)
14 diff --git a/init/Kconfig b/init/Kconfig
15 index 9063c81b9665..fb66d3ef78e0 100644
18 @@ -1687,6 +1687,15 @@ config EMBEDDED
19 an embedded system so certain expert options are available
22 +config MANGLE_BOOTARGS
23 + bool "Rename offending bootargs"
26 + Sometimes the bootloader passed bogus root= and rootfstype=
27 + parameters to the kernel, and while you want to ignore them,
28 + you need to know the values f.e. to support dual firmware
29 + layouts on the flash.
31 config HAVE_PERF_EVENTS
34 diff --git a/init/main.c b/init/main.c
35 index ae3996ae9bac..3855fa4ffb95 100644
38 @@ -352,6 +352,29 @@ static inline void setup_nr_cpu_ids(void) { }
39 static inline void smp_prepare_cpus(unsigned int maxcpus) { }
42 +#ifdef CONFIG_MANGLE_BOOTARGS
43 +static void __init mangle_bootargs(char *command_line)
48 + rootdev = strstr(command_line, "root=/dev/mtdblock");
51 + strncpy(rootdev, "mangled_rootblock=", 18);
53 + rootfs = strstr(command_line, "rootfstype");
56 + strncpy(rootfs, "mangled_fs", 10);
60 +static void __init mangle_bootargs(char *command_line)
66 * We need to store the untouched command line for future reference.
67 * We also need to store the touched command line since the parameter
68 @@ -504,6 +527,7 @@ asmlinkage __visible void __init start_kernel(void)
69 pr_notice("%s", linux_banner);
70 setup_arch(&command_line);
71 mm_init_cpumask(&init_mm);
72 + mangle_bootargs(command_line);
73 setup_command_line(command_line);
75 setup_per_cpu_areas();