summaryrefslogtreecommitdiff
path: root/src/kernel
diff options
context:
space:
mode:
authordzwdz2021-09-22 20:20:09 +0200
committerdzwdz2021-09-22 20:20:09 +0200
commit521e2bcedb8eb5d13f4c527275c81d3a0f31f2b6 (patch)
tree7c7b022c162af81f268af44e41560eb1e1b6e557 /src/kernel
parent67bb45ec35874a6a5580fe8fbc73484837255076 (diff)
_syscall_open: strip the mount prefix in a better way
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/syscalls.c11
1 files 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,