1
0

100-find_active_root.patch 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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_fixed_partitions(struct mtd_info *master,
  12. const struct mtd_partition **pparts,
  13. struct mtd_part_parser_data *data)
  14. @@ -33,6 +35,7 @@ static int parse_fixed_partitions(struct
  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,13 @@ static int parse_fixed_partitions(struct
  23. parts[i].size = of_read_number(reg + a_cells, s_cells);
  24. parts[i].of_node = pp;
  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. + if (!partname)
  33. + partname = of_get_property(pp, "name", &len);
  34. + }
  35. parts[i].name = partname;
  36. if (of_get_property(pp, "read-only", &len))
  37. @@ -219,6 +226,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);