summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/init/main.c3
-rw-r--r--src/kernel/syscalls.c8
2 files changed, 9 insertions, 2 deletions
diff --git a/src/init/main.c b/src/init/main.c
index 8e78b87..1a6162a 100644
--- a/src/init/main.c
+++ b/src/init/main.c
@@ -61,7 +61,8 @@ void fs_test(void) {
// parent: accesses the fs
log("\n\n");
- _syscall_mount(front, argify("/init"));
+ // the trailing slash should be ignored by mount()
+ _syscall_mount(front, argify("/init/"));
read_file(argify("/init/fake.txt"));
read_file(argify("/init/1.txt"));
read_file(argify("/init/2.txt"));
diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c
index af3e0aa..1b91eb7 100644
--- a/src/kernel/syscalls.c
+++ b/src/kernel/syscalls.c
@@ -103,7 +103,13 @@ int _syscall_mount(handle_t handle, const char __user *path, int len) {
goto fail;
len = path_simplify(path_buf, path_buf, len);
if (len < 0) goto fail;
- // TODO remove trailing slash
+
+ // remove trailing slash
+ // mounting something under `/this` and `/this/` should be equalivent
+ if (path_buf[len - 1] == '/') {
+ if (len == 0) goto fail;
+ len--;
+ }
if (handle >= 0) { // mounting a real backend?
if (handle >= HANDLE_MAX)