3 @@ -361,6 +361,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.
18 + bool "Flattened-Image-Tree (FIT) partition support" if PARTITION_ADVANCED
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.
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);
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
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>
65 static int (*check_part[])(struct parsed_partitions *) = {
66 @@ -46,6 +50,9 @@ static int (*check_part[])(struct parsed
67 #ifdef CONFIG_EFI_PARTITION
68 efi_partition, /* this must come before msdos */
70 +#ifdef CONFIG_FIT_PARTITION
73 #ifdef CONFIG_SGI_PARTITION
76 @@ -694,6 +701,11 @@ static bool blk_add_partition(struct gen
77 (state->parts[p].flags & ADDPART_FLAG_RAID))
78 md_autodetect_dev(part_to_dev(part)->devt);
80 +#ifdef CONFIG_FIT_PARTITION
81 + if ((state->parts[p].flags & ADDPART_FLAG_ROOTDEV) && ROOT_DEV == 0)
82 + ROOT_DEV = part_to_dev(part)->devt;
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;
93 /* Initialize the gendisk of this ubiblock device */
94 +#ifdef CONFIG_FIT_PARTITION
100 pr_err("UBI: block: alloc_disk failed\n");
102 @@ -413,6 +417,9 @@ int ubiblock_create(struct ubi_volume_in
105 gd->private_data = dev;
106 +#ifdef CONFIG_FIT_PARTITION
107 + gd->flags |= GENHD_FL_EXT_DEVT;
109 sprintf(gd->disk_name, "ubiblock%d_%d", dev->ubi_num, dev->vol_id);
110 set_capacity(gd, disk_capacity);
112 --- a/block/partitions/efi.c
113 +++ b/block/partitions/efi.c
114 @@ -706,6 +706,9 @@ int efi_partition(struct parsed_partitio
115 gpt_entry *ptes = NULL;
117 unsigned ssz = bdev_logical_block_size(state->bdev) / 512;
118 +#ifdef CONFIG_FIT_PARTITION
119 + u32 extra_slot = 64;
122 if (!find_valid_gpt(state, &gpt, &ptes) || !gpt || !ptes) {
124 @@ -739,6 +742,11 @@ int efi_partition(struct parsed_partitio
125 ARRAY_SIZE(ptes[i].partition_name));
126 utf16_le_to_7bit(ptes[i].partition_name, label_max, info->volname);
127 state->parts[i + 1].has_info = true;
128 +#ifdef CONFIG_FIT_PARTITION
129 + /* If this is a U-Boot FIT volume it may have subpartitions */
130 + if (!efi_guidcmp(ptes[i].partition_type_guid, PARTITION_LINUX_FIT_GUID))
131 + (void) parse_fit_partitions(state, start * ssz, size * ssz, &extra_slot, 1);
136 --- a/block/partitions/efi.h
137 +++ b/block/partitions/efi.h
139 #define PARTITION_LINUX_LVM_GUID \
140 EFI_GUID( 0xe6d6d379, 0xf507, 0x44c2, \
141 0xa2, 0x3c, 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28)
142 +#define PARTITION_LINUX_FIT_GUID \
143 + EFI_GUID( 0xcae9be83, 0xb15f, 0x49cc, \
144 + 0x86, 0x3f, 0x08, 0x1b, 0x74, 0x4a, 0x2d, 0x93)
146 typedef struct _gpt_header {
148 --- a/drivers/mtd/mtdblock.c
149 +++ b/drivers/mtd/mtdblock.c
150 @@ -334,7 +334,11 @@ static void mtdblock_remove_dev(struct m
151 static struct mtd_blktrans_ops mtdblock_tr = {
153 .major = MTD_BLOCK_MAJOR,
154 +#ifdef CONFIG_FIT_PARTITION
160 .open = mtdblock_open,
161 .flush = mtdblock_flush,
162 --- a/drivers/mtd/mtd_blkdevs.c
163 +++ b/drivers/mtd/mtd_blkdevs.c
164 @@ -407,18 +407,8 @@ int add_mtd_blktrans_dev(struct mtd_blkt
165 gd->first_minor = (new->devnum) << tr->part_bits;
166 gd->fops = &mtd_block_ops;
169 - if (new->devnum < 26)
170 - snprintf(gd->disk_name, sizeof(gd->disk_name),
171 - "%s%c", tr->name, 'a' + new->devnum);
173 - snprintf(gd->disk_name, sizeof(gd->disk_name),
174 - "%s%c%c", tr->name,
175 - 'a' - 1 + new->devnum / 26,
176 - 'a' + new->devnum % 26);
178 - snprintf(gd->disk_name, sizeof(gd->disk_name),
179 - "%s%d", tr->name, new->devnum);
180 + snprintf(gd->disk_name, sizeof(gd->disk_name),
181 + "%s%d", tr->name, new->devnum);
183 set_capacity(gd, ((u64)new->size * tr->blksize) >> 9);
185 --- a/block/partitions/msdos.c
186 +++ b/block/partitions/msdos.c
187 @@ -563,6 +563,15 @@ static void parse_minix(struct parsed_pa
188 #endif /* CONFIG_MINIX_SUBPARTITION */
191 +static void parse_fit_mbr(struct parsed_partitions *state,
192 + sector_t offset, sector_t size, int origin)
194 +#ifdef CONFIG_FIT_PARTITION
195 + u32 extra_slot = 64;
196 + (void) parse_fit_partitions(state, offset, size, &extra_slot, 1);
197 +#endif /* CONFIG_FIT_PARTITION */
202 void (*parse)(struct parsed_partitions *, sector_t, sector_t, int);
203 @@ -574,6 +583,7 @@ static struct {
204 {UNIXWARE_PARTITION, parse_unixware},
205 {SOLARIS_X86_PARTITION, parse_solaris_x86},
206 {NEW_SOLARIS_X86_PARTITION, parse_solaris_x86},
207 + {FIT_PARTITION, parse_fit_mbr},
211 --- a/include/linux/msdos_partition.h
212 +++ b/include/linux/msdos_partition.h
213 @@ -31,6 +31,7 @@ enum msdos_sys_ind {
214 LINUX_LVM_PARTITION = 0x8e,
215 LINUX_RAID_PARTITION = 0xfd, /* autodetect RAID partition */
217 + FIT_PARTITION = 0x2e, /* U-Boot uImage.FIT */
218 SOLARIS_X86_PARTITION = 0x82, /* also Linux swap partitions */
219 NEW_SOLARIS_X86_PARTITION = 0xbf,