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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. --- a/block/blk.h
  2. +++ b/block/blk.h
  3. @@ -354,6 +354,8 @@ void blk_free_ext_minor(unsigned int min
  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. int bdev_add_partition(struct gendisk *disk, int partno, sector_t start,
  10. sector_t length);
  11. int bdev_del_partition(struct gendisk *disk, int partno);
  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. @@ -12,6 +12,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. @@ -48,6 +52,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. @@ -408,6 +415,11 @@ static struct block_device *add_partitio
  76. goto out_del;
  77. }
  78. +#ifdef CONFIG_FIT_PARTITION
  79. + if (flags & ADDPART_FLAG_READONLY)
  80. + bdev->bd_read_only = true;
  81. +#endif
  82. +
  83. /* everything is up and running, commence */
  84. err = xa_insert(&disk->part_tbl, partno, bdev, GFP_KERNEL);
  85. if (err)
  86. @@ -598,6 +610,11 @@ static bool blk_add_partition(struct gen
  87. (state->parts[p].flags & ADDPART_FLAG_RAID))
  88. md_autodetect_dev(part->bd_dev);
  89. +#ifdef CONFIG_FIT_PARTITION
  90. + if ((state->parts[p].flags & ADDPART_FLAG_ROOTDEV) && ROOT_DEV == 0)
  91. + ROOT_DEV = part->bd_dev;
  92. +#endif
  93. +
  94. return true;
  95. }
  96. --- a/drivers/mtd/ubi/block.c
  97. +++ b/drivers/mtd/ubi/block.c
  98. @@ -428,6 +428,9 @@ int ubiblock_create(struct ubi_volume_in
  99. goto out_cleanup_disk;
  100. }
  101. gd->private_data = dev;
  102. +#ifdef CONFIG_FIT_PARTITION
  103. + gd->flags |= GENHD_FL_EXT_DEVT;
  104. +#endif
  105. sprintf(gd->disk_name, "ubiblock%d_%d", dev->ubi_num, dev->vol_id);
  106. set_capacity(gd, disk_capacity);
  107. dev->gd = gd;
  108. --- a/drivers/mtd/mtd_blkdevs.c
  109. +++ b/drivers/mtd/mtd_blkdevs.c
  110. @@ -345,6 +345,8 @@ int add_mtd_blktrans_dev(struct mtd_blkt
  111. gd->first_minor = (new->devnum) << tr->part_bits;
  112. gd->minors = 1 << tr->part_bits;
  113. gd->fops = &mtd_block_ops;
  114. + if (IS_ENABLED(CONFIG_FIT_PARTITION) && !mtd_type_is_nand(new->mtd))
  115. + gd->flags |= GENHD_FL_EXT_DEVT;
  116. if (tr->part_bits)
  117. if (new->devnum < 26)
  118. --- a/block/partitions/efi.c
  119. +++ b/block/partitions/efi.c
  120. @@ -716,6 +716,9 @@ int efi_partition(struct parsed_partitio
  121. gpt_entry *ptes = NULL;
  122. u32 i;
  123. unsigned ssz = queue_logical_block_size(state->disk->queue) / 512;
  124. +#ifdef CONFIG_FIT_PARTITION
  125. + u32 extra_slot = 64;
  126. +#endif
  127. if (!find_valid_gpt(state, &gpt, &ptes) || !gpt || !ptes) {
  128. kfree(gpt);
  129. @@ -749,6 +752,11 @@ int efi_partition(struct parsed_partitio
  130. ARRAY_SIZE(ptes[i].partition_name));
  131. utf16_le_to_7bit(ptes[i].partition_name, label_max, info->volname);
  132. state->parts[i + 1].has_info = true;
  133. +#ifdef CONFIG_FIT_PARTITION
  134. + /* If this is a U-Boot FIT volume it may have subpartitions */
  135. + if (!efi_guidcmp(ptes[i].partition_type_guid, PARTITION_LINUX_FIT_GUID))
  136. + (void) parse_fit_partitions(state, start * ssz, size * ssz, &extra_slot, 1);
  137. +#endif
  138. }
  139. kfree(ptes);
  140. kfree(gpt);
  141. --- a/block/partitions/efi.h
  142. +++ b/block/partitions/efi.h
  143. @@ -52,6 +52,9 @@
  144. #define PARTITION_LINUX_LVM_GUID \
  145. EFI_GUID( 0xe6d6d379, 0xf507, 0x44c2, \
  146. 0xa2, 0x3c, 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28)
  147. +#define PARTITION_LINUX_FIT_GUID \
  148. + EFI_GUID( 0xcae9be83, 0xb15f, 0x49cc, \
  149. + 0x86, 0x3f, 0x08, 0x1b, 0x74, 0x4a, 0x2d, 0x93)
  150. typedef struct _gpt_header {
  151. __le64 signature;
  152. --- a/block/partitions/msdos.c
  153. +++ b/block/partitions/msdos.c
  154. @@ -564,6 +564,15 @@ static void parse_minix(struct parsed_pa
  155. #endif /* CONFIG_MINIX_SUBPARTITION */
  156. }
  157. +static void parse_fit_mbr(struct parsed_partitions *state,
  158. + sector_t offset, sector_t size, int origin)
  159. +{
  160. +#ifdef CONFIG_FIT_PARTITION
  161. + u32 extra_slot = 64;
  162. + (void) parse_fit_partitions(state, offset, size, &extra_slot, 1);
  163. +#endif /* CONFIG_FIT_PARTITION */
  164. +}
  165. +
  166. static struct {
  167. unsigned char id;
  168. void (*parse)(struct parsed_partitions *, sector_t, sector_t, int);
  169. @@ -575,6 +584,7 @@ static struct {
  170. {UNIXWARE_PARTITION, parse_unixware},
  171. {SOLARIS_X86_PARTITION, parse_solaris_x86},
  172. {NEW_SOLARIS_X86_PARTITION, parse_solaris_x86},
  173. + {FIT_PARTITION, parse_fit_mbr},
  174. {0, NULL},
  175. };
  176. --- a/include/linux/msdos_partition.h
  177. +++ b/include/linux/msdos_partition.h
  178. @@ -31,6 +31,7 @@ enum msdos_sys_ind {
  179. LINUX_LVM_PARTITION = 0x8e,
  180. LINUX_RAID_PARTITION = 0xfd, /* autodetect RAID partition */
  181. + FIT_PARTITION = 0x2e, /* U-Boot uImage.FIT */
  182. SOLARIS_X86_PARTITION = 0x82, /* also Linux swap partitions */
  183. NEW_SOLARIS_X86_PARTITION = 0xbf,