summaryrefslogtreecommitdiff
path: root/src/fcntl/open.c
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-02-09 13:14:01 -0500
committerJakob Kaivo <jkk@ung.org>2019-02-09 13:14:01 -0500
commit253a32e2f9ff1cbb8edbe7c79834a678daebeb93 (patch)
tree599cf5baf01c6dae33a2f89989b08b7d553f7fd0 /src/fcntl/open.c
parent88d0b5e7ffbf0554b236dc46225846061b5f4817 (diff)
merge POSIX.1-1988/1990
Diffstat (limited to 'src/fcntl/open.c')
-rw-r--r--src/fcntl/open.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/fcntl/open.c b/src/fcntl/open.c
new file mode 100644
index 00000000..f0968556
--- /dev/null
+++ b/src/fcntl/open.c
@@ -0,0 +1,30 @@
+#include "sys/types.h"
+#include <fcntl.h>
+#include "sys/stat.h" /* OH */
+#include "errno.h"
+#include "stdarg.h"
+#include "nonstd/syscall.h"
+
+int open(const char *path, int oflag, ...)
+{
+ SCNO(scno, "open", -1);
+
+ mode_t mode = 0;
+ if (oflag & O_CREAT) {
+ va_list ap;
+ va_start(ap, oflag);
+ mode = va_arg(ap, mode_t);
+ va_end(ap);
+ }
+
+ int r = __libc.syscall(scno, path, oflag, mode);
+ if (r < 0) {
+ errno = -r;
+ return -1;
+ }
+
+ return r;
+}
+/*
+POSIX(1)
+*/