projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
use libc-internal malloc for pthread_atfork
[musl]
/
src
/
fcntl
/
open.c
diff --git
a/src/fcntl/open.c
b/src/fcntl/open.c
index
be44208
..
4c3c827
100644
(file)
--- a/
src/fcntl/open.c
+++ b/
src/fcntl/open.c
@@
-1,16
+1,21
@@
#include <fcntl.h>
#include <stdarg.h>
#include "syscall.h"
#include <fcntl.h>
#include <stdarg.h>
#include "syscall.h"
-#include "libc.h"
int open(const char *filename, int flags, ...)
{
int open(const char *filename, int flags, ...)
{
- mode_t mode;
- va_list ap;
- va_start(ap, flags);
- mode = va_arg(ap, mode_t);
- va_end(ap);
- return syscall_cp(SYS_open, filename, flags|O_LARGEFILE, mode);
-}
+ mode_t mode = 0;
+
+ if ((flags & O_CREAT) || (flags & O_TMPFILE) == O_TMPFILE) {
+ va_list ap;
+ va_start(ap, flags);
+ mode = va_arg(ap, mode_t);
+ va_end(ap);
+ }
-LFS64(open);
+ int fd = __sys_open_cp(filename, flags, mode);
+ if (fd>=0 && (flags & O_CLOEXEC))
+ __syscall(SYS_fcntl, fd, F_SETFD, FD_CLOEXEC);
+
+ return __syscall_ret(fd);
+}