100-find_active_root.patch 1.7 KB

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