From: Stefan Jumarea Date: Thu, 20 Apr 2023 10:29:49 +0000 (+0300) Subject: lib/vfscore: Fix error return on symlink syscall X-Git-Tag: RELEASE-0.13.0~158 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=51c1a7271b650e9a520bd6ee642b8139fd46abbe;p=unikraft%2Funikraft.git lib/vfscore: Fix error return on symlink syscall The `sys_symlink()` function returns `ENOENT` if the lookup failed, instead of the actual error code `lookup()` exited with. This may not always be right, since `lookup()` can return other error codes (for example `ELOOP`). Fix that by not setting the error code and just jump to the end of the function. Signed-off-by: Stefan Jumarea GitHub-Closes: #849 Reviewed-by: Andra Paraschiv Approved-by: Marc Rittinghaus Tested-by: Unikraft CI GitHub-Closes: #851 --- diff --git a/lib/vfscore/syscalls.c b/lib/vfscore/syscalls.c index 743a0ae90..45e74b8ff 100644 --- a/lib/vfscore/syscalls.c +++ b/lib/vfscore/syscalls.c @@ -883,10 +883,9 @@ sys_symlink(const char *oldpath, const char *newpath) } /* parent directory for new path must exist */ - if ((error = lookup(np, &newdirdp, &name)) != 0) { - error = ENOENT; + if ((error = lookup(np, &newdirdp, &name)) != 0) goto out; - } + vn_lock(newdirdp->d_vnode); /* newpath should not already exist */