From 4b8669f968aae6dc0267c8d46ef265432c681b46 Mon Sep 17 00:00:00 2001
From: Tavian Barnes <tavianator@tavianator.com>
Date: Mon, 22 Apr 2024 10:49:25 -0400
Subject: config: Check for acl_get_file()

---
 config/acl-get-file.c | 8 ++++++++
 config/header.mk      | 1 +
 src/fsade.h           | 2 +-
 src/prelude.h         | 7 -------
 4 files changed, 10 insertions(+), 8 deletions(-)
 create mode 100644 config/acl-get-file.c

diff --git a/config/acl-get-file.c b/config/acl-get-file.c
new file mode 100644
index 0000000..89fbf23
--- /dev/null
+++ b/config/acl-get-file.c
@@ -0,0 +1,8 @@
+#include <stddef.h>
+#include <sys/types.h>
+#include <sys/acl.h>
+
+int main(void) {
+	acl_t acl = acl_get_file(".", ACL_TYPE_DEFAULT);
+	return acl == (acl_t)NULL;
+}
diff --git a/config/header.mk b/config/header.mk
index c8f8d7c..5da0629 100644
--- a/config/header.mk
+++ b/config/header.mk
@@ -10,6 +10,7 @@ include config/exports.mk
 # All header fragments we generate
 HEADERS := \
     ${GEN}/acl-get-entry.h \
+    ${GEN}/acl-get-file.h \
     ${GEN}/acl-get-tag-type.h \
     ${GEN}/acl-is-trivial-np.h \
     ${GEN}/aligned-alloc.h \
diff --git a/src/fsade.h b/src/fsade.h
index cd5c34f..fc0809e 100644
--- a/src/fsade.h
+++ b/src/fsade.h
@@ -11,7 +11,7 @@
 
 #include "prelude.h"
 
-#define BFS_CAN_CHECK_ACL BFS_USE_SYS_ACL_H
+#define BFS_CAN_CHECK_ACL BFS_HAS_ACL_GET_FILE
 
 #define BFS_CAN_CHECK_CAPABILITIES BFS_USE_LIBCAP
 
diff --git a/src/prelude.h b/src/prelude.h
index bf87386..7a646a7 100644
--- a/src/prelude.h
+++ b/src/prelude.h
@@ -49,9 +49,6 @@ extern const char bfs_version[];
 #if __has_include(<paths.h>)
 #  define BFS_HAS_PATHS_H true
 #endif
-#if __has_include(<sys/acl.h>)
-#  define BFS_HAS_SYS_ACL_H true
-#endif
 #if __has_include(<sys/extattr.h>)
 #  define BFS_HAS_SYS_EXTATTR_H true
 #endif
@@ -78,7 +75,6 @@ extern const char bfs_version[];
 
 #define BFS_HAS_MNTENT_H __GLIBC__
 #define BFS_HAS_PATHS_H true
-#define BFS_HAS_SYS_ACL_H true
 #define BFS_HAS_SYS_EXTATTR_H __FreeBSD__
 #define BFS_HAS_SYS_MKDEV_H false
 #define BFS_HAS_SYS_PARAM_H true
@@ -95,9 +91,6 @@ extern const char bfs_version[];
 #ifndef BFS_USE_PATHS_H
 #  define BFS_USE_PATHS_H BFS_HAS_PATHS_H
 #endif
-#ifndef BFS_USE_SYS_ACL_H
-#  define BFS_USE_SYS_ACL_H (BFS_HAS_SYS_ACL_H && !__illumos__ && (!__linux__ || BFS_USE_LIBACL))
-#endif
 #ifndef BFS_USE_SYS_EXTATTR_H
 #  define BFS_USE_SYS_EXTATTR_H BFS_HAS_SYS_EXTATTR_H
 #endif
-- 
cgit v1.2.3