Fix pathconf statvfs namespace (bug 18507).
[glibc.git] / sysdeps / unix / sysv / linux / openat.c
blob677712330e8a01fc39c873b11a07224e5e73ee14
1 /* Copyright (C) 2005-2015 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
18 #include <errno.h>
19 #include <fcntl.h>
20 #include <stdarg.h>
21 #include <stddef.h>
22 #include <stdio.h>
23 #include <string.h>
24 #include <sys/stat.h>
25 #include <sysdep-cancel.h>
26 #include <not-cancel.h>
29 #ifndef OPENAT
30 # define OPENAT openat
31 #endif
34 #define OPENAT_NOT_CANCEL CONCAT (OPENAT)
35 #define CONCAT(name) CONCAT2 (name)
36 #define CONCAT2(name) __##name##_nocancel
39 int
40 OPENAT_NOT_CANCEL (int fd, const char *file, int oflag, mode_t mode)
43 /* We have to add the O_LARGEFILE flag for openat64. */
44 #ifdef MORE_OFLAGS
45 oflag |= MORE_OFLAGS;
46 #endif
48 return INLINE_SYSCALL (openat, 4, fd, file, oflag, mode);
51 #define UNDERIZE(name) UNDERIZE_1 (name)
52 #define UNDERIZE_1(name) __##name
53 #define __OPENAT UNDERIZE (OPENAT)
56 /* Open FILE with access OFLAG. Interpret relative paths relative to
57 the directory associated with FD. If OFLAG includes O_CREAT or
58 O_TMPFILE, a fourth argument is the file protection. */
59 int
60 __OPENAT (int fd, const char *file, int oflag, ...)
62 mode_t mode = 0;
63 if (__OPEN_NEEDS_MODE (oflag))
65 va_list arg;
66 va_start (arg, oflag);
67 mode = va_arg (arg, mode_t);
68 va_end (arg);
71 return SYSCALL_CANCEL (openat, fd, file, oflag, mode);
73 libc_hidden_def (__OPENAT)
74 weak_alias (__OPENAT, OPENAT)