Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Mar 2017 00:02:12 +0000 (UTC)
From:      Martin Matuska <mm@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r315876 - in head: contrib/libarchive/libarchive contrib/libarchive/libarchive/test contrib/libarchive/tar contrib/libarchive/tar/test contrib/libarchive/test_utils lib/libarchive lib/l...
Message-ID:  <201703240002.v2O02CK1085189@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mm
Date: Fri Mar 24 00:02:12 2017
New Revision: 315876
URL: https://svnweb.freebsd.org/changeset/base/315876

Log:
  MFV r315875:
  Sync libarchive with vendor.
  
  Vendor changes (FreeBSD-related):
  - store extended attributes with extattr_set_link() if no fd is provided
  - add extended attribute tests to libarchive and bsdtar
  - fix tar's test_option_acls
  - support the UF_HIDDEN file flag
  
  X-MFC with:	315636

Added:
  head/contrib/libarchive/libarchive/archive_platform_xattr.h
     - copied unchanged from r315875, vendor/libarchive/dist/libarchive/archive_platform_xattr.h
  head/contrib/libarchive/libarchive/test/test_xattr_platform.c
     - copied unchanged from r315875, vendor/libarchive/dist/libarchive/test/test_xattr_platform.c
  head/contrib/libarchive/tar/test/test_option_xattrs.c
     - copied unchanged from r315875, vendor/libarchive/dist/tar/test/test_option_xattrs.c
Modified:
  head/contrib/libarchive/libarchive/archive_entry.c
  head/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c
  head/contrib/libarchive/libarchive/archive_write_disk_posix.c
  head/contrib/libarchive/tar/bsdtar.1
  head/contrib/libarchive/tar/test/test_option_acls.c
  head/contrib/libarchive/test_utils/test_common.h
  head/contrib/libarchive/test_utils/test_main.c
  head/lib/libarchive/config_freebsd.h
  head/lib/libarchive/tests/Makefile
  head/usr.bin/tar/tests/Makefile
Directory Properties:
  head/contrib/libarchive/   (props changed)

