920-mangle_bootargs.patch 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. From: Imre Kaloz <kaloz@openwrt.org>
  2. Subject: init: add CONFIG_MANGLE_BOOTARGS and disable it by default
  3. Enabling this option renames the bootloader supplied root=
  4. and rootfstype= variables, which might have to be know but
  5. would break the automatisms libreCMC uses.
  6. Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
  7. ---
  8. init/Kconfig | 9 +++++++++
  9. init/main.c | 24 ++++++++++++++++++++++++
  10. 2 files changed, 33 insertions(+)
  11. --- a/init/Kconfig
  12. +++ b/init/Kconfig
  13. @@ -1427,6 +1427,15 @@ config EMBEDDED
  14. an embedded system so certain expert options are available
  15. for configuration.
  16. +config MANGLE_BOOTARGS
  17. + bool "Rename offending bootargs"
  18. + depends on EXPERT
  19. + help
  20. + Sometimes the bootloader passed bogus root= and rootfstype=
  21. + parameters to the kernel, and while you want to ignore them,
  22. + you need to know the values f.e. to support dual firmware
  23. + layouts on the flash.
  24. +
  25. config HAVE_PERF_EVENTS
  26. bool
  27. help
  28. --- a/init/main.c
  29. +++ b/init/main.c
  30. @@ -358,6 +358,29 @@ static inline void setup_nr_cpu_ids(void
  31. static inline void smp_prepare_cpus(unsigned int maxcpus) { }
  32. #endif
  33. +#ifdef CONFIG_MANGLE_BOOTARGS
  34. +static void __init mangle_bootargs(char *command_line)
  35. +{
  36. + char *rootdev;
  37. + char *rootfs;
  38. +
  39. + rootdev = strstr(command_line, "root=/dev/mtdblock");
  40. +
  41. + if (rootdev)
  42. + strncpy(rootdev, "mangled_rootblock=", 18);
  43. +
  44. + rootfs = strstr(command_line, "rootfstype");
  45. +
  46. + if (rootfs)
  47. + strncpy(rootfs, "mangled_fs", 10);
  48. +
  49. +}
  50. +#else
  51. +static void __init mangle_bootargs(char *command_line)
  52. +{
  53. +}
  54. +#endif
  55. +
  56. /*
  57. * We need to store the untouched command line for future reference.
  58. * We also need to store the touched command line since the parameter
  59. @@ -539,6 +562,7 @@ asmlinkage __visible void __init start_k
  60. add_device_randomness(command_line, strlen(command_line));
  61. boot_init_stack_canary();
  62. mm_init_cpumask(&init_mm);
  63. + mangle_bootargs(command_line);
  64. setup_command_line(command_line);
  65. setup_nr_cpu_ids();
  66. setup_per_cpu_areas();