yuezonghe | 824eb0c | 2024-06-27 02:32:26 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org> |
| 3 | * |
| 4 | * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. |
| 5 | */ |
| 6 | |
| 7 | #include <features.h> |
| 8 | #include <fcntl.h> |
| 9 | #include <stdarg.h> |
| 10 | #ifdef __UCLIBC_HAS_THREADS_NATIVE__ |
| 11 | #include <errno.h> |
| 12 | #include <sysdep-cancel.h> |
| 13 | #endif |
| 14 | |
| 15 | #ifdef __UCLIBC_HAS_LFS__ |
| 16 | |
| 17 | #ifndef O_LARGEFILE |
| 18 | # define O_LARGEFILE 0100000 |
| 19 | #endif |
| 20 | |
| 21 | /* Open FILE with access OFLAG. If OFLAG includes O_CREAT, |
| 22 | a third argument is the file protection. */ |
| 23 | int open64 (const char *file, int oflag, ...) |
| 24 | { |
| 25 | mode_t mode = 0; |
| 26 | |
| 27 | if (oflag & O_CREAT) |
| 28 | { |
| 29 | va_list arg; |
| 30 | va_start (arg, oflag); |
| 31 | mode = va_arg (arg, mode_t); |
| 32 | va_end (arg); |
| 33 | } |
| 34 | |
| 35 | #ifdef __UCLIBC_HAS_THREADS_NATIVE__ |
| 36 | if (SINGLE_THREAD_P) |
| 37 | return INLINE_SYSCALL (open, 3, file, oflag | O_LARGEFILE, mode); |
| 38 | |
| 39 | int oldtype = LIBC_CANCEL_ASYNC (); |
| 40 | |
| 41 | int result = INLINE_SYSCALL (open, 3, file, oflag | O_LARGEFILE, mode); |
| 42 | |
| 43 | LIBC_CANCEL_RESET (oldtype); |
| 44 | |
| 45 | return result; |
| 46 | #else |
| 47 | return open(file, oflag | O_LARGEFILE, mode); |
| 48 | #endif |
| 49 | } |
| 50 | #ifndef __LINUXTHREADS_OLD__ |
| 51 | libc_hidden_def(open64) |
| 52 | #else |
| 53 | libc_hidden_weak(open64) |
| 54 | strong_alias(open64,__libc_open64) |
| 55 | #endif |
| 56 | |
| 57 | #endif /* __UCLIBC_HAS_LFS__ */ |