]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
lib/vfscore: Fix error return on symlink syscall
authorStefan Jumarea <stefanjumarea02@gmail.com>
Thu, 20 Apr 2023 10:29:49 +0000 (13:29 +0300)
committerUnikraft <monkey@unikraft.io>
Tue, 25 Apr 2023 10:34:43 +0000 (10:34 +0000)
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 <stefanjumarea02@gmail.com>
GitHub-Closes: #849
Reviewed-by: Andra Paraschiv <andra@unikraft.io>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #851

lib/vfscore/syscalls.c

index 743a0ae90a8aaf22837dcd9bbac640384b933df0..45e74b8ff683c9e85aa6e8278a14814e6873b64f 100644 (file)
@@ -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 */