aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFrançois Charlier <fcharlier@ploup.net>2013-10-01 21:57:14 +0200
committerDaniel Stenberg <daniel@haxx.se>2013-10-01 22:53:47 +0200
commit3d43a487813a94dc8521bd8d970725efbd922bf7 (patch)
tree1934becfe2aa61b0687979e64604845fc31ba417 /src
parentc8b05b809e6f241aa4e0087c7552e2959d77b69c (diff)
xattr: add support for FreeBSD xattr API
Diffstat (limited to 'src')
-rw-r--r--src/tool_xattr.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/tool_xattr.c b/src/tool_xattr.c
index 505bdb17a..b2666d973 100644
--- a/src/tool_xattr.c
+++ b/src/tool_xattr.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -23,13 +23,18 @@
#ifdef HAVE_FSETXATTR
# include <sys/xattr.h> /* header from libc, not from libattr */
+# define USE_XATTR
+#elif defined(__FreeBSD_version) && (__FreeBSD_version > 500000)
+# include <sys/types.h>
+# include <sys/extattr.h>
+# define USE_XATTR
#endif
#include "tool_xattr.h"
#include "memdebug.h" /* keep this as LAST include */
-#ifdef HAVE_FSETXATTR
+#ifdef USE_XATTR
/* mapping table of curl metadata to extended attribute names */
static const struct xattr_mapping {
@@ -60,6 +65,12 @@ 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)
+ 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++;