From 93af95b3419edfc127c6ea4245753540190c520e Mon Sep 17 00:00:00 2001 From: dzwdz Date: Mon, 11 Jul 2022 22:21:57 +0200 Subject: user: add shorthand close() and fork() wrappers for those syscalls --- src/user/lib/stdlib.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/user/lib/stdlib.c') diff --git a/src/user/lib/stdlib.c b/src/user/lib/stdlib.c index c055d04..32b4f06 100644 --- a/src/user/lib/stdlib.c +++ b/src/user/lib/stdlib.c @@ -62,7 +62,7 @@ libc_file *file_open(const char *path, int flags) { f = malloc(sizeof *f); if (!f) { - _syscall_close(h); + close(h); return NULL; } f->pos = 0; @@ -114,7 +114,16 @@ int file_write(libc_file *f, const char *buf, size_t len) { } void file_close(libc_file *f) { - if (f->fd > 0) _syscall_close(f->fd); + if (f->fd > 0) close(f->fd); if (f != &_stdin_null && f != &_stdout_null) free(f); } + + +int fork(void) { + return _syscall_fork(0, NULL); +} + +int close(handle_t h) { + return _syscall_close(h); +} -- cgit v1.2.3