diff --git a/kernel-src/arch/x86-64/syscall.asm b/kernel-src/arch/x86-64/syscall.asm index c80c4097..99ba7391 100644 --- a/kernel-src/arch/x86-64/syscall.asm +++ b/kernel-src/arch/x86-64/syscall.asm @@ -4,13 +4,15 @@ extern syscall_mmap extern syscall_openat extern syscall_read extern syscall_seek +extern syscall_close syscalltab: dq syscall_print dq syscall_mmap dq syscall_openat dq syscall_read dq syscall_seek -syscallcount equ 5 +dq syscall_close +syscallcount equ 6 section .text global arch_syscall_entry ; on entry: diff --git a/kernel-src/sys/syscalls/close.c b/kernel-src/sys/syscalls/close.c new file mode 100644 index 00000000..46505553 --- /dev/null +++ b/kernel-src/sys/syscalls/close.c @@ -0,0 +1,13 @@ +#include +#include + +syscallret_t syscall_close(context_t *context, int fd) { + syscallret_t ret = { + .ret = -1 + }; + + ret.errno = fd_close(fd); + ret.ret = 0; + + return ret; +} diff --git a/patches/mlibc/jinx-working-patch.patch b/patches/mlibc/jinx-working-patch.patch index 4235a9a0..e25f861d 100644 --- a/patches/mlibc/jinx-working-patch.patch +++ b/patches/mlibc/jinx-working-patch.patch @@ -113,10 +113,10 @@ index 0000000..e5b087a + diff --git mlibc-workdir/sysdeps/astral/generic/generic.cpp mlibc-workdir/sysdeps/astral/generic/generic.cpp new file mode 100644 -index 0000000..b92f59e +index 0000000..0f88fe5 --- /dev/null +++ mlibc-workdir/sysdeps/astral/generic/generic.cpp -@@ -0,0 +1,151 @@ +@@ -0,0 +1,152 @@ +#include +#include +#include @@ -244,7 +244,8 @@ index 0000000..b92f59e + } + + int sys_close(int fd) { -+ return ENOSYS; ++ long r; ++ return syscall(SYSCALL_CLOSE, &r, fd); + } + + int sys_vm_map(void *hint, size_t size, int prot, int flags, int fd, off_t offset, void **window) { @@ -287,10 +288,10 @@ index 0000000..990eca0 +#endif diff --git mlibc-workdir/sysdeps/astral/include/astral/syscall.h mlibc-workdir/sysdeps/astral/include/astral/syscall.h new file mode 100644 -index 0000000..1947f70 +index 0000000..bb2e40d --- /dev/null +++ mlibc-workdir/sysdeps/astral/include/astral/syscall.h -@@ -0,0 +1,28 @@ +@@ -0,0 +1,29 @@ +#ifndef _SYSCALL_H_INCLUDE +#define _SYSCALL_H_INCLUDE + @@ -299,6 +300,7 @@ index 0000000..1947f70 +#define SYSCALL_OPENAT 2 +#define SYSCALL_READ 3 +#define SYSCALL_SEEK 4 ++#define SYSCALL_CLOSE 5 + +#include +#include