From bbf01054bf943db4394027d77915f9625ebde81e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Mon, 26 Oct 2020 21:16:43 +0100 Subject: Add compat wrapper for fstatat --- Compat.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Compat.c (limited to 'Compat.c') diff --git a/Compat.c b/Compat.c new file mode 100644 index 00000000..25aa9f73 --- /dev/null +++ b/Compat.c @@ -0,0 +1,46 @@ +/* +htop - Compat.c +(C) 2020 Christian Göttsche +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 + +#include "Compat.h" +#ifndef HAVE_FSTATAT +#include "XUtils.h" +#endif + + +int Compat_fstatat(int dirfd, + const char* dirpath, + const char* pathname, + struct stat* statbuf, + int flags) { + +#ifdef HAVE_FSTATAT + + (void)dirpath; + + return fstatat(dirfd, pathname, statbuf, flags); + +#else + + (void)dirfd; + + char path[4096]; + xSnprintf(path, sizeof(path), "%s/%s", dirpath, pathname); + + if (flags & AT_SYMLINK_NOFOLLOW) + return lstat(path, statbuf); + + return stat(path, statbuf); + +#endif +} -- cgit v1.2.3