920-mangle_bootargs.patch 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. From: Imre Kaloz <[email protected]>
  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 OpenWrt uses.
  6. Signed-off-by: Imre Kaloz <[email protected]>
  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. @@ -1827,6 +1827,15 @@ config EMBEDDED
  14. If unsure, say N.
  15. +config MANGLE_BOOTARGS
  16. + bool "Rename offending bootargs"
  17. + depends on EXPERT
  18. + help
  19. + Sometimes the bootloader passed bogus root= and rootfstype=
  20. + parameters to the kernel, and while you want to ignore them,
  21. + you need to know the values f.e. to support dual firmware
  22. + layouts on the flash.
  23. +
  24. config HAVE_PERF_EVENTS
  25. bool
  26. help
  27. --- a/init/main.c
  28. +++ b/init/main.c
  29. @@ -611,6 +611,29 @@ static inline void setup_nr_cpu_ids(void
  30. static inline void smp_prepare_cpus(unsigned int maxcpus) { }
  31. #endif
  32. +#ifdef CONFIG_MANGLE_BOOTARGS
  33. +static void __init mangle_bootargs(char *command_line)
  34. +{
  35. + char *rootdev;
  36. + char *rootfs;
  37. +
  38. + rootdev = strstr(command_line, "root=/dev/mtdblock");
  39. +
  40. + if (rootdev)
  41. + strncpy(rootdev, "mangled_rootblock=", 18);
  42. +
  43. + rootfs = strstr(command_line, "rootfstype");
  44. +
  45. + if (rootfs)
  46. + strncpy(rootfs, "mangled_fs", 10);
  47. +
  48. +}
  49. +#else
  50. +static void __init mangle_bootargs(char *command_line)
  51. +{
  52. +}
  53. +#endif
  54. +
  55. /*
  56. * We need to store the untouched command line for future reference.
  57. * We also need to store the touched command line since the parameter
  58. @@ -958,6 +981,7 @@ asmlinkage __visible void __init __no_sa
  59. pr_notice("%s", linux_banner);
  60. early_security_init();
  61. setup_arch(&command_line);
  62. + mangle_bootargs(command_line);
  63. setup_boot_config();
  64. setup_command_line(command_line);
  65. setup_nr_cpu_ids();