From b2d31717511bd21854840bd69875ca80b875137a Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Mon, 22 Apr 2024 09:45:54 -0400 Subject: config: Check for acl_get_{entry,tag_type}() --- config/acl-get-entry.c | 8 ++++++++ config/acl-get-tag-type.c | 10 ++++++++++ config/header.mk | 2 ++ src/fsade.c | 32 ++++++++++++++++++++------------ 4 files changed, 40 insertions(+), 12 deletions(-) create mode 100644 config/acl-get-entry.c create mode 100644 config/acl-get-tag-type.c diff --git a/config/acl-get-entry.c b/config/acl-get-entry.c new file mode 100644 index 0000000..3cce771 --- /dev/null +++ b/config/acl-get-entry.c @@ -0,0 +1,8 @@ +#include +#include + +int main(void) { + acl_t acl = acl_get_file(".", ACL_TYPE_DEFAULT); + acl_entry_t entry; + return acl_get_entry(acl, ACL_FIRST_ENTRY, &entry); +} diff --git a/config/acl-get-tag-type.c b/config/acl-get-tag-type.c new file mode 100644 index 0000000..2901956 --- /dev/null +++ b/config/acl-get-tag-type.c @@ -0,0 +1,10 @@ +#include +#include +#include + +int main(void) { + acl_entry_t entry; + memset(&entry, 0, sizeof(entry)); + acl_tag_t tag; + return acl_get_tag_type(entry, &tag); +} diff --git a/config/header.mk b/config/header.mk index 4da0fd2..c8f8d7c 100644 --- a/config/header.mk +++ b/config/header.mk @@ -9,6 +9,8 @@ include config/exports.mk # All header fragments we generate HEADERS := \ + ${GEN}/acl-get-entry.h \ + ${GEN}/acl-get-tag-type.h \ ${GEN}/acl-is-trivial-np.h \ ${GEN}/aligned-alloc.h \ ${GEN}/confstr.h \ diff --git a/src/fsade.c b/src/fsade.c index 02b12d0..dac2ca6 100644 --- a/src/fsade.c +++ b/src/fsade.c @@ -123,9 +123,19 @@ static bool is_absence_error(int error) { /** Unified interface for incompatible acl_get_entry() implementations. */ static int bfs_acl_entry(acl_t acl, int which, acl_entry_t *entry) { -#if __DragonFly__ && !defined(ACL_FIRST_ENTRY) && !defined(ACL_NEXT_ENTRY) -# define ACL_FIRST_ENTRY 0 -# define ACL_NEXT_ENTRY 1 +#if BFS_HAS_ACL_GET_ENTRY + int ret = acl_get_entry(acl, which, entry); +# if __APPLE__ + // POSIX.1e specifies a return value of 1 for success, but macOS returns 0 instead + return !ret; +# else + return ret; +# endif +#elif __DragonFly__ +# if !defined(ACL_FIRST_ENTRY) && !defined(ACL_NEXT_ENTRY) +# define ACL_FIRST_ENTRY 0 +# define ACL_NEXT_ENTRY 1 +# endif switch (which) { case ACL_FIRST_ENTRY: @@ -142,24 +152,22 @@ static int bfs_acl_entry(acl_t acl, int which, acl_entry_t *entry) { acl_entry_t last = &acl->acl_entry[acl->acl_cnt]; return *entry == last; #else - int ret = acl_get_entry(acl, which, entry); -# if __APPLE__ - // POSIX.1e specifies a return value of 1 for success, but macOS returns 0 instead - return !ret; -# else - return ret; -# endif + errno = ENOTSUP; + return -1; #endif } /** Unified interface for acl_get_tag_type(). */ attr(maybe_unused) static int bfs_acl_tag_type(acl_entry_t entry, acl_tag_t *tag) { -#if __DragonFly__ +#if BFS_HAS_ACL_GET_TAG_TYPE + return acl_get_tag_type(entry, tag); +#elif __DragonFly__ *tag = entry->ae_tag; return 0; #else - return acl_get_tag_type(entry, tag); + errno = ENOTSUP; + return -1; #endif } -- cgit v1.2.3