Modified: head/contrib/libarchive/libarchive/archive_entry.c
==============================================================================
--- head/contrib/libarchive/libarchive/archive_entry.c	Thu Mar 23 23:44:31 2017	(r315875)
+++ head/contrib/libarchive/libarchive/archive_entry.c	Fri Mar 24 00:02:12 2017	(r315876)
@@ -1708,6 +1708,9 @@ static struct flag {
 #ifdef UF_COMPRESSED
 	{ "nocompressed",L"nocompressed",	UF_COMPRESSED,	0 },
 #endif
+#ifdef UF_HIDDEN
+	{ "nohidden",	L"nohidden",		UF_HIDDEN,	0 },
+#endif
 #if defined(FS_UNRM_FL)
         { "nouunlink",	L"nouunlink",		FS_UNRM_FL,	0},
 #elif defined(EXT2_UNRM_FL)

Copied: head/contrib/libarchive/libarchive/archive_platform_xattr.h (from r315875, vendor/libarchive/dist/libarchive/archive_platform_xattr.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/contrib/libarchive/libarchive/archive_platform_xattr.h	Fri Mar 24 00:02:12 2017	(r315876, copy of r315875, vendor/libarchive/dist/libarchive/archive_platform_xattr.h)
@@ -0,0 +1,41 @@
+/*-
+ * Copyright (c) 2017 Martin Matuska
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+/* !!ONLY FOR USE INTERNALLY TO LIBARCHIVE!! */
+
+#ifndef ARCHIVE_PLATFORM_XATTR_H_INCLUDED
+#define ARCHIVE_PLATFORM_XATTR_H_INCLUDED
+
+/*
+ * Determine if we support extended attributes
+ */
+#if ARCHIVE_XATTR_LINUX || ARCHIVE_XATTR_DARWIN || ARCHIVE_XATTR_FREEBSD || \
+    ARCHIVE_XATTR_AIX
+#define ARCHIVE_XATTR_SUPPORT     1
+#endif
+
+#endif	/* ARCHIVE_PLATFORM_XATTR_H_INCLUDED */

Modified: head/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c
==============================================================================
--- head/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c	Thu Mar 23 23:44:31 2017	(r315875)
+++ head/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c	Fri Mar 24 00:02:12 2017	(r315876)
@@ -423,12 +423,10 @@ setup_mac_metadata(struct archive_read_d
 }
 #endif
 
-#if (HAVE_FGETXATTR && HAVE_FLISTXATTR && HAVE_LISTXATTR && \
-    HAVE_LLISTXATTR && HAVE_GETXATTR && HAVE_LGETXATTR) || \
-    (HAVE_FGETEA && HAVE_FLISTEA && HAVE_LISTEA)
+#if ARCHIVE_XATTR_LINUX || ARCHIVE_XATTR_DARWIN || ARCHIVE_XATTR_AIX
 
 /*
- * Linux and AIX extended attribute support.
+ * Linux, Darwin and AIX extended attribute support.
  *
  * TODO:  By using a stack-allocated buffer for the first
  * call to getxattr(), we might be able to avoid the second
@@ -446,21 +444,32 @@ setup_xattr(struct archive_read_disk *a,
 	ssize_t size;
 	void *value = NULL;
 
-#if HAVE_FGETXATTR
-	if (fd >= 0)
+
+	if (fd >= 0) {
+#if ARCHIVE_XATTR_LINUX
 		size = fgetxattr(fd, name, NULL, 0);
-	else if (!a->follow_symlinks)
-		size = lgetxattr(accpath, name, NULL, 0);
-	else
-		size = getxattr(accpath, name, NULL, 0);
-#elif HAVE_FGETEA
-	if (fd >= 0)
+#elif ARCHIVE_XATTR_DARWIN
+		size = fgetxattr(fd, name, NULL, 0, 0, 0);
+#elif ARCHIVE_XATTR_AIX
 		size = fgetea(fd, name, NULL, 0);
-	else if (!a->follow_symlinks)
+#endif
+	} else if (!a->follow_symlinks) {
+#if ARCHIVE_XATTR_LINUX
+		size = lgetxattr(accpath, name, NULL, 0);
+#elif ARCHIVE_XATTR_DARWIN
+		size = getxattr(accpath, name, NULL, 0, 0, XATTR_NOFOLLOW);
+#elif ARCHIVE_XATTR_AIX
 		size = lgetea(accpath, name, NULL, 0);
-	else
+#endif
+	} else {
+#if ARCHIVE_XATTR_LINUX
+		size = getxattr(accpath, name, NULL, 0);
+#elif ARCHIVE_XATTR_DARWIN
+		size = getxattr(accpath, name, NULL, 0, 0, 0);
+#elif ARCHIVE_XATTR_AIX
 		size = getea(accpath, name, NULL, 0);
 #endif
+	}
 
 	if (size == -1) {
 		archive_set_error(&a->archive, errno,
@@ -473,21 +482,32 @@ setup_xattr(struct archive_read_disk *a,
 		return (ARCHIVE_FATAL);
 	}
 
-#if HAVE_FGETXATTR
-	if (fd >= 0)
+
+	if (fd >= 0) {
+#if ARCHIVE_XATTR_LINUX
 		size = fgetxattr(fd, name, value, size);
-	else if (!a->follow_symlinks)
-		size = lgetxattr(accpath, name, value, size);
-	else
-		size = getxattr(accpath, name, value, size);
-#elif HAVE_FGETEA
-	if (fd >= 0)
+#elif ARCHIVE_XATTR_DARWIN
+		size = fgetxattr(fd, name, value, size, 0, 0);
+#elif ARCHIVE_XATTR_AIX
 		size = fgetea(fd, name, value, size);
-	else if (!a->follow_symlinks)
+#endif
+	} else if (!a->follow_symlinks) {
+#if ARCHIVE_XATTR_LINUX
+		size = lgetxattr(accpath, name, value, size);
+#elif ARCHIVE_XATTR_DARWIN
+		size = getxattr(accpath, name, value, size, 0, XATTR_NOFOLLOW);
+#elif ARCHIVE_XATTR_AIX
 		size = lgetea(accpath, name, value, size);
-	else
+#endif
+	} else {
+#if ARCHIVE_XATTR_LINUX
+		size = getxattr(accpath, name, value, size);
+#elif ARCHIVE_XATTR_DARWIN
+		size = getxattr(accpath, name, value, size, 0, 0);
+#elif ARCHIVE_XATTR_AIX
 		size = getea(accpath, name, value, size);
 #endif
+	}
 
 	if (size == -1) {
 		archive_set_error(&a->archive, errno,
@@ -517,21 +537,31 @@ setup_xattrs(struct archive_read_disk *a
 			return (ARCHIVE_WARN);
 	}
 
-#if HAVE_FLISTXATTR
-	if (*fd >= 0)
+	if (*fd >= 0) {
+#if ARCHIVE_XATTR_LINUX
 		list_size = flistxattr(*fd, NULL, 0);
-	else if (!a->follow_symlinks)
-		list_size = llistxattr(path, NULL, 0);
-	else
-		list_size = listxattr(path, NULL, 0);
-#elif HAVE_FLISTEA
-	if (*fd >= 0)
+#elif ARCHIVE_XATTR_DARWIN
+		list_size = flistxattr(*fd, NULL, 0, 0);
+#elif ARCHIVE_XATTR_AIX
 		list_size = flistea(*fd, NULL, 0);
-	else if (!a->follow_symlinks)
+#endif
+	} else if (!a->follow_symlinks) {
+#if ARCHIVE_XATTR_LINUX
+		list_size = llistxattr(path, NULL, 0);
+#elif ARCHIVE_XATTR_DARWIN
+		list_size = listxattr(path, NULL, 0, XATTR_NOFOLLOW);
+#elif ARCHIVE_XATTR_AIX
 		list_size = llistea(path, NULL, 0);
-	else
+#endif
+	} else {
+#if ARCHIVE_XATTR_LINUX
+		list_size = listxattr(path, NULL, 0);
+#elif ARCHIVE_XATTR_DARWIN
+		list_size = listxattr(path, NULL, 0, 0);
+#elif ARCHIVE_XATTR_AIX
 		list_size = listea(path, NULL, 0);
 #endif
+	}
 
 	if (list_size == -1) {
 		if (errno == ENOTSUP || errno == ENOSYS)
@@ -549,21 +579,31 @@ setup_xattrs(struct archive_read_disk *a
 		return (ARCHIVE_FATAL);
 	}
 
-#if HAVE_FLISTXATTR
-	if (*fd >= 0)
+	if (*fd >= 0) {
+#if ARCHIVE_XATTR_LINUX
 		list_size = flistxattr(*fd, list, list_size);
-	else if (!a->follow_symlinks)
-		list_size = llistxattr(path, list, list_size);
-	else
-		list_size = listxattr(path, list, list_size);
-#elif HAVE_FLISTEA
-	if (*fd >= 0)
+#elif ARCHIVE_XATTR_DARWIN
+		list_size = flistxattr(*fd, list, list_size, 0);
+#elif ARCHIVE_XATTR_AIX
 		list_size = flistea(*fd, list, list_size);
-	else if (!a->follow_symlinks)
+#endif
+	} else if (!a->follow_symlinks) {
+#if ARCHIVE_XATTR_LINUX
+		list_size = llistxattr(path, list, list_size);
+#elif ARCHIVE_XATTR_DARWIN
+		list_size = listxattr(path, list, list_size, XATTR_NOFOLLOW);
+#elif ARCHIVE_XATTR_AIX
 		list_size = llistea(path, list, list_size);
-	else
+#endif
+	} else {
+#if ARCHIVE_XATTR_LINUX
+		list_size = listxattr(path, list, list_size);
+#elif ARCHIVE_XATTR_DARWIN
+		list_size = listxattr(path, list, list_size, 0);
+#elif ARCHIVE_XATTR_AIX
 		list_size = listea(path, list, list_size);
 #endif
+	}
 
 	if (list_size == -1) {
 		archive_set_error(&a->archive, errno,
@@ -583,8 +623,7 @@ setup_xattrs(struct archive_read_disk *a
 	return (ARCHIVE_OK);
 }
 
-#elif HAVE_EXTATTR_GET_FILE && HAVE_EXTATTR_LIST_FILE && \
-    HAVE_DECL_EXTATTR_NAMESPACE_USER
+#elif ARCHIVE_XATTR_FREEBSD
 
 /*
  * FreeBSD extattr interface.

Modified: head/contrib/libarchive/libarchive/archive_write_disk_posix.c
==============================================================================
--- head/contrib/libarchive/libarchive/archive_write_disk_posix.c	Thu Mar 23 23:44:31 2017	(r315875)
+++ head/contrib/libarchive/libarchive/archive_write_disk_posix.c	Fri Mar 24 00:02:12 2017	(r315876)
@@ -39,9 +39,9 @@ __FBSDID("$FreeBSD$");
 #ifdef HAVE_SYS_EXTATTR_H
 #include <sys/extattr.h>
 #endif
-#if defined(HAVE_SYS_XATTR_H)
+#if HAVE_SYS_XATTR_H
 #include <sys/xattr.h>
-#elif defined(HAVE_ATTR_XATTR_H)
+#elif HAVE_ATTR_XATTR_H
 #include <attr/xattr.h>
 #endif
 #ifdef HAVE_SYS_EA_H
@@ -664,8 +664,21 @@ _archive_write_disk_header(struct archiv
 	}
 #endif
 
-	if (a->flags & ARCHIVE_EXTRACT_XATTR)
+	if (a->flags & ARCHIVE_EXTRACT_XATTR) {
+#if ARCHIVE_XATTR_DARWIN
+		/*
+		 * On MacOS, extended attributes get stored in mac_metadata,
+		 * too. If we intend to extract mac_metadata and it is present
+		 * we skip extracting extended attributes.
+		 */
+		size_t metadata_size;
+
+		if ((a->flags & ARCHIVE_EXTRACT_MAC_METADATA) == 0 ||
+		    archive_entry_mac_metadata(a->entry,
+		    &metadata_size) == NULL || metadata_size == 0)
+#endif
 		a->todo |= TODO_XATTR;
+	}
 	if (a->flags & ARCHIVE_EXTRACT_FFLAGS)
 		a->todo |= TODO_FFLAGS;
 	if (a->flags & ARCHIVE_EXTRACT_SECURE_SYMLINKS) {
@@ -4070,9 +4083,9 @@ skip_appledouble:
 }
 #endif
 
