diff --git a/components/dfs/dfs_v2/src/dfs_posix.c b/components/dfs/dfs_v2/src/dfs_posix.c index f28d7fb2f1..2e270501e7 100644 --- a/components/dfs/dfs_v2/src/dfs_posix.c +++ b/components/dfs/dfs_v2/src/dfs_posix.c @@ -827,7 +827,7 @@ int rmdir(const char *pathname) if (!pathname) { - rt_set_errno(-RT_ERROR); + rt_set_errno(-EPERM); return -1; } @@ -852,7 +852,7 @@ int rmdir(const char *pathname) if (dirent) { - rt_set_errno(-RT_ERROR); + rt_set_errno(-EPERM); return -1; } } @@ -861,7 +861,7 @@ int rmdir(const char *pathname) { if (S_ISLNK(stat.st_mode)) { - rt_set_errno(-RT_ERROR); + rt_set_errno(-EPERM); return -1; } } diff --git a/components/lwp/lwp_syscall.c b/components/lwp/lwp_syscall.c index 077f6d86af..7dff63dbcd 100644 --- a/components/lwp/lwp_syscall.c +++ b/components/lwp/lwp_syscall.c @@ -4478,8 +4478,9 @@ sysret_t sys_mkdir(const char *path, mode_t mode) sysret_t sys_rmdir(const char *path) { -#ifdef ARCH_MM_MMU int err = 0; + int ret = 0; +#ifdef ARCH_MM_MMU int len = 0; char *kpath = RT_NULL; @@ -4501,14 +4502,22 @@ sysret_t sys_rmdir(const char *path) return -EINVAL; } - err = rmdir(kpath); + ret = rmdir(kpath); + if(ret < 0) + { + err = GET_ERRNO(); + } kmem_put(kpath); - return (err < 0 ? GET_ERRNO() : err); + return (err < 0 ? err : ret); #else - int ret = rmdir(path); - return (ret < 0 ? GET_ERRNO() : ret); + ret = rmdir(path); + if(ret < 0) + { + err = GET_ERRNO(); + } + return (err < 0 ? err : ret); #endif }