From 42ad59bdb6df99ccd146d6d67cb8c838be709ec5 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Tue, 26 Mar 2024 18:25:07 -0400 Subject: kernel: Add sys_close() Signed-off-by: Ian Moffett --- sys/kern/kern_filedesc.c | 10 ++++++++++ sys/kern/kern_syscall.c | 1 + 2 files changed, 11 insertions(+) (limited to 'sys/kern') diff --git a/sys/kern/kern_filedesc.c b/sys/kern/kern_filedesc.c index c429125..6f59508 100644 --- a/sys/kern/kern_filedesc.c +++ b/sys/kern/kern_filedesc.c @@ -330,3 +330,13 @@ sys_open(struct syscall_args *args) dynfree(pathbuf); return ret; } + +/* + * arg0: fd + */ +uint64_t +sys_close(struct syscall_args *args) +{ + fd_close_fdnum(this_td(), args->arg0); + return 0; +} diff --git a/sys/kern/kern_syscall.c b/sys/kern/kern_syscall.c index dc37274..4acfdc5 100644 --- a/sys/kern/kern_syscall.c +++ b/sys/kern/kern_syscall.c @@ -44,4 +44,5 @@ uint64_t(*g_syscall_table[__MAX_SYSCALLS])(struct syscall_args *args) = { sys_exit, sys_write, sys_open, + sys_close, }; -- cgit v1.2.3