summaryrefslogtreecommitdiffstats
path: root/usr/klibc/openat.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/klibc/openat.c')
-rw-r--r--usr/klibc/openat.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/usr/klibc/openat.c b/usr/klibc/openat.c
new file mode 100644
index 0000000..8e5baa0
--- /dev/null
+++ b/usr/klibc/openat.c
@@ -0,0 +1,22 @@
+/*
+ * openat.c
+ *
+ * On 32-bit platforms we need to pass O_LARGEFILE to the openat()
+ * system call, to indicate that we're 64-bit safe.
+ */
+
+#define _KLIBC_IN_OPEN_C
+#include <unistd.h>
+#include <fcntl.h>
+#include <bitsize.h>
+
+#if _BITSIZE == 32 && !defined(__i386__) && !defined(__m68k__) && defined(__NR_openat)
+
+extern int __openat(int, const char *, int, mode_t);
+
+int openat(int dirfd, const char *pathname, int flags, mode_t mode)
+{
+ return __openat(dirfd, pathname, flags | O_LARGEFILE, mode);
+}
+
+#endif