summaryrefslogtreecommitdiffstats
path: root/src/fsade.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-08-27 16:23:47 -0400
committerTavian Barnes <tavianator@tavianator.com>2024-08-28 17:33:20 -0400
commit4890e2754c238c51497a19b67fb2458ef108f558 (patch)
tree1e590b06485b206a7c96c044fbb393b4df73498e /src/fsade.c
parent49e8620fe191da4fabc79896d05d56cb531ed673 (diff)
downloadbfs-4890e2754c238c51497a19b67fb2458ef108f558.tar.xz
prelude: Rely more on __has_include()
Rather than a bunch of manual fallback macros, just provide a fallback definition that returns false.
Diffstat (limited to 'src/fsade.c')
-rw-r--r--src/fsade.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/fsade.c b/src/fsade.c
index 11dcd9b..a5073ab 100644
--- a/src/fsade.c
+++ b/src/fsade.c
@@ -26,10 +26,12 @@
# include <selinux/selinux.h>
#endif
-#if BFS_USE_SYS_EXTATTR_H
+#if __has_include(<sys/extattr.h>)
# include <sys/extattr.h>
-#elif BFS_USE_SYS_XATTR_H
+# define BFS_USE_EXTATTR true
+#elif __has_include(<sys/xattr.h>)
# include <sys/xattr.h>
+# define BFS_USE_XATTR true
#endif
/**
@@ -344,7 +346,7 @@ int bfs_check_capabilities(const struct BFTW *ftwbuf) {
#if BFS_CAN_CHECK_XATTRS
-#if BFS_USE_SYS_EXTATTR_H
+#if BFS_USE_EXTATTR
/** Wrapper for extattr_list_{file,link}. */
static ssize_t bfs_extattr_list(const char *path, enum bfs_type type, int namespace) {
@@ -390,13 +392,13 @@ static ssize_t bfs_extattr_get(const char *path, enum bfs_type type, int namespa
#endif
}
-#endif // BFS_USE_SYS_EXTATTR_H
+#endif // BFS_USE_EXTATTR
int bfs_check_xattrs(const struct BFTW *ftwbuf) {
const char *path = fake_at(ftwbuf);
ssize_t len;
-#if BFS_USE_SYS_EXTATTR_H
+#if BFS_USE_EXTATTR
len = bfs_extattr_list(path, ftwbuf->type, EXTATTR_NAMESPACE_SYSTEM);
if (len <= 0) {
len = bfs_extattr_list(path, ftwbuf->type, EXTATTR_NAMESPACE_USER);
@@ -432,7 +434,7 @@ int bfs_check_xattr_named(const struct BFTW *ftwbuf, const char *name) {
const char *path = fake_at(ftwbuf);
ssize_t len;
-#if BFS_USE_SYS_EXTATTR_H
+#if BFS_USE_EXTATTR
len = bfs_extattr_get(path, ftwbuf->type, EXTATTR_NAMESPACE_SYSTEM, name);
if (len < 0) {
len = bfs_extattr_get(path, ftwbuf->type, EXTATTR_NAMESPACE_USER, name);