410-block-fit-partition-parser.patch 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. --- a/block/blk.h
  2. +++ b/block/blk.h
  3. @@ -361,6 +361,8 @@ char *disk_name(struct gendisk *hd, int
  4. #define ADDPART_FLAG_NONE 0
  5. #define ADDPART_FLAG_RAID 1
  6. #define ADDPART_FLAG_WHOLEDISK 2
  7. +#define ADDPART_FLAG_READONLY 4
  8. +#define ADDPART_FLAG_ROOTDEV 8
  9. void delete_partition(struct hd_struct *part);
  10. int bdev_add_partition(struct block_device *bdev, int partno,
  11. sector_t start, sector_t length);
  12. --- a/block/partitions/Kconfig
  13. +++ b/block/partitions/Kconfig
  14. @@ -101,6 +101,13 @@ config ATARI_PARTITION
  15. Say Y here if you would like to use hard disks under Linux which
  16. were partitioned under the Atari OS.
  17. +config FIT_PARTITION
  18. + bool "Flattened-Image-Tree (FIT) partition support" if PARTITION_ADVANCED
  19. + default n
  20. + help
  21. + Say Y here if your system needs to mount the filesystem part of
  22. + a Flattened-Image-Tree (FIT) image commonly used with Das U-Boot.
  23. +
  24. config IBM_PARTITION
  25. bool "IBM disk label and partition support"
  26. depends on PARTITION_ADVANCED && S390
  27. --- a/block/partitions/Makefile
  28. +++ b/block/partitions/Makefile
  29. @@ -8,6 +8,7 @@ obj-$(CONFIG_ACORN_PARTITION) += acorn.o
  30. obj-$(CONFIG_AMIGA_PARTITION) += amiga.o
  31. obj-$(CONFIG_ATARI_PARTITION) += atari.o
  32. obj-$(CONFIG_AIX_PARTITION) += aix.o
  33. +obj-$(CONFIG_FIT_PARTITION) += fit.o
  34. obj-$(CONFIG_CMDLINE_PARTITION) += cmdline.o
  35. obj-$(CONFIG_MAC_PARTITION) += mac.o
  36. obj-$(CONFIG_LDM_PARTITION) += ldm.o
  37. --- a/block/partitions/check.h
  38. +++ b/block/partitions/check.h
  39. @@ -58,6 +58,7 @@ int amiga_partition(struct parsed_partit
  40. int atari_partition(struct parsed_partitions *state);
  41. int cmdline_partition(struct parsed_partitions *state);
  42. int efi_partition(struct parsed_partitions *state);
  43. +int fit_partition(struct parsed_partitions *state);
  44. int ibm_partition(struct parsed_partitions *);
  45. int karma_partition(struct parsed_partitions *state);
  46. int ldm_partition(struct parsed_partitions *state);
  47. @@ -68,3 +69,5 @@ int sgi_partition(struct parsed_partitio
  48. int sun_partition(struct parsed_partitions *state);
  49. int sysv68_partition(struct parsed_partitions *state);
  50. int ultrix_partition(struct parsed_partitions *state);
  51. +
  52. +int parse_fit_partitions(struct parsed_partitions *state, u64 start_sector, u64 nr_sectors, int *slot, int add_remain);
  53. --- a/block/partitions/core.c
  54. +++ b/block/partitions/core.c
  55. @@ -10,6 +10,10 @@
  56. #include <linux/vmalloc.h>
  57. #include <linux/blktrace_api.h>
  58. #include <linux/raid/detect.h>
  59. +#ifdef CONFIG_FIT_PARTITION
  60. +#include <linux/root_dev.h>
  61. +#endif
  62. +
  63. #include "check.h"
  64. static int (*check_part[])(struct parsed_partitions *) = {
  65. @@ -46,6 +50,9 @@ static int (*check_part[])(struct parsed
  66. #ifdef CONFIG_EFI_PARTITION
  67. efi_partition, /* this must come before msdos */
  68. #endif
  69. +#ifdef CONFIG_FIT_PARTITION
  70. + fit_partition,
  71. +#endif
  72. #ifdef CONFIG_SGI_PARTITION
  73. sgi_partition,
  74. #endif
  75. @@ -694,6 +701,14 @@ static bool blk_add_partition(struct gen
  76. (state->parts[p].flags & ADDPART_FLAG_RAID))
  77. md_autodetect_dev(part_to_dev(part)->devt);
  78. +#ifdef CONFIG_FIT_PARTITION
  79. + if ((state->parts[p].flags & ADDPART_FLAG_ROOTDEV) && ROOT_DEV == 0)
  80. + ROOT_DEV = part_to_dev(part)->devt;
  81. +
  82. + if (state->parts[p].flags & ADDPART_FLAG_READONLY)
  83. + part->policy = true;
  84. +#endif
  85. +
  86. return true;
  87. }
  88. --- a/drivers/mtd/ubi/block.c
  89. +++ b/drivers/mtd/ubi/block.c
  90. @@ -396,7 +396,11 @@ int ubiblock_create(struct ubi_volume_in
  91. dev->leb_size = vi->usable_leb_size;
  92. /* Initialize the gendisk of this ubiblock device */
  93. +#ifdef CONFIG_FIT_PARTITION
  94. + gd = alloc_disk(0);
  95. +#else
  96. gd = alloc_disk(1);
  97. +#endif
  98. if (!gd) {
  99. pr_err("UBI: block: alloc_disk failed\n");
  100. ret = -ENODEV;
  101. @@ -413,6 +417,9 @@ int ubiblock_create(struct ubi_volume_in
  102. goto out_put_disk;
  103. }
  104. gd->private_data = dev;
  105. +#ifdef CONFIG_FIT_PARTITION
  106. + gd->flags |= GENHD_FL_EXT_DEVT;
  107. +#endif
  108. sprintf(gd->disk_name, "ubiblock%d_%d", dev->ubi_num, dev->vol_id);
  109. set_capacity(gd, disk_capacity);
  110. dev->gd = gd;
  111. --- a/block/partitions/efi.c
  112. +++ b/block/partitions/efi.c
  113. @@ -706,6 +706,9 @@ int efi_partition(struct parsed_partitio
  114. gpt_entry *ptes = NULL;
  115. u32 i;
  116. unsigned ssz = bdev_logical_block_size(state->bdev) / 512;
  117. +#ifdef CONFIG_FIT_PARTITION
  118. + u32 extra_slot = 64;
  119. +#endif
  120. if (!find_valid_gpt(state, &gpt, &ptes) || !gpt || !ptes) {
  121. kfree(gpt);
  122. @@ -739,6 +742,11 @@ int efi_partition(struct parsed_partitio
  123. ARRAY_SIZE(ptes[i].partition_name));
  124. utf16_le_to_7bit(ptes[i].partition_name, label_max, info->volname);
  125. state->parts[i + 1].has_info = true;
  126. +#ifdef CONFIG_FIT_PARTITION
  127. + /* If this is a U-Boot FIT volume it may have subpartitions */
  128. + if (!efi_guidcmp(ptes[i].partition_type_guid, PARTITION_LINUX_FIT_GUID))
  129. + (void) parse_fit_partitions(state, start * ssz, size * ssz, &extra_slot, 1);
  130. +#endif
  131. }
  132. kfree(ptes);
  133. kfree(gpt);
  134. --- a/block/partitions/efi.h
  135. +++ b/block/partitions/efi.h
  136. @@ -52,6 +52,9 @@
  137. #define PARTITION_LINUX_LVM_GUID \
  138. EFI_GUID( 0xe6d6d379, 0xf507, 0x44c2, \
  139. 0xa2, 0x3c, 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28)
  140. +#define PARTITION_LINUX_FIT_GUID \
  141. + EFI_GUID( 0xcae9be83, 0xb15f, 0x49cc, \
  142. + 0x86, 0x3f, 0x08, 0x1b, 0x74, 0x4a, 0x2d, 0x93)
  143. typedef struct _gpt_header {
  144. __le64 signature;
  145. --- a/drivers/mtd/mtdblock.c
  146. +++ b/drivers/mtd/mtdblock.c
  147. @@ -334,7 +334,11 @@ static void mtdblock_remove_dev(struct m
  148. static struct mtd_blktrans_ops mtdblock_tr = {
  149. .name = "mtdblock",
  150. .major = MTD_BLOCK_MAJOR,
  151. +#ifdef CONFIG_FIT_PARTITION
  152. + .part_bits = 2,
  153. +#else
  154. .part_bits = 0,
  155. +#endif
  156. .blksize = 512,
  157. .open = mtdblock_open,
  158. .flush = mtdblock_flush,
  159. --- a/drivers/mtd/mtd_blkdevs.c
  160. +++ b/drivers/mtd/mtd_blkdevs.c
  161. @@ -407,18 +407,8 @@ int add_mtd_blktrans_dev(struct mtd_blkt
  162. gd->first_minor = (new->devnum) << tr->part_bits;
  163. gd->fops = &mtd_block_ops;
  164. - if (tr->part_bits)
  165. - if (new->devnum < 26)
  166. - snprintf(gd->disk_name, sizeof(gd->disk_name),
  167. - "%s%c", tr->name, 'a' + new->devnum);
  168. - else
  169. - snprintf(gd->disk_name, sizeof(gd->disk_name),
  170. - "%s%c%c", tr->name,
  171. - 'a' - 1 + new->devnum / 26,
  172. - 'a' + new->devnum % 26);
  173. - else
  174. - snprintf(gd->disk_name, sizeof(gd->disk_name),
  175. - "%s%d", tr->name, new->devnum);
  176. + snprintf(gd->disk_name, sizeof(gd->disk_name),
  177. + "%s%d", tr->name, new->devnum);
  178. set_capacity(gd, ((u64)new->size * tr->blksize) >> 9);
  179. --- a/block/partitions/msdos.c
  180. +++ b/block/partitions/msdos.c
  181. @@ -563,6 +563,15 @@ static void parse_minix(struct parsed_pa
  182. #endif /* CONFIG_MINIX_SUBPARTITION */
  183. }
  184. +static void parse_fit_mbr(struct parsed_partitions *state,
  185. + sector_t offset, sector_t size, int origin)
  186. +{
  187. +#ifdef CONFIG_FIT_PARTITION
  188. + u32 extra_slot = 64;
  189. + (void) parse_fit_partitions(state, offset, size, &extra_slot, 1);
  190. +#endif /* CONFIG_FIT_PARTITION */
  191. +}
  192. +
  193. static struct {
  194. unsigned char id;
  195. void (*parse)(struct parsed_partitions *, sector_t, sector_t, int);
  196. @@ -574,6 +583,7 @@ static struct {
  197. {UNIXWARE_PARTITION, parse_unixware},
  198. {SOLARIS_X86_PARTITION, parse_solaris_x86},
  199. {NEW_SOLARIS_X86_PARTITION, parse_solaris_x86},
  200. + {FIT_PARTITION, parse_fit_mbr},
  201. {0, NULL},
  202. };
  203. --- a/include/linux/msdos_partition.h
  204. +++ b/include/linux/msdos_partition.h
  205. @@ -31,6 +31,7 @@ enum msdos_sys_ind {
  206. LINUX_LVM_PARTITION = 0x8e,
  207. LINUX_RAID_PARTITION = 0xfd, /* autodetect RAID partition */
  208. + FIT_PARTITION = 0x2e, /* U-Boot uImage.FIT */
  209. SOLARIS_X86_PARTITION = 0x82, /* also Linux swap partitions */
  210. NEW_SOLARIS_X86_PARTITION = 0xbf,