diff options
author | Anton Kling <anton@kling.gg> | 2023-11-20 00:42:11 +0100 |
---|---|---|
committer | Anton Kling <anton@kling.gg> | 2023-11-20 00:42:11 +0100 |
commit | c7e384a6357db8bcd0d02d6fa9a9f549d8b40fd3 (patch) | |
tree | c83e0030ebaee2bba194b2ac599cdf0cc9eac60e /userland | |
parent | b353808b13db85abbbc0c3331c04c778620ed017 (diff) |
LibC: Allow open to accept multiple arguments
Diffstat (limited to 'userland')
-rw-r--r-- | userland/libc/include/fcntl.h | 3 | ||||
-rw-r--r-- | userland/libc/libc.c | 11 |
2 files changed, 12 insertions, 2 deletions
diff --git a/userland/libc/include/fcntl.h b/userland/libc/include/fcntl.h index 7f0906d..29134be 100644 --- a/userland/libc/include/fcntl.h +++ b/userland/libc/include/fcntl.h @@ -4,9 +4,10 @@ #define O_WRITE (1 << 2) #define O_CREAT (1 << 3) #define O_TRUNC (1 << 4) +#define O_APPEND (1 << 5) #define O_RDONLY O_READ #define O_WRONLY O_WRITE #define O_RDWR (O_WRITE | O_READ) -int open(const char *file, int flags, int mode); +int open(const char *file, int flags, ...); diff --git a/userland/libc/libc.c b/userland/libc/libc.c index e2f064d..dafd502 100644 --- a/userland/libc/libc.c +++ b/userland/libc/libc.c @@ -1,5 +1,6 @@ #include <assert.h> #include <errno.h> +#include <fcntl.h> #include <stdio.h> #include <string.h> #include <syscall.h> @@ -181,7 +182,15 @@ void perror(const char *s) { printf("%s\n", strerror(errno)); } -int open(const char *file, int flags, int mode) { +int open(const char *file, int flags, ...) { + mode_t mode = 0; + + if (flags & O_CREAT) { + va_list ap; + va_start(ap, flags); + mode = va_arg(ap, mode_t); + va_end(ap); + } struct SYS_OPEN_PARAMS args = { .file = file, .flags = flags, |