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(+)
16 @@ -1427,6 +1427,15 @@ config EMBEDDED
17 an embedded system so certain expert options are available
20 +config MANGLE_BOOTARGS
21 + bool "Rename offending bootargs"
24 + Sometimes the bootloader passed bogus root= and rootfstype=
25 + parameters to the kernel, and while you want to ignore them,
26 + you need to know the values f.e. to support dual firmware
27 + layouts on the flash.
29 config HAVE_PERF_EVENTS
34 @@ -359,6 +359,29 @@ static inline void setup_nr_cpu_ids(void
35 static inline void smp_prepare_cpus(unsigned int maxcpus) { }
38 +#ifdef CONFIG_MANGLE_BOOTARGS
39 +static void __init mangle_bootargs(char *command_line)
44 + rootdev = strstr(command_line, "root=/dev/mtdblock");
47 + strncpy(rootdev, "mangled_rootblock=", 18);
49 + rootfs = strstr(command_line, "rootfstype");
52 + strncpy(rootfs, "mangled_fs", 10);
56 +static void __init mangle_bootargs(char *command_line)
62 * We need to store the untouched command line for future reference.
63 * We also need to store the touched command line since the parameter
64 @@ -540,6 +563,7 @@ asmlinkage __visible void __init start_k
65 add_device_randomness(command_line, strlen(command_line));
66 boot_init_stack_canary();
67 mm_init_cpumask(&init_mm);
68 + mangle_bootargs(command_line);
69 setup_command_line(command_line);
71 setup_per_cpu_areas();