From 2d6da2e52066067e4c82a2e16f73438319e1db81 Mon Sep 17 00:00:00 2001 From: Benny Baumann Date: Thu, 29 Oct 2020 23:02:57 +0100 Subject: Add compat wrapper for readlinkat --- Compat.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'Compat.c') diff --git a/Compat.c b/Compat.c index 25aa9f73..6401f696 100644 --- a/Compat.c +++ b/Compat.c @@ -13,9 +13,7 @@ in the source distribution for its full text. #include #include "Compat.h" -#ifndef HAVE_FSTATAT #include "XUtils.h" -#endif int Compat_fstatat(int dirfd, @@ -44,3 +42,27 @@ int Compat_fstatat(int dirfd, #endif } + +int Compat_readlinkat(int dirfd, + const char* dirpath, + const char* pathname, + char* buf, + size_t bufsize) { + +#ifdef HAVE_READLINKAT + + (void)dirpath; + + return readlinkat(dirfd, pathname, buf, bufsize); + +#else + + (void)dirfd; + + char path[4096]; + xSnprintf(path, sizeof(path), "%s/%s", dirpath, pathname); + + return readlink(path, buf, bufsize); + +#endif +} -- cgit v1.2.3