From c55e4d40216ef5d1d6143e23133208bbc83ad634 Mon Sep 17 00:00:00 2001 From: feiniks <36756310+feiniks@users.noreply.github.com> Date: Thu, 8 Aug 2024 16:53:40 +0800 Subject: [PATCH] Check if the system supports xattr (#2802) * Check if the system supports xattr * Support xatttr for FreeBSD and NetBSD --------- Co-authored-by: heran yang --- lib/utils.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/utils.c b/lib/utils.c index 0f0c041a..079bd9b7 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -50,9 +50,16 @@ #ifndef WIN32 #include +#endif + +#ifdef __linux__ #include #endif +#if defined __FreeBSD__ || defined __NetBSD__ +#include +#endif + #include #include "log.h" @@ -2724,6 +2731,12 @@ out: #ifdef __APPLE__ return getxattr (path, name, value, size, 0, 0); #endif + +#if defined __FreeBSD__ || defined __NetBSD__ + return extattr_get_file (path, EXTATTR_NAMESPACE_USER, name, value, size); +#endif + + return -1; } int @@ -2772,6 +2785,12 @@ out: #ifdef __APPLE__ return setxattr (path, name, value, size, 0, 0); #endif + +#if defined __FreeBSD__ || defined __NetBSD__ + return extattr_set_file (path, EXTATTR_NAMESPACE_USER, name, value, size); +#endif + + return -1; } int