From c4c227e36762edd16d58439816e21c2eabd84da7 Mon Sep 17 00:00:00 2001 From: zhuzhuzhu <945386260@qq.com> Date: Sun, 25 Aug 2024 22:56:03 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E5=A4=8D=E3=80=91=E4=BF=AE?= =?UTF-8?q?=E5=A4=8Dsymlink=E7=B3=BB=E7=BB=9F=E8=B0=83=E7=94=A8=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E5=80=BC=E4=B8=8D=E6=98=AF=E9=A2=84=E6=9C=9F=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/dfs/dfs_v2/src/dfs_file.c | 4 ++++ components/lwp/lwp_syscall.c | 17 ++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/components/dfs/dfs_v2/src/dfs_file.c b/components/dfs/dfs_v2/src/dfs_file.c index 53e110ef59..1f98d5ceab 100644 --- a/components/dfs/dfs_v2/src/dfs_file.c +++ b/components/dfs/dfs_v2/src/dfs_file.c @@ -1567,6 +1567,10 @@ int dfs_file_symlink(const char *target, const char *linkpath) rt_free(parent); } } + else + { + rt_set_errno(-EPERM); + } if (fullpath != linkpath) rt_free(fullpath); diff --git a/components/lwp/lwp_syscall.c b/components/lwp/lwp_syscall.c index bbb0573c5c..077f6d86af 100644 --- a/components/lwp/lwp_syscall.c +++ b/components/lwp/lwp_syscall.c @@ -5909,28 +5909,31 @@ sysret_t sys_link(const char *existing, const char *new) sysret_t sys_symlink(const char *existing, const char *new) { int ret = -1; - + int err = 0 ; #ifdef ARCH_MM_MMU - int err; - err = lwp_user_strlen(existing); - if (err <= 0) + ret = lwp_user_strlen(existing); + if (ret <= 0) { return -EFAULT; } - err = lwp_user_strlen(new); - if (err <= 0) + ret = lwp_user_strlen(new); + if (ret <= 0) { return -EFAULT; } #endif #ifdef RT_USING_DFS_V2 ret = dfs_file_symlink(existing, new); + if(ret < 0) + { + err = GET_ERRNO(); + } #else SET_ERRNO(EFAULT); #endif - return (ret < 0 ? GET_ERRNO() : ret); + return (err < 0 ? err : ret); } sysret_t sys_eventfd2(unsigned int count, int flags)