X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Ffcntl%2Fopen.c;h=3928a6e6696f05106e81bfd70a84210ce431e62a;hb=15094943050eb9a564f409323070e50b40f78816;hp=064d298c01bcd15cb461d6543282b9563b241f6f;hpb=aa398f56fa398f2202b04e82c67f822f3233786f;p=musl diff --git a/src/fcntl/open.c b/src/fcntl/open.c index 064d298c..3928a6e6 100644 --- a/src/fcntl/open.c +++ b/src/fcntl/open.c @@ -1,21 +1,24 @@ #include -#include #include #include "syscall.h" #include "libc.h" int open(const char *filename, int flags, ...) { - int r; - mode_t mode; - va_list ap; - va_start(ap, flags); - mode = va_arg(ap, mode_t); - va_end(ap); - CANCELPT_BEGIN; - r = syscall(SYS_open, filename, flags|O_LARGEFILE, mode); - CANCELPT_END; - return r; + 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); + } + + 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); } LFS64(open);