diff options
Diffstat (limited to 'src/kernel')
-rw-r--r-- | src/kernel/syscalls.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c index 48e67db..d39aed9 100644 --- a/src/kernel/syscalls.c +++ b/src/kernel/syscalls.c @@ -135,9 +135,20 @@ fail: return -1; } -int _syscall_read(handle_t handle, char __user *buf, int len) { - if (handle < 0 || handle >= HANDLE_MAX) return -1; - return -1; +int _syscall_read(handle_t handle_num, 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; + return vfs_request_create((struct vfs_request) { + .type = VFSOP_READ, + .output = { + .buf = (userptr_t) buf, + .len = len, + }, + .id = handle->file.id, + .caller = process_current, + .backend = handle->file.backend, + }); } int _syscall_write(handle_t handle_num, const char __user *buf, int len) { |