diff options
Diffstat (limited to 'src/kernel')
-rw-r--r-- | src/kernel/syscalls.c | 6 | ||||
-rw-r--r-- | src/kernel/vfs/request.c | 10 | ||||
-rw-r--r-- | src/kernel/vfs/request.h | 6 |
3 files changed, 11 insertions, 11 deletions
diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c index b247619..18ecd25 100644 --- a/src/kernel/syscalls.c +++ b/src/kernel/syscalls.c @@ -87,7 +87,7 @@ handle_t _syscall_open(const char __user *path, int len) { mount = vfs_mount_resolve(process_current->mount, path_buf, len); if (!mount) goto fail; - vfs_request_create((struct vfs_request) { + return vfs_request_create((struct vfs_request) { .type = VFSOP_OPEN, .input = { .kern = true, @@ -97,7 +97,6 @@ handle_t _syscall_open(const char __user *path, int len) { .caller = process_current, .backend = mount->backend, }); - // doesn't return / fallthrough to fail fail: kfree(path_buf); @@ -145,7 +144,7 @@ int _syscall_write(handle_t handle_num, const char __user *buf, int len) { struct handle *handle = &process_current->handles[handle_num]; if (handle_num < 0 || handle_num >= HANDLE_MAX) return -1; if (handle->type != HANDLE_FILE) return -1; - vfs_request_create((struct vfs_request) { + return vfs_request_create((struct vfs_request) { .type = VFSOP_WRITE, .input = { .buf = (userptr_t) buf, @@ -155,7 +154,6 @@ int _syscall_write(handle_t handle_num, const char __user *buf, int len) { .caller = process_current, .backend = handle->file.backend, }); - return -1; } int _syscall_close(handle_t handle) { diff --git a/src/kernel/vfs/request.c b/src/kernel/vfs/request.c index a8f2fc0..9f0a14f 100644 --- a/src/kernel/vfs/request.c +++ b/src/kernel/vfs/request.c @@ -6,7 +6,7 @@ #include <kernel/vfs/root.h> // dispatches a VFS operation to the correct process -_Noreturn void vfs_request_create(struct vfs_request req_) { +int vfs_request_create(struct vfs_request req_) { struct vfs_request *req; int ret; process_current->state = PS_WAITS4FS; @@ -18,7 +18,8 @@ _Noreturn void vfs_request_create(struct vfs_request req_) { switch (req->backend->type) { case VFS_BACK_ROOT: ret = vfs_root_handler(req); - vfs_request_finish(req, ret); + ret = vfs_request_finish(req, ret); + return ret; case VFS_BACK_USER: if (req->backend->handler == NULL) { // backend isn't ready yet, join the queue @@ -69,8 +70,7 @@ fail: panic(); // TODO } -// returns from a VFS operation to the calling process -_Noreturn void vfs_request_finish(struct vfs_request *req, int ret) { +int vfs_request_finish(struct vfs_request *req, int ret) { struct process *caller = req->caller; if (req->type == VFSOP_OPEN && ret >= 0) { @@ -95,5 +95,5 @@ _Noreturn void vfs_request_finish(struct vfs_request *req, int ret) { req->caller->state = PS_RUNNING; regs_savereturn(&req->caller->regs, ret); kfree(req); - process_switch(caller); + return ret; } diff --git a/src/kernel/vfs/request.h b/src/kernel/vfs/request.h index 52af544..8f5cf92 100644 --- a/src/kernel/vfs/request.h +++ b/src/kernel/vfs/request.h @@ -45,6 +45,8 @@ struct vfs_request { struct vfs_backend *backend; }; -_Noreturn void vfs_request_create(struct vfs_request); +/** Assigns the vfs_request to the caller, and calls the backend. Might not + * return - can switch processes! */ +int vfs_request_create(struct vfs_request); _Noreturn void vfs_request_pass2handler(struct vfs_request *); -_Noreturn void vfs_request_finish(struct vfs_request *, int ret); +int vfs_request_finish(struct vfs_request *, int ret); |