From fc00c656c96528112d05cf0edf8631bd5eaea446 Mon Sep 17 00:00:00 2001 From: Kacper Date: Sun, 7 Dec 2025 20:10:31 +0100 Subject: Add build system scaffolding and libc headers --- lib/libc/fcntl/open.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 lib/libc/fcntl/open.c (limited to 'lib/libc/fcntl/open.c') diff --git a/lib/libc/fcntl/open.c b/lib/libc/fcntl/open.c new file mode 100644 index 00000000..dbdff8f9 --- /dev/null +++ b/lib/libc/fcntl/open.c @@ -0,0 +1,23 @@ +#include +#include +#include + +int open(const char *path, int oflag, ...) +{ + long ret; + mode_t mode = 0; + + if ((oflag & O_CREAT)) { + va_list ap; + va_start(ap, oflag); + mode = va_arg(ap, mode_t); + va_end(ap); + } + + ret = syscall(open, path, oflag, mode); + + if (ret >= 0 && (oflag & O_CLOEXEC)) + return syscall(fcntl, ret, F_SETFD, FD_CLOEXEC); + + return ret; +} -- cgit v1.2.3