svn commit: r305431 - in projects/clang390-import: contrib/gcclibs/libcpp contrib/libarchive contrib/libarchive/libarchive contrib/libarchive/libarchive/test contrib/top lib/libarchive lib/libc/std...

Dimitry Andric dim at FreeBSD.org
Mon Sep 5 18:05:48 UTC 2016


Author: dim
Date: Mon Sep  5 18:05:45 2016
New Revision: 305431
URL: https://svnweb.freebsd.org/changeset/base/305431

Log:
  Merge ^/head r305397 through r305430.

Added:
  projects/clang390-import/contrib/libarchive/README.md
     - copied unchanged from r305430, head/contrib/libarchive/README.md
  projects/clang390-import/sys/dev/bhnd/cores/usb/
     - copied from r305430, head/sys/dev/bhnd/cores/usb/
  projects/clang390-import/sys/dev/iicbus/sy8106a.c
     - copied unchanged from r305430, head/sys/dev/iicbus/sy8106a.c
Deleted:
  projects/clang390-import/contrib/libarchive/README
Modified:
  projects/clang390-import/contrib/gcclibs/libcpp/system.h
  projects/clang390-import/contrib/libarchive/libarchive/archive_acl.c
  projects/clang390-import/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c
  projects/clang390-import/contrib/libarchive/libarchive/archive_read_disk_posix.c
  projects/clang390-import/contrib/libarchive/libarchive/test/test_acl_freebsd_posix1e.c
  projects/clang390-import/contrib/top/commands.c
  projects/clang390-import/contrib/top/machine.h
  projects/clang390-import/contrib/top/top.c
  projects/clang390-import/contrib/top/top.xs
  projects/clang390-import/lib/libarchive/config_freebsd.h
  projects/clang390-import/lib/libc/stdio/fgets.c
  projects/clang390-import/lib/libc/stdio/fgetws.c
  projects/clang390-import/sys/arm/allwinner/aw_thermal.c
  projects/clang390-import/sys/arm/allwinner/clk/aw_pll.c
  projects/clang390-import/sys/arm/allwinner/clk/aw_thsclk.c
  projects/clang390-import/sys/arm/allwinner/files.allwinner
  projects/clang390-import/sys/arm/arm/minidump_machdep.c
  projects/clang390-import/sys/arm/conf/ALLWINNER
  projects/clang390-import/sys/boot/fdt/dts/arm64/a64.dtsi
  projects/clang390-import/sys/dev/hyperv/netvsc/hv_net_vsc.c
  projects/clang390-import/sys/dev/hyperv/netvsc/hv_rndis_filter.c
  projects/clang390-import/sys/dev/hyperv/netvsc/hv_rndis_filter.h
  projects/clang390-import/sys/dev/hyperv/vmbus/vmbus_chan.c
  projects/clang390-import/sys/dev/hyperv/vmbus/vmbus_reg.h
  projects/clang390-import/sys/dev/usb/template/usb_template.c
  projects/clang390-import/sys/dev/usb/usb_device.c
  projects/clang390-import/sys/dev/usb/usb_device.h
  projects/clang390-import/sys/dev/usb/usb_generic.c
  projects/clang390-import/sys/dev/usb/usb_request.c
  projects/clang390-import/sys/dev/usb/usb_transfer.c
  projects/clang390-import/sys/dev/usb/usb_util.c
  projects/clang390-import/sys/mips/broadcom/files.broadcom
  projects/clang390-import/sys/mips/conf/BCM
  projects/clang390-import/sys/net/rndis.h
  projects/clang390-import/sys/sparc64/sparc64/pmap.c
  projects/clang390-import/sys/sys/param.h
  projects/clang390-import/usr.bin/top/machine.c
  projects/clang390-import/usr.sbin/bsdinstall/partedit/gpart_ops.c
Directory Properties:
  projects/clang390-import/   (props changed)
  projects/clang390-import/contrib/libarchive/   (props changed)
  projects/clang390-import/contrib/libarchive/libarchive/   (props changed)
  projects/clang390-import/contrib/top/   (props changed)

Modified: projects/clang390-import/contrib/gcclibs/libcpp/system.h
==============================================================================
--- projects/clang390-import/contrib/gcclibs/libcpp/system.h	Mon Sep  5 18:02:37 2016	(r305430)
+++ projects/clang390-import/contrib/gcclibs/libcpp/system.h	Mon Sep  5 18:05:45 2016	(r305431)
@@ -347,9 +347,12 @@ extern void abort (void);
    ??? C99 designated initializers are not supported by most C++
    compilers, including G++.  -- gdr, 2005-05-18  */
 #if !defined(HAVE_DESIGNATED_INITIALIZERS)
