1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* provide a replacement openat function
4 Copyright (C) 2004-2006, 2008-2010 Free Software Foundation, Inc.
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 /* written by Jim Meyering */
21 #ifndef _GL_HEADER_OPENAT
22 #define _GL_HEADER_OPENAT
26 #include <sys/types.h>
33 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
34 # define __attribute__(x) /* empty */
38 #ifndef ATTRIBUTE_NORETURN
39 # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
44 int openat_permissive (int fd, char const *file, int flags, mode_t mode,
46 bool openat_needs_fchdir (void);
50 # define openat_permissive(Fd, File, Flags, Mode, Cwd_errno) \
51 openat (Fd, File, Flags, Mode)
52 # define openat_needs_fchdir() false
56 void openat_restore_fail (int) ATTRIBUTE_NORETURN;
57 void openat_save_fail (int) ATTRIBUTE_NORETURN;
59 /* Using these function names makes application code
60 slightly more readable than it would be with
61 fchownat (..., 0) or fchownat (..., AT_SYMLINK_NOFOLLOW). */
63 chownat (int fd, char const *file, uid_t owner, gid_t group)
65 return fchownat (fd, file, owner, group, 0);
69 lchownat (int fd, char const *file, uid_t owner, gid_t group)
71 return fchownat (fd, file, owner, group, AT_SYMLINK_NOFOLLOW);
75 chmodat (int fd, char const *file, mode_t mode)
77 return fchmodat (fd, file, mode, 0);
81 lchmodat (int fd, char const *file, mode_t mode)
83 return fchmodat (fd, file, mode, AT_SYMLINK_NOFOLLOW);
87 statat (int fd, char const *name, struct stat *st)
89 return fstatat (fd, name, st, 0);
93 lstatat (int fd, char const *name, struct stat *st)
95 return fstatat (fd, name, st, AT_SYMLINK_NOFOLLOW);
99 /* For now, there are no wrappers named laccessat or leuidaccessat,
100 since gnulib doesn't support faccessat(,AT_SYMLINK_NOFOLLOW) and
101 since access rights on symlinks are of limited utility. */
104 accessat (int fd, char const *file, int mode)
106 return faccessat (fd, file, mode, 0);
110 euidaccessat (int fd, char const *file, int mode)
112 return faccessat (fd, file, mode, AT_EACCESS);
116 #endif /* _GL_HEADER_OPENAT */