This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new af5eb413193 fs/mount: Build fs_procfs_mount.c when any of its entries 
is enabled.
af5eb413193 is described below

commit af5eb413193e597dee5ba1d3808cf033a1328b73
Author: Marco Casaroli <[email protected]>
AuthorDate: Fri Nov 13 08:34:08 2026 +0100

    fs/mount: Build fs_procfs_mount.c when any of its entries is enabled.
    
    fs_procfs_mount.c gives g_mount_operations for the procfs entries
    fs/mount, fs/blocks and fs/usage.  fs/procfs/fs_procfs.c uses it for
    each of these entries that is not excluded.  But Make.defs and
    CMakeLists.txt build the file only when CONFIG_FS_PROCFS_EXCLUDE_MOUNT
    is not set.  With CONFIG_FS_PROCFS_EXCLUDE_MOUNT=y and fs/blocks or
    fs/usage enabled, the link fails:
    
      undefined reference to `g_mount_operations'
    
    Build the file when at least one of the three entries is enabled.
    
    In mount_open(), give each relpath check its own "if".  With fs/mount
    excluded, the "else if" of fs/blocks attached to the O_RDONLY check
    above it.  Also check fs/usage only when it is enabled, as the other
    two entries do.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 fs/mount/CMakeLists.txt    | 5 ++++-
 fs/mount/Make.defs         | 2 +-
 fs/mount/fs_procfs_mount.c | 8 ++++++--
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/fs/mount/CMakeLists.txt b/fs/mount/CMakeLists.txt
index f02cae57a31..a561c4244b7 100644
--- a/fs/mount/CMakeLists.txt
+++ b/fs/mount/CMakeLists.txt
@@ -29,7 +29,10 @@ if(NOT CONFIG_DISABLE_MOUNTPOINT)
     list(APPEND SRCS fs_automount.c)
   endif()
 
-  if(CONFIG_FS_PROCFS AND NOT CONFIG_FS_PROCFS_EXCLUDE_MOUNT)
+  if(CONFIG_FS_PROCFS
+     AND (NOT CONFIG_FS_PROCFS_EXCLUDE_MOUNT
+          OR NOT CONFIG_FS_PROCFS_EXCLUDE_BLOCKS
+          OR NOT CONFIG_FS_PROCFS_EXCLUDE_USAGE))
     list(APPEND SRCS fs_procfs_mount.c fs_gettype.c)
   endif()
 
diff --git a/fs/mount/Make.defs b/fs/mount/Make.defs
index 181613283d0..ea484c22f14 100644
--- a/fs/mount/Make.defs
+++ b/fs/mount/Make.defs
@@ -31,7 +31,7 @@ CSRCS += fs_automount.c
 endif
 
 ifeq  ($(CONFIG_FS_PROCFS),y)
-ifneq ($(CONFIG_FS_PROCFS_EXCLUDE_MOUNT),y)
+ifneq 
($(CONFIG_FS_PROCFS_EXCLUDE_MOUNT)$(CONFIG_FS_PROCFS_EXCLUDE_BLOCKS)$(CONFIG_FS_PROCFS_EXCLUDE_USAGE),yyy)
 CSRCS += fs_procfs_mount.c fs_gettype.c
 endif
 endif
diff --git a/fs/mount/fs_procfs_mount.c b/fs/mount/fs_procfs_mount.c
index 6b076b0ca74..8ae573cfaa1 100644
--- a/fs/mount/fs_procfs_mount.c
+++ b/fs/mount/fs_procfs_mount.c
@@ -397,18 +397,22 @@ static int mount_open(FAR struct file *filep, FAR const 
char *relpath,
     {
       id = FS_MOUNT_FILE;
     }
+  else
 #endif
 #ifndef CONFIG_FS_PROCFS_EXCLUDE_BLOCKS
-  else if (strcmp(relpath, "fs/blocks") == 0)
+  if (strcmp(relpath, "fs/blocks") == 0)
     {
       id = FS_BLOCKS_FILE;
     }
+  else
 #endif
-  else if (strcmp(relpath, "fs/usage") == 0)
+#ifndef CONFIG_FS_PROCFS_EXCLUDE_USAGE
+  if (strcmp(relpath, "fs/usage") == 0)
     {
       id = FS_USAGE_FILE;
     }
   else
+#endif
     {
       ferr("ERROR: relpath is '%s'\n", relpath);
       return -ENOENT;

Reply via email to