From: Richard Weinberger <rich…@nod.at> After a long hiatus I finally found some time to work on MUSE again. Rationale: ---------- A common task when working with flash devices is emulating them, to run tests or to inspect dumps from real hardware. The MTD subsystem has plenty of emulators for that: mtdram, block2mtd, nandsim. Each of them implements an ad-hoc MTD and has various drawbacks. Over the last years some developers tried to extend them, but these attempts were often rejected because they just added more ad-hoc features instead of addressing the overall problems. MUSE is a novel approach to address the need for advanced MTD emulators. Advanced means in this context: supporting different (vendor specific) image formats, different ways of fault injection (fuzzing), and recording and replaying IO to emulate power cuts. The core goal of MUSE is to have the complexity on the userspace side and only a small MTD driver in kernelspace. While playing with different approaches I realized that FUSE offers everything we need. So MUSE is a little like CUSE, except that it does not implement a bare character device but an MTD. Users of MUSE: -------------- mtdsim[0] is a MUSE based MTD simulator written in Rust I'm currently working on. So far it can simulate NOR, RAM and NAND style flashes. It can operate in memory and read/write nanddump style images. It also supports injecting bit-flips, and recording and replaying IO for deterministic power-cut testing of the users on top of the MTD. [0]: https://git.infradead.org/users/rw/mtdsim.git Changelog: ---------- Changes since v3: - Moved MUSE driver to drivers/mtd/ - Moved transport related FUSE header defines to include/net/fuse.h, including CUSE specific adoptions. - Many minor bug fixes - Support for in- and out-band within the same MTD operation - Code rebased to 7.4-rc4 Changes since v2 (RFC): - OOB support - MUSE_READ/WRITE opcodes are no longer a min IO MTD unit - MTD partitions support via mtdparts string - More code cleanup - Code rebased to 5.11-rc4 Changes since v1 (RFC): - Rewrote IO path, fuse_direct_io() is no longer used. Instead of cheating fuse_direct_io() use custom ops to implement reading and writing. That way MUSE no longer needs a dummy file object nor a fuse file object. In MTD all IO is synchronous and operations on kernel buffers, this makes IO processing simple for MUSE. - Support for bad blocks. - No more (ab)use of FUSE ops such as FUSE_FSYNC. - Major code cleanup. This series can also be found at: git://git.kernel.org/pub/scm/linux/kernel/git/rw/misc.git muse_v4 Richard Weinberger (10): fuse: Share cuse_parse_one() as fuse_kv_parse_one() fuse: Add a public header for users outside of fs/fuse/ fuse: Add an interface for userspace backed devices fuse: Convert CUSE to the interface for userspace backed devices fuse: Allow three output arguments per request fuse: Add MUSE specific defines to FUSE interface mtd: Add MTD_MUSE flag mtd: Allow passing a custom mtdparts string to the cmdline parser mtd: Implement MUSE - MTD in userspace MAINTAINERS: Add entry for MUSE Documentation/ABI/testing/sysfs-class-mtd | 8 + MAINTAINERS | 8 + drivers/mtd/Kconfig | 15 + drivers/mtd/Makefile | 1 + drivers/mtd/muse.c | 995 ++++++++++++++++++++++ drivers/mtd/parsers/cmdlinepart.c | 99 ++- fs/fuse/Kconfig | 4 + fs/fuse/Makefile | 1 + fs/fuse/args.h | 44 +- fs/fuse/cuse.c | 114 +-- fs/fuse/dev.h | 12 +- fs/fuse/fuse_dev_i.h | 3 +- fs/fuse/fuse_i.h | 8 +- fs/fuse/helper.c | 242 ++++++ include/linux/mtd/partitions.h | 2 + include/net/fuse.h | 98 +++ include/uapi/linux/fuse.h | 249 +++++- include/uapi/mtd/mtd-abi.h | 1 + 18 files changed, 1736 insertions(+), 168 deletions(-) create mode 100644 drivers/mtd/muse.c create mode 100644 fs/fuse/helper.c create mode 100644 include/net/fuse.h
-- 2.55.0