Skip to content

Commit 9d54c8a

Browse files
ezequielgarciadedekind
authored andcommitted
UBI: R/O block driver on top of UBI volumes
This commit introduces read-only block device emulation on top of UBI volumes. Given UBI takes care of wear leveling and bad block management it's possible to add a thin layer to enable block device access to UBI volumes. This allows to use a block-oriented filesystem on a flash device. The UBI block devices are meant to be used in conjunction with any regular, block-oriented file system (e.g. ext4), although it's primarily targeted at read-only file systems, such as squashfs. Block devices are created upon user request through new ioctls: UBI_IOCVOLATTBLK to attach and UBI_IOCVOLDETBLK to detach. Also, a new UBI module parameter is added 'ubi.block'. This parameter is needed in order to attach a block device on boot-up time, allowing to mount the rootfs on a ubiblock device. For instance, you could have these kernel parameters: ubi.mtd=5 ubi.block=0,0 root=/dev/ubiblock0_0 Or, if you compile ubi as a module: $ modprobe ubi mtd=/dev/mtd5 block=/dev/ubi0_0 Artem: amend commentaries and massage the patch a little bit. Signed-off-by: Ezequiel Garcia <[email protected]> Signed-off-by: Artem Bityutskiy <[email protected]>
1 parent 5547fec commit 9d54c8a

File tree

7 files changed

+718
-0
lines changed

7 files changed

+718
-0
lines changed

drivers/mtd/ubi/Kconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,19 @@ config MTD_UBI_GLUEBI
8787
work on top of UBI. Do not enable this unless you use legacy
8888
software.
8989

90+
config MTD_UBI_BLOCK
91+
bool "Read-only block devices on top of UBI volumes"
92+
default n
93+
help
94+
This option enables read-only UBI block devices support. UBI block
95+
devices will be layered on top of UBI volumes, which means that the
96+
UBI driver will transparently handle things like bad eraseblocks and
97+
bit-flips. You can put any block-oriented file system on top of UBI
98+
volumes in read-only mode (e.g., ext4), but it is probably most
99+
practical for read-only file systems, like squashfs.
100+
101+
When selected, this feature will be built in the UBI driver.
102+
103+
If in doubt, say "N".
104+
90105
endif # MTD_UBI

drivers/mtd/ubi/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ obj-$(CONFIG_MTD_UBI) += ubi.o
33
ubi-y += vtbl.o vmt.o upd.o build.o cdev.o kapi.o eba.o io.o wl.o attach.o
44
ubi-y += misc.o debug.o
55
ubi-$(CONFIG_MTD_UBI_FASTMAP) += fastmap.o
6+
ubi-$(CONFIG_MTD_UBI_BLOCK) += block.o
67

78
obj-$(CONFIG_MTD_UBI_GLUEBI) += gluebi.o

0 commit comments

Comments
 (0)