curl-library
[PATCH] xattr: add support for FreeBSD xattr API
From: François Charlier <fcharlier_at_ploup.net>
Date: Tue, 1 Oct 2013 21:57:14 +0200
Date: Tue, 1 Oct 2013 21:57:14 +0200
---
src/tool_xattr.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/tool_xattr.c b/src/tool_xattr.c
index 505bdb1..36ad7a9 100644
--- a/src/tool_xattr.c
+++ b/src/tool_xattr.c
@@ -23,13 +23,17 @@
#ifdef HAVE_FSETXATTR
# include <sys/xattr.h> /* header from libc, not from libattr */
+#elif defined(__FreeBSD_version) && (__FreeBSD_version > 500000)
+# include <sys/types.h>
+# include <sys/extattr.h>
#endif
#include "tool_xattr.h"
#include "memdebug.h" /* keep this as LAST include */
-#ifdef HAVE_FSETXATTR
+#if defined(HAVE_FSETXATTR) || \
+ (defined(__FreeBSD_version) && (__FreeBSD_version > 500000))
/* mapping table of curl metadata to extended attribute names */
static const struct xattr_mapping {
@@ -60,6 +64,11 @@ int fwrite_xattr(CURL *curl, int fd)
err = fsetxattr(fd, mappings[i].attr, value, strlen(value), 0, 0);
#elif defined(HAVE_FSETXATTR_5)
err = fsetxattr(fd, mappings[i].attr, value, strlen(value), 0);
+#elif (defined(__FreeBSD_version) && (__FreeBSD_version > 500000))
+ err = extattr_set_fd(fd, EXTATTR_NAMESPACE_USER, mappings[i].attr, value,
+ strlen(value));
+ // FreeBSD's extattr_set_fd returns the length of the extended attribute
+ err = err < 0 ? err : 0;
#endif
}
i++;
--
1.8.3.2
--SUOF0GtieIMvvwua
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
--SUOF0GtieIMvvwua--
Received on 2001-09-17