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 3aa3c215049 fs/vfs: provide link fallback without softlinks
3aa3c215049 is described below

commit 3aa3c215049d6fd69746c752b39436de7fca7bb1
Author: Felipe Moura <[email protected]>
AuthorDate: Wed Jun 24 16:50:15 2026 -0300

    fs/vfs: provide link fallback without softlinks
    
    Build fs_link.c unconditionally so link() remains available even when
    CONFIG_PSEUDOFS_SOFTLINKS is disabled. Return ENOSYS in that
    configuration instead of leaving applications with an undefined symbol.
    
    Signed-off-by: Felipe Moura <[email protected]>
---
 fs/vfs/CMakeLists.txt |  5 +++--
 fs/vfs/Make.defs      |  4 ++--
 fs/vfs/fs_link.c      | 23 +++++++++++------------
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/fs/vfs/CMakeLists.txt b/fs/vfs/CMakeLists.txt
index f1b6b45f743..3880b2a3727 100644
--- a/fs/vfs/CMakeLists.txt
+++ b/fs/vfs/CMakeLists.txt
@@ -51,7 +51,8 @@ set(SRCS
     fs_dir.c
     fs_fsync.c
     fs_syncfs.c
-    fs_truncate.c)
+    fs_truncate.c
+    fs_link.c)
 
 # File notify support
 
@@ -66,7 +67,7 @@ if(NOT "${CONFIG_FS_LOCK_BUCKET_SIZE}" STREQUAL "0")
 endif()
 
 if(NOT "${CONFIG_PSEUDOFS_SOFTLINKS}" STREQUAL "0")
-  list(APPEND SRCS fs_link.c fs_symlink.c fs_readlink.c)
+  list(APPEND SRCS fs_symlink.c fs_readlink.c)
 endif()
 
 # Pseudofile support
diff --git a/fs/vfs/Make.defs b/fs/vfs/Make.defs
index 75b7ad168c4..ce2a7a5f5af 100644
--- a/fs/vfs/Make.defs
+++ b/fs/vfs/Make.defs
@@ -27,7 +27,7 @@ CSRCS += fs_epoll.c fs_fchstat.c fs_fstat.c fs_fstatfs.c 
fs_ioctl.c fs_lseek.c
 CSRCS += fs_mkdir.c fs_open.c fs_poll.c fs_pread.c fs_pwrite.c fs_read.c
 CSRCS += fs_rename.c fs_rmdir.c fs_select.c fs_sendfile.c fs_stat.c
 CSRCS += fs_statfs.c fs_uio.c fs_unlink.c fs_write.c fs_dir.c fs_fsync.c
-CSRCS += fs_syncfs.c fs_truncate.c
+CSRCS += fs_syncfs.c fs_truncate.c fs_link.c
 
 ifeq ($(CONFIG_FS_NOTIFY),y)
 CSRCS += fs_inotify.c
@@ -38,7 +38,7 @@ CSRCS += fs_lock.c
 endif
 
 ifneq ($(CONFIG_PSEUDOFS_SOFTLINKS),0)
-CSRCS += fs_link.c fs_symlink.c fs_readlink.c
+CSRCS += fs_symlink.c fs_readlink.c
 endif
 
 # Pseudofile support
diff --git a/fs/vfs/fs_link.c b/fs/vfs/fs_link.c
index ffdb193706f..e47ac41fffe 100644
--- a/fs/vfs/fs_link.c
+++ b/fs/vfs/fs_link.c
@@ -26,14 +26,9 @@
 
 #include <nuttx/config.h>
 
+#include <errno.h>
 #include <unistd.h>
 
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-#ifdef CONFIG_PSEUDOFS_SOFTLINKS
-
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
@@ -42,10 +37,8 @@
  * Name: link
  *
  * Description:
- *  The link function provides a wrapper to symlink. Solely to provide
- *  compatibility to posix compatibility layer.
- *
- *  See symlink for details on limitations.
+ *  The link function provides a wrapper to symlink when pseudo filesystem
+ *  softlinks are enabled. Otherwise, hard links are unsupported.
  *
  * Input Parameters:
  *   path1 - Points to a pathname naming an existing file.
@@ -60,7 +53,13 @@
 
 int link(FAR const char *path1, FAR const char *path2)
 {
+#ifdef CONFIG_PSEUDOFS_SOFTLINKS
   return symlink(path1, path2);
-}
+#else
+  (void)path1;
+  (void)path2;
 
-#endif /* CONFIG_PSEUDOFS_SOFTLINKS */
+  set_errno(ENOSYS);
+  return ERROR;
+#endif
+}

Reply via email to