diff options
author | Benny Baumann <BenBE@geshi.org> | 2020-10-29 23:02:57 +0100 |
---|---|---|
committer | Benny Baumann <BenBE@geshi.org> | 2020-11-09 19:17:57 +0100 |
commit | 2d6da2e52066067e4c82a2e16f73438319e1db81 (patch) | |
tree | 5e3180abd332708ae94ec34b56d9e89dddb2a6e5 /Compat.c | |
parent | 84dad4c38ee4eb16ea8716891419b0a3780f3818 (diff) |
Add compat wrapper for readlinkat
Diffstat (limited to 'Compat.c')
-rw-r--r-- | Compat.c | 26 |
1 files changed, 24 insertions, 2 deletions
@@ -13,9 +13,7 @@ in the source distribution for its full text. #include <sys/stat.h> #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 +} |