-#define HAVE_DESIGNATED_INITIALIZERS \
-  ((!defined(__cplusplus) && (GCC_VERSION >= 2007)) \
-   || (__STDC_VERSION__ >= 199901L))
+# if (!defined(__cplusplus) && (GCC_VERSION >= 2007)) \
+     ||(__STDC_VERSION__ >= 199901L)
+#  define HAVE_DESIGNATED_INITIALIZERS 1
+# else
+#  define HAVE_DESIGNATED_INITIALIZERS 0
+# endif
 #endif
 
 /* Be conservative and only use enum bitfields with GCC.

Copied: projects/clang390-import/contrib/libarchive/README.md (from r305430, head/contrib/libarchive/README.md)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/clang390-import/contrib/libarchive/README.md	Mon Sep  5 18:05:45 2016	(r305431, copy of r305430, head/contrib/libarchive/README.md)
@@ -0,0 +1,222 @@
+# Welcome to libarchive!
+
+The libarchive project develops a portable, efficient C library that
+can read and write streaming archives in a variety of formats.  It
+also includes implementations of the common `tar`, `cpio`, and `zcat`
+command-line tools that use the libarchive library.
+
+## Questions?  Issues?
+
+* http://www.libarchive.org is the home for ongoing
+  libarchive development, including documentation,
+  and links to the libarchive mailing lists.
+* To report an issue, use the issue tracker at
+  https://github.com/libarchive/libarchive/issues
+* To submit an enhancement to libarchive, please
+  submit a pull request via GitHub: https://github.com/libarchive/libarchive/pulls
+
+## Contents of the Distribution
+
+This distribution bundle includes the following major components:
+
+* **libarchive**: a library for reading and writing streaming archives
+* **tar**: the 'bsdtar' program is a full-featured 'tar' implementation built on libarchive
+* **cpio**: the 'bsdcpio' program is a different interface to essentially the same functionality
+* **cat**: the 'bsdcat' program is a simple replacement tool for zcat, bzcat, xzcat, and such
+* **examples**: Some small example programs that you may find useful.
+* **examples/minitar**: a compact sample demonstrating use of libarchive.
+* **contrib**:  Various items sent to me by third parties; please contact the authors with any questions.
+
+The top-level directory contains the following information files:
+
+* **NEWS** - highlights of recent changes
+* **COPYING** - what you can do with this
+* **INSTALL** - installation instructions
+* **README** - this file
+* **CMakeLists.txt** - input for "cmake" build tool, see INSTALL
+* **configure** - configuration script, see INSTALL for details.  If your copy of the source lacks a `configure` script, you can try to construct it by running the script in `build/autogen.sh` (or use `cmake`).
+
+The following files in the top-level directory are used by the 'configure' script:
+* `Makefile.am`, `aclocal.m4`, `configure.ac` - used to build this distribution, only needed by maintainers
+* `Makefile.in`, `config.h.in` - templates used by configure script
+
+## Documentation
+
+In addition to the informational articles and documentation
+in the online [libarchive Wiki](https://github.com/libarchive/libarchive/wiki),
+the distribution also includes a number of manual pages:
+
+ * bsdtar.1 explains the use of the bsdtar program
+ * bsdcpio.1 explains the use of the bsdcpio program
+ * bsdcat.1 explains the use of the bsdcat program
+ * libarchive.3 gives an overview of the library as a whole
+ * archive_read.3, archive_write.3, archive_write_disk.3, and
+   archive_read_disk.3 provide detailed calling sequences for the read
+   and write APIs
+ * archive_entry.3 details the "struct archive_entry" utility class
+ * archive_internals.3 provides some insight into libarchive's
+   internal structure and operation.
+ * libarchive-formats.5 documents the file formats supported by the library
+ * cpio.5, mtree.5, and tar.5 provide detailed information about these
+   popular archive formats, including hard-to-find details about
+   modern cpio and tar variants.
+
+The manual pages above are provided in the 'doc' directory in
+a number of different formats.
+
+You should also read the copious comments in `archive.h` and the
+source code for the sample programs for more details.  Please let us
+know about any errors or omissions you find.
+
+## Supported Formats
+
+Currently, the library automatically detects and reads the following fomats:
+  * Old V7 tar archives
+  * POSIX ustar
+  * GNU tar format (including GNU long filenames, long link names, and sparse files)
+  * Solaris 9 extended tar format (including ACLs)
+  * POSIX pax interchange format
+  * POSIX octet-oriented cpio
+  * SVR4 ASCII cpio
+  * POSIX octet-oriented cpio
+  * Binary cpio (big-endian or little-endian)
+  * ISO9660 CD-ROM images (with optional Rockridge or Joliet extensions)
+  * ZIP archives (with uncompressed or "deflate" compressed entries, including support for encrypted Zip archives)
+  * GNU and BSD 'ar' archives
+  * 'mtree' format
+  * 7-Zip archives
+  * Microsoft CAB format
+  * LHA and LZH archives
+  * RAR archives (with some limitations due to RAR's proprietary status)
+  * XAR archives
+
+The library also detects and handles any of the following before evaluating the archive:
+  * uuencoded files
+  * files with RPM wrapper
+  * gzip compression
+  * bzip2 compression
+  * compress/LZW compression
+  * lzma, lzip, and xz compression
+  * lz4 compression
+  * lzop compression
+
+The library can create archives in any of the following formats:
+  * POSIX ustar
+  * POSIX pax interchange format
+  * "restricted" pax format, which will create ustar archives except for
+    entries that require pax extensions (for long filenames, ACLs, etc).
+  * Old GNU tar format
+  * Old V7 tar format
+  * POSIX octet-oriented cpio
+  * SVR4 "newc" cpio
+  * shar archives
+  * ZIP archives (with uncompressed or "deflate" compressed entries)
+  * GNU and BSD 'ar' archives
+  * 'mtree' format
+  * ISO9660 format
+  * 7-Zip archives
+  * XAR archives
+
+When creating archives, the result can be filtered with any of the following:
+  * uuencode
+  * gzip compression
+  * bzip2 compression
+  * compress/LZW compression
+  * lzma, lzip, and xz compression
+  * lz4 compression
+  * lzop compression
+
+## Notes about the Library Design
+
+The following notes address many of the most common
+questions we are asked about libarchive:
+
+* This is a heavily stream-oriented system.  That means that
+  it is optimized to read or write the archive in a single
+  pass from beginning to end.  For example, this allows
+  libarchive to process archives too large to store on disk
+  by processing them on-the-fly as they are read from or
+  written to a network or tape drive.  This also makes
+  libarchive useful for tools that need to produce
+  archives on-the-fly (such as webservers that provide
+  archived contents of a users account).
+
+* In-place modification and random access to the contents
+  of an archive are not directly supported.  For some formats,
+  this is not an issue: For example, tar.gz archives are not
+  designed for random access.  In some other cases, libarchive
+  can re-open an archive and scan it from the beginning quickly
+  enough to provide the needed abilities even without true
+  random access.  Of course, some applications do require true
+  random access; those applications should consider alternatives
+  to libarchive.
+
+* The library is designed to be extended with new compression and
+  archive formats.  The only requirement is that the format be
+  readable or writable as a stream and that each archive entry be
+  independent.  There are articles on the libarchive Wiki explaining
+  how to extend libarchive.
+
+* On read, compression and format are always detected automatically.
+
+* The same API is used for all formats; in particular, it's very
+  easy for software using libarchive to transparently handle
+  any of libarchive's archiving formats.
+
+* Libarchive's automatic support for decompression can be used
+  without archiving by explicitly selecting the "raw" and "empty"
+  formats.
+
+* I've attempted to minimize static link pollution.  If you don't
+  explicitly invoke a particular feature (such as support for a
+  particular compression or format), it won't get pulled in to
+  statically-linked programs.  In particular, if you don't explicitly
+  enable a particular compression or decompression support, you won't
+  need to link against the corresponding compression or decompression
+  libraries.  This also reduces the size of statically-linked
+  binaries in environments where that matters.
+
+* The library is generally _thread safe_ depending on the platform:
+  it does not define any global variables of its own.  However, some
+  platforms do not provide fully thread-safe versions of key C library
+  functions.  On those platforms, libarchive will use the non-thread-safe
+  functions.  Patches to improve this are of great interest to us.
+
+* In particular, libarchive's modules to read or write a directory
+  tree do use `chdir()` to optimize the directory traversals.  This
+  can cause problems for programs that expect to do disk access from
+  multiple threads.  Of course, those modules are completely
+  optional and you can use the rest of libarchive without them.
+
+* The library is _not_ thread aware, however.  It does no locking
+  or thread management of any kind.  If you create a libarchive
+  object and need to access it from multiple threads, you will
+  need to provide your own locking.
+
+* On read, the library accepts whatever blocks you hand it.
+  Your read callback is free to pass the library a byte at a time
+  or mmap the entire archive and give it to the library at once.
+  On write, the library always produces correctly-blocked output.
+
+* The object-style approach allows you to have multiple archive streams
+  open at once.  bsdtar uses this in its "@archive" extension.
+
+* The archive itself is read/written using callback functions.
+  You can read an archive directly from an in-memory buffer or
+  write it to a socket, if you wish.  There are some utility
+  functions to provide easy-to-use "open file," etc, capabilities.
+
+* The read/write APIs are designed to allow individual entries
+  to be read or written to any data source:  You can create
+  a block of data in memory and add it to a tar archive without
+  first writing a temporary file.  You can also read an entry from
+  an archive and write the data directly to a socket.  If you want
+  to read/write entries to disk, there are convenience functions to
+  make this especially easy.
+
+* Note: The "pax interchange format" is a POSIX standard extended tar
+  format that should be used when the older _ustar_ format is not
+  appropriate.  It has many advantages over other tar formats
+  (including the legacy GNU tar format) and is widely supported by
+  current tar implementations.
+

Modified: projects/clang390-import/contrib/libarchive/libarchive/archive_acl.c
==============================================================================
--- projects/clang390-import/contrib/libarchive/libarchive/archive_acl.c	Mon Sep  5 18:02:37 2016	(r305430)
+++ projects/clang390-import/contrib/libarchive/libarchive/archive_acl.c	Mon Sep  5 18:05:45 2016	(r305431)
@@ -707,10 +707,11 @@ archive_acl_text_l(struct archive_acl *a
 			if (r != 0)
 				return (-1);
 			*p++ = separator;
-			if (flags & ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID)
+			if (name == NULL || (flags & ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID)) {
 				id = ap->id;
-			else
+			} else {
 				id = -1;
+			}
 			append_entry(&p, NULL, ap->tag, name,
 			    ap->permset, id);
 			count++;

Modified: projects/clang390-import/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c
==============================================================================
--- projects/clang390-import/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c	Mon Sep  5 18:02:37 2016	(r305430)
+++ projects/clang390-import/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c	Mon Sep  5 18:05:45 2016	(r305431)
@@ -419,12 +419,32 @@ setup_acls(struct archive_read_disk *a,
 	if (accpath == NULL)
 		accpath = archive_entry_pathname(entry);
 
+	if (*fd < 0 && a->tree != NULL) {
+		if (a->follow_symlinks ||
+		    archive_entry_filetype(entry) != AE_IFLNK)
+			*fd = a->open_on_current_dir(a->tree,
+			    accpath, O_RDONLY | O_NONBLOCK);
+		if (*fd < 0) {
+			if (a->tree_enter_working_dir(a->tree) != 0) {
+				archive_set_error(&a->archive, errno,
+				    "Couldn't access %s", accpath);
+				return (ARCHIVE_FAILED);
+			}
+		}
+	}
+
 	archive_entry_acl_clear(entry);
 
+	acl = NULL;
+
 #ifdef ACL_TYPE_NFS4
 	/* Try NFS4 ACL first. */
 	if (*fd >= 0)
