You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2021/07/18 13:26:07 UTC

[incubator-nuttx] 02/02: fs: mkdir return EEXIST if the path already exist

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/incubator-nuttx.git

commit 02a6966ad5de551a9f2adb0f97c21d404170c79b
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sat Jul 17 23:15:33 2021 +0800

    fs: mkdir return EEXIST if the path already exist
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
    Change-Id: Ie1808697b860974367c17e0ba614ca5cae79f324
---
 fs/vfs/fs_mkdir.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fs/vfs/fs_mkdir.c b/fs/vfs/fs_mkdir.c
index aae409a..67229e7 100644
--- a/fs/vfs/fs_mkdir.c
+++ b/fs/vfs/fs_mkdir.c
@@ -79,6 +79,12 @@ int mkdir(const char *pathname, mode_t mode)
       inode = desc.node;
       DEBUGASSERT(inode != NULL);
 
+      if (desc.relpath[0] == '\0')
+        {
+          errcode = EEXIST;
+          goto errout_with_inode;
+        }
+
 #ifndef CONFIG_DISABLE_MOUNTPOINT
       /* Check if the inode is a valid mountpoint. */