【修复】修复rmdir系统调用返回值不符合用户预期问题

This commit is contained in:
zhuzhuzhu 2024-08-25 22:57:15 +08:00 committed by GitHub
parent d9fac09f71
commit dc232080a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 8 deletions

View File

@ -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;
}
}

View File

@ -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
}