From 5abfbff30588e70efb5fc414f32b4bbda333f3f8 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Mon, 2 May 2022 18:08:54 +0200 Subject: kernel/syscall: implement _syscall_close() --- src/kernel/syscalls.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/kernel') diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c index 285ce58..ffacdbc 100644 --- a/src/kernel/syscalls.c +++ b/src/kernel/syscalls.c @@ -155,9 +155,13 @@ int _syscall_write(handle_t handle_num, const void __user *buf, size_t len, int }); } -int _syscall_close(handle_t handle) { - if (handle < 0 || handle >= HANDLE_MAX) return -1; - return -1; +int _syscall_close(handle_t hid) { + if (hid < 0 || hid >= HANDLE_MAX) return -1; + struct handle **h = &process_current->handles[hid]; + if (!*h) return -1; + handle_close(*h); + *h = NULL; + return 0; } handle_t _syscall_fs_fork2(void) { -- cgit v1.2.3