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 8c7ca1fb0e94c9369d8c3fcbed0d0eca3e46ecb1
Author: zhengyu16 <[email protected]>
AuthorDate: Mon Sep 29 15:04:53 2025 +0800

    fs/inode: return ENOTDIR if a path prefix is not a directory
    
    While walking the path components, a non-final component must refer to a
    directory.  When descending into a child, verify the parent inode is a
    pseudo directory; if it is not, stop the search and return -ENOTDIR as
    required by POSIX for a path prefix that is not a directory.
    
    Signed-off-by: zhengyu16 <[email protected]>
---
 fs/inode/fs_inodesearch.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/fs/inode/fs_inodesearch.c b/fs/inode/fs_inodesearch.c
index 460a5554dbf..fd8b147bb6a 100644
--- a/fs/inode/fs_inodesearch.c
+++ b/fs/inode/fs_inodesearch.c
@@ -387,6 +387,13 @@ static int _inode_search(FAR struct inode_search_s *desc)
               above = inode;
               left  = NULL;
               inode = inode->i_child;
+              if (!INODE_IS_PSEUDODIR(above))
+                {
+                  /* The prefix of the path is not a directory */
+
+                  ret = -ENOTDIR;
+                  break;
+                }
             }
         }
     }

Reply via email to