]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
lib/vfscore: Fix file path resolution for 9pfs setup
authorAndra Paraschiv <andra@unikraft.org>
Wed, 10 May 2023 10:40:27 +0000 (13:40 +0300)
committerUnikraft <monkey@unikraft.io>
Thu, 11 May 2023 08:21:08 +0000 (08:21 +0000)
The path resolution doesn't correctly work for a set of file cases
(e.g. symlinks to binaries or shared libraries).

One setup example is using 9pfs and the entire root local filesystem,
while running the "ls" binary and loading the shared libraries:

unikraft/support/scripts/qemu-guest -k build/app-elfloader_qemu-x86_64
-e / -a "/bin/ls /"

A "/" character is omitted from the last part of the path e.g. "/binls"
instead of "/bin/ls". Update the logic to include the missing character.

Signed-off-by: Andra Paraschiv <andra@unikraft.org>
Reviewed-by: Florin Postolache <florin.postolache.of@gmail.com>
Reviewed-by: Ioan-Teodor Teugea <ioan_teodor.teugea@stud.acs.upb.ro>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #883

lib/vfscore/lookup.c

index 941da8fedc74c0e14c17076ffd5fe9c1315b24bf..4e86f608ded298f2017da2c94927ccb2d3ada1a2 100644 (file)
@@ -78,7 +78,7 @@ namei_follow_link(struct dentry *dp, char *node, char *name, char *fp, size_t mo
        }
        link[sz] = 0;
 
-       p = fp + mountpoint_len + strlen(node);
+       p = fp + mountpoint_len + strlen(node) - 1;
        c = strlen(node) - strlen(name) - 1;
        node[c] = 0;