+#if HAVE_ACL_GET_FD_NP
+		acl = acl_get_fd_np(*fd, ACL_TYPE_NFS4);
+#else
 		acl = acl_get_fd(*fd);
+#endif
 #if HAVE_ACL_GET_LINK_NP
 	else if (!a->follow_symlinks)
 		acl = acl_get_link_np(accpath, ACL_TYPE_NFS4);
@@ -437,12 +457,19 @@ setup_acls(struct archive_read_disk *a,
 #endif
 	else
 		acl = acl_get_file(accpath, ACL_TYPE_NFS4);
+
 #if HAVE_ACL_IS_TRIVIAL_NP
-	/* Ignore "trivial" ACLs that just mirror the file mode. */
-	acl_is_trivial_np(acl, &r);
-	if (r) {
-		acl_free(acl);
-		acl = NULL;
+	if (acl != NULL && acl_is_trivial_np(acl, &r) == 0) {
+		/* Ignore "trivial" ACLs that just mirror the file mode. */
+		if (r) {
+			acl_free(acl);
+			acl = NULL;
+			/*
+			 * Simultaneous NFSv4 and POSIX.1e ACLs for the same
+			 * entry are not allowed, so we should return here
+			 */
+			return (ARCHIVE_OK);
+		}
 	}
 #endif
 	if (acl != NULL) {
@@ -450,7 +477,7 @@ setup_acls(struct archive_read_disk *a,
 		acl_free(acl);
 		return (ARCHIVE_OK);
 	}
-#endif
+#endif	/* ACL_TYPE_NFS4 */
 
 	/* Retrieve access ACL from file. */
 	if (*fd >= 0)
@@ -467,10 +494,22 @@ setup_acls(struct archive_read_disk *a,
 #endif
 	else
 		acl = acl_get_file(accpath, ACL_TYPE_ACCESS);
+
+#if HAVE_ACL_IS_TRIVIAL_NP
+	/* Ignore "trivial" ACLs that just mirror the file mode. */
+	if (acl != NULL && acl_is_trivial_np(acl, &r) == 0) {
+		if (r) {
+			acl_free(acl);
+			acl = NULL;
+		}
+	}
+#endif
+
 	if (acl != NULL) {
 		translate_acl(a, entry, acl,
 		    ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
 		acl_free(acl);
+		acl = NULL;
 	}
 
 	/* Only directories can have default ACLs. */

Modified: projects/clang390-import/contrib/libarchive/libarchive/archive_read_disk_posix.c
==============================================================================
--- projects/clang390-import/contrib/libarchive/libarchive/archive_read_disk_posix.c	Mon Sep  5 18:02:37 2016	(r305430)
+++ projects/clang390-import/contrib/libarchive/libarchive/archive_read_disk_posix.c	Mon Sep  5 18:05:45 2016	(r305431)
@@ -1504,10 +1504,19 @@ setup_current_filesystem(struct archive_
 	struct tree *t = a->tree;
 	struct statfs sfs;
 #if defined(HAVE_GETVFSBYNAME) && defined(VFCF_SYNTHETIC)
-#  if defined(HAVE_STRUCT_VFSCONF)
-	struct vfsconf vfc;
-#  else
+/* TODO: configure should set GETVFSBYNAME_ARG_TYPE to make
+ * this accurate; some platforms have both and we need the one that's
+ * used by getvfsbyname()
+ *
+ * Then the following would become:
+ *  #if defined(GETVFSBYNAME_ARG_TYPE)
+ *   GETVFSBYNAME_ARG_TYPE vfc;
+ *  #endif
+ */
+#  if defined(HAVE_STRUCT_XVFSCONF)
 	struct xvfsconf vfc;
+#  else
+	struct vfsconf vfc;
 #  endif
 #endif
 	int r, xr = 0;

Modified: projects/clang390-import/contrib/libarchive/libarchive/test/test_acl_freebsd_posix1e.c
==============================================================================
--- projects/clang390-import/contrib/libarchive/libarchive/test/test_acl_freebsd_posix1e.c	Mon Sep  5 18:02:37 2016	(r305430)
+++ projects/clang390-import/contrib/libarchive/libarchive/test/test_acl_freebsd_posix1e.c	Mon Sep  5 18:05:45 2016	(r305431)
@@ -70,15 +70,9 @@ set_acls(struct archive_entry *ae, struc
 }
 
 static int
-acl_match(acl_entry_t aclent, struct myacl_t *myacl)
-{
-	gid_t g, *gp;
-	uid_t u, *up;
-	acl_tag_t tag_type;
-	acl_permset_t opaque_ps;
+acl_entry_get_perm(acl_entry_t aclent) {
 	int permset = 0;
-
-	acl_get_tag_type(aclent, &tag_type);
+	acl_permset_t opaque_ps;
 
 	/* translate the silly opaque permset to a bitmap */
 	acl_get_permset(aclent, &opaque_ps);
@@ -88,10 +82,61 @@ acl_match(acl_entry_t aclent, struct mya
 		permset |= ARCHIVE_ENTRY_ACL_WRITE;
 	if (acl_get_perm_np(opaque_ps, ACL_READ))
 		permset |= ARCHIVE_ENTRY_ACL_READ;
+	return permset;
+}
+
+#if 0
+static int
+acl_get_specific_entry(acl_t acl, acl_tag_t requested_tag_type, int requested_tag) {
+	int entry_id = ACL_FIRST_ENTRY;
+	acl_entry_t acl_entry;
+	acl_tag_t acl_tag_type;
+	
+	while (1 == acl_get_entry(acl, entry_id, &acl_entry)) {
+		/* After the first time... */
+		entry_id = ACL_NEXT_ENTRY;
+
+		/* If this matches, return perm mask */
+		acl_get_tag_type(acl_entry, &acl_tag_type);
+		if (acl_tag_type == requested_tag_type) {
+			switch (acl_tag_type) {
+			case ACL_USER_OBJ:
+				if ((uid_t)requested_tag == *(uid_t *)(acl_get_qualifier(acl_entry))) {
+					return acl_entry_get_perm(acl_entry);
+				}
+				break;
+			case ACL_GROUP_OBJ:
+				if ((gid_t)requested_tag == *(gid_t *)(acl_get_qualifier(acl_entry))) {
+					return acl_entry_get_perm(acl_entry);
+				}
+				break;
+			case ACL_USER:
+			case ACL_GROUP:
+			case ACL_OTHER:
+				return acl_entry_get_perm(acl_entry);
+			default:
+				failure("Unexpected ACL tag type");
+				assert(0);
+			}
+		}
+
 
-	if (permset != myacl->permset)
+	}
+	return -1;
+}
+#endif
+
+static int
+acl_match(acl_entry_t aclent, struct myacl_t *myacl)
+{
+	gid_t g, *gp;
+	uid_t u, *up;
+	acl_tag_t tag_type;
+
+	if (myacl->permset != acl_entry_get_perm(aclent))
 		return (0);
 
+	acl_get_tag_type(aclent, &tag_type);
 	switch (tag_type) {
 	case ACL_USER_OBJ:
 		if (myacl->tag != ARCHIVE_ENTRY_ACL_USER_OBJ) return (0);
@@ -190,7 +235,7 @@ compare_acls(acl_t acl, struct myacl_t *
  * Verify ACL restore-to-disk.  This test is FreeBSD-specific.
  */
 
-DEFINE_TEST(test_acl_freebsd_posix1e)
+DEFINE_TEST(test_acl_freebsd_posix1e_restore)
 {
 #if !defined(__FreeBSD__)
 	skipping("FreeBSD-specific ACL restore test");
@@ -263,3 +308,111 @@ DEFINE_TEST(test_acl_freebsd_posix1e)
 	acl_free(acl);
 #endif
 }
+
+/*
+ * Verify ACL reaed-from-disk.  This test is FreeBSD-specific.
+ */
+DEFINE_TEST(test_acl_freebsd_posix1e_read)
+{
+#if !defined(__FreeBSD__)
+	skipping("FreeBSD-specific ACL read test");
+#elif __FreeBSD__ < 5
+	skipping("ACL read supported only on FreeBSD 5.0 and later");
+#else
+	struct archive *a;
+	struct archive_entry *ae;
+	int n, fd;
+	const char *acl1_text, *acl2_text;
+	acl_t acl1, acl2;
+
+	/*
+	 * Manually construct a directory and two files with
+	 * different ACLs.  This also serves to verify that ACLs
+	 * are supported on the local filesystem.
+	 */
+
+	/* Create a test file f1 with acl1 */
+	acl1_text = "user::rwx,group::rwx,other::rwx,user:1:rw-,group:15:r-x,mask::rwx";
+	acl1 = acl_from_text(acl1_text);
+	assert((void *)acl1 != NULL);
+	fd = open("f1", O_WRONLY | O_CREAT | O_EXCL, 0777);
+	failure("Could not create test file?!");
+	if (!assert(fd >= 0)) {
+		acl_free(acl1);
+		return;
+	}
+	n = acl_set_fd(fd, acl1);
+	acl_free(acl1);
+	if (n != 0 && errno == EOPNOTSUPP) {
+		close(fd);
+		skipping("ACL tests require that ACL support be enabled on the filesystem");
+		return;
+	}
+	if (n != 0 && errno == EINVAL) {
+		close(fd);
+		skipping("This filesystem does not support POSIX.1e ACLs");
+		return;
+	}
+	failure("acl_set_fd(): errno = %d (%s)",
+	    errno, strerror(errno));
+	assertEqualInt(0, n);
+	close(fd);
+
+	assertMakeDir("d", 0700);
+
+	/*
+	 * Create file d/f1 with acl2
+	 *
+	 * This differs from acl1 in the u:1: and g:15: permissions.
+	 *
+	 * This file deliberately has the same name but a different ACL.
+	 * Github Issue #777 explains how libarchive's directory traversal
+	 * did not always correctly enter directories before attempting
+	 * to read ACLs, resulting in reading the ACL from a like-named
+	 * file in the wrong directory.
+	 */
+	acl2_text = "user::rwx,group::rwx,other::---,user:1:r--,group:15:r--,mask::rwx";
+	acl2 = acl_from_text(acl2_text);
+	assert((void *)acl2 != NULL);
+	fd = open("d/f1", O_WRONLY | O_CREAT | O_EXCL, 0777);
+	failure("Could not create test file?!");
+	if (!assert(fd >= 0)) {
+		acl_free(acl2);
+		return;
+	}
+	n = acl_set_fd(fd, acl2);
+	acl_free(acl2);
+	if (n != 0 && errno == EOPNOTSUPP) {
+		close(fd);
+		skipping("ACL tests require that ACL support be enabled on the filesystem");
+		return;
+	}
+	if (n != 0 && errno == EINVAL) {
+		close(fd);
+		skipping("This filesystem does not support POSIX.1e ACLs");
+		return;
+	}
+	failure("acl_set_fd(): errno = %d (%s)",
+	    errno, strerror(errno));
+	assertEqualInt(0, n);
+	close(fd);
+
+	/* Create a read-from-disk object. */
+	assert(NULL != (a = archive_read_disk_new()));
+	assertEqualIntA(a, ARCHIVE_OK, archive_read_disk_open(a, "."));
+	assert(NULL != (ae = archive_entry_new()));
+
+	/* Walk the dir until we see both of the files */
+	while (ARCHIVE_OK == archive_read_next_header2(a, ae)) {
+		archive_read_disk_descend(a);
+		if (strcmp(archive_entry_pathname(ae), "./f1") == 0) {
+			assertEqualString(archive_entry_acl_text(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS), acl1_text);
+			    
+		} else if (strcmp(archive_entry_pathname(ae), "./d/f1") == 0) {
+			assertEqualString(archive_entry_acl_text(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS), acl2_text);
+		}
+	}
+
+	archive_free(a);
+#endif
+}

Modified: projects/clang390-import/contrib/top/commands.c
==============================================================================
--- projects/clang390-import/contrib/top/commands.c	Mon Sep  5 18:02:37 2016	(r305430)
+++ projects/clang390-import/contrib/top/commands.c	Mon Sep  5 18:05:45 2016	(r305431)
@@ -104,6 +104,7 @@ S       - toggle the displaying of syste
 a       - toggle the displaying of process titles\n\
 t       - toggle the display of this process\n\
 u       - display processes for only one user (+ selects all users)\n\
+w       - toggle the display of swap use for each process\n\
 z       - toggle the displaying of the system idle process\n\
 \n\
 \n", stdout);

Modified: projects/clang390-import/contrib/top/machine.h
==============================================================================
--- projects/clang390-import/contrib/top/machine.h	Mon Sep  5 18:02:37 2016	(r305430)
+++ projects/clang390-import/contrib/top/machine.h	Mon Sep  5 18:05:45 2016	(r305431)
@@ -72,6 +72,7 @@ struct process_select
     int wcpu;		/* show weighted cpu */
     int jid;		/* only this jid (unless jid == -1) */
     int jail;		/* show jail ID */
+    int swap;		/* show swap usage */
     int kidle;		/* show per-CPU idle threads */
     char *command;	/* only this command (unless == NULL) */
 };
@@ -82,8 +83,8 @@ char	*format_header();
 char	*format_next_process();
 void	 toggle_pcpustats(void);
 void	 get_system_info(struct system_info *si);
-int		 machine_init(struct statics *statics, char do_unames);
-int		 proc_owner(int pid);
+int	 machine_init(struct statics *statics, char do_unames);
+int	 proc_owner(int pid);
 
 /* non-int routines typically used by the machine dependent module */
 char	*printable();

Modified: projects/clang390-import/contrib/top/top.c
==============================================================================
--- projects/clang390-import/contrib/top/top.c	Mon Sep  5 18:02:37 2016	(r305430)
+++ projects/clang390-import/contrib/top/top.c	Mon Sep  5 18:05:45 2016	(r305431)
@@ -188,9 +188,9 @@ char *argv[];
     fd_set readfds;
 
 #ifdef ORDER
-    static char command_chars[] = "\f qh?en#sdkriIutHmSCajzPJo";
+    static char command_chars[] = "\f qh?en#sdkriIutHmSCajzPJwo";
 #else
-    static char command_chars[] = "\f qh?en#sdkriIutHmSCajzPJ";
+    static char command_chars[] = "\f qh?en#sdkriIutHmSCajzPJw";
 #endif
 /* these defines enumerate the "strchr"s of the commands in command_chars */
 #define CMD_redraw	0
@@ -219,8 +219,9 @@ char *argv[];
 #define CMD_kidletog	22
 #define CMD_pcputog	23
 #define CMD_jail	24
+#define CMD_swaptog	25
 #ifdef ORDER
-#define CMD_order       25
+#define CMD_order       26
 #endif
 
     /* set the buffer for stdout */
@@ -254,6 +255,7 @@ char *argv[];
     ps.wcpu    = 1;
     ps.jid     = -1;
     ps.jail    = No;
+    ps.swap    = No;
     ps.kidle   = Yes;
     ps.command = NULL;
 
@@ -280,7 +282,7 @@ char *argv[];
 	    optind = 1;
 	}
 
-	while ((i = getopt(ac, av, "CSIHPabijJ:nquvzs:d:U:m:o:t")) != EOF)
+	while ((i = getopt(ac, av, "CSIHPabijJ:nquvzs:d:U:m:o:tw")) != EOF)
 	{
 	    switch(i)
 	    {
@@ -418,6 +420,10 @@ char *argv[];
 		pcpu_stats = !pcpu_stats;
 		break;
 
+	      case 'w':
+		ps.swap = 1;
+		break;
+
 	      case 'z':
 		ps.kidle = !ps.kidle;
 		break;
@@ -1141,6 +1147,15 @@ restart:
 				reset_display();
 				putchar('\r');
 				break;
+			    case CMD_swaptog:
+				ps.swap = !ps.swap;
+				new_message(MT_standout | MT_delayed,
+				    " %sisplaying per-process swap usage.",
+				    ps.swap ? "D" : "Not d");
+				header_text = format_header(uname_field);
+				reset_display();
+				putchar('\r');
+				break;
 			    default:
 				new_message(MT_standout, " BAD CASE IN SWITCH!");
 				putchar('\r');

Modified: projects/clang390-import/contrib/top/top.xs
==============================================================================
--- projects/clang390-import/contrib/top/top.xs	Mon Sep  5 18:02:37 2016	(r305430)
+++ projects/clang390-import/contrib/top/top.xs	Mon Sep  5 18:05:45 2016	(r305431)
@@ -10,7 +10,7 @@ top \- display and update information ab
 .SH SYNOPSIS
 .B top
 [
-.B \-abCHIijnPqStuvz
+.B \-abCHIijnPqStuvwz
 ] [
 .BI \-d count
 ] [
@@ -148,6 +148,9 @@ Write version number information to stde
 No other processing takes place when this option is used.  To see current
 revision information while top is running, use the help command \*(lq?\*(rq.
 .TP
+.B \-w
+Display approximate swap usage for each process.
+.TP
 .B \-z
 Do not display the system idle process.
 .TP
@@ -167,11 +170,12 @@ Set the delay between screen updates to
 seconds.  The default delay between updates is \nD seconds.
 .TP
 .BI \-o field
-Sort the process display area on the specified field.  The field name is
-the name of the column as seen in the output, but in lower case.  Likely
-values are \*(lqcpu\*(rq, \*(lqsize\*(rq, \*(lqres\*(rq, and \*(lqtime\*(rq,
-but may vary on different operating systems.  Note that
-not all operating systems support this option.
+Sort the process display area on the specified field.  The field name
+is the name of the column as seen in the output, but in lower case:
+\*(lqcpu\*(lq, \*(rqsize\*(lq, \*(rqres\*(lq, \*(rqtime\*(lq,
+\*(rqpri\*(lq, \*(rqthreads\*(lq, \*(lqtotal\*(lq, \*(rqread\*(lq,
+\*(rqwrite\*(lq, \*(rqfault\*(lq, \*(rqvcsw\*(lq, \*(rqivcsw\*(lq,
+\*(lqjid\*(lq, \*(rqswap\*(lq or \*(rqpid\*(lq.
 .TP
 .BI \-J jail
 Show only those processes owned by
@@ -226,6 +230,7 @@ The options
 .BR \-S ,
 .BR \-t ,
 .BR \-u ,
+.BR \-w ,
 and
 .B \-z
 are actually toggles.  A second specification of any of these options
@@ -346,6 +351,9 @@ Toggle the display of the
 .I top
 process.
 .TP
+.B w
+Toggle the display of swap usage.
+.TP
 .B z
 Toggle the display of the system idle process.
 .SH "THE DISPLAY"
@@ -379,8 +387,9 @@ is specified, a UID column will be subst
 PRI is the current priority of the process,
 NICE is the nice amount (in the range \-20 to 20),
 SIZE is the total size of the process (text, data, and stack),
-RES is the current amount of resident memory (both SIZE and RES are
-given in kilobytes),
+RES is the current amount of resident memory,
+SWAP is the approximate amount of swap, if enabled
+(SIZE, RES and SWAP are given in kilobytes),
 STATE is the current state (one of \*(lqSTART\*(rq, \*(lqRUN\*(rq
 (shown as \*(lqCPUn\*(rq on SMP systems), \*(lqSLEEP\*(rq, \*(lqSTOP\*(rq,
 \*(lqZOMB\*(rq, \*(lqWAIT\*(rq, \*(lqLOCK\*(rq or the event on which the

Modified: projects/clang390-import/lib/libarchive/config_freebsd.h
==============================================================================
--- projects/clang390-import/lib/libarchive/config_freebsd.h	Mon Sep  5 18:02:37 2016	(r305430)
+++ projects/clang390-import/lib/libarchive/config_freebsd.h	Mon Sep  5 18:05:45 2016	(r305431)
@@ -30,6 +30,7 @@
 /* FreeBSD 5.0 and later have ACL and extattr support. */
 #if __FreeBSD__ > 4
 #define HAVE_ACL_CREATE_ENTRY 1
+#define HAVE_ACL_GET_FD_NP 1
 #define HAVE_ACL_GET_LINK_NP 1
 #define HAVE_ACL_GET_PERM_NP 1
 #define HAVE_ACL_INIT 1
@@ -45,6 +46,7 @@
 #define HAVE_EXTATTR_LIST_FILE 1
 #define HAVE_EXTATTR_SET_FD 1
 #define HAVE_EXTATTR_SET_FILE 1
+#define HAVE_STRUCT_XVFSCONF 1
 #define HAVE_SYS_ACL_H 1
 #define HAVE_SYS_EXTATTR_H 1
 #endif

Modified: projects/clang390-import/lib/libc/stdio/fgets.c
==============================================================================
--- projects/clang390-import/lib/libc/stdio/fgets.c	Mon Sep  5 18:02:37 2016	(r305430)
+++ projects/clang390-import/lib/libc/stdio/fgets.c	Mon Sep  5 18:05:45 2016	(r305431)
@@ -37,6 +37,7 @@ static char sccsid[] = "@(#)fgets.c	8.2 
 __FBSDID("$FreeBSD$");
 
 #include "namespace.h"
+#include <errno.h>
 #include <stdio.h>
 #include <string.h>
 #include "un-namespace.h"
@@ -55,11 +56,16 @@ fgets(char * __restrict buf, int n, FILE
 	char *s;
 	unsigned char *p, *t;
 
-	if (n <= 0)		/* sanity check */
-		return (NULL);
-
 	FLOCKFILE(fp);
 	ORIENT(fp, -1);
+
+	if (n <= 0) {		/* sanity check */
+		fp->_flags |= __SERR;
+		errno = EINVAL;
+		FUNLOCKFILE(fp);
+		return (NULL);
+	}
+
 	s = buf;
 	n--;			/* leave space for NUL */
 	while (n != 0) {
@@ -69,7 +75,7 @@ fgets(char * __restrict buf, int n, FILE
 		if ((len = fp->_r) <= 0) {
 			if (__srefill(fp)) {
 				/* EOF/error: stop with partial or no line */
-				if (s == buf) {
+				if (!__sfeof(fp) || s == buf) {
 					FUNLOCKFILE(fp);
 					return (NULL);
 				}

Modified: projects/clang390-import/lib/libc/stdio/fgetws.c
==============================================================================
--- projects/clang390-import/lib/libc/stdio/fgetws.c	Mon Sep  5 18:02:37 2016	(r305430)
+++ projects/clang390-import/lib/libc/stdio/fgetws.c	Mon Sep  5 18:05:45 2016	(r305431)
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
 wchar_t *
 fgetws_l(wchar_t * __restrict ws, int n, FILE * __restrict fp, locale_t locale)
 {
+	int sret;
 	wchar_t *wsp;
 	size_t nconv;
 	const char *src;
@@ -56,23 +57,31 @@ fgetws_l(wchar_t * __restrict ws, int n,
 	ORIENT(fp, 1);
 
 	if (n <= 0) {
+		fp->_flags |= __SERR;
 		errno = EINVAL;
 		goto error;
 	}
 
+	wsp = ws;
+	if (n == 1)
+		goto ok;
+
 	if (fp->_r <= 0 && __srefill(fp))
-		/* EOF */
+		/* EOF or ferror */
 		goto error;
-	wsp = ws;
+
+	sret = 0;
 	do {
 		src = fp->_p;
 		nl = memchr(fp->_p, '\n', fp->_r);
 		nconv = l->__mbsnrtowcs(wsp, &src,
 		    nl != NULL ? (nl - fp->_p + 1) : fp->_r,
 		    n - 1, &fp->_mbstate);
-		if (nconv == (size_t)-1)
+		if (nconv == (size_t)-1) {
 			/* Conversion error */
+			fp->_flags |= __SERR;
 			goto error;
+		}
 		if (src == NULL) {
 			/*
 			 * We hit a null byte. Increment the character count,
@@ -88,23 +97,30 @@ fgetws_l(wchar_t * __restrict ws, int n,
 		fp->_p = (unsigned char *)src;
 		n -= nconv;
 		wsp += nconv;
-	} while (wsp[-1] != L'\n' && n > 1 && (fp->_r > 0 ||
-	    __srefill(fp) == 0));
-	if (wsp == ws)
-		/* EOF */
+	} while ((wsp == ws || wsp[-1] != L'\n') && n > 1 && (fp->_r > 0 ||
+	    (sret = __srefill(fp)) == 0));
+	if (sret && !__sfeof(fp))
+		/* ferror */
 		goto error;
-	if (!l->__mbsinit(&fp->_mbstate))
+	if (!l->__mbsinit(&fp->_mbstate)) {
 		/* Incomplete character */
+		fp->_flags |= __SERR;
+		errno = EILSEQ;
 		goto error;
+	}
+	if (wsp == ws)
+		/* EOF */
+		goto error;
+ok:
 	*wsp = L'\0';
 	FUNLOCKFILE(fp);
-
 	return (ws);
 
 error:
 	FUNLOCKFILE(fp);
 	return (NULL);
 }
+
 wchar_t *
 fgetws(wchar_t * __restrict ws, int n, FILE * __restrict fp)
 {

Modified: projects/clang390-import/sys/arm/allwinner/aw_thermal.c
==============================================================================
--- projects/clang390-import/sys/arm/allwinner/aw_thermal.c	Mon Sep  5 18:02:37 2016	(r305430)
+++ projects/clang390-import/sys/arm/allwinner/aw_thermal.c	Mon Sep  5 18:05:45 2016	(r305431)
@@ -82,16 +82,26 @@ __FBSDID("$FreeBSD$");
 #define	A83T_FILTER		0x4
 #define	A83T_INTC		0x1000
 #define	A83T_TEMP_BASE		2719000
+#define	A83T_TEMP_MUL		1000
 #define	A83T_TEMP_DIV		14186
 #define	A83T_CLK_RATE		24000000
 
 #define	A64_ADC_ACQUIRE_TIME	0x190
 #define	A64_FILTER		0x6
-#define A64_INTC		0x18000
+#define	A64_INTC		0x18000
 #define	A64_TEMP_BASE		2170000
+#define	A64_TEMP_MUL		1000
 #define	A64_TEMP_DIV		8560
 #define	A64_CLK_RATE		4000000
 
+#define	H3_ADC_ACQUIRE_TIME	0x3f
+#define	H3_FILTER		0x6
+#define	H3_INTC			0x191000
+#define	H3_TEMP_BASE		217000000
+#define	H3_TEMP_MUL		121168
+#define	H3_TEMP_DIV		1000000
+#define	H3_CLK_RATE		4000000
+
 #define	TEMP_C_TO_K		273
 #define	SENSOR_ENABLE_ALL	(SENSOR0_EN|SENSOR1_EN|SENSOR2_EN)
 #define	SHUT_INT_ALL		(SHUT_INT0_STS|SHUT_INT1_STS|SHUT_INT2_STS)
@@ -110,8 +120,10 @@ struct aw_thermal_config {
 	uint32_t			adc_acquire_time;
 	uint32_t			filter;
 	uint32_t			intc;
-	uint32_t			temp_base;
-	uint32_t			temp_div;
+	int				temp_base;
+	int				temp_mul;
+	int				temp_div;
+	int				calib;
 };
 
 static const struct aw_thermal_config a83t_config = {
@@ -135,7 +147,9 @@ static const struct aw_thermal_config a8
 	.filter = A83T_FILTER,
 	.intc = A83T_INTC,
 	.temp_base = A83T_TEMP_BASE,
+	.temp_mul = A83T_TEMP_MUL,
 	.temp_div = A83T_TEMP_DIV,
+	.calib = 1,
 };
 
 static const struct aw_thermal_config a64_config = {
@@ -159,11 +173,30 @@ static const struct aw_thermal_config a6
 	.filter = A64_FILTER,
 	.intc = A64_INTC,
 	.temp_base = A64_TEMP_BASE,
+	.temp_mul = A64_TEMP_MUL,
 	.temp_div = A64_TEMP_DIV,
 };
 
+static const struct aw_thermal_config h3_config = {
+	.nsensors = 1,
+	.sensors = {
+		[0] = {
+			.name = "cpu",
+			.desc = "CPU temperature",
+		},
+	},
+	.clk_rate = H3_CLK_RATE,
+	.adc_acquire_time = H3_ADC_ACQUIRE_TIME,
+	.filter = H3_FILTER,
+	.intc = H3_INTC,
+	.temp_base = H3_TEMP_BASE,
+	.temp_mul = H3_TEMP_MUL,
+	.temp_div = H3_TEMP_DIV,
+};
+
 static struct ofw_compat_data compat_data[] = {
 	{ "allwinner,sun8i-a83t-ts",	(uintptr_t)&a83t_config },
+	{ "allwinner,sun8i-h3-ts",	(uintptr_t)&h3_config },
 	{ "allwinner,sun50i-a64-ts",	(uintptr_t)&a64_config },
 	{ NULL,				(uintptr_t)NULL }
 };
@@ -191,14 +224,16 @@ aw_thermal_init(struct aw_thermal_softc 
 	uint32_t calib0, calib1;
 	int error;
 
-	/* Read calibration settings from SRAM */
-	error = aw_sid_read_tscalib(&calib0, &calib1);
-	if (error != 0)
-		return (error);
-
-	/* Write calibration settings to thermal controller */
-	WR4(sc, THS_CALIB0, calib0);
-	WR4(sc, THS_CALIB1, calib1);
+	if (sc->conf->calib) {
+		/* Read calibration settings from SRAM */
+		error = aw_sid_read_tscalib(&calib0, &calib1);
+		if (error != 0)
+			return (error);
+
+		/* Write calibration settings to thermal controller */
+		WR4(sc, THS_CALIB0, calib0);
+		WR4(sc, THS_CALIB1, calib1);
+	}
 
 	/* Configure ADC acquire time (CLK_IN/(N+1)) and enable sensors */
 	WR4(sc, THS_CTRL1, ADC_CALI_EN);
@@ -221,7 +256,8 @@ aw_thermal_init(struct aw_thermal_softc 
 static int
 aw_thermal_reg_to_temp(struct aw_thermal_softc *sc, uint32_t val)

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


More information about the svn-src-projects mailing list