summaryrefslogtreecommitdiff
path: root/src/kernel/syscalls.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/syscalls.c')
-rw-r--r--src/kernel/syscalls.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c
index 8f520ab..4718b4b 100644
--- a/src/kernel/syscalls.c
+++ b/src/kernel/syscalls.c
@@ -141,8 +141,18 @@ int _syscall_fd_read(handle_t handle, user_ptr buf, int len) {
return -1;
}
-int _syscall_fd_write(handle_t handle, user_ptr buf, int len) {
- if (handle < 0 || handle >= HANDLE_MAX) return -1;
+int _syscall_fd_write(handle_t handle_num, user_ptr 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_backend_dispatch(handle->file.backend, (struct vfs_op) {
+ .type = VFSOP_WRITE,
+ .rw = {
+ .buf = buf,
+ .buf_len = len,
+ .id = handle->file.id,
+ }
+ });
return -1;
}