From 521e2bcedb8eb5d13f4c527275c81d3a0f31f2b6 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Wed, 22 Sep 2021 20:20:09 +0200 Subject: _syscall_open: strip the mount prefix in a better way --- src/kernel/syscalls.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c index 16238e7..af3e0aa 100644 --- a/src/kernel/syscalls.c +++ b/src/kernel/syscalls.c @@ -68,12 +68,19 @@ handle_t _syscall_open(const char __user *path, int len) { mount = vfs_mount_resolve(process_current->mount, path_buf, len); if (!mount) goto fail; + if (mount->prefix_len > 0) { // strip prefix + len -= mount->prefix_len; + // i can't just adjust path_buf, because it needs to be passed to free() + // later on + memcpy(path_buf, path_buf + mount->prefix_len, len); + } + return vfs_request_create((struct vfs_request) { .type = VFSOP_OPEN, .input = { .kern = true, - .buf_kern = &path_buf[mount->prefix_len], // TODO this is unfreeable - .len = len - mount->prefix_len, + .buf_kern = path_buf, + .len = len, }, .caller = process_current, .backend = mount->backend, -- cgit v1.2.3