【修复】修复link系统调用返回值问题

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

View File

@ -1379,6 +1379,7 @@ int dfs_file_link(const char *oldname, const char *newname)
if (dfs_file_isdir(oldname) == 0)
{
rt_set_errno(-EPERM);
return ret;
}

View File

@ -5013,7 +5013,8 @@ ssize_t sys_readlink(char* path, char *buf, size_t bufsz)
err = dfs_file_readlink(copy_path, link_fn, DFS_PATH_MAX);
if (err > 0)
{
rtn = lwp_put_to_user(buf, link_fn, bufsz > err ? err : bufsz - 1);
buf[bufsz > err ? err : bufsz] = '\0';
rtn = lwp_put_to_user(buf, link_fn, bufsz > err ? err : bufsz);
}
else
{
@ -5855,7 +5856,7 @@ sysret_t sys_umount2(char *__special_file, int __flags)
sysret_t sys_link(const char *existing, const char *new)
{
int ret = -1;
int err = 0;
#ifdef RT_USING_DFS_V2
#ifdef ARCH_MM_MMU
int len = 0;
@ -5902,6 +5903,10 @@ sysret_t sys_link(const char *existing, const char *new)
}
ret = dfs_file_link(kexisting, knew);
if(ret < 0)
{
err = GET_ERRNO();
}
kmem_put(knew);
kmem_put(kexisting);
@ -5910,9 +5915,10 @@ sysret_t sys_link(const char *existing, const char *new)
#endif
#else
SET_ERRNO(EFAULT);
err = GET_ERRNO();
#endif
return (ret < 0 ? GET_ERRNO() : ret);
return (err < 0 ? err : ret);
}
sysret_t sys_symlink(const char *existing, const char *new)