-#if HAVE_LSETXATTR || HAVE_LSETEA
+#if ARCHIVE_XATTR_LINUX || ARCHIVE_XATTR_DARWIN || ARCHIVE_XATTR_AIX
 /*
- * Restore extended attributes -  Linux and AIX implementations:
+ * Restore extended attributes -  Linux, Darwin and AIX implementations:
  * AIX' ea interface is syntaxwise identical to the Linux xattr interface.
  */
 static int
@@ -4092,20 +4105,22 @@ set_xattrs(struct archive_write_disk *a)
 				strncmp(name, "xfsroot.", 8) != 0 &&
 				strncmp(name, "system.", 7) != 0) {
 			int e;
-#if HAVE_FSETXATTR
-			if (a->fd >= 0)
+			if (a->fd >= 0) {
+#if ARCHIVE_XATTR_LINUX
 				e = fsetxattr(a->fd, name, value, size, 0);
-			else
-#elif HAVE_FSETEA
-			if (a->fd >= 0)
+#elif ARCHIVE_XATTR_DARWIN
+				e = fsetxattr(a->fd, name, value, size, 0, 0);
+#elif ARCHIVE_XATTR_AIX
 				e = fsetea(a->fd, name, value, size, 0);
-			else
 #endif
-			{
-#if HAVE_LSETXATTR
+			} else {
+#if ARCHIVE_XATTR_LINUX
 				e = lsetxattr(archive_entry_pathname(entry),
 				    name, value, size, 0);
-#elif HAVE_LSETEA
+#elif ARCHIVE_XATTR_DARWIN
+				e = setxattr(archive_entry_pathname(entry),
+				    name, value, size, 0, XATTR_NOFOLLOW);
+#elif ARCHIVE_XATTR_AIX
 				e = lsetea(archive_entry_pathname(entry),
 				    name, value, size, 0);
 #endif
@@ -4134,7 +4149,7 @@ set_xattrs(struct archive_write_disk *a)
 	}
 	return (ret);
 }
-#elif HAVE_EXTATTR_SET_FILE && HAVE_DECL_EXTATTR_NAMESPACE_USER
+#elif ARCHIVE_XATTR_FREEBSD
 /*
  * Restore extended attributes -  FreeBSD implementation
  */
@@ -4169,15 +4184,12 @@ set_xattrs(struct archive_write_disk *a)
 				continue;
 			}
 			errno = 0;
