1
0

995-mangle_bootargs.patch 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. --- a/init/main.c
  2. +++ b/init/main.c
  3. @@ -356,6 +356,29 @@ static inline void setup_nr_cpu_ids(void
  4. static inline void smp_prepare_cpus(unsigned int maxcpus) { }
  5. #endif
  6. +#ifdef CONFIG_MANGLE_BOOTARGS
  7. +static void __init mangle_bootargs(char *command_line)
  8. +{
  9. + char *rootdev;
  10. + char *rootfs;
  11. +
  12. + rootdev = strstr(command_line, "root=/dev/mtdblock");
  13. +
  14. + if (rootdev)
  15. + strncpy(rootdev, "mangled_rootblock=", 18);
  16. +
  17. + rootfs = strstr(command_line, "rootfstype");
  18. +
  19. + if (rootfs)
  20. + strncpy(rootfs, "mangled_fs", 10);
  21. +
  22. +}
  23. +#else
  24. +static void __init mangle_bootargs(char *command_line)
  25. +{
  26. +}
  27. +#endif
  28. +
  29. /*
  30. * We need to store the untouched command line for future reference.
  31. * We also need to store the touched command line since the parameter
  32. @@ -529,6 +552,7 @@ asmlinkage __visible void __init start_k
  33. pr_notice("%s", linux_banner);
  34. setup_arch(&command_line);
  35. mm_init_cpumask(&init_mm);
  36. + mangle_bootargs(command_line);
  37. setup_command_line(command_line);
  38. setup_nr_cpu_ids();
  39. setup_per_cpu_areas();
  40. --- a/init/Kconfig
  41. +++ b/init/Kconfig
  42. @@ -1648,6 +1648,15 @@ config EMBEDDED
  43. an embedded system so certain expert options are available
  44. for configuration.
  45. +config MANGLE_BOOTARGS
  46. + bool "Rename offending bootargs"
  47. + depends on EXPERT
  48. + help
  49. + Sometimes the bootloader passed bogus root= and rootfstype=
  50. + parameters to the kernel, and while you want to ignore them,
  51. + you need to know the values f.e. to support dual firmware
  52. + layouts on the flash.
  53. +
  54. config HAVE_PERF_EVENTS
  55. bool
  56. help