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

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