image: add support for building FIT image with filesystem
[openwrt/openwrt.git] / target / linux / generic / hack-5.4 / 400-block-fit-partition-parser.patch
1 --- a/block/partitions/Kconfig
2 +++ b/block/partitions/Kconfig
3 @@ -101,6 +101,13 @@ config ATARI_PARTITION
4 Say Y here if you would like to use hard disks under Linux which
5 were partitioned under the Atari OS.
6
7 +config FIT_PARTITION
8 + bool "Flattened-Image-Tree (FIT) partition support" if PARTITION_ADVANCED
9 + default n
10 + help
11 + Say Y here if your system needs to mount the filesystem part of
12 + a Flattened-Image-Tree (FIT) image commonly used with Das U-Boot.
13 +
14 config IBM_PARTITION
15 bool "IBM disk label and partition support"
16 depends on PARTITION_ADVANCED && S390
17 --- a/block/partitions/Makefile
18 +++ b/block/partitions/Makefile
19 @@ -9,6 +9,7 @@ obj-$(CONFIG_ACORN_PARTITION) += acorn.o
20 obj-$(CONFIG_AMIGA_PARTITION) += amiga.o
21 obj-$(CONFIG_ATARI_PARTITION) += atari.o
22 obj-$(CONFIG_AIX_PARTITION) += aix.o
23 +obj-$(CONFIG_FIT_PARTITION) += fit.o
24 obj-$(CONFIG_CMDLINE_PARTITION) += cmdline.o
25 obj-$(CONFIG_MAC_PARTITION) += mac.o
26 obj-$(CONFIG_LDM_PARTITION) += ldm.o
27 --- a/drivers/mtd/ubi/block.c
28 +++ b/drivers/mtd/ubi/block.c
29 @@ -396,7 +396,7 @@ int ubiblock_create(struct ubi_volume_in
30 dev->leb_size = vi->usable_leb_size;
31
32 /* Initialize the gendisk of this ubiblock device */
33 - gd = alloc_disk(1);
34 + gd = alloc_disk(0);
35 if (!gd) {
36 pr_err("UBI: block: alloc_disk failed\n");
37 ret = -ENODEV;
38 @@ -413,6 +413,7 @@ int ubiblock_create(struct ubi_volume_in
39 goto out_put_disk;
40 }
41 gd->private_data = dev;
42 + gd->flags |= GENHD_FL_EXT_DEVT;
43 sprintf(gd->disk_name, "ubiblock%d_%d", dev->ubi_num, dev->vol_id);
44 set_capacity(gd, disk_capacity);
45 dev->gd = gd;
46 --- a/block/partition-generic.c
47 +++ b/block/partition-generic.c
48 @@ -18,6 +18,7 @@
49 #include <linux/ctype.h>
50 #include <linux/genhd.h>
51 #include <linux/blktrace_api.h>
52 +#include <linux/root_dev.h>
53
54 #include "partitions/check.h"
55
56 @@ -634,6 +635,8 @@ rescan:
57 if (state->parts[p].flags & ADDPART_FLAG_RAID)
58 md_autodetect_dev(part_to_dev(part)->devt);
59 #endif
60 + if ((state->parts[p].flags & ADDPART_FLAG_ROOTDEV) && ROOT_DEV == 0)
61 + ROOT_DEV = part_to_dev(part)->devt;
62 }
63 free_partitions(state);
64 return 0;
65 --- a/block/partitions/check.c
66 +++ b/block/partitions/check.c
67 @@ -33,6 +33,7 @@
68 #include "ibm.h"
69 #include "ultrix.h"
70 #include "efi.h"
71 +#include "fit.h"
72 #include "karma.h"
73 #include "sysv68.h"
74 #include "cmdline.h"
75 @@ -73,6 +74,9 @@ static int (*check_part[])(struct parsed
76 #ifdef CONFIG_EFI_PARTITION
77 efi_partition, /* this must come before msdos */
78 #endif
79 +#ifdef CONFIG_FIT_PARTITION
80 + fit_partition,
81 +#endif
82 #ifdef CONFIG_SGI_PARTITION
83 sgi_partition,
84 #endif
85 --- a/include/linux/genhd.h
86 +++ b/include/linux/genhd.h
87 @@ -614,6 +614,7 @@ struct unixware_disklabel {
88 #define ADDPART_FLAG_NONE 0
89 #define ADDPART_FLAG_RAID 1
90 #define ADDPART_FLAG_WHOLEDISK 2
91 +#define ADDPART_FLAG_ROOTDEV 4
92
93 extern int blk_alloc_devt(struct hd_struct *part, dev_t *devt);
94 extern void blk_free_devt(dev_t devt);
95 --- /dev/null
96 +++ b/block/partitions/fit.h
97 @@ -0,0 +1,2 @@
98 +/* SPDX-License-Identifier: GPL-2.0 */
99 +int fit_partition(struct parsed_partitions *);