mtd-root.patch 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. diff -Nur linux-2.6.31.4.orig/drivers/mtd/Kconfig linux-2.6.31.4/drivers/mtd/Kconfig
  2. --- linux-2.6.31.4.orig/drivers/mtd/Kconfig 2009-10-12 22:15:40.000000000 +0200
  3. +++ linux-2.6.31.4/drivers/mtd/Kconfig 2009-10-21 11:45:10.557679089 +0200
  4. @@ -53,6 +53,11 @@
  5. should normally be compiled as kernel modules. The modules perform
  6. various checks and verifications when loaded.
  7. +config MTD_ROOTFS_ROOT_DEV
  8. + bool "Automatically set 'rootfs' partition to be root filesystem"
  9. + depends on MTD_PARTITIONS
  10. + default y
  11. +
  12. config MTD_REDBOOT_PARTS
  13. tristate "RedBoot partition table parsing"
  14. depends on MTD_PARTITIONS
  15. diff -Nur linux-2.6.31.4.orig/drivers/mtd/mtdpart.c linux-2.6.31.4/drivers/mtd/mtdpart.c
  16. --- linux-2.6.31.4.orig/drivers/mtd/mtdpart.c 2009-10-12 22:15:40.000000000 +0200
  17. +++ linux-2.6.31.4/drivers/mtd/mtdpart.c 2009-10-21 11:46:39.593679219 +0200
  18. @@ -18,6 +18,7 @@
  19. #include <linux/mtd/mtd.h>
  20. #include <linux/mtd/partitions.h>
  21. #include <linux/mtd/compatmac.h>
  22. +#include <linux/root_dev.h>
  23. /* Our partition linked list */
  24. static LIST_HEAD(mtd_partitions);
  25. @@ -35,7 +36,7 @@
  26. * the pointer to that structure with this macro.
  27. */
  28. #define PART(x) ((struct mtd_part *)(x))
  29. -
  30. +#define IS_PART(mtd) (mtd->read == part_read)
  31. /*
  32. * MTD methods which simply translate the effective address and pass through
  33. @@ -517,14 +518,23 @@
  34. {
  35. struct mtd_part *slave;
  36. uint64_t cur_offset = 0;
  37. - int i;
  38. + int i, j;
  39. printk(KERN_NOTICE "Creating %d MTD partitions on \"%s\":\n", nbparts, master->name);
  40. - for (i = 0; i < nbparts; i++) {
  41. - slave = add_one_partition(master, parts + i, i, cur_offset);
  42. + for (i = 0, j = 0; i < nbparts; i++) {
  43. + slave = add_one_partition(master, parts + i, j++, cur_offset);
  44. if (!slave)
  45. return -ENOMEM;
  46. + if (!strcmp(parts[i].name, "rootfs")) {
  47. +#ifdef CONFIG_MTD_ROOTFS_ROOT_DEV
  48. + if (ROOT_DEV == 0) {
  49. + printk(KERN_NOTICE "mtd: partition \"rootfs\" "
  50. + "set to be root filesystem\n");
  51. + ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, slave->mtd.index);
  52. + }
  53. +#endif
  54. + }
  55. cur_offset = slave->offset + slave->mtd.size;
  56. }