From a5bd09d5a995400c4f4ec1270e1ad380d238783c Mon Sep 17 00:00:00 2001 From: dzwdz Date: Fri, 27 Aug 2021 19:36:37 +0200 Subject: make vfs_mount_resolve pass all the tests --- src/kernel/vfs/mount.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/kernel/vfs/mount.c') diff --git a/src/kernel/vfs/mount.c b/src/kernel/vfs/mount.c index bf98957..bd06370 100644 --- a/src/kernel/vfs/mount.c +++ b/src/kernel/vfs/mount.c @@ -21,7 +21,16 @@ struct vfs_mount *vfs_mount_resolve( for (; top; top = top->prev) { if (top->prefix_len > path_len) continue; - if (memcmp(top->prefix, path, top->prefix_len) == 0) + if (memcmp(top->prefix, path, top->prefix_len) != 0) + continue; + + /* ensure that there's no garbage after the match + * recognize that e.g. /thisasdf doesn't get recognized as mounted under + * /this */ + + if (top->prefix_len == path_len) // can't happen if prefix == path + break; + if (path[top->prefix_len] == '/') break; } return top; -- cgit v1.2.3