diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/init/main.c | 2 | ||||
-rw-r--r-- | src/kernel/tests/vfs.c | 8 | ||||
-rw-r--r-- | src/kernel/vfs/mount.c | 11 |
3 files changed, 14 insertions, 7 deletions
diff --git a/src/init/main.c b/src/init/main.c index 413cdad..71732cd 100644 --- a/src/init/main.c +++ b/src/init/main.c @@ -15,8 +15,6 @@ const char *multipageify(const char *str); #define mount(fd, path) _syscall_fd_mount(fd, path, sizeof(path)-1) int main(void) { - // TODO don't dispatch /ttywhatever to the tty driver - tty_fd = _syscall_fs_open("/tty", sizeof("/tty") - 1); if (tty_fd < 0) _syscall_exit(argify("couldn't open tty")); diff --git a/src/kernel/tests/vfs.c b/src/kernel/tests/vfs.c index cfbf86b..0871f92 100644 --- a/src/kernel/tests/vfs.c +++ b/src/kernel/tests/vfs.c @@ -70,7 +70,7 @@ TEST(vfs_mount_resolve) { mount = mount2; \ } while (0) - ADD_MOUNT("/"); + ADD_MOUNT(""); // root mount ADD_MOUNT("/dir/shadowed"); ADD_MOUNT("/dir"); @@ -82,10 +82,10 @@ TEST(vfs_mount_resolve) { && (0 == memcmp(mount2->prefix, expected, mount2->prefix_len))); \ } while (0) - TEST_WRAPPER("/", "/"); - TEST_WRAPPER("/test", "/"); + TEST_WRAPPER("/", ""); + TEST_WRAPPER("/test", ""); TEST_WRAPPER("/dir", "/dir"); - TEST_WRAPPER("/dirry", "/"); + TEST_WRAPPER("/dirry", ""); TEST_WRAPPER("/dir/", "/dir"); TEST_WRAPPER("/dir/shadowed", "/dir"); TEST_WRAPPER("/dir/shadowed/", "/dir"); 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; |