From 2ff2859c237a0b4928c28a0086dd2f5fb9b2da70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Fri, 20 Nov 2020 17:50:34 +0100 Subject: Add compat mode for systems without openat(2) --- Compat.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'Compat.h') diff --git a/Compat.h b/Compat.h index e513b1d3..c8942735 100644 --- a/Compat.h +++ b/Compat.h @@ -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 #include +#include #include @@ -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, -- cgit v1.2.3