Revert "Update to 7.40.1"
[platform/upstream/curl.git] / src / tool_xattr.c
index 9c7e704..b2666d9 100644 (file)
@@ -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
 
 #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 <curl/curl.h>
-
 #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 {
@@ -62,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++;