diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2020-11-20 17:50:34 +0100 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2020-11-28 12:35:34 +0100 |
commit | 2ff2859c237a0b4928c28a0086dd2f5fb9b2da70 (patch) | |
tree | 27f74d10d90d21fc7732d7e0b0b9bb0a01619a21 /Compat.h | |
parent | 638207a2ff91089de7679b4ed20fc0b01116c37c (diff) |
Add compat mode for systems without openat(2)
Diffstat (limited to 'Compat.h')
-rw-r--r-- | Compat.h | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -7,7 +7,11 @@ Released under the GNU GPLv2, see the COPYING file in the source distribution for its full text. */ +#include "config.h" // IWYU pragma: keep + +#include <fcntl.h> #include <stddef.h> +#include <unistd.h> #include <sys/stat.h> @@ -22,6 +26,30 @@ int Compat_fstatat(int dirfd, struct stat* statbuf, int flags); +#ifdef HAVE_OPENAT + +typedef int openat_arg_t; + +static inline void Compat_openatArgClose(openat_arg_t dirfd) { + close(dirfd); +} + +static inline int Compat_openat(openat_arg_t dirfd, const char* pathname, int flags) { + return openat(dirfd, pathname, flags); +} + +#else /* HAVE_OPENAT */ + +typedef const char* openat_arg_t; + +static inline void Compat_openatArgClose(openat_arg_t dirpath) { + (void)dirpath; +} + +int Compat_openat(openat_arg_t dirpath, const char* pathname, int flags); + +#endif /* HAVE_OPENAT */ + int Compat_readlinkat(int dirfd, const char* dirpath, const char* pathname, |