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 *mtd_node;
  16. struct device_node *ofpart_node;
  17. + const char *owrtpart = "ubi";
  18. const char *partname;
  19. struct device_node *pp;
  20. int nr_parts, i, ret = 0;
  21. @@ -110,9 +113,15 @@ static int parse_ofpart_partitions(struc
  22. (*pparts)[i].offset = of_read_number(reg, a_cells);
  23. (*pparts)[i].size = of_read_number(reg + a_cells, s_cells);
  24. - partname = of_get_property(pp, "label", &len);
  25. - if (!partname)
  26. - partname = of_get_property(pp, "name", &len);
  27. + if (mangled_rootblock && (i == mangled_rootblock)) {
  28. + partname = owrtpart;
  29. + } else {
  30. + partname = of_get_property(pp, "label", &len);
  31. +
  32. + if (!partname)
  33. + partname = of_get_property(pp, "name", &len);
  34. + }
  35. +
  36. (*pparts)[i].name = partname;
  37. if (of_get_property(pp, "read-only", &len))
  38. @@ -215,6 +224,18 @@ static int __init ofpart_parser_init(voi
  39. return 0;
  40. }
  41. +static int __init active_root(char *str)
  42. +{
  43. + get_option(&str, &mangled_rootblock);
  44. +
  45. + if (!mangled_rootblock)
  46. + return 1;
  47. +
  48. + return 1;
  49. +}
  50. +
  51. +__setup("mangled_rootblock=", active_root);
  52. +
  53. static void __exit ofpart_parser_exit(void)
  54. {
  55. deregister_mtd_parser(&ofpart_parser);