From 206ca77636cca94d14d7486a7a0e2679bf107a28 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Thu, 16 Sep 2021 06:33:26 +0000 Subject: fs_read stub, basic implementation in userland --- src/kernel/syscalls.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/kernel/syscalls.c') 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) { -- cgit v1.2.3