-#if HAVE_EXTATTR_SET_FD
-			if (a->fd >= 0)
+
+			if (a->fd >= 0) {
 				e = extattr_set_fd(a->fd, namespace, name,
 				    value, size);
-			else
-#endif
-			/* TODO: should we use extattr_set_link() instead? */
-			{
-				e = extattr_set_file(
+			} else {
+				e = extattr_set_link(
 				    archive_entry_pathname(entry), namespace,
 				    name, value, size);
 			}

Copied: head/contrib/libarchive/libarchive/test/test_xattr_platform.c (from r315875, vendor/libarchive/dist/libarchive/test/test_xattr_platform.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/contrib/libarchive/libarchive/test/test_xattr_platform.c	Fri Mar 24 00:02:12 2017	(r315876, copy of r315875, vendor/libarchive/dist/libarchive/test/test_xattr_platform.c)
@@ -0,0 +1,102 @@
+/*-
+ * Copyright (c) 2003-2010 Tim Kientzle
+ * Copyright (c) 2017 Martin Matuska
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_xattr_platform)
+{
+#if !ARCHIVE_XATTR_SUPPORT
+	skipping("Extended attributes are not supported on this platform");
+#else /* ARCHIVE_XATTR_SUPPORT */
+	struct archive *a;
+	struct archive_entry *ae;
+	const char *name;
+	const void *value;
+	size_t size, insize;
+	int e, r;
+	const char *attrname = "user.libarchive.test";
+	const char *readval = "readval";
+	const char *writeval = "writeval";
+
+	assertMakeFile("readtest", 0644, "a");
+
+	if (!setXattr("readtest", attrname, readval, strlen(readval) + 1)) {
+		skipping("Extended attributes are not supported on this "
+		    "filesystem");
+		return;
+	}
+
+	/* Read test */
+	assert(NULL != (a = archive_read_disk_new()));
+	ae = archive_entry_new();
+	assert(ae != NULL);
+	archive_entry_set_pathname(ae, "readtest");
+	assertEqualInt(ARCHIVE_OK,
+		archive_read_disk_entry_from_file(a, ae, -1, NULL));
+	e = archive_entry_xattr_reset(ae);
+	assert(e > 0);
+
+	r = 0;
+	while (archive_entry_xattr_next(ae, &name, &value,
+	    &size) == ARCHIVE_OK) {
+		if (name != NULL && value != NULL && size > 0 &&
+		    strcmp(name, attrname) == 0) {
+			failure("Attribute value does not match");
+			assertEqualString((const char *)value, readval);
+			r = 1;
+			break;
+		}
+	}
+	failure("Attribute not found: %s", attrname);
+	assertEqualInt(r, 1);
+
+	archive_entry_free(ae);
+	assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+
+	assert(NULL != (a = archive_write_disk_new()));
+	archive_write_disk_set_options(a, ARCHIVE_EXTRACT_TIME |
+	    ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_XATTR);
+
+	/* Write test */
+	ae = archive_entry_new();
+	assert(ae != NULL);
+	archive_entry_set_pathname(ae, "writetest");
+	archive_entry_set_filetype(ae, AE_IFREG);
+	archive_entry_set_perm(ae, 0654);
+	archive_entry_set_mtime(ae, 123456, 7890);
+	archive_entry_set_size(ae, 0);
+	archive_entry_xattr_add_entry(ae, attrname, writeval,
+	    strlen(writeval) + 1);
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
+	archive_entry_free(ae);
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
+
+	value = getXattr("writetest", attrname, &insize);
+	if (assertEqualInt(insize, strlen(writeval) + 1) != 0)
+		assertEqualMem(value, writeval, insize);
+#endif
+}

Modified: head/contrib/libarchive/tar/bsdtar.1
==============================================================================
--- head/contrib/libarchive/tar/bsdtar.1	Thu Mar 23 23:44:31 2017	(r315875)
+++ head/contrib/libarchive/tar/bsdtar.1	Fri Mar 24 00:02:12 2017	(r315876)
@@ -169,7 +169,7 @@ restricted pax format and bzip2 compress
 (c, r, u, x modes only)
 Archive or extract POSIX.1e or NFSv4 ACLs. This is the reverse of
 .Fl Fl no-acls
-and the default behavior in c, r, and u modes (except Mac OS X) or if
+and the default behavior in c, r, and u modes (except on Mac OS X) or if
 .Nm
 is run in x mode as root. On Mac OS X this option translates extended ACLs
 to NFSv4 ACLs. To store extended ACLs the
@@ -396,7 +396,7 @@ except it compares mtime entries instead
 Honor the nodump file flag by skipping this file.
 .It Fl Fl nopreserveHFSCompression
 (x mode only)
-Mac OS X specific(v10.6 or later). Do not compress extracted regular files
+Mac OS X specific (v10.6 or later). Do not compress extracted regular files
 which were compressed with HFS+ compression before archived.
 By default, compress the regular files again with HFS+ compression.
 .It Fl Fl null
@@ -416,7 +416,7 @@ Do not archive or extract POSIX.1e or NF
 .Fl Fl acls
 and the default behavior if
 .Nm
-is run as non-root in x mode (on Mac OS X also in c, r and u modes).
+is run as non-root in x mode (on Mac OS X as any user in c, r, u and x modes).
 .It Fl Fl no-fflags
 (c, r, u, x modes only)
 Do not archive or extract file flags. This is the reverse of

Modified: head/contrib/libarchive/tar/test/test_option_acls.c
==============================================================================
--- head/contrib/libarchive/tar/test/test_option_acls.c	Thu Mar 23 23:44:31 2017	(r315875)
+++ head/contrib/libarchive/tar/test/test_option_acls.c	Fri Mar 24 00:02:12 2017	(r315876)
@@ -25,9 +25,9 @@
 #include "test.h"
 __FBSDID("$FreeBSD$");
 
-#if HAVE_POSIX_ACL || HAVE_DARWIN_ACL
+#if ARCHIVE_ACL_FREEBSD || ARCHIVE_ACL_DARWIN || ARCHIVE_ACL_LIBACL
 static const acl_perm_t acl_perms[] = {
-#if HAVE_DARWIN_ACL
+#if ARCHIVE_ACL_DARWIN
     ACL_READ_DATA,
     ACL_LIST_DIRECTORY,
     ACL_WRITE_DATA,
@@ -46,11 +46,11 @@ static const acl_perm_t acl_perms[] = {
     ACL_WRITE_SECURITY,
     ACL_CHANGE_OWNER,
     ACL_SYNCHRONIZE
-#else /* !HAVE_DARWIN_ACL */
+#else /* !ARCHIVE_ACL_DARWIN */
     ACL_EXECUTE,
     ACL_WRITE,
     ACL_READ,
-#if HAVE_FREEBSD_NFS4_ACL
+#if ARCHIVE_ACL_FREEBSD_NFS4
     ACL_READ_DATA,
     ACL_LIST_DIRECTORY,
     ACL_WRITE_DATA,
@@ -67,18 +67,18 @@ static const acl_perm_t acl_perms[] = {
     ACL_WRITE_ACL,
     ACL_WRITE_OWNER,
     ACL_SYNCHRONIZE
-#endif	/* HAVE_FREEBSD_NFS4_ACL */
-#endif /* !HAVE_DARWIN_ACL */
+#endif	/* ARCHIVE_ACL_FREEBSD_NFS4 */
+#endif /* !ARCHIVE_ACL_DARWIN */
 };
-#if HAVE_DARWIN_ACL || HAVE_FREEBSD_NFS4_ACL
+#if ARCHIVE_ACL_DARWIN || ARCHIVE_ACL_FREEBSD_NFS4
 static const acl_flag_t acl_flags[] = {
-#if HAVE_DARWIN_ACL
+#if ARCHIVE_ACL_DARWIN
     ACL_ENTRY_INHERITED,
     ACL_ENTRY_FILE_INHERIT,
     ACL_ENTRY_DIRECTORY_INHERIT,
     ACL_ENTRY_LIMIT_INHERIT,
     ACL_ENTRY_ONLY_INHERIT
-#else	/* HAVE_FREEBSD_NFS4_ACL */
+#else	/* ARCHIVE_ACL_FREEBSD_NFS4 */
     ACL_ENTRY_FILE_INHERIT,
     ACL_ENTRY_DIRECTORY_INHERIT,
     ACL_ENTRY_NO_PROPAGATE_INHERIT,
@@ -86,9 +86,9 @@ static const acl_flag_t acl_flags[] = {
     ACL_ENTRY_SUCCESSFUL_ACCESS,
     ACL_ENTRY_FAILED_ACCESS,
     ACL_ENTRY_INHERITED
-#endif	/* HAVE_FREEBSD_NFS4_ACL */
+#endif	/* ARCHIVE_ACL_FREEBSD_NFS4 */
 };
-#endif /* HAVE_DARWIN_ACL || HAVE_FREEBSD_NFS4_ACL */
+#endif /* ARCHIVE_ACL_DARWIN || ARCHIVE_ACL_FREEBSD_NFS4 */
 
 /*
  * Compare two ACL entries on FreeBSD or on Mac OS X
@@ -100,10 +100,10 @@ compare_acl_entry(acl_entry_t ae_a, acl_
 	acl_permset_t permset_a, permset_b;
 	int perm_a, perm_b, perm_start, perm_end;
 	void *qual_a, *qual_b;
-#if HAVE_FREEBSD_NFS4_ACL
+#if ARCHIVE_ACL_FREEBSD_NFS4
 	acl_entry_type_t type_a, type_b;
 #endif
-#if HAVE_FREEBSD_NFS4_ACL || HAVE_DARWIN_ACL
+#if ARCHIVE_ACL_FREEBSD_NFS4 || ARCHIVE_ACL_DARWIN
 	acl_flagset_t flagset_a, flagset_b;
 	int flag_a, flag_b;
 #endif
@@ -123,7 +123,7 @@ compare_acl_entry(acl_entry_t ae_a, acl_
 		return (0);
 
 	/* Compare ACL qualifier */
-#if HAVE_DARWIN_ACL
+#if ARCHIVE_ACL_DARWIN
 	if (tag_a == ACL_EXTENDED_ALLOW || tag_b == ACL_EXTENDED_DENY)
 #else
 	if (tag_a == ACL_USER || tag_a == ACL_GROUP)
@@ -139,7 +139,7 @@ compare_acl_entry(acl_entry_t ae_a, acl_
 			acl_free(qual_a);
 			return (-1);
 		}
-#if HAVE_DARWIN_ACL
+#if ARCHIVE_ACL_DARWIN
 		if (memcmp(((guid_t *)qual_a)->g_guid,
 		    ((guid_t *)qual_b)->g_guid, KAUTH_GUID_SIZE) != 0)
 #else
@@ -157,7 +157,7 @@ compare_acl_entry(acl_entry_t ae_a, acl_
 		acl_free(qual_b);
 	}
 
-#if HAVE_FREEBSD_NFS4_ACL
+#if ARCHIVE_ACL_FREEBSD_NFS4
 	if (is_nfs4) {
 		/* Compare NFS4 ACL type */
 		r = acl_get_entry_type_np(ae_a, &type_a);
@@ -185,7 +185,7 @@ compare_acl_entry(acl_entry_t ae_a, acl_
 
 	perm_start = 0;
 	perm_end = (int)(sizeof(acl_perms) / sizeof(acl_perms[0]));
-#if HAVE_FREEBSD_NFS4_ACL
+#if ARCHIVE_ACL_FREEBSD_NFS4
 	if (is_nfs4)
 		perm_start = 3;
 	else
@@ -193,7 +193,7 @@ compare_acl_entry(acl_entry_t ae_a, acl_
 #endif
 	/* Cycle through all perms and compare their value */
 	for (i = perm_start; i < perm_end; i++) {
-#if HAVE_LIBACL
+#if ARCHIVE_ACL_LIBACL
 		perm_a = acl_get_perm(permset_a, acl_perms[i]);
 		perm_b = acl_get_perm(permset_b, acl_perms[i]);
 #else
@@ -206,7 +206,7 @@ compare_acl_entry(acl_entry_t ae_a, acl_
 			return (0);
 	}
 
-#if HAVE_FREEBSD_NFS4_ACL || HAVE_DARWIN_ACL
+#if ARCHIVE_ACL_FREEBSD_NFS4 || ARCHIVE_ACL_DARWIN
 	if (is_nfs4) {
 		r = acl_get_flagset_np(ae_a, &flagset_a);
 		failure("acl_get_flagset_np() error: %s", strerror(errno));
@@ -227,14 +227,14 @@ compare_acl_entry(acl_entry_t ae_a, acl_
 				return (0);
 		}
 	}
-#else	/* HAVE_FREEBSD_NFS4_ACL || HAVE_DARWIN_ACL*/
+#else	/* ARCHIVE_ACL_FREEBSD_NFS4 || ARCHIVE_ACL_DARWIN */
 	(void)is_nfs4;	/* UNUSED */
 #endif
 	return (1);
 }
-#endif	/* HAVE_POSIX_ACL || HAVE_DARWIN_ACL */
+#endif	/* ARCHIVE_ACL_FREEBSD || ARCHIVE_ACL_DARWIN || ARCHIVE_ACL_LIBACL */
 
-#if HAVE_SUN_ACL || HAVE_DARWIN_ACL || HAVE_POSIX_ACL
+#if ARCHIVE_ACL_SUPPORT
 /*
  * Clear default ACLs or inheritance flags
  */
@@ -243,15 +243,17 @@ clear_inheritance_flags(const char *path
 {
 	switch (type) {
 	case ARCHIVE_TEST_ACL_TYPE_POSIX1E:
-#if HAVE_POSIX_ACL
+#if ARCHIVE_ACL_POSIX1E
+#if !ARCHIVE_ACL_SUNOS
 		acl_delete_def_file(path);
 #else
 		/* Solaris */
 		setTestAcl(path);
 #endif
+#endif	/* ARCHIVE_ACL_POSIX1E */
 		break;
 	case ARCHIVE_TEST_ACL_TYPE_NFS4:
-#if HAVE_NFS4_ACL
+#if ARCHIVE_ACL_NFS4
 		setTestAcl(path);
 #endif
 		break;
@@ -266,31 +268,40 @@ compare_acls(const char *path_a, const c
 {
 	int ret = 1;
 	int is_nfs4 = 0;
-#if HAVE_SUN_ACL
+#if ARCHIVE_ACL_SUNOS
 	void *acl_a, *acl_b;
 	int aclcnt_a, aclcnt_b;
         aclent_t *aclent_a, *aclent_b;
         ace_t *ace_a, *ace_b;
 	int e;
-#else
+#elif ARCHIVE_ACL_DARWIN || ARCHIVE_ACL_FREEBSD || ARCHIVE_ACL_LIBACL
 	acl_t acl_a, acl_b;
 	acl_entry_t aclent_a, aclent_b;
 	int a, b, r;
 #endif
+#if ARCHIVE_ACL_LIBRICHACL
+	struct richacl *richacl_a, *richacl_b;
+
+	richacl_a = NULL;
+	richacl_b = NULL;
+#endif
 
+#if ARCHIVE_ACL_DARWIN || ARCHIVE_ACL_FREEBSD || ARCHIVE_ACL_LIBACL || \
+    ARCHIVE_ACL_SUNOS
 	acl_a = NULL;
 	acl_b = NULL;
-#if HAVE_SUN_ACL
+#endif
+#if ARCHIVE_ACL_SUNOS
 	acl_a = sunacl_get(GETACL, &aclcnt_a, 0, path_a);
 	if (acl_a == NULL) {
-#if HAVE_SUN_NFS4_ACL
+#if ARCHIVE_ACL_SUNOS_NFS4
 		is_nfs4 = 1;
 		acl_a = sunacl_get(ACE_GETACL, &aclcnt_a, 0, path_a);
 #endif
 		failure("acl_get() error: %s", strerror(errno));
 		if (assert(acl_a != NULL) == 0)
 			return (-1);
-#if HAVE_SUN_NFS4_ACL
+#if ARCHIVE_ACL_SUNOS_NFS4
 		acl_b = sunacl_get(ACE_GETACL, &aclcnt_b, 0, path_b);
 #endif
 	} else
@@ -321,7 +332,7 @@ compare_acls(const char *path_a, const c
 				goto exit_free;
 			}
 		}
-#if HAVE_SUN_NFS4_ACL
+#if ARCHIVE_ACL_SUNOS_NFS4
 		else {
 			ace_a = &((ace_t *)acl_a)[e];
 			ace_b = &((ace_t *)acl_b)[e];
@@ -335,30 +346,57 @@ compare_acls(const char *path_a, const c
 		}
 #endif
 	}
-#else	/* !HAVE_SUN_ACL */
-#if HAVE_DARWIN_ACL
+#else	/* !ARCHIVE_ACL_SUNOS */
+#if ARCHIVE_ACL_LIBRICHACL
+	richacl_a = richacl_get_file(path_a);
+#if !ARCHIVE_ACL_LIBACL
+	if (richacl_a == NULL &&
+	    (errno == ENODATA || errno == ENOTSUP || errno == ENOSYS))
+		return (0);
+	failure("richacl_get_file() error: %s (%s)", path_a, strerror(errno));
+	if (assert(richacl_a != NULL) == 0)
+		return (-1);
+#endif
+	if (richacl_a != NULL) {
+		richacl_b = richacl_get_file(path_b);
+		if (richacl_b == NULL &&
+		    (errno == ENODATA || errno == ENOTSUP || errno == ENOSYS))
+			return (0);
+		failure("richacl_get_file() error: %s (%s)", path_b,
+		    strerror(errno));
+		if (assert(richacl_b != NULL) == 0) {
+			richacl_free(richacl_a);
+			return (-1);
+		}
+		if (richacl_compare(richacl_a, richacl_b) == 0)
+			ret = 0;
+		richacl_free(richacl_a);
+		richacl_free(richacl_b);
+		return (ret);
+        }
+#endif /* ARCHIVE_ACL_LIBRICHACL */
+#if ARCHIVE_ACL_DARWIN || ARCHIVE_ACL_FREEBSD || ARCHIVE_ACL_LIBACL
+#if ARCHIVE_ACL_DARWIN
 	is_nfs4 = 1;
 	acl_a = acl_get_file(path_a, ACL_TYPE_EXTENDED);
-#elif HAVE_FREEBSD_NFS4_ACL
+#elif ARCHIVE_ACL_FREEBSD_NFS4
 	acl_a = acl_get_file(path_a, ACL_TYPE_NFS4);
 	if (acl_a != NULL)
 		is_nfs4 = 1;
 #endif
-#if !HAVE_DARWIN_ACL
 	if (acl_a == NULL)
 		acl_a = acl_get_file(path_a, ACL_TYPE_ACCESS);
-#endif
 	failure("acl_get_file() error: %s (%s)", path_a, strerror(errno));
 	if (assert(acl_a != NULL) == 0)
 		return (-1);
-#if HAVE_DARWIN_ACL
+#if ARCHIVE_ACL_DARWIN
 	acl_b = acl_get_file(path_b, ACL_TYPE_EXTENDED);
-#elif HAVE_FREEBSD_NFS4_ACL
+#elif ARCHIVE_ACL_FREEBSD_NFS4
 	acl_b = acl_get_file(path_b, ACL_TYPE_NFS4);
 #endif
-#if !HAVE_DARWIN_ACL
+#if !ARCHIVE_ACL_DARWIN
 	if (acl_b == NULL) {
-#if HAVE_FREEBSD_NFS4_ACL
+#if ARCHIVE_ACL_FREEBSD_NFS4
 		if (is_nfs4) {
 			acl_free(acl_a);
 			return (0);
@@ -382,7 +420,7 @@ compare_acls(const char *path_a, const c
 		ret = 0;
 		goto exit_free;
 	}
-#if HAVE_DARWIN_ACL
+#if ARCHIVE_ACL_DARWIN
 	while (a == 0 && b == 0)
 #else	/* FreeBSD, Linux */
 	while (a == 1 && b == 1)
@@ -399,9 +437,10 @@ compare_acls(const char *path_a, const c
 	/* Entry count must match */
 	if (a != b)
 		ret = 0;
-#endif	/* !HAVE_SUN_ACL */
+#endif	/* ARCHIVE_ACL_DARWIN || ARCHIVE_ACL_FREEBSD || ARCHIVE_ACL_LIBACL */
+#endif	/* !ARCHIVE_ACL_SUNOS */
 exit_free:
-#if HAVE_SUN_ACL
+#if ARCHIVE_ACL_SUNOS
 	free(acl_a);
 	free(acl_b);
 #else
@@ -410,13 +449,13 @@ exit_free:
 #endif
 	return (ret);
 }
-#endif	/* HAVE_SUN_ACL || HAVE_DARWIN_ACL || HAVE_POSIX_ACL */
+#endif	/* ARCHIVE_ACL_SUPPORT */
 
 DEFINE_TEST(test_option_acls)
 {
-#if !HAVE_SUN_ACL && !HAVE_DARWIN_ACL && !HAVE_POSIX_ACL
+#if !ARCHIVE_ACL_SUPPORT
         skipping("ACLs are not supported on this platform");
-#else   /* HAVE_SUN_ACL || HAVE_DARWIN_ACL || HAVE_POSIX_ACL */
+#else   /* ARCHIVE_ACL_SUPPORT */
 	int acltype, r;
 
 	assertMakeFile("f", 0644, "a");
@@ -465,5 +504,5 @@ DEFINE_TEST(test_option_acls)
 	assertEqualInt(r, 0);
 	r = compare_acls("f", "noacls_noacls/f");
 	assertEqualInt(r, 0);
-#endif	/* HAVE_SUN_ACL || HAVE_DARWIN_ACL || HAVE_POSIX_ACL */
+#endif	/* ARCHIVE_ACL_SUPPORT */
 }

Copied: head/contrib/libarchive/tar/test/test_option_xattrs.c (from r315875, vendor/libarchive/dist/tar/test/test_option_xattrs.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/contrib/libarchive/tar/test/test_option_xattrs.c	Fri Mar 24 00:02:12 2017	(r315876, copy of r315875, vendor/libarchive/dist/tar/test/test_option_xattrs.c)
@@ -0,0 +1,87 @@
+/*-
+ * Copyright (c) 2017 Martin Matuska
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_option_xattrs)
+{
+#if !ARCHIVE_XATTR_SUPPORT
+        skipping("Extended atributes are not supported on this platform");
+#else	/* ARCHIVE_XATTR_SUPPORT */
+
+	const char *testattr = "user.libarchive.test";
+	const char *testval = "testval";
+	const void *readval;
+	size_t size;
+	int r;
+
+	/* Create a file. */
+	assertMakeFile("f", 0644, "a");
+
+	if (!setXattr("f", "user.libarchive.test", testval,
+	    strlen(testval) + 1)) {
+		skipping("Can't set user extended attributes on this "
+		    "filesystem");
+		return;
+	}
+
+	/* Archive with xattrs */
+	r = systemf("%s -c --no-mac-metadata --xattrs -f xattrs.tar f >xattrs.out 2>xattrs.err", testprog);
+	assertEqualInt(r, 0);
+
+	/* Archive without xattrs */
+	r = systemf("%s -c --no-mac-metadata --no-xattrs -f noxattrs.tar f >noxattrs.out 2>noxattrs.err", testprog);
+	assertEqualInt(r, 0);
+
+	/* Extract xattrs with xattrs */
+	assertMakeDir("xattrs_xattrs", 0755);
+	r = systemf("%s -x -C xattrs_xattrs --no-same-permissions --xattrs -f xattrs.tar >xattrs_xattrs.out 2>xattrs_xattrs.err", testprog);
+	assertEqualInt(r, 0);
+	readval = getXattr("xattrs_xattrs/f", testattr, &size);
+	if(assertEqualInt(size, strlen(testval) + 1) != 0)
+		assertEqualMem(readval, testval, size);
+
+	/* Extract xattrs without xattrs */
+	assertMakeDir("xattrs_noxattrs", 0755);
+	r = systemf("%s -x -C xattrs_noxattrs -p --no-xattrs -f xattrs.tar >xattrs_noxattrs.out 2>xattrs_noxattrs.err", testprog);
+	assertEqualInt(r, 0);
+	readval = getXattr("xattrs_noxattrs/f", testattr, &size);
+	assert(readval == NULL);
+
+	/* Extract noxattrs with xattrs */
+	assertMakeDir("noxattrs_xattrs", 0755);
+	r = systemf("%s -x -C noxattrs_xattrs --no-same-permissions --xattrs -f noxattrs.tar >noxattrs_xattrs.out 2>noxattrs_xattrs.err", testprog);
+	assertEqualInt(r, 0);	
+	readval = getXattr("noxattrs_xattrs/f", testattr, &size);
+	assert(readval == NULL);
+
+	/* Extract noxattrs with noxattrs */
+	assertMakeDir("noxattrs_noxattrs", 0755);
+	r = systemf("%s -x -C noxattrs_noxattrs -p --no-xattrs -f noxattrs.tar >noxattrs_noxattrs.out 2>noxattrs_noxattrs.err", testprog);
+	assertEqualInt(r, 0);
+	readval = getXattr("noxattrs_noxattrs/f", testattr, &size);
+	assert(readval == NULL);
+#endif	/* ARCHIVE_XATTR_SUPPORT */
+}

Modified: head/contrib/libarchive/test_utils/test_common.h
==============================================================================
--- head/contrib/libarchive/test_utils/test_common.h	Thu Mar 23 23:44:31 2017	(r315875)
+++ head/contrib/libarchive/test_utils/test_common.h	Fri Mar 24 00:02:12 2017	(r315876)
@@ -79,6 +79,9 @@
 #ifdef HAVE_SYS_ACL_H
 #include <sys/acl.h>
 #endif
+#ifdef HAVE_SYS_RICHACL_H
+#include <sys/richacl.h>
+#endif
 #ifdef HAVE_WINDOWS_H
 #include <windows.h>
 #endif
@@ -131,6 +134,7 @@
 #define	ARCHIVE_TEST_ACL_TYPE_POSIX1E	1
 #define	ARCHIVE_TEST_ACL_TYPE_NFS4	2
 
+#include "archive_platform_xattr.h"
 
 /*
  * Redefine DEFINE_TEST for use in defining the test functions.
@@ -343,6 +347,12 @@ int canNodump(void);
 /* Set test ACLs */
 int setTestAcl(const char *path);
 
+/* Get extended attribute */
+const void *getXattr(const char *, const char *, size_t *);
+
+/* Set extended attribute */
+int setXattr(const char *, const char *, const void *, size_t);
+
 /* Return true if the file has large i-node number(>0xffffffff). */
 int is_LargeInode(const char *);
 

Modified: head/contrib/libarchive/test_utils/test_main.c
==============================================================================
--- head/contrib/libarchive/test_utils/test_main.c	Thu Mar 23 23:44:31 2017	(r315875)
+++ head/contrib/libarchive/test_utils/test_main.c	Fri Mar 24 00:02:12 2017	(r315876)
@@ -67,6 +67,17 @@
 #ifdef HAVE_SYS_ACL_H
 #include <sys/acl.h>
 #endif
+#ifdef HAVE_SYS_EA_H
+#include <sys/ea.h>
+#endif
+#ifdef HAVE_SYS_EXTATTR_H
+#include <sys/extattr.h>
+#endif
+#if HAVE_SYS_XATTR_H
+#include <sys/xattr.h>
+#elif HAVE_ATTR_XATTR_H
+#include <attr/xattr.h>
+#endif
 #ifdef HAVE_SYS_RICHACL_H
 #include <sys/richacl.h>
 #endif
@@ -2440,6 +2451,83 @@ canNodump(void)
 	return (0);
 }
 
+/* Get extended attribute from a path */
+const void *
+getXattr(const char *path, const char *name, size_t *sizep)
+{ 
+	void *value = NULL;
+#if ARCHIVE_XATTR_SUPPORT
+	ssize_t size;
+#if ARCHIVE_XATTR_LINUX
+	size = lgetxattr(path, name, NULL, 0);
+#elif ARCHIVE_XATTR_DARWIN
+	size = getxattr(path, name, NULL, 0, 0, XATTR_NOFOLLOW);
+#elif ARCHIVE_XATTR_AIX
+	size = lgetea(path, name, NULL, 0);
+#elif ARCHIVE_XATTR_FREEBSD
+	size = extattr_get_link(path, EXTATTR_NAMESPACE_USER, name + 5,
+	    NULL, 0);
+#endif
+
+	if (size >= 0) {

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703240002.v2O02CK1085189>