This is an automated email from the ASF dual-hosted git repository. GUIDINGLI pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit cb79c6986b9da4e90ee91efb165c69d694dfa9c8 Author: jingfei <[email protected]> AuthorDate: Tue Jul 28 17:26:08 2026 +0800 fs/driver: add CONFIG_BLOCK_PARTITION and CONFIG_BLOCK_MERGE 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]> --- fs/Kconfig | 22 ++++++++++++++++++++++ fs/driver/CMakeLists.txt | 12 +++++++++--- fs/driver/Make.defs | 9 ++++++++- fs/driver/driver.h | 2 +- include/nuttx/fs/fs.h | 4 ++-- 5 files changed, 42 insertions(+), 7 deletions(-) diff --git a/fs/Kconfig b/fs/Kconfig index 0d9519e51ed..5d88785ddad 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -51,6 +51,28 @@ config FS_BLOCK_DRIVER to use block drivers (e.g. an FTL over MTD) for raw access without mounting them. +config BLOCK_PARTITION + bool "Block partition inode helpers" if DISABLE_MOUNTPOINT + depends on FS_BLOCK_DRIVER + default FS_BLOCK_DRIVER + ---help--- + Register block partition driver inodes (register_blockpartition / + register_partition_with_inode) built on top of the block driver + inode helpers. Always enabled with mount points. With + DISABLE_MOUNTPOINT, disable to drop fs_blockpartition.c when + block partitions are not needed. + +config BLOCK_MERGE + bool "Block merge inode helpers" if DISABLE_MOUNTPOINT + depends on FS_BLOCK_DRIVER + default FS_BLOCK_DRIVER + ---help--- + Register a merged block driver inode (register_merge_blockdriver) + that presents multiple non-contiguous partitions as one contiguous + block device. Always enabled with mount points. With + DISABLE_MOUNTPOINT, disable to drop fs_blockmerge.c when the + merge helper is not needed. + config FS_LARGEFILE bool "Large File Support" default n diff --git a/fs/driver/CMakeLists.txt b/fs/driver/CMakeLists.txt index fea8a40d7ac..8a96a807dc7 100644 --- a/fs/driver/CMakeLists.txt +++ b/fs/driver/CMakeLists.txt @@ -39,9 +39,15 @@ if(CONFIG_FS_BLOCK_DRIVER) fs_unregisterblockdriver.c fs_findblockdriver.c fs_openblockdriver.c - fs_closeblockdriver.c - fs_blockpartition.c - fs_blockmerge.c) + fs_closeblockdriver.c) + + if(CONFIG_BLOCK_PARTITION) + list(APPEND SRCS fs_blockpartition.c) + endif() + + if(CONFIG_BLOCK_MERGE) + list(APPEND SRCS fs_blockmerge.c) + endif() if(CONFIG_BCH AND NOT CONFIG_DISABLE_PSEUDOFS_OPERATIONS) list(APPEND SRCS fs_blockproxy.c) diff --git a/fs/driver/Make.defs b/fs/driver/Make.defs index 856357d29ec..66fb072e189 100644 --- a/fs/driver/Make.defs +++ b/fs/driver/Make.defs @@ -32,7 +32,14 @@ endif ifeq ($(CONFIG_FS_BLOCK_DRIVER),y) CSRCS += fs_registerblockdriver.c fs_unregisterblockdriver.c CSRCS += fs_findblockdriver.c fs_openblockdriver.c fs_closeblockdriver.c -CSRCS += fs_blockpartition.c fs_blockmerge.c + +ifeq ($(CONFIG_BLOCK_PARTITION),y) +CSRCS += fs_blockpartition.c +endif + +ifeq ($(CONFIG_BLOCK_MERGE),y) +CSRCS += fs_blockmerge.c +endif ifeq ($(CONFIG_BCH),y) ifneq ($(CONFIG_DISABLE_PSEUDOFS_OPERATIONS),y) diff --git a/fs/driver/driver.h b/fs/driver/driver.h index 42dfa05c3af..c6658c83e79 100644 --- a/fs/driver/driver.h +++ b/fs/driver/driver.h @@ -69,7 +69,7 @@ extern "C" * ****************************************************************************/ -#ifdef CONFIG_FS_BLOCK_DRIVER +#ifdef CONFIG_BLOCK_PARTITION int register_partition_with_inode(FAR const char *partition, mode_t mode, FAR struct inode *parent, off_t firstsector, off_t nsectors); diff --git a/include/nuttx/fs/fs.h b/include/nuttx/fs/fs.h index 6b6f043f1e4..5da6be7eabc 100644 --- a/include/nuttx/fs/fs.h +++ b/include/nuttx/fs/fs.h @@ -716,7 +716,7 @@ int register_blockdriver(FAR const char *path, * ****************************************************************************/ -#ifdef CONFIG_FS_BLOCK_DRIVER +#ifdef CONFIG_BLOCK_MERGE int register_merge_blockdriver(FAR const char *merge, ...); #endif @@ -743,7 +743,7 @@ int register_merge_blockdriver(FAR const char *merge, ...); * ****************************************************************************/ -#ifdef CONFIG_FS_BLOCK_DRIVER +#ifdef CONFIG_BLOCK_PARTITION int register_blockpartition(FAR const char *partition, mode_t mode, FAR const char *parent, off_t firstsector, off_t nsectors);
