Updated Serbian translations for gold, gprof and opcodes sub-directories
[binutils-gdb.git] / gnulib / import / openat.h
blob56919ef8dc47fc16f8df12bc2b75d7e45b7d0b89
1 /* provide a replacement openat function
2 Copyright (C) 2004-2006, 2008-2022 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program 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
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* written by Jim Meyering */
19 #ifndef _GL_HEADER_OPENAT
20 #define _GL_HEADER_OPENAT
22 #include <fcntl.h>
24 #include <sys/types.h>
25 #include <sys/stat.h>
26 #include <unistd.h>
27 #include <stdbool.h>
29 #ifndef _GL_INLINE_HEADER_BEGIN
30 #error "Please include config.h first."
31 #endif
32 _GL_INLINE_HEADER_BEGIN
34 #if !HAVE_OPENAT
36 int openat_permissive (int fd, char const *file, int flags, mode_t mode,
37 int *cwd_errno);
38 bool openat_needs_fchdir (void);
40 #else
42 # define openat_permissive(Fd, File, Flags, Mode, Cwd_errno) \
43 openat (Fd, File, Flags, Mode)
44 # define openat_needs_fchdir() false
46 #endif
48 _Noreturn void openat_restore_fail (int);
49 _Noreturn void openat_save_fail (int);
51 /* Using these function names makes application code
52 slightly more readable than it would be with
53 fchownat (..., 0) or fchownat (..., AT_SYMLINK_NOFOLLOW). */
55 #if GNULIB_CHOWNAT
57 # ifndef CHOWNAT_INLINE
58 # define CHOWNAT_INLINE _GL_INLINE
59 # endif
61 CHOWNAT_INLINE int
62 chownat (int fd, char const *file, uid_t owner, gid_t group)
64 return fchownat (fd, file, owner, group, 0);
67 CHOWNAT_INLINE int
68 lchownat (int fd, char const *file, uid_t owner, gid_t group)
70 return fchownat (fd, file, owner, group, AT_SYMLINK_NOFOLLOW);
73 #endif
75 #if GNULIB_CHMODAT
77 # ifndef CHMODAT_INLINE
78 # define CHMODAT_INLINE _GL_INLINE
79 # endif
81 CHMODAT_INLINE int
82 chmodat (int fd, char const *file, mode_t mode)
84 return fchmodat (fd, file, mode, 0);
87 CHMODAT_INLINE int
88 lchmodat (int fd, char const *file, mode_t mode)
90 return fchmodat (fd, file, mode, AT_SYMLINK_NOFOLLOW);
93 #endif
95 #if GNULIB_STATAT
97 # ifndef STATAT_INLINE
98 # define STATAT_INLINE _GL_INLINE
99 # endif
101 _GL_ATTRIBUTE_DEPRECATED
102 STATAT_INLINE int
103 statat (int fd, char const *name, struct stat *st)
105 return fstatat (fd, name, st, 0);
108 _GL_ATTRIBUTE_DEPRECATED
109 STATAT_INLINE int
110 lstatat (int fd, char const *name, struct stat *st)
112 return fstatat (fd, name, st, AT_SYMLINK_NOFOLLOW);
115 #endif
117 /* For now, there are no wrappers named laccessat or leuidaccessat,
118 since gnulib doesn't support faccessat(,AT_SYMLINK_NOFOLLOW) and
119 since access rights on symlinks are of limited utility. Likewise,
120 wrappers are not provided for accessat or euidaccessat, so as to
121 avoid dragging in -lgen on some platforms. */
123 _GL_INLINE_HEADER_END
125 #endif /* _GL_HEADER_OPENAT */