summaryrefslogtreecommitdiff
path: root/src/kernel/syscalls.c
diff options
context:
space:
mode:
authordzwdz2021-09-07 19:37:38 +0200
committerdzwdz2021-09-07 19:37:38 +0200
commit2f48f3c88c11c802a1dfc9d803b1d9715cb95b33 (patch)
tree8331e0002a9e896bf6ee849ad2528d73ac5f8a99 /src/kernel/syscalls.c
parent844cd82f89e003a83d763402a6a20abc22252322 (diff)
reimplement _syscall_mount
Diffstat (limited to 'src/kernel/syscalls.c')
-rw-r--r--src/kernel/syscalls.c10
1 files changed, 4 insertions, 6 deletions
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;