Repository navigation
fs: decouple block/MTD driver support from DISABLE_MOUNTPOINT - #22226
Merged
Merged
Conversation
Split the block and MTD driver inode helpers out of the CONFIG_DISABLE_MOUNTPOINT build guard so they can be compiled independently of mountpoint support. Introduce CONFIG_FS_BLOCK_DRIVER to gate the block driver inode helpers, the block_operations vtable and ftl.c. It is always enabled with mount points and can be selected with DISABLE_MOUNTPOINT, so configurations with mount points build the same objects as before. The MTD driver inode helpers are gated by CONFIG_MTD, since they do not call any block function; find_mtddriver() and close_mtddriver() keep their -ENODEV stubs for builds with mount points but without MTD. fs_mtdproxy.c opens the auto-created FTL block device through open_blockdriver() and then unlinks it, so FS_MTD_PROXY now also depends on FS_BLOCK_DRIVER and on nx_unlink() being built, and the block-inode branch of nx_unlink() follows CONFIG_FS_BLOCK_DRIVER. Use the build layer (Make.defs/CMakeLists.txt) as the single cropping point for the block/MTD inode helper sources and drop the redundant in-file whole-file #ifdef guards. Signed-off-by: cuiziwei <[email protected]> Signed-off-by: jingfei <[email protected]>
Add dedicated Kconfig options to gate the block partition and block
merge inode helpers separately from the base block driver inode helpers:
CONFIG_BLOCK_PARTITION gates fs_blockpartition.c
(register_blockpartition /
register_partition_with_inode)
CONFIG_BLOCK_MERGE gates fs_blockmerge.c
(register_merge_blockdriver)
Both depend on FS_BLOCK_DRIVER and, like it, are always enabled with
mount points, so existing configurations keep building these helpers
unchanged. A target built with DISABLE_MOUNTPOINT that selects
FS_BLOCK_DRIVER but does not need block partition or merge support can
drop the corresponding object files.
The build layer (Make.defs/CMakeLists.txt) gates the two source files on
the new options, and the public/private prototypes
(register_blockpartition, register_merge_blockdriver,
register_partition_with_inode) follow the same guards.
Signed-off-by: cuiziwei <[email protected]>
Signed-off-by: jingfei <[email protected]>
Build the partition table support whenever block or MTD partitions are
available (CONFIG_BLOCK_PARTITION || CONFIG_MTD_PARTITION) instead of
gating the whole directory on !CONFIG_DISABLE_MOUNTPOINT. This lets the
partition parser be built for raw block/MTD partition access without
pulling in mountpoint support, and dropped entirely when neither kind of
partition is configured.
The Make.defs/CMakeLists.txt directory guard and the Kconfig menu guard
switch to the BLOCK_PARTITION || MTD_PARTITION condition, and
fs/Makefile includes fs/partition outside the mount point block, as
CMake already does. Inside
fs_partition.c the block path (parse_block_partition, the block branch
of read_partition_block, and the register_partition_with_inode call) is
gated by CONFIG_BLOCK_PARTITION, and the MTD path by
CONFIG_MTD_PARTITION. In <nuttx/fs/partition.h> struct partition_s
stays visible, since boards use it for static partition tables, and
parse_block_partition() / parse_mtd_partition() are declared under
their own option.
[skip-cmake-parity]: CMake needs no change, since fs/CMakeLists.txt
already adds every subdirectory and fs/partition/CMakeLists.txt gates
itself.
Also tighten two consistency points:
- The register_partition_with_mtd prototype guard is narrowed from
CONFIG_MTD to CONFIG_MTD_PARTITION so declaration, definition
(fs_mtdpartition.c) and call site all agree.
- fs_partition.c includes <errno.h> explicitly, since
read_partition_block now returns -ENODEV when the state holds
neither a block nor an MTD device.
Signed-off-by: cuiziwei <[email protected]>
Signed-off-by: jingfei <[email protected]>
jingfei195887
requested review from
Donny9,
GUIDINGLI,
btashton,
hartmannathan,
jerpelea,
pkarashchenko,
pussuw and
xiaoxiang781216
as code owners
November 23, 2026 16:05
xiaoxiang781216
approved these changes
Nov 23, 2026
1 task done
|
GUIDINGLI
approved these changes
Nov 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Block and MTD driver support is tied to
CONFIG_DISABLE_MOUNTPOINT:the block driver inode helpers,
struct block_operations,ftl.cand thepartition parser are all built only with mount points. A small target that
has no file system to mount but wants raw access to an FTL over MTD (for
example to read a boot partition) cannot build them; with
DISABLE_MOUNTPOINT=yandMTD=yon master,drivers/mtd/ftl.canddrivers/bchfail to compile.This series decouples them:
New
CONFIG_FS_BLOCK_DRIVERgates the block driver inode helpers, theblock_operationsvtable andftl.c. It is always enabled with mountpoints and only selectable with
DISABLE_MOUNTPOINT. The MTD inodehelpers are gated by
CONFIG_MTD;find_mtddriver()/close_mtddriver()keep their-ENODEVstubs.mtd_proxy()opens itstemporary FTL device with
open_blockdriver()and then unlinks it, soFS_MTD_PROXYalso depends onFS_BLOCK_DRIVERand onnx_unlink()being built, and the block-inode branch of
nx_unlink()followsCONFIG_FS_BLOCK_DRIVER.Separate options for
fs_blockpartition.candfs_blockmerge.c. LikeFS_BLOCK_DRIVERthey are always enabled with mount points and can onlybe turned off with
DISABLE_MOUNTPOINT.The partition parser builds when either partition type is enabled.
struct partition_sstays visible (boards use it for static tables);parse_block_partition()/parse_mtd_partition()are declared undertheir own option.
Impact
FS_BLOCK_DRIVER,BLOCK_PARTITION,BLOCK_MERGE. No function signature changes.the same objects are built as before (checked below).
DISABLE_MOUNTPOINT=y: unchanged unlessFS_BLOCK_DRIVERis selected.Testing
Host: Ubuntu 22.04 x86_64, gcc 13.1.0. Base: master e0a754b.
Build matrix on
sim:nsh(Make), master vs this PR. TheDISABLE_MOUNTPOINTrows also setFS_BINFS=n DEV_LOOP=n, because the simboard code mounts binfs and registers
/dev/loopunconditionally.FS_BLOCK_DRIVERandBLOCK_PARTITIONdo not exist on master, so themaster rows are built without them.
MTD BCH FS_ROMFS RAMMTD MTD_PARTITION MBR_PARTITIONMTD BCH BLOCK_PARTITION=n BLOCK_MERGE=nDISABLE_MOUNTPOINTDISABLE_MOUNTPOINT MTD RAMMTDftl.c:g_bopshas incomplete typeDISABLE_MOUNTPOINT FS_BLOCK_DRIVER MTD RAMMTD BCH FS_MTD_PROXY MTD_PARTITIONbchlib_setup.c: no memberi_bopsBLOCK_PARTITION=n BLOCK_MERGE=n MBR_PARTITION GPT_PARTITIONbchlib_setup.c: no memberi_bopsDISABLE_MOUNTPOINT DISABLE_PSEUDOFS_OPERATIONS FS_BLOCK_DRIVER MTD RAMMTD BCHbchlib_setup.c: no memberi_bopsAll builds of this PR have 0 warnings. Each of the three commits was also
built on its own with the mount point and
DISABLE_MOUNTPOINTrows above.Runtime on
sim:nshwithDISABLE_MOUNTPOINT FS_BLOCK_DRIVER MTD RAMMTD BCH FS_MTD_PROXY MTD_PARTITION(plusFS_BINFS=n DEV_LOOP=n SYSTEM_NXINIT=n INIT_ENTRYPOINT="nsh_main"). Master cannot build thisconfiguration, so the comparison is this PR with and without the
CONFIG_FS_BLOCK_DRIVERguard on the block-inode branch ofnx_unlink().dd if=/dev/rammtd of=/dev/null bs=512 count=8opens the MTD devicethrough block_proxy() and mtd_proxy():
failed to open '/dev/rammtd', errno 6 (ENXIO)tmpb000002left behind./tools/checkpatch.sh -m -g master..HEAD: all checks pass.sim:nsh+MTD RAMMTD BCH FS_MTD_PROXY MTD_PARTITION MBR_PARTITION:Make and CMake builds pass with no warnings in the changed files;
ostestexits with status 0.PR verification Self-Check