summaryrefslogtreecommitdiffstats
path: root/Compat.c
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2020-10-26 21:16:43 +0100
committercgzones <cgzones@googlemail.com>2020-10-29 22:21:42 +0100
commitbbf01054bf943db4394027d77915f9625ebde81e (patch)
treeee5e94bd207c2c0df8e11792064c694b27de8d02 /Compat.c
parent049046c700ea42e8f9bb77f5efbb5a66ed3c4651 (diff)
Add compat wrapper for fstatat
Diffstat (limited to 'Compat.c')
-rw-r--r--Compat.c46
1 files changed, 46 insertions, 0 deletions
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 <fcntl.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#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
+}

© 2014-2024 Faster IT GmbH | imprint | privacy policy