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

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

commit 4924a6a30b783dadbe37dbaa97924ae9fe572fe7
Author: Marco Casaroli <[email protected]>
AuthorDate: Mon Oct 12 05:20:10 2026 +0200

    fs/v9fs: Keep the walk error in open(), and honour O_NOFOLLOW.
    
    open() changed every walk error to ENOENT, and with O_CREAT it tried to
    create the file after any error.  A symbolic link loop gave ENOENT
    instead of ELOOP, and a missing directory on the path was hidden.  Now
    open() creates the file only when the walk returns ENOENT, and it
    returns the walk error otherwise.
    
    open() also followed a symbolic link in the last name when O_NOFOLLOW
    was given.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 fs/v9fs/v9fs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/v9fs/v9fs.c b/fs/v9fs/v9fs.c
index 28a40efee9a..52514c40b06 100644
--- a/fs/v9fs/v9fs.c
+++ b/fs/v9fs/v9fs.c
@@ -205,7 +205,8 @@ static int v9fs_vfs_open(FAR struct file *filep, FAR const 
char *relpath,
       return -ENOMEM;
     }
 
-  ret = v9fs_client_walk(client, relpath, NULL, false);
+  ret = v9fs_client_walk(client, relpath, NULL,
+                         (oflags & O_NOFOLLOW) != 0);
   if (ret >= 0)
     {
       file->fid = ret;
@@ -216,7 +217,7 @@ static int v9fs_vfs_open(FAR struct file *filep, FAR const 
char *relpath,
           goto err_put;
         }
     }
-  else if ((oflags & O_CREAT) != 0)
+  else if (ret == -ENOENT && (oflags & O_CREAT) != 0)
     {
       /* We expect to create this file */
 
@@ -240,7 +241,6 @@ static int v9fs_vfs_open(FAR struct file *filep, FAR const 
char *relpath,
       /* We expect to open this file */
 
       ferr("ERROR: Can't find the fid of relpath: %d\n", ret);
-      ret = -ENOENT;
       goto err_free;
     }
 

Reply via email to