From a26876079cb155b013461aa525276b9cc8598ccf Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sat, 18 Sep 2021 12:23:08 +0200 Subject: implement NULL mounts --- src/kernel/syscalls.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/kernel/syscalls.c') diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c index 1bc9694..57774c2 100644 --- a/src/kernel/syscalls.c +++ b/src/kernel/syscalls.c @@ -104,12 +104,10 @@ fail: int _syscall_mount(handle_t handle, const char __user *path, int len) { struct vfs_mount *mount = NULL; - char *path_buf; + struct vfs_backend *backend = NULL; + char *path_buf = NULL; 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); @@ -121,6 +119,14 @@ int _syscall_mount(handle_t handle, const char __user *path, int len) { if (len < 0) goto fail; // TODO remove trailing slash + if (handle >= 0) { // mounting a real backend + if (handle >= HANDLE_MAX) + goto fail; + if (process_current->handles[handle].type != HANDLE_FS_FRONT) + goto fail; + backend = process_current->handles[handle].fs.backend; + } // otherwise backend == NULL + // append to mount list mount = kmalloc(sizeof *mount); mount->prev = process_current->mount; @@ -128,6 +134,8 @@ int _syscall_mount(handle_t handle, const char __user *path, int len) { mount->prefix_len = len; mount->backend = process_current->handles[handle].fs.backend; process_current->mount = mount; + return 0; + fail: kfree(path_buf); kfree(mount); -- cgit v1.2.3