diff options
author | dzwdz | 2021-09-07 19:37:38 +0200 |
---|---|---|
committer | dzwdz | 2021-09-07 19:37:38 +0200 |
commit | 2f48f3c88c11c802a1dfc9d803b1d9715cb95b33 (patch) | |
tree | 8331e0002a9e896bf6ee849ad2528d73ac5f8a99 | |
parent | 844cd82f89e003a83d763402a6a20abc22252322 (diff) |
reimplement _syscall_mount
-rw-r--r-- | src/init/main.c | 4 | ||||
-rw-r--r-- | src/kernel/syscalls.c | 10 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/init/main.c b/src/init/main.c index deacb15..41f51d3 100644 --- a/src/init/main.c +++ b/src/init/main.c @@ -28,8 +28,10 @@ int main(void) { } void fs_test(void) { - handle_t front, back; + handle_t front, back, file; front = _syscall_fs_create((void*)&back); // TODO change user_ptr to void* + _syscall_mount(front, argify("/mnt")); + file = _syscall_open(argify("/mnt/test")); } void misc_tests(void) { 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; |