| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#ifndef _GL_HEADER_OPENAT |
| 20 |
#define _GL_HEADER_OPENAT |
| 21 |
|
| 22 |
#include <fcntl.h> |
| 23 |
|
| 24 |
#include <sys/types.h> |
| 25 |
#include <sys/stat.h> |
| 26 |
#include <unistd.h> |
| 27 |
#include <stdbool.h> |
| 28 |
|
| 29 |
#ifndef _GL_INLINE_HEADER_BEGIN |
| 30 |
#error "Please include config.h first." |
| 31 |
#endif |
| 32 |
_GL_INLINE_HEADER_BEGIN |
| 33 |
|
| 34 |
#if !HAVE_OPENAT |
| 35 |
|
| 36 |
int openat_permissive (int fd, char const *file, int flags, mode_t mode, |
| 37 |
int *cwd_errno); |
| 38 |
bool openat_needs_fchdir (void); |
| 39 |
|
| 40 |
#else |
| 41 |
|
| 42 |
# define openat_permissive(Fd, File, Flags, Mode, Cwd_errno) \ |
| 43 |
openat (Fd, File, Flags, Mode) |
| 44 |
# define openat_needs_fchdir() false |
| 45 |
|
| 46 |
#endif |
| 47 |
|
| 48 |
_Noreturn void openat_restore_fail (int); |
| 49 |
_Noreturn void openat_save_fail (int); |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
#if GNULIB_CHOWNAT |
| 56 |
|
| 57 |
# ifndef CHOWNAT_INLINE |
| 58 |
# define CHOWNAT_INLINE _GL_INLINE |
| 59 |
# endif |
| 60 |
|
| 61 |
CHOWNAT_INLINE int |
| 62 |
chownat (int fd, char const *file, uid_t owner, gid_t group) |
| 63 |
{ |
| 64 |
return fchownat (fd, file, owner, group, 0); |
| 65 |
} |
| 66 |
|
| 67 |
CHOWNAT_INLINE int |
| 68 |
lchownat (int fd, char const *file, uid_t owner, gid_t group) |
| 69 |
{ |
| 70 |
return fchownat (fd, file, owner, group, AT_SYMLINK_NOFOLLOW); |
| 71 |
} |
| 72 |
|
| 73 |
#endif |
| 74 |
|
| 75 |
#if GNULIB_CHMODAT |
| 76 |
|
| 77 |
# ifndef CHMODAT_INLINE |
| 78 |
# define CHMODAT_INLINE _GL_INLINE |
| 79 |
# endif |
| 80 |
|
| 81 |
CHMODAT_INLINE int |
| 82 |
chmodat (int fd, char const *file, mode_t mode) |
| 83 |
{ |
| 84 |
return fchmodat (fd, file, mode, 0); |
| 85 |
} |
| 86 |
|
| 87 |
CHMODAT_INLINE int |
| 88 |
lchmodat (int fd, char const *file, mode_t mode) |
| 89 |
{ |
| 90 |
return fchmodat (fd, file, mode, AT_SYMLINK_NOFOLLOW); |
| 91 |
} |
| 92 |
|
| 93 |
#endif |
| 94 |
|
| 95 |
#if GNULIB_STATAT |
| 96 |
|
| 97 |
# ifndef STATAT_INLINE |
| 98 |
# define STATAT_INLINE _GL_INLINE |
| 99 |
# endif |
| 100 |
|
| 101 |
STATAT_INLINE int |
| 102 |
statat (int fd, char const *name, struct stat *st) |
| 103 |
{ |
| 104 |
return fstatat (fd, name, st, 0); |
| 105 |
} |
| 106 |
|
| 107 |
STATAT_INLINE int |
| 108 |
lstatat (int fd, char const *name, struct stat *st) |
| 109 |
{ |
| 110 |
return fstatat (fd, name, st, AT_SYMLINK_NOFOLLOW); |
| 111 |
} |
| 112 |
|
| 113 |
#endif |
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
_GL_INLINE_HEADER_END |
| 122 |
|
| 123 |
#endif |