00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _GL_HEADER_OPENAT
00022 #define _GL_HEADER_OPENAT
00023
00024 #include <fcntl.h>
00025
00026 #include <sys/types.h>
00027 #include <sys/stat.h>
00028 #include <dirent.h>
00029 #include <unistd.h>
00030 #include <stdbool.h>
00031
00032 #ifndef __attribute__
00033 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
00034 # define __attribute__(x)
00035 # endif
00036 #endif
00037
00038 #ifndef ATTRIBUTE_NORETURN
00039 # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
00040 #endif
00041
00042 #if !HAVE_OPENAT
00043
00044 int openat_permissive (int fd, char const *file, int flags, mode_t mode,
00045 int *cwd_errno);
00046 bool openat_needs_fchdir (void);
00047
00048 #else
00049
00050 # define openat_permissive(Fd, File, Flags, Mode, Cwd_errno) \
00051 openat (Fd, File, Flags, Mode)
00052 # define openat_needs_fchdir() false
00053
00054 #endif
00055
00056 void openat_restore_fail (int) ATTRIBUTE_NORETURN;
00057 void openat_save_fail (int) ATTRIBUTE_NORETURN;
00058
00059
00060
00061
00062 static inline int
00063 chownat (int fd, char const *file, uid_t owner, gid_t group)
00064 {
00065 return fchownat (fd, file, owner, group, 0);
00066 }
00067
00068 static inline int
00069 lchownat (int fd, char const *file, uid_t owner, gid_t group)
00070 {
00071 return fchownat (fd, file, owner, group, AT_SYMLINK_NOFOLLOW);
00072 }
00073
00074 static inline int
00075 chmodat (int fd, char const *file, mode_t mode)
00076 {
00077 return fchmodat (fd, file, mode, 0);
00078 }
00079
00080 static inline int
00081 lchmodat (int fd, char const *file, mode_t mode)
00082 {
00083 return fchmodat (fd, file, mode, AT_SYMLINK_NOFOLLOW);
00084 }
00085
00086 static inline int
00087 statat (int fd, char const *name, struct stat *st)
00088 {
00089 return fstatat (fd, name, st, 0);
00090 }
00091
00092 static inline int
00093 lstatat (int fd, char const *name, struct stat *st)
00094 {
00095 return fstatat (fd, name, st, AT_SYMLINK_NOFOLLOW);
00096 }
00097
00098
00099
00100
00101
00102
00103
00104 #endif