summaryrefslogtreecommitdiffstats
path: root/fsade.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2020-01-08 14:47:27 -0500
committerTavian Barnes <tavianator@tavianator.com>2020-01-08 15:11:36 -0500
commit2215f7a5d902764755673cc15a317982f0f15592 (patch)
treec164da27ad2bfbaa3e45439abd5c3c623f348250 /fsade.c
parent82dd2eb052aea282de099c2a26fd36f94649a5ae (diff)
downloadbfs-2215f7a5d902764755673cc15a317982f0f15592.tar.xz
fsade: Support checking for xattrs (extattrs) on FreeBSD
Diffstat (limited to 'fsade.c')
-rw-r--r--fsade.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/fsade.c b/fsade.c
index 84c6978..668f586 100644
--- a/fsade.c
+++ b/fsade.c
@@ -30,7 +30,9 @@
# include <sys/capability.h>
#endif
-#if BFS_CAN_CHECK_XATTRS
+#if BFS_HAS_SYS_EXTATTR
+# include <sys/extattr.h>
+#elif BFS_HAS_SYS_XATTR
# include <sys/xattr.h>
#endif
@@ -281,7 +283,15 @@ int bfs_check_xattrs(const struct BFTW *ftwbuf) {
const char *path = fake_at(ftwbuf);
ssize_t len;
-#if __APPLE__
+#if BFS_HAS_SYS_EXTATTR
+ ssize_t (*extattr_list)(const char *, int, void*, size_t) =
+ ftwbuf->typeflag == BFTW_LNK ? extattr_list_link : extattr_list_file;
+
+ len = extattr_list(path, EXTATTR_NAMESPACE_SYSTEM, NULL, 0);
+ if (len <= 0) {
+ len = extattr_list(path, EXTATTR_NAMESPACE_USER, NULL, 0);
+ }
+#elif __APPLE__
int options = ftwbuf->typeflag == BFTW_LNK ? XATTR_NOFOLLOW : 0;
len = listxattr(path, NULL, 0, options);
#else