From 40661849d61d4f21d575c87d0560a2ca01ef77d6 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Sat, 17 Jul 2021 23:15:33 +0800 Subject: [PATCH] fs: mkdir return EEXIST if the path already exist Signed-off-by: Xiang Xiao 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 aae409afecc..67229e71308 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. */