From 2f48f3c88c11c802a1dfc9d803b1d9715cb95b33 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Tue, 7 Sep 2021 19:37:38 +0200 Subject: reimplement _syscall_mount --- src/kernel/syscalls.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/kernel/syscalls.c') diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c index 5d792ce..d2217eb 100644 --- a/src/kernel/syscalls.c +++ b/src/kernel/syscalls.c @@ -104,10 +104,11 @@ handle_t _syscall_open(const user_ptr path, int len) { int _syscall_mount(handle_t handle, const user_ptr path, int len) { struct vfs_mount *mount = NULL; char *path_buf; - int res; if (len > PATH_MAX) return -1; if (handle < 0 || handle >= HANDLE_MAX) return -1; + if (process_current->handles[handle].type != HANDLE_FS_FRONT) + return -1; // copy the path to the kernel path_buf = kmalloc(len); @@ -125,11 +126,8 @@ int _syscall_mount(handle_t handle, const user_ptr path, int len) { mount->prev = process_current->mount; mount->prefix = path_buf; mount->prefix_len = len; - - res = -1; // TODO pass to filesystem - if (res < 0) goto fail; + mount->backend = process_current->handles[handle].fs.backend; process_current->mount = mount; - return 0; fail: kfree(path_buf); kfree(mount); @@ -179,7 +177,7 @@ handle_t _syscall_fs_create(user_ptr back_user) { NULL, (uintptr_t)&back, sizeof(handle_t))) goto fail; - backend = kmalloc(sizeof(struct vfs_backend)); + backend = kmalloc(sizeof(struct vfs_backend)); // TODO never freed backend->type = VFS_BACK_USER; process_current->handles[front].fs.backend = backend; process_current->handles[back ].fs.backend = backend; -- cgit v1.2.3