summaryrefslogtreecommitdiffstats
path: root/usr/klibc/open.c
blob: 5305c3d2d9b8c15ff9990c33d93ae848509870fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
 * open.c
 *
 * On 32-bit platforms we need to pass O_LARGEFILE to the open()
 * system call, to indicate that we're 64-bit safe.
 *
 * For 64 bit systems without the open syscall, pass straight
 * through into openat.
 */

#define _KLIBC_IN_OPEN_C
#include <unistd.h>
#include <fcntl.h>
#include <bitsize.h>
#include <sys/syscall.h>

#ifndef __NR_open
#if _BITSIZE == 32

extern int __openat(int, const char *, int, mode_t);

int open(const char *pathname, int flags, mode_t mode)
{
	return __openat(AT_FDCWD, pathname, flags | O_LARGEFILE, mode);
}

#else

__extern int openat(int, const char *, int, ...);

int open(const char *pathname, int flags, mode_t mode)
{
	return openat(AT_FDCWD, pathname, flags, mode);
}

#endif /* _BITSIZE == 32 */

#elif _BITSIZE == 32 && !defined(__i386__) && !defined(__m68k__)

extern int __open(const char *, int, mode_t);

int open(const char *pathname, int flags, mode_t mode)
{
	return __open(pathname, flags | O_LARGEFILE, mode);
}

#endif /* __NR_open */