Skip to contentSkip to conversation

block: add uImage.FIT block partition driver

RFC PATCH In review Daniel Golle 3 participants 3 messages Dec 13, 2022 – Dec 15, 2022 Block layer

lore
Share & tools
lore
#0 lore raw

RFC PATCH 2/2 block: add uImage.FIT block partition driver

Add a small block driver which allows exposing filesystem sub-images contained in U-Boot uImage.FIT images as block partitions. The driver is intended for system using the U-Boot bootloader and requires the user to specify the lower block device to be specified as module parameter 'lower_dev'.

The initial approach of using a partition parser for this job has been NACK'ed[1], the suggestion was to implement a tiny stackable block driver instead for this job. Here it comes.

As discussed previously, the removal-notification part doesn't work at this point as it depends on a future change introducing such notifications[2].

[1]: https://lore.kernel.org/lkml/[email protected]/
[2]: https://lore.kernel.org/lkml/[email protected]/

---

 MAINTAINERS            |   6 +
 drivers/block/Kconfig  |  11 +
 drivers/block/Makefile |   2 +
 drivers/block/fitblk.c | 493 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 512 insertions(+)
 create mode 100644 drivers/block/fitblk.c
MAINTAINERS +6 -0
index 08b67532e374..39402d6d0b9c 100644
@@ -21184,6 +21184,12 @@ F:	Documentation/filesystems/ubifs-authentication.rst
 F:	Documentation/filesystems/ubifs.rst
 F:	fs/ubifs/
 
+U-BOOT UIMAGE.FIT PARSER
+M:	Daniel Golle <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/block/fitblk.c
+
 UBLK USERSPACE BLOCK DRIVER
 M:	Ming Lei <[email protected]>
 L:	[email protected]
drivers/block/Kconfig +11 -0
index a41145d52de9..f8618bc869b2 100644
@@ -383,6 +383,17 @@ config VIRTIO_BLK
 	  This is the virtual block driver for virtio.  It can be used with
           QEMU based VMMs (like KVM or Xen).  Say Y or M.
 
+config UIMAGE_FIT_BLK
+	bool "uImage.FIT block driver"
+	help
+	  This is driver allows using filesystems contained in uImage.FIT images
+	  by mapping them as block devices.
+
+	  This driver can currently not be built as a module.
+
+	  Say Y if you want to mount filesystems sub-images of a uImage.FIT
+	  stored in a block device partition, mtdblock or ubiblock device.
+
 config BLK_DEV_RBD
 	tristate "Rados block device (RBD)"
 	depends on INET && BLOCK
drivers/block/Makefile +2 -0
index 101612cba303..60ab4fc1442d 100644
@@ -39,4 +39,6 @@ obj-$(CONFIG_BLK_DEV_NULL_BLK)	+= null_blk/
 
 obj-$(CONFIG_BLK_DEV_UBLK)			+= ublk_drv.o
 
+obj-$(CONFIG_UIMAGE_FIT_BLK)	+= fitblk.o
+
 swim_mod-y	:= swim.o swim_asm.o
drivers/block/fitblk.c new file +493 -0

493 lines not on this page · raw message

Signature · 1 line
2.39.0
#1 lore raw

drivers/block/Kconfig config VIRTIO_BLK · line 389

Quoted 12 lines · Daniel Golle
drivers/block/Kconfig +4 -0
index a41145d52de9..f8618bc869b2 100644
@@ -383,6 +383,17 @@ config VIRTIO_BLK
 	  This is the virtual block driver for virtio.  It can be used with
           QEMU based VMMs (like KVM or Xen).  Say Y or M.
 
+config UIMAGE_FIT_BLK
+	bool "uImage.FIT block driver"
+	help
+	  This is driver allows using filesystems contained in uImage.FIT images

This driver allows

Quoted 6 lines
drivers/block/Kconfig +6 -0
+	  by mapping them as block devices.
+
+	  This driver can currently not be built as a module.
+
+	  Say Y if you want to mount filesystems sub-images of a uImage.FIT
+	  stored in a block device partition, mtdblock or ubiblock device.
Signature · 1 line
~Randy
#2 lore raw
In reply to Daniel Golle

drivers/block/fitblk.c line 456

Quoted 3 lines
drivers/block/fitblk.c new file +3 -0
+	dev = class_find_device_by_devt(&block_class, devt);
+	if (!dev)
+		return -EPROBE_DEFER;

FYI, class_find_device_by_devt is not for driver use. The only reson it isn't marker static is because of various legacy driver model and devtmpfs interactions.