5d56cf44626fe2d70b0a03f748c14e220e8a900b
[15.05/openwrt.git] / target / linux / generic / patches-3.18 / 995-mangle_bootargs.patch
1 --- a/init/main.c
2 +++ b/init/main.c
3 @@ -379,6 +379,26 @@ static void __init setup_command_line(ch
4         strcpy(static_command_line, command_line);
5  }
6  
7 +#ifdef CONFIG_MANGLE_BOOTARGS
8 +static void __init mangle_bootargs(char *command_line)
9 +{
10 +       char *rootdev;
11 +       char *rootfs;
12 +
13 +       rootdev = strstr(command_line, "root=/dev/mtdblock");
14 +       strncpy(rootdev, "mangled_rootblock=", 18);
15 +
16 +       rootfs = strstr(command_line, "rootfstype");
17 +       strncpy(rootfs, "mangled_fs", 10);
18 +
19 +}
20 +#else
21 +static void __init mangle_bootargs(char *command_line)
22 +{
23 +}
24 +#endif
25 +
26 +
27  /*
28   * We need to finalize in a non-__init function or else race conditions
29   * between the root thread and the init thread may cause start_kernel to
30 @@ -530,6 +550,7 @@ asmlinkage __visible void __init start_k
31         pr_notice("%s", linux_banner);
32         setup_arch(&command_line);
33         mm_init_cpumask(&init_mm);
34 +       mangle_bootargs(command_line);
35         setup_command_line(command_line);
36         setup_nr_cpu_ids();
37         setup_per_cpu_areas();
38 --- a/init/Kconfig
39 +++ b/init/Kconfig
40 @@ -1597,6 +1597,15 @@ config EMBEDDED
41           an embedded system so certain expert options are available
42           for configuration.
43  
44 +config MANGLE_BOOTARGS
45 +       bool "Rename offending bootargs"
46 +       depends on EXPERT
47 +       help
48 +         Sometimes the bootloader passed bogus root= and rootfstype=
49 +         parameters to the kernel, and while you want to ignore them,
50 +         you need to know the values f.e. to support dual firmware
51 +         layouts on the flash.
52 +
53  config HAVE_PERF_EVENTS
54         bool
55         help