100-find_active_root.patch 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. The WRT1900AC among other Linksys routers uses a dual-firmware layout.
  2. Dynamically rename the active partition to "ubi".
  3. Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
  4. --- a/drivers/mtd/ofpart.c
  5. +++ b/drivers/mtd/ofpart.c
  6. @@ -25,12 +25,15 @@ static bool node_has_compatible(struct d
  7. return of_get_property(pp, "compatible", NULL);
  8. }
  9. +static int mangled_rootblock;
  10. +
  11. static int parse_ofpart_partitions(struct mtd_info *master,
  12. struct mtd_partition **pparts,
  13. struct mtd_part_parser_data *data)
  14. {
  15. struct device_node *node;
  16. const char *partname;
  17. + const char *owrtpart = "ubi";
  18. struct device_node *pp;
  19. int nr_parts, i;
  20. @@ -78,9 +81,15 @@ static int parse_ofpart_partitions(struc
  21. (*pparts)[i].offset = of_read_number(reg, a_cells);
  22. (*pparts)[i].size = of_read_number(reg + a_cells, s_cells);
  23. - partname = of_get_property(pp, "label", &len);
  24. - if (!partname)
  25. - partname = of_get_property(pp, "name", &len);
  26. + if (mangled_rootblock && (i == mangled_rootblock)) {
  27. + partname = owrtpart;
  28. + } else {
  29. + partname = of_get_property(pp, "label", &len);
  30. +
  31. + if (!partname)
  32. + partname = of_get_property(pp, "name", &len);
  33. + }
  34. +
  35. (*pparts)[i].name = partname;
  36. if (of_get_property(pp, "read-only", &len))
  37. @@ -178,6 +187,18 @@ static int __init ofpart_parser_init(voi
  38. return 0;
  39. }
  40. +static int __init active_root(char *str)
  41. +{
  42. + get_option(&str, &mangled_rootblock);
  43. +
  44. + if (!mangled_rootblock)
  45. + return 1;
  46. +
  47. + return 1;
  48. +}
  49. +
  50. +__setup("mangled_rootblock=", active_root);
  51. +
  52. static void __exit ofpart_parser_exit(void)
  53. {
  54. deregister_mtd_parser(&ofpart_parser);