From 02a6966ad5de551a9f2adb0f97c21d404170c79b 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 aae409afec..67229e7130 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. */