From 006afeb21f13a37eae630e02741ef38b22b088eb Mon Sep 17 00:00:00 2001 From: yinshengkai Date: Mon, 24 Apr 2023 11:55:36 +0800 Subject: [PATCH] fs/inode: when searching for nextname skip "/" and "./" fix the problem that stat fails to use the relative path An error will be reported if used in the following way: stat("//./bin", &st); Signed-off-by: yinshengkai --- fs/inode/fs_inodesearch.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/fs/inode/fs_inodesearch.c b/fs/inode/fs_inodesearch.c index 7dda789359e..553c143f3b7 100644 --- a/fs/inode/fs_inodesearch.c +++ b/fs/inode/fs_inodesearch.c @@ -559,5 +559,16 @@ FAR const char *inode_nextname(FAR const char *name) name++; } + /* Skip single '.' path segment, but not '..' */ + + if (*name == '.' && *(name + 1) == '/') + { + /* If there is a '/' after '.', + * continue searching from the next character + */ + + name = inode_nextname(name); + } + return name; }