--- old/README	Wed Oct  5 00:33:05 2016
+++ new/README	Wed Oct  5 00:33:05 2016
@@ -1,3 +1,91 @@
+Last illumos-joyent commit:  d21e83058c8edeb1becd9202380d088cb056f0c4
+
+This is an attempt to port over LX zones into OmniOS.  It's going to be a long,
+painful slog, and I don't mean the ZFS kind, either.  :)
+
+An IPS repo that matches public updates of the r151019 bloody repo can be
+found at http:/pkg.omniti.com/omnios/LX/.  ipkg and lipkg zones can boot,
+appear to be fully functional, but need more testing.  LX zones can be
+installed using ZFS send streams (gzipped or uncompressed) from Joyent's
+images, or from tarballs often used for Docker image setup.  The
+"kernel-version" attribute must be set by the administrator to match the
+installed image.  For example:
+
+	# zonecfg -z lx0 export
+	create -b
+	set zonepath=/zones/lx0
+	set brand=lx
+	set autoboot=false
+	set ip-type=exclusive
+	add net
+	set physical=lx0
+	end
+	add attr
+	set name=kernel-version
+	set type=string
+	set value=2.6.32
+	end
+	#
+
+This matches a CentOS 6.8 image from Joyent.  To install the image:
+
+     zoneadm -z lx0 install -s /root/path/to/centos68.gz
+
+A tarball install uses the -t flag instead:
+
+     zoneadm -z lx0 install -s /root/path/to/docker-ubuntu.tgz
+
+Effective September 1st, one can use SmartOS-style IP address and DNS
+configuration using zonecfg parameters.  Here's the above zone with a pre-
+configured set of networking parameters:
+
+	# zonecfg -z lx0 export
+	create -b
+	set zonepath=/zones/lx0
+	set brand=lx
+	set autoboot=false
+	set ip-type=exclusive
+	add net
+	set physical=lx0
+	add property (name=gateway,value="192.168.0.1")
+	add property (name=ips,value="192.168.0.69/24")
+	add property (name=primary,value="true")
+	end
+	add attr
+	set name=dns-domain
+	set type=string
+	set value=example.com
+	end
+	add attr
+	set name=resolvers
+	set type=string
+	set value=192.168.0.1
+	end
+	add attr
+	set name=kernel-version
+	set type=string
+	set value=2.6.32
+	end
+	#
+
+You'd obtain the .gz file from Joyent's image servers.
+
+LX zones boot, and if not configured with zonecfg(1M), one needs to use
+/native tools and/or scripts to configure networking on them.  (NOTE:  This
+follows the OmniOS adminstrative model for zones.)  LX zones need even more
+testing than ipkg/lipkg zones, but appear to at least boot and allow both
+"zlogin -C" console logins and "zlogin" direct logins.  Some distros do not
+present a console login on the first boot, and the zone may need to be
+rebooted
+
+I reserve the right to burn this repo to the ground and start fresh.
+
+This repo also has the "joyent" branch, which is a downstream of illumos-joyent.
+
+Thanks -- Dan
+
+===========
+
 illumos gate README - Sep 16, 2012.
 
 This is the illumos gate.  This is the illumos source tree.  It contains
--- old/exception_lists/check_rtime	Wed Oct  5 00:33:05 2016
+++ new/exception_lists/check_rtime	Wed Oct  5 00:33:05 2016
@@ -139,8 +139,8 @@
 UNUSED_RPATH	/usr/sfw/lib.*\ from\ .*libpq\.so\.5
 UNUSED_RPATH	/usr/lib.*\ from\ .*/usr/lib/mps
 UNUSED_RPATH	/usr/ccs/lib.*\ from\ .*/usr/lib/mps
-UNUSED_RPATH	/usr/gnu/lib.*\ from\ .*/usr/lib/libpython2\..
-UNUSED_RPATH	/usr/gnu/lib.*\ from\ .*/usr/lib/64/libpython2\..
+UNUSED_RPATH	/usr/gnu/lib.*\ from\ .*/usr/lib/libpython2\.6
+UNUSED_RPATH	/usr/gnu/lib.*\ from\ .*/usr/lib/64/libpython2\.6
 UNUSED_RPATH	/usr/snadm/lib.*\ from\ .*/usr/snadm/lib/libspmicommon\.so\.1
 
 
@@ -233,4 +233,10 @@
 # unneeded library.
 UNREF_OBJ	lib/(libdevinfo|libcfgadm)\.so\.1; .*\ of\ .*SUNW,Netra-CP2300/lib/libprtdiag_psr\.so\.1
 
+# The lx brand's VDSO object is a bit special. Its construction leads us
+# to end up having several symbols for shared objects all at the same
+# address of zero. We should root cause this further and either add an
+# explicit exception for this kind of thing or better, fix the issues
+# it's upset about.
+SKIP	^usr/lib/brand/MACH(lx)/lx_vdso\.so\.1$
 
--- old/exception_lists/interface_check	Wed Oct  5 00:33:05 2016
+++ new/exception_lists/interface_check	Wed Oct  5 00:33:05 2016
@@ -56,7 +56,7 @@
 PLUGIN		^usr/lib/mdb
 PLUGIN		^usr/lib/pci
 PLUGIN		^usr/lib/picl/plugins
-PLUGIN		^usr/lib/python2.[467]
+PLUGIN		^usr/lib/python2.[46]
 PLUGIN		^usr/lib/rcm/modules
 PLUGIN		^usr/lib/scsi/plugins
 PLUGIN		^usr/lib/sysevent/modules
@@ -94,6 +94,7 @@
 NOVERDEF	^usr/lib/picl/plugins$
 NOVERDEF	^usr/sadm/admin/dhcpmgr/dhcpmgr\.so\.1$
 NOVERDEF	^usr/sadm/admin/printmgr/lib/libpmgr\.so\.1$
+NOVERDEF	^usr/MACH(lib)/lx_brand\.so\.1$
 
 
 # Objects that are allowed to deviate from our standard version
@@ -100,6 +101,8 @@
 # names.
 NONSTD_VERNAME	^MACH(lib)/libsqlite-sys\.so\.
 NONSTD_VERNAME	^usr/MACH(lib)/libtecla\.so\.1$
+NONSTD_VERNAME	^usr/lib/brand/lx/lx_vdso\.so\.1$
+NONSTD_VERNAME	^usr/lib/brand/lx/amd64/lx_vdso\.so\.1$
 
 # These libc variants have an SONAME of libc\.so\.1$
 NONSTD_VERNAME	^usr/MACH(lib)/libc/libc_hwcap[1-3]+\.so\.1$
--- old/exception_lists/packaging	Wed Oct  5 00:33:05 2016
+++ new/exception_lists/packaging	Wed Oct  5 00:33:05 2016
@@ -24,7 +24,6 @@
 # Copyright 2012 OmniTI Computer Consulting, Inc.  All rights reserved.
 # Copyright 2014 Garrett D'Amore <garrett@damore.org>
 # Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
-# Copyright 2016 Toomas Soome <tsoome@me.com>
 #
 
 #
@@ -40,6 +39,7 @@
 usr/include/bsm/audit_private.h
 usr/include/bsm/devalloc.h
 usr/include/getxby_door.h
+usr/include/lastlog.h
 usr/include/passwdutil.h
 usr/include/priv_utils.h
 usr/include/rpcsvc/daemon_utils.h
@@ -49,10 +49,6 @@
 usr/include/sys/winlockio.h
 usr/include/scsi/plugins/ses/vendor/sun_impl.h
 #
-# Private lofi interface.
-#
-usr/include/sys/lofi_impl.h
-#
 # Private/Internal libraries of the Cryptographic Framework.
 #
 lib/libkcfd.so
@@ -989,14 +985,10 @@
 # debugging program for libadutils
 #
 usr/bin/test-getdc
+
 #
-# libficl-sys is private
+# LX Brand internals
 #
-usr/include/ficllocal.h
-usr/lib/amd64/llib-lficl-sys.ln		i386
-usr/lib/amd64/libficl-sys.so		i386
-usr/lib/sparcv9/llib-lficl-sys.ln	sparc
-usr/lib/sparcv9/libficl-sys.so		sparc
-usr/lib/llib-lficl-sys
-usr/lib/llib-lficl-sys.ln
-usr/lib/libficl-sys.so
+
+usr/include/sys/inotify.h
+usr/include/sys/zfd.h
--- old/usr/src/Makefile.lint	Wed Oct  5 00:33:05 2016
+++ new/usr/src/Makefile.lint	Wed Oct  5 00:33:05 2016
@@ -194,7 +194,6 @@
 	cmd/ls \
 	cmd/luxadm \
 	cmd/lvm \
-	cmd/machid \
 	cmd/mailwrapper \
 	cmd/makekey \
 	cmd/mdb \
@@ -460,6 +459,7 @@
 	lib/pam_modules \
 	lib/passwdutil \
 	lib/pkcs11 \
+	lib/print \
 	lib/raidcfg_plugins \
 	lib/scsi \
 	lib/smbsrv \
No differences encountered
--- old/usr/src/Targetdirs	Wed Oct  5 00:33:05 2016
+++ new/usr/src/Targetdirs	Wed Oct  5 00:33:05 2016
@@ -23,10 +23,10 @@
 # Copyright 2011, Richard Lowe
 # Copyright (c) 2012 by Delphix. All rights reserved.
 # Copyright (c) 2012, Igor Kozhukhov <ikozhukhov@gmail.com>
-# Copyright 2012 OmniTI Computer Consulting, Inc.  All rights reserved.
 # Copyright (c) 2013 RackTop Systems.
 # Copyright 2014 Garrett D'Amore <garrett@damore.org>
 # Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
+# Copyright 2015 OmniTI Computer Consulting, Inc.  All rights reserved.
 #
 
 #
@@ -53,9 +53,8 @@
 	/boot/grub/bin		\
 	/platform/i86pc		\
 	/lib/libmvec		\
-	/usr/lib/brand/lx	\
+	/usr/lib/brand/lx \
 	/usr/lib/brand/lx/amd64 \
-	/usr/lib/brand/lx/distros \
 	/usr/lib/xen		\
 	/usr/lib/xen/bin
 
@@ -249,6 +248,7 @@
 	/usr/lib/abi \
 	/usr/lib/brand \
 	/usr/lib/brand/ipkg \
+	/usr/lib/brand/lipkg \
 	/usr/lib/brand/labeled \
 	/usr/lib/brand/shared \
 	/usr/lib/brand/sn1 \
@@ -283,16 +283,15 @@
 	/usr/lib/mdb/kvm \
 	/usr/lib/mdb/proc \
 	/usr/lib/nfs \
-	/usr/lib/varpd \
 	/usr/net \
 	/usr/net/servers \
 	/usr/lib/pool \
-	/usr/lib/python$(PYTHON_VERSION) \
-	/usr/lib/python$(PYTHON_VERSION)/vendor-packages \
-	/usr/lib/python$(PYTHON_VERSION)/vendor-packages/64 \
-	/usr/lib/python$(PYTHON_VERSION)/vendor-packages/solaris \
-	/usr/lib/python$(PYTHON_VERSION)/vendor-packages/zfs \
-	/usr/lib/python$(PYTHON_VERSION)/vendor-packages/beadm \
+	/usr/lib/python2.6 \
+	/usr/lib/python2.6/vendor-packages \
+	/usr/lib/python2.6/vendor-packages/64 \
+	/usr/lib/python2.6/vendor-packages/solaris \
+	/usr/lib/python2.6/vendor-packages/zfs \
+	/usr/lib/python2.6/vendor-packages/beadm \
 	/usr/lib/rcap \
 	/usr/lib/rcap/$(MACH32) \
 	/usr/lib/sa  \
@@ -470,7 +469,6 @@
 	/usr/lib/security/$(MACH64) \
 	/usr/lib/smbsrv/$(MACH64) \
 	/usr/lib/abi/$(MACH64) \
-	/usr/lib/varpd/$(MACH64) \
 	/usr/sbin/$(MACH64) \
 	/usr/ucb/$(MACH64) \
 	/usr/ucblib/$(MACH64) \
@@ -531,7 +529,6 @@
 	/usr/lib/lwp/64 \
 	/usr/lib/secure/64 \
 	/usr/lib/security/64 \
-	/usr/lib/varpd/64 \
 	/usr/xpg4/lib/64 \
 	/var/ld/64 \
 	/usr/ucblib/64
@@ -639,7 +636,6 @@
 $(BUILD64) $(ROOT)/usr/lib/link_audit/64:=	LINKDEST=$(MACH64)
 $(BUILD64) $(ROOT)/usr/lib/secure/64:=	LINKDEST=$(MACH64)
 $(BUILD64) $(ROOT)/usr/lib/security/64:=	LINKDEST=$(MACH64)
-$(BUILD64) $(ROOT)/usr/lib/varpd/64:=	LINKDEST=$(MACH64)
 $(BUILD64) $(ROOT)/usr/xpg4/lib/64:=	LINKDEST=$(MACH64)
 $(BUILD64) $(ROOT)/var/ld/64:=		LINKDEST=$(MACH64)
 $(BUILD64) $(ROOT)/usr/ucblib/64:=	LINKDEST=$(MACH64)
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/cmd/cmd-inet/usr.sbin/arp.c	Wed Oct  5 00:33:06 2016
+++ new/usr/src/cmd/cmd-inet/usr.sbin/arp.c	Wed Oct  5 00:33:06 2016
@@ -126,8 +126,8 @@
 		(void) execl(netstat_path, "netstat",
 		    (n_flag ? "-np" : "-p"),
 		    "-f", "inet", (char *)0);
-		(void) fprintf(stderr, "failed to exec netstat: %s\n",
-		    strerror(errno));
+		(void) fprintf(stderr, "failed to exec %s: %s\n",
+		    netstat_path, strerror(errno));
 		exit(1);
 
 	} else if (s_flag && (argsleft >= 2)) {
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/cmd/devfsadm/misc_link.c	Wed Oct  5 00:33:06 2016
+++ new/usr/src/cmd/devfsadm/misc_link.c	Wed Oct  5 00:33:06 2016
@@ -212,9 +212,6 @@
 	{ "pseudo", "ddi_pseudo", "tpm",
 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, minor_name
 	},
-	{ "pseudo", "ddi_pseudo", "overlay",
-	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, minor_name
-	}
 };
 
 DEVFSADM_CREATE_INIT_V0(misc_cbt);
--- old/usr/src/cmd/dlmgmtd/dlmgmt_db.c	Wed Oct  5 00:33:06 2016
+++ new/usr/src/cmd/dlmgmtd/dlmgmt_db.c	Wed Oct  5 00:33:06 2016
@@ -555,10 +555,6 @@
 	    linkp->ll_zoneid, flags, &err)) == NULL)
 		return (err);
 
-	/* If transient op and onloan, use the global zone cache file. */
-	if (flags == DLMGMT_ACTIVE && linkp->ll_onloan)
-		req->ls_zoneid = GLOBAL_ZONEID;
-
 	/*
 	 * If the return error is EINPROGRESS, this request is handled
 	 * asynchronously; return success.
@@ -727,11 +723,11 @@
 	len = strlen(buf);
 	attr_name[0] = '\0';
 	for (i = 0; i < len; i++) {
-		rename = B_FALSE;
 		char		c = buf[i];
 		boolean_t	match = (c == '=' ||
 		    (c == ',' && !found_type) || c == ';');
 
+		rename = B_FALSE;
 		/*
 		 * Move to the next character if there is no match and
 		 * if we have not reached the last character.
@@ -1499,12 +1495,10 @@
 		boot = B_TRUE;
 	}
 
-	if (zone_file_exists(zoneroot, DLMGMT_PERSISTENT_DB_PATH)) {
-		req->ls_flags = DLMGMT_PERSIST;
-		err = dlmgmt_process_db_req(req);
-		if (err != 0 && err != ENOENT)
-			goto done;
-	}
+	req->ls_flags = DLMGMT_PERSIST;
+	err = dlmgmt_process_db_req(req);
+	if (err != 0 && err != ENOENT)
+		goto done;
 	err = 0;
 	if (rewrite_needed) {
 		/*
@@ -1562,7 +1556,6 @@
 				(void) dlmgmt_destroy_common(linkp,
 				    DLMGMT_ACTIVE | DLMGMT_PERSIST);
 			}
-
 		}
 		linkp = next_linkp;
 	}
--- old/usr/src/cmd/dlmgmtd/dlmgmt_door.c	Wed Oct  5 00:33:07 2016
+++ new/usr/src/cmd/dlmgmtd/dlmgmt_door.c	Wed Oct  5 00:33:07 2016
@@ -21,7 +21,6 @@
 
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011, Joyent Inc. All rights reserved.
  */
 
 /*
@@ -65,6 +64,7 @@
 #include <unistd.h>
 #include "dlmgmt_impl.h"
 
+
 typedef void dlmgmt_door_handler_t(void *, void *, size_t *, zoneid_t,
     ucred_t *);
 
@@ -449,10 +449,6 @@
 	dlmgmt_link_t		*linkp;
 	int			err = 0;
 
-	/* Enable the global zone to lookup links it has given away. */
-	if (zoneid == GLOBAL_ZONEID && getlinkid->ld_zoneid != -1)
-		zoneid = getlinkid->ld_zoneid;
-
 	/*
 	 * Hold the reader lock to access the link
 	 */
@@ -1275,19 +1271,7 @@
 			    "zone %d: %s", linkid, oldzoneid, strerror(err));
 			goto done;
 		}
-
-		if (newzoneid == GLOBAL_ZONEID && linkp->ll_onloan) {
-			/*
-			 * We can only reassign a loaned VNIC back to the
-			 * global zone when the zone is shutting down, since
-			 * otherwise the VNIC is in use by the zone and will be
-			 * busy.  Leave the VNIC assigned to the zone so we can
-			 * still see it and delete it when dlmgmt_zonehalt()
-			 * runs.
-			 */
-			goto done;
-		}
-
+		avl_remove(&dlmgmt_loan_avl, linkp);
 		linkp->ll_onloan = B_FALSE;
 	}
 	if (newzoneid != GLOBAL_ZONEID) {
@@ -1298,6 +1282,7 @@
 			(void) zone_add_datalink(oldzoneid, linkid);
 			goto done;
 		}
+		avl_add(&dlmgmt_loan_avl, linkp);
 		linkp->ll_onloan = B_TRUE;
 	}
 
--- old/usr/src/cmd/dlmgmtd/dlmgmt_impl.h	Wed Oct  5 00:33:07 2016
+++ new/usr/src/cmd/dlmgmtd/dlmgmt_impl.h	Wed Oct  5 00:33:07 2016
@@ -21,7 +21,6 @@
 
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011, Joyent Inc. All rights reserved.
  */
 
 /*
--- old/usr/src/cmd/dlmgmtd/dlmgmt_main.c	Wed Oct  5 00:33:07 2016
+++ new/usr/src/cmd/dlmgmtd/dlmgmt_main.c	Wed Oct  5 00:33:07 2016
@@ -126,7 +126,7 @@
 	dlmgmt_door_fd = -1;
 }
 
-static int
+int
 dlmgmt_door_attach(zoneid_t zoneid, char *rootdir)
 {
 	int	fd;
@@ -232,7 +232,7 @@
 static int
 dlmgmt_allzones_init(void)
 {
-	int		i;
+	int		err, i;
 	zoneid_t	*zids = NULL;
 	uint_t		nzids, nzids_saved;
 
@@ -253,37 +253,11 @@
 	}
 
 	for (i = 0; i < nzids; i++) {
-		int res;
-		zone_status_t status;
-
-		/*
-		 * Skip over zones that have gone away or are going down
-		 * since we got the list.  Process all zones in the list,
-		 * logging errors for any that failed.
-		 */
-		if (zone_getattr(zids[i], ZONE_ATTR_STATUS, &status,
-		    sizeof (status)) < 0)
-			continue;
-		switch (status) {
-			case ZONE_IS_SHUTTING_DOWN:
-			case ZONE_IS_EMPTY:
-			case ZONE_IS_DOWN:
-			case ZONE_IS_DYING:
-			case ZONE_IS_DEAD:
-				/* FALLTHRU */
-				continue;
-			default:
-				break;
-		}
-		if ((res = dlmgmt_zone_init(zids[i])) != 0) {
-			(void) fprintf(stderr, "zone (%ld) init error %s",
-			    zids[i], strerror(res));
-			dlmgmt_log(LOG_ERR, "zone (%d) init error %s",
-			    zids[i], strerror(res));
-		}
+		if ((err = dlmgmt_zone_init(zids[i])) != 0)
+			break;
 	}
 	free(zids);
-	return (0);
+	return (err);
 }
 
 static int
--- old/usr/src/cmd/dlmgmtd/dlmgmt_util.c	Wed Oct  5 00:33:07 2016
+++ new/usr/src/cmd/dlmgmtd/dlmgmt_util.c	Wed Oct  5 00:33:07 2016
@@ -21,7 +21,6 @@
 
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011, Joyent Inc. All rights reserved.
  */
 
 /*
@@ -46,10 +45,13 @@
 /*
  * There are three datalink AVL tables.  The dlmgmt_name_avl tree contains all
  * datalinks and is keyed by zoneid and link name.  The dlmgmt_id_avl also
- * contains all datalinks, and it is keyed by link ID.
+ * contains all datalinks, and it is keyed by link ID.  The dlmgmt_loan_avl is
+ * keyed by link name, and contains the set of global-zone links that are
+ * currently on loan to non-global zones.
  */
 avl_tree_t	dlmgmt_name_avl;
 avl_tree_t	dlmgmt_id_avl;
+avl_tree_t	dlmgmt_loan_avl;
 
 avl_tree_t	dlmgmt_dlconf_avl;
 
@@ -160,6 +162,8 @@
 	    offsetof(dlmgmt_link_t, ll_name_node));
 	avl_create(&dlmgmt_id_avl, cmp_link_by_id, sizeof (dlmgmt_link_t),
 	    offsetof(dlmgmt_link_t, ll_id_node));
+	avl_create(&dlmgmt_loan_avl, cmp_link_by_name, sizeof (dlmgmt_link_t),
+	    offsetof(dlmgmt_link_t, ll_loan_node));
 	avl_create(&dlmgmt_dlconf_avl, cmp_dlconf_by_id,
 	    sizeof (dlmgmt_dlconf_t), offsetof(dlmgmt_dlconf_t, ld_node));
 	dlmgmt_nextlinkid = 1;
@@ -177,6 +181,7 @@
 
 	avl_destroy(&dlmgmt_dlconf_avl);
 	avl_destroy(&dlmgmt_name_avl);
+	avl_destroy(&dlmgmt_loan_avl);
 	avl_destroy(&dlmgmt_id_avl);
 }
 
@@ -380,6 +385,7 @@
 
 			linkp->ll_zoneid = zoneid;
 			avl_add(&dlmgmt_name_avl, linkp);
+			avl_add(&dlmgmt_loan_avl, linkp);
 			linkp->ll_onloan = B_TRUE;
 		}
 	} else if (linkp->ll_zoneid != GLOBAL_ZONEID) {
@@ -424,6 +430,10 @@
 	(void) strlcpy(link.ll_link, name, MAXLINKNAMELEN);
 	link.ll_zoneid = zoneid;
 	linkp = avl_find(&dlmgmt_name_avl, &link, NULL);
+	if (linkp == NULL && zoneid == GLOBAL_ZONEID) {
+		/* The link could be on loan to a non-global zone? */
+		linkp = avl_find(&dlmgmt_loan_avl, &link, NULL);
+	}
 	return (linkp);
 }
 
@@ -502,6 +512,8 @@
 
 	if ((flags & DLMGMT_ACTIVE) && linkp->ll_zoneid != GLOBAL_ZONEID) {
 		(void) zone_remove_datalink(linkp->ll_zoneid, linkp->ll_linkid);
+		if (linkp->ll_onloan)
+			avl_remove(&dlmgmt_loan_avl, linkp);
 	}
 
 	if (linkp->ll_flags == 0) {
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/cmd/prstat/prstat.c	Wed Oct  5 00:33:08 2016
+++ new/usr/src/cmd/prstat/prstat.c	Wed Oct  5 00:33:08 2016
@@ -26,7 +26,6 @@
  * Use is subject to license terms.
  *
  * Portions Copyright 2009 Chad Mynhier
- * Copyright 2012 Joyent, Inc.  All rights reserved.
  */
 
 #include <sys/types.h>
@@ -264,13 +263,8 @@
 	size_t i;
 	uint_t flags = 0;
 	int ret;
-	size_t physmem;
+	size_t physmem = sysconf(_SC_PHYS_PAGES) * pagesize;
 
-	if (!(opts.o_outpmode & OPT_VMUSAGE))
-		return;
-
-	physmem = sysconf(_SC_PHYS_PAGES) * pagesize;
-
 	/*
 	 * Determine what swap/rss results to calculate.  getvmusage() will
 	 * prune results returned to non-global zones automatically, so
@@ -1420,7 +1414,7 @@
 	pagesize = sysconf(_SC_PAGESIZE);
 
 	while ((opt = getopt(argc, argv,
-	    "vVcd:HmarRLtu:U:n:p:C:P:h:s:S:j:k:TJWz:Z")) != (int)EOF) {
+	    "vcd:HmarRLtu:U:n:p:C:P:h:s:S:j:k:TJWz:Z")) != (int)EOF) {
 		switch (opt) {
 		case 'r':
 			opts.o_outpmode |= OPT_NORESOLVE;
@@ -1500,9 +1494,6 @@
 			while (p = strtok(NULL, ", "))
 				add_uid(&ruid_tbl, p);
 			break;
-		case 'V':
-			opts.o_outpmode |= OPT_VMUSAGE;
-			break;
 		case 'p':
 			fill_table(&pid_tbl, optarg, 'p');
 			break;
No differences encountered
--- old/usr/src/cmd/ptools/Makefile.bld	Wed Oct  5 00:33:08 2016
+++ new/usr/src/cmd/ptools/Makefile.bld	Wed Oct  5 00:33:08 2016
@@ -22,13 +22,10 @@
 #
 # Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
-# Copyright 2015 Joyent, Inc.
 #
 
 PROG:sh = basename `cd ..; pwd`
 
-include ../../../Makefile.ctf
-
 OBJS = $(PROG).o
 
 SRCS = ../$(PROG).c
@@ -114,12 +111,16 @@
 CPPFLAGS_pwdx =		$(CINC)
 OBJS_pwdx =		$(COBJS)
 
-LN_pargs =		penv pauxv
-
 CPPFLAGS +=	$(CPPFLAGS_$(PROG))
 OBJS +=		$(OBJS_$(PROG))
 SRCS +=		$(SRCS_$(PROG))
 
+# For lint, always include ptools_common.c, but suppress the "defined but
+# not used" error, in case a given ptool doesn't need it.
+SRCS +=		../../common/ptools_common.c
+LINTFLAGS +=	-xerroff=E_NAME_DEF_NOT_USED2
+LINTFLAGS64 +=	-xerroff=E_NAME_DEF_NOT_USED2
+
 INSTALL_NEW=
 INSTALL_LEGACY=$(RM) $(ROOTPROCBINSYMLINK) ; \
 	$(LN) -s ../../bin/$(PROG) $(ROOTPROCBINSYMLINK)
@@ -128,23 +129,19 @@
 
 elfcap.o:	$(ELFCAP)/elfcap.c
 		$(COMPILE.c) -o $@ $(ELFCAP)/elfcap.c
-		$(POST_PROCESS_O)
 
 pmap_common.o:	$(PMAP)/pmap_common.c
 		$(COMPILE.c) -o $@ $(PMAP)/pmap_common.c
-		$(POST_PROCESS_O)
 
 %.o:	../%.c
 	$(COMPILE.c) $<
-	$(POST_PROCESS_O)
 
 %.o:	../../common/%.c
 	$(COMPILE.c) $<
 	$(POST_PROCESS_O)
 
-all:	$(PROG) $(LN_$(PROG))
+all:	$(PROG)
 
-ROOTBINLN=$(LN_$(PROG):%=$(ROOTBIN)/%)
 ROOTBINPROG=$(ROOTBIN)/$(PROG)
 ROOTPROCBINSYMLINK=$(ROOT)/usr/proc/bin/$(PROG)
 
@@ -156,23 +153,11 @@
 # Install the ptool, symlinking it into /usr/proc/bin if PTOOL_TYPE is set
 # to LEGACY.
 #
-install: all $(ROOTISAPROG) $(ROOTISALN)
+install: all $(ROOTISAPROG)
 	-$(RM) $(ROOTBINPROG)
 	-$(LN) $(ISAEXEC) $(ROOTBINPROG)
 	-$(INSTALL_$(PTOOL_TYPE))
 
-$(ROOTBINLN):
-	-$(RM) $@
-	-$(LN) $(ISAEXEC) $@
-
-$(ROOTISALN): $(ROOTISAPROG)
-	-$(RM) $@
-	-$(LN) $(ROOTISAPROG) $@
-
-$(LN_$(PROG)): $(PROG)
-	-$(RM) $@
-	-$(LN) $(PROG) $@
-
 clean:
 	$(RM) $(OBJS)
 
No differences encountered
No differences encountered
--- old/usr/src/cmd/ptools/pargs/pargs.c	Wed Oct  5 00:33:08 2016
+++ new/usr/src/cmd/ptools/pargs/pargs.c	Wed Oct  5 00:33:08 2016
@@ -73,14 +73,7 @@
 #include <wctype.h>
 #include <widec.h>
 #include <elfcap.h>
-#include <libgen.h>
 
-typedef enum pargs_cmd {
-	PARGS_ARGV,
-	PARGS_ENV,
-	PARGS_AUXV
-} pargs_cmd_t;
-
 typedef struct pargs_data {
 	struct ps_prochandle *pd_proc;	/* target proc handle */
 	psinfo_t *pd_psinfo;		/* target psinfo */
@@ -1290,24 +1283,19 @@
 	int opt;
 	int error = 1;
 	core_content_t content = 0;
-	pargs_cmd_t cmd = PARGS_ARGV;
 
 	(void) setlocale(LC_ALL, "");
 
-	command = basename(argv[0]);
+	if ((command = strrchr(argv[0], '/')) != NULL)
+		command++;
+	else
+		command = argv[0];
 
-	if (strcmp(command, "penv") == 0)
-		cmd = PARGS_ENV;
-	else if (strcmp(command, "pauxv") == 0)
-		cmd = PARGS_AUXV;
-
 	while ((opt = getopt(argc, argv, "acelxF")) != EOF) {
 		switch (opt) {
 		case 'a':		/* show process arguments */
 			content |= CC_CONTENT_STACK;
 			aflag++;
-			if (cmd != PARGS_ARGV)
-				errflg++;
 			break;
 		case 'c':		/* force 7-bit ascii */
 			cflag++;
@@ -1315,19 +1303,13 @@
 		case 'e':		/* show environment variables */
 			content |= CC_CONTENT_STACK;
 			eflag++;
-			if (cmd != PARGS_ARGV)
-				errflg++;
 			break;
 		case 'l':
 			lflag++;
 			aflag++;	/* -l implies -a */
-			if (cmd != PARGS_ARGV)
-				errflg++;
 			break;
 		case 'x':		/* show aux vector entries */
 			xflag++;
-			if (cmd != PARGS_ARGV)
-				errflg++;
 			break;
 		case 'F':
 			/*
@@ -1344,19 +1326,8 @@
 
 	/* -a is the default if no options are specified */
 	if ((aflag + eflag + xflag + lflag) == 0) {
-		switch (cmd) {
-		case PARGS_ARGV:
-			aflag++;
-			content |= CC_CONTENT_STACK;
-			break;
-		case PARGS_ENV:
-			content |= CC_CONTENT_STACK;
-			eflag++;
-			break;
-		case PARGS_AUXV:
-			xflag++;
-			break;
-		}
+		aflag++;
+		content |= CC_CONTENT_STACK;
 	}
 
 	/* -l cannot be used with the -x or -e flags */
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/cmd/rcap/rcapadm/Makefile	Wed Oct  5 00:33:09 2016
+++ new/usr/src/cmd/rcap/rcapadm/Makefile	Wed Oct  5 00:33:09 2016
@@ -40,7 +40,7 @@
 
 $(NOT_RELEASE_BUILD)CPPFLAGS 	+= -DDEBUG
 CPPFLAGS 			+= -I$(COMMON_DIR)
-LDLIBS 				+= -lumem -lscf -lzonecfg
+LDLIBS 				+= -lscf -lzonecfg
 
 LINTFLAGS 			+= $(LDLIBS) -mnu
 
No differences encountered
--- old/usr/src/cmd/rcap/rcapd/Makefile.rcapd	Wed Oct  5 00:33:09 2016
+++ new/usr/src/cmd/rcap/rcapd/Makefile.rcapd	Wed Oct  5 00:33:09 2016
@@ -55,7 +55,7 @@
 $(NOT_RELEASE_BUILD)CPPFLAGS 	+= -DDEBUG
 CPPFLAGS			+= -DDEBUG_MSG
 CPPFLAGS 			+= -I$(COMMON_DIR)
-LDLIBS 				+= -lkstat -lproc -lproject -lzonecfg -lumem -lscf
+LDLIBS 				+= -lkstat -lproc -lproject -lumem -lscf
 LDLIBS				+= $(EXTRA_LDLIBS)
 
 LINTFLAGS			+= -u
No differences encountered
No differences encountered
--- old/usr/src/cmd/rcap/rcapstat/Makefile	Wed Oct  5 00:33:09 2016
+++ new/usr/src/cmd/rcap/rcapstat/Makefile	Wed Oct  5 00:33:09 2016
@@ -43,7 +43,7 @@
 
 $(NOT_RELEASE_BUILD)CPPFLAGS 	+= -DDEBUG
 CPPFLAGS 			+= -I$(COMMON_DIR) -I$(STATCOMMONDIR)
-LDLIBS 				+= -lumem -lzonecfg -lscf
+LDLIBS 				+= -lumem -lscf
 LDFLAGS				+= $(MAPFILE.NGB:%=-M%)
 
 LINTFLAGS			+= $(LDLIBS) -mnu
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/cmd/truss/print.c	Wed Oct  5 00:33:10 2016
+++ new/usr/src/cmd/truss/print.c	Wed Oct  5 00:33:10 2016
@@ -2003,7 +2003,6 @@
 	case UDP_EXCLBIND:		return ("UDP_EXCLBIND");
 	case UDP_RCVHDR:		return ("UDP_RCVHDR");
 	case UDP_NAT_T_ENDPOINT:	return ("UDP_NAT_T_ENDPOINT");
-	case UDP_SRCPORT_HASH:		return ("UDP_SRCPORT_HASH");
 	case UDP_SND_TO_CONNECTED:	return ("UDP_SND_TO_CONNECTED");
 
 	default:			(void) snprintf(pri->code_buf,
No differences encountered
--- old/usr/src/cmd/zlogin/zlogin.c	Wed Oct  5 00:33:10 2016
+++ new/usr/src/cmd/zlogin/zlogin.c	Wed Oct  5 00:33:10 2016
@@ -22,8 +22,8 @@
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2013 DEY Storage Systems, Inc.
  * Copyright (c) 2014 Gary Mills
- * Copyright 2016 Joyent, Inc.
  * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2016 Joyent, Inc.
  */
 
 /*
@@ -285,7 +285,7 @@
 	    sizeof (servaddr)) == -1) {
 		if (verbose)
 			zperror(gettext("Could not connect to zone"));
-		close(sockfd);
+		(void) close(sockfd);
 		return (-1);
 	}
 	return (sockfd);
@@ -561,8 +561,8 @@
 	if (ioctl(0, TIOCGWINSZ, &ws) == 0) {
 		if (ctlfd != -1) {
 			char buf[BUFSIZ];
-			snprintf(buf, sizeof (buf), "TIOCSWINSZ %hu %hu\n",
-			    ws.ws_row, ws.ws_col);
+			(void) snprintf(buf, sizeof (buf),
+			    "TIOCSWINSZ %hu %hu\n", ws.ws_row, ws.ws_col);
 			(void) send_ctl_sock(buf, strlen(buf));
 		} else {
 			(void) ioctl(masterfd, TIOCSWINSZ, &ws);
@@ -580,7 +580,7 @@
 	connect_flags ^= ZLOGIN_ZFD_EOF;
 	if (ctlfd != -1) {
 		char buf[BUFSIZ];
-		snprintf(buf, sizeof (buf), "SETFLAGS %u\n",
+		(void) snprintf(buf, sizeof (buf), "SETFLAGS %u\n",
 		    connect_flags);
 		(void) send_ctl_sock(buf, strlen(buf));
 	}
@@ -2217,7 +2217,7 @@
 			    (imode ? "server_ctl" : "console_sock"), B_FALSE);
 			if (masterfd != -1)
 				break;
-			sleep(1);
+			(void) sleep(1);
 		}
 
 		if (retry == MAX_RETRY) {
No differences encountered
--- old/usr/src/cmd/zoneadm/zoneadm.c	Wed Oct  5 00:33:10 2016
+++ new/usr/src/cmd/zoneadm/zoneadm.c	Wed Oct  5 00:33:10 2016
@@ -22,8 +22,8 @@
 /*
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
- * Copyright 2015, Joyent Inc. All rights reserved.
  * Copyright (c) 2015 by Delphix. All rights reserved.
+ * Copyright 2015, Joyent Inc. All rights reserved.
  */
 
 /*
@@ -107,6 +107,9 @@
 
 #define	CLUSTER_BRAND_NAME	"cluster"
 
+static zone_entry_t *zents;
+static size_t nzents;
+
 #define	LOOPBACK_IF	"lo0"
 #define	SOCKET_AF(af)	(((af) == AF_UNSPEC) ? AF_INET : (af))
 
@@ -405,6 +408,19 @@
 	va_end(alist);
 }
 
+static void *
+safe_calloc(size_t nelem, size_t elsize)
+{
+	void *r = calloc(nelem, elsize);
+
+	if (r == NULL) {
+		zerror(gettext("failed to allocate %lu bytes: %s"),
+		    (ulong_t)nelem * elsize, strerror(errno));
+		exit(Z_ERR);
+	}
+	return (r);
+}
+
 static void
 zone_print(zone_entry_t *zent, boolean_t verbose, boolean_t parsable)
 {
@@ -476,9 +492,6 @@
 	(void) strlcpy(zent->zbrand, "???", sizeof (zent->zbrand));
 	zent->zstate_str = "???";
 
-	if (strcmp(zone_name, GLOBAL_ZONENAME) == 0)
-		zid = zent->zdid = GLOBAL_ZONEID;
-
 	zent->zid = zid;
 
 	if (zonecfg_get_uuid(zone_name, uuid) == Z_OK &&
@@ -523,8 +536,8 @@
 	zent->zstate_str = zone_state_str(zent->zstate_num);
 
 	/*
-	 * A zone's brand might only be available in the .xml file describing
-	 * it, which is only visible to the global zone.  This causes
+	 * A zone's brand is only available in the .xml file describing it,
+	 * which is only visible to the global zone.  This causes
 	 * zone_get_brand() to fail when called from within a non-global
 	 * zone.  Fortunately we only do this on labeled systems, where we
 	 * know all zones are native.
@@ -594,63 +607,165 @@
 	return (Z_OK);
 }
 
+/*
+ * fetch_zents() calls zone_list(2) to find out how many zones are running
+ * (which is stored in the global nzents), then calls zone_list(2) again
+ * to fetch the list of running zones (stored in the global zents).  This
+ * function may be called multiple times, so if zents is already set, we
+ * return immediately to save work.
+ *
+ * Note that the data about running zones can change while this function
+ * is running, so its possible that the list of zones will have empty slots
+ * at the end.
+ */
+
 static int
-zone_print_list(zone_state_t min_state, boolean_t verbose, boolean_t parsable)
+fetch_zents(void)
 {
-	zone_entry_t zent;
-	FILE *cookie;
-	struct zoneent *ze;
+	zoneid_t *zids = NULL;
+	uint_t nzents_saved;
+	int i, retv;
+	FILE *fp;
+	boolean_t inaltroot;
+	zone_entry_t *zentp;
+	const char *altroot;
 
-	/*
-	 * Get the full list of zones from the configuration.
-	 */
-	cookie = setzoneent();
-	while ((ze = getzoneent_private(cookie)) != NULL) {
-		char *name = ze->zone_name;
-		zoneid_t zid;
+	if (nzents > 0)
+		return (Z_OK);
 
-		zid = getzoneidbyname(name);
+	if (zone_list(NULL, &nzents) != 0) {
+		zperror(gettext("failed to get zoneid list"), B_FALSE);
+		return (Z_ERR);
+	}
 
-		if (ze->zone_brand[0] == '\0') {
-			/* old, incomplete index entry */
-			if (lookup_zone_info(name, zid, &zent) != Z_OK) {
-				free(ze);
+again:
+	if (nzents == 0)
+		return (Z_OK);
+
+	zids = safe_calloc(nzents, sizeof (zoneid_t));
+	nzents_saved = nzents;
+
+	if (zone_list(zids, &nzents) != 0) {
+		zperror(gettext("failed to get zone list"), B_FALSE);
+		free(zids);
+		return (Z_ERR);
+	}
+	if (nzents != nzents_saved) {
+		/* list changed, try again */
+		free(zids);
+		goto again;
+	}
+
+	zents = safe_calloc(nzents, sizeof (zone_entry_t));
+
+	inaltroot = zonecfg_in_alt_root();
+	if (inaltroot) {
+		fp = zonecfg_open_scratch("", B_FALSE);
+		altroot = zonecfg_get_root();
+	} else {
+		fp = NULL;
+	}
+	zentp = zents;
+	retv = Z_OK;
+	for (i = 0; i < nzents; i++) {
+		char name[ZONENAME_MAX];
+		char altname[ZONENAME_MAX];
+		char rev_altroot[MAXPATHLEN];
+
+		if (getzonenamebyid(zids[i], name, sizeof (name)) < 0) {
+			/*
+			 * There is a race condition where the zone may have
+			 * shutdown since we retrieved the number of running
+			 * zones above.  This is not an error, there will be
+			 * an empty slot at the end of the list.
+			 */
+			continue;
+		}
+		if (zonecfg_is_scratch(name)) {
+			/* Ignore scratch zones by default */
+			if (!inaltroot)
 				continue;
+			if (fp == NULL ||
+			    zonecfg_reverse_scratch(fp, name, altname,
+			    sizeof (altname), rev_altroot,
+			    sizeof (rev_altroot)) == -1) {
+				zerror(gettext("could not resolve scratch "
+				    "zone %s"), name);
+				retv = Z_ERR;
+				continue;
 			}
+			/* Ignore zones in other alternate roots */
+			if (strcmp(rev_altroot, altroot) != 0)
+				continue;
+			(void) strcpy(name, altname);
 		} else {
-			/* new, full index entry */
-			(void) strlcpy(zent.zname, name, sizeof (zent.zname));
-			(void) strlcpy(zent.zroot, ze->zone_path,
-			    sizeof (zent.zroot));
-			uuid_unparse(ze->zone_uuid, zent.zuuid);
-			(void) strlcpy(zent.zbrand, ze->zone_brand,
-			    sizeof (zent.zbrand));
-			zent.ziptype = ze->zone_iptype;
-			zent.zdid = ze->zone_did;
-			zent.zid = zid;
+			/* Ignore non-scratch when in an alternate root */
+			if (inaltroot && strcmp(name, GLOBAL_ZONENAME) != 0)
+				continue;
+		}
+		if (lookup_zone_info(name, zids[i], zentp) != Z_OK) {
+			/*
+			 * There is a race condition where the zone may have
+			 * shutdown since we retrieved the number of running
+			 * zones above.  This is not an error, there will be
+			 * an empty slot at the end of the list.
+			 */
+			continue;
+		}
+		zentp++;
+	}
+	nzents = zentp - zents;
+	if (fp != NULL)
+		zonecfg_close_scratch(fp);
 
-			if (zid != -1) {
-				int err;
+	free(zids);
+	return (retv);
+}
 
-				err = zone_get_state(name,
-				    (zone_state_t *)&ze->zone_state);
-				if (err != Z_OK) {
-					errno = err;
-					zperror2(name, gettext("could not get "
-					    "state"));
-					free(ze);
-					continue;
-				}
-			}
+static int
+zone_print_list(zone_state_t min_state, boolean_t verbose, boolean_t parsable)
+{
+	int i;
+	zone_entry_t zent;
+	FILE *cookie;
+	char *name;
 
-			zent.zstate_num = ze->zone_state;
-			zent.zstate_str = zone_state_str(zent.zstate_num);
+	/*
+	 * First get the list of running zones from the kernel and print them.
+	 * If that is all we need, then return.
+	 */
+	if ((i = fetch_zents()) != Z_OK) {
+		/*
+		 * No need for error messages; fetch_zents() has already taken
+		 * care of this.
+		 */
+		return (i);
+	}
+	for (i = 0; i < nzents; i++)
+		zone_print(&zents[i], verbose, parsable);
+	if (min_state >= ZONE_STATE_RUNNING)
+		return (Z_OK);
+	/*
+	 * Next, get the full list of zones from the configuration, skipping
+	 * any we have already printed.
+	 */
+	cookie = setzoneent();
+	while ((name = getzoneent(cookie)) != NULL) {
+		for (i = 0; i < nzents; i++) {
+			if (strcmp(zents[i].zname, name) == 0)
+				break;
 		}
-
+		if (i < nzents) {
+			free(name);
+			continue;
+		}
+		if (lookup_zone_info(name, ZONE_ID_UNDEFINED, &zent) != Z_OK) {
+			free(name);
+			continue;
+		}
+		free(name);
 		if (zent.zstate_num >= min_state)
 			zone_print(&zent, verbose, parsable);
-
-		free(ze);
 	}
 	endzoneent(cookie);
 	return (Z_OK);
@@ -911,12 +1026,8 @@
 		(void) printf(gettext("WARNING: %s is on a temporary "
 		    "file system.\n"), rpath);
 	}
-	if (cmd_num != CMD_BOOT && cmd_num != CMD_REBOOT &&
-	    cmd_num != CMD_READY) {
-		/* we checked when we installed, no need to check each boot */
-		if (crosscheck_zonepaths(rpath) != Z_OK)
-			return (Z_ERR);
-	}
+	if (crosscheck_zonepaths(rpath) != Z_OK)
+		return (Z_ERR);
 	/*
 	 * Try to collect and report as many minor errors as possible
 	 * before returning, so the user can learn everything that needs
@@ -1103,7 +1214,6 @@
 ready_func(int argc, char *argv[])
 {
 	zone_cmd_arg_t zarg;
-	boolean_t debug = B_FALSE;
 	int arg;
 
 	if (zonecfg_in_alt_root()) {
@@ -1112,14 +1222,11 @@
 	}
 
 	optind = 0;
-	if ((arg = getopt(argc, argv, "?X")) != EOF) {
+	if ((arg = getopt(argc, argv, "?")) != EOF) {
 		switch (arg) {
 		case '?':
 			sub_usage(SHELP_READY, CMD_READY);
 			return (optopt == '?' ? Z_OK : Z_USAGE);
-		case 'X':
-			debug = B_TRUE;
-			break;
 		default:
 			sub_usage(SHELP_READY, CMD_READY);
 			return (Z_USAGE);
@@ -1136,7 +1243,6 @@
 		return (Z_ERR);
 
 	zarg.cmd = Z_READY;
-	zarg.debug = debug;
 	if (zonecfg_call_zoneadmd(target_zone, &zarg, locale, B_TRUE) != 0) {
 		zerror(gettext("call to %s failed"), "zoneadmd");
 		return (Z_ERR);
@@ -1149,7 +1255,6 @@
 {
 	zone_cmd_arg_t zarg;
 	boolean_t force = B_FALSE;
-	boolean_t debug = B_FALSE;
 	int arg;
 
 	if (zonecfg_in_alt_root()) {
@@ -1176,7 +1281,7 @@
 	 *	zoneadm -z myzone boot -- -s -v -m verbose.
 	 */
 	optind = 0;
-	while ((arg = getopt(argc, argv, "?fsX")) != EOF) {
+	while ((arg = getopt(argc, argv, "?fs")) != EOF) {
 		switch (arg) {
 		case '?':
 			sub_usage(SHELP_BOOT, CMD_BOOT);
@@ -1188,9 +1293,6 @@
 		case 'f':
 			force = B_TRUE;
 			break;
-		case 'X':
-			debug = B_TRUE;
-			break;
 		default:
 			sub_usage(SHELP_BOOT, CMD_BOOT);
 			return (Z_USAGE);
@@ -1216,7 +1318,6 @@
 	if (verify_details(CMD_BOOT, argv) != Z_OK)
 		return (Z_ERR);
 	zarg.cmd = force ? Z_FORCEBOOT : Z_BOOT;
-	zarg.debug = debug;
 	if (zonecfg_call_zoneadmd(target_zone, &zarg, locale, B_TRUE) != 0) {
 		zerror(gettext("call to %s failed"), "zoneadmd");
 		return (Z_ERR);
@@ -1526,10 +1627,10 @@
  *     not already running (or ready).
  */
 static int
-sanity_check(char *zone, int cmd_num, boolean_t need_running,
+sanity_check(char *zone, int cmd_num, boolean_t running,
     boolean_t unsafe_when_running, boolean_t force)
 {
-	boolean_t is_running = B_FALSE;
+	zone_entry_t *zent;
 	priv_set_t *privset;
 	zone_state_t state, min_state;
 	char kernzone[ZONENAME_MAX];
@@ -1600,15 +1701,15 @@
 	}
 
 	if (!zonecfg_in_alt_root()) {
-		/* Avoid the xml read overhead of lookup_running_zone */
-		if (getzoneidbyname(zone) != -1)
-			is_running = B_TRUE;
-
-	} else if ((fp = zonecfg_open_scratch("", B_FALSE)) != NULL) {
-		if (zonecfg_find_scratch(fp, zone, zonecfg_get_root(), kernzone,
-		    sizeof (kernzone)) == 0 && getzoneidbyname(kernzone) != -1)
-			is_running = B_TRUE;
-
+		zent = lookup_running_zone(zone);
+	} else if ((fp = zonecfg_open_scratch("", B_FALSE)) == NULL) {
+		zent = NULL;
+	} else {
+		if (zonecfg_find_scratch(fp, zone, zonecfg_get_root(),
+		    kernzone, sizeof (kernzone)) == 0)
+			zent = lookup_running_zone(kernzone);
+		else
+			zent = NULL;
 		zonecfg_close_scratch(fp);
 	}
 
@@ -1615,8 +1716,8 @@
 	/*
 	 * Look up from the kernel for 'running' zones.
 	 */
-	if (need_running && !force) {
-		if (!is_running) {
+	if (running && !force) {
+		if (zent == NULL) {
 			zerror(gettext("not running"));
 			return (Z_ERR);
 		}
@@ -1623,31 +1724,28 @@
 	} else {
 		int err;
 
-		err = zone_get_state(zone, &state);
-
-		if (unsafe_when_running && is_running) {
+		if (unsafe_when_running && zent != NULL) {
 			/* check whether the zone is ready or running */
-			char *zstate_str;
-
-			if (err != Z_OK) {
+			if ((err = zone_get_state(zent->zname,
+			    &zent->zstate_num)) != Z_OK) {
 				errno = err;
-				zperror2(zone, gettext("could not get state"));
+				zperror2(zent->zname,
+				    gettext("could not get state"));
 				/* can't tell, so hedge */
-				zstate_str = "ready/running";
+				zent->zstate_str = "ready/running";
 			} else {
-				zstate_str = zone_state_str(state);
+				zent->zstate_str =
+				    zone_state_str(zent->zstate_num);
 			}
 			zerror(gettext("%s operation is invalid for %s zones."),
-			    cmd_to_str(cmd_num), zstate_str);
+			    cmd_to_str(cmd_num), zent->zstate_str);
 			return (Z_ERR);
 		}
-
-		if (err != Z_OK) {
+		if ((err = zone_get_state(zone, &state)) != Z_OK) {
 			errno = err;
 			zperror2(zone, gettext("could not get state"));
 			return (Z_ERR);
 		}
-
 		switch (cmd_num) {
 		case CMD_UNINSTALL:
 			if (state == ZONE_STATE_CONFIGURED) {
@@ -1735,7 +1833,6 @@
 halt_func(int argc, char *argv[])
 {
 	zone_cmd_arg_t zarg;
-	boolean_t debug = B_FALSE;
 	int arg;
 
 	if (zonecfg_in_alt_root()) {
@@ -1744,14 +1841,11 @@
 	}
 
 	optind = 0;
-	if ((arg = getopt(argc, argv, "?X")) != EOF) {
+	if ((arg = getopt(argc, argv, "?")) != EOF) {
 		switch (arg) {
 		case '?':
 			sub_usage(SHELP_HALT, CMD_HALT);
 			return (optopt == '?' ? Z_OK : Z_USAGE);
-		case 'X':
-			debug = B_TRUE;
-			break;
 		default:
 			sub_usage(SHELP_HALT, CMD_HALT);
 			return (Z_USAGE);
@@ -1777,7 +1871,6 @@
 		return (Z_ERR);
 
 	zarg.cmd = Z_HALT;
-	zarg.debug = debug;
 	return ((zonecfg_call_zoneadmd(target_zone, &zarg, locale,
 	    B_TRUE) == 0) ?  Z_OK : Z_ERR);
 }
@@ -1855,7 +1948,6 @@
 reboot_func(int argc, char *argv[])
 {
 	zone_cmd_arg_t zarg;
-	boolean_t debug = B_FALSE;
 	int arg;
 
 	if (zonecfg_in_alt_root()) {
@@ -1864,14 +1956,11 @@
 	}
 
 	optind = 0;
-	if ((arg = getopt(argc, argv, "?X")) != EOF) {
+	if ((arg = getopt(argc, argv, "?")) != EOF) {
 		switch (arg) {
 		case '?':
 			sub_usage(SHELP_REBOOT, CMD_REBOOT);
 			return (optopt == '?' ? Z_OK : Z_USAGE);
-		case 'X':
-			debug = B_TRUE;
-			break;
 		default:
 			sub_usage(SHELP_REBOOT, CMD_REBOOT);
 			return (Z_USAGE);
@@ -1906,7 +1995,6 @@
 		return (Z_ERR);
 
 	zarg.cmd = Z_REBOOT;
-	zarg.debug = debug;
 	return ((zonecfg_call_zoneadmd(target_zone, &zarg, locale, B_TRUE) == 0)
 	    ? Z_OK : Z_ERR);
 }
@@ -2134,10 +2222,6 @@
 	if (strcmp(fstab->zone_fs_type, MNTTYPE_ZFS) == 0)
 		return (verify_fs_zfs(fstab));
 
-	if (strcmp(fstab->zone_fs_type, MNTTYPE_HYPRLOFS) == 0 &&
-	    strcmp(fstab->zone_fs_special, "swap") == 0)
-			return (Z_OK);
-
 	if (stat64(fstab->zone_fs_special, &st) != 0) {
 		(void) fprintf(stderr, gettext("could not verify fs "
 		    "%s: could not access %s: %s\n"), fstab->zone_fs_dir,
@@ -2541,6 +2625,7 @@
 	dladm_handle_t dh;
 	dladm_status_t status;
 	datalink_id_t linkid;
+	char errmsg[DLADM_STRSIZE];
 
 	in_alt_root = zonecfg_in_alt_root();
 	if (in_alt_root)
@@ -2623,6 +2708,11 @@
 				dladm_close(dh);
 			}
 			if (status != DLADM_STATUS_OK) {
+				(void) fprintf(stderr,
+				    gettext("WARNING: skipping network "
+				    "interface '%s': %s\n"),
+				    nwiftab.zone_nwif_physical,
+				    dladm_status2str(status, errmsg));
 				break;
 			}
 			dl_owner_zid = ALL_ZONES;
@@ -2720,8 +2810,9 @@
 verify_fix_did(zone_dochandle_t handle)
 {
 	zoneid_t mydid;
-	struct zoneent *ze;
+	zone_entry_t zent;
 	FILE *cookie;
+	char *name;
 	boolean_t fix = B_FALSE;
 
 	mydid = zonecfg_get_did(handle);
@@ -2732,34 +2823,20 @@
 
 	/* Get the full list of zones from the configuration. */
 	cookie = setzoneent();
-	while ((ze = getzoneent_private(cookie)) != NULL) {
-		char *name;
-		zoneid_t did;
+	while ((name = getzoneent(cookie)) != NULL) {
+		if (strcmp(target_zone, name) == 0) {
+			free(name);
+			break;	/* Once we find our entry, stop. */
+		}
 
-		name = ze->zone_name;
-		if (strcmp(name, GLOBAL_ZONENAME) == 0 ||
-		    strcmp(name, target_zone) == 0) {
-			free(ze);
+		if (strcmp(name, "global") == 0 ||
+		    lookup_zone_info(name, ZONE_ID_UNDEFINED, &zent) != Z_OK) {
+			free(name);
 			continue;
 		}
 
-		if (ze->zone_brand[0] == '\0') {
-			/* old, incomplete index entry */
-			zone_entry_t zent;
-
-			if (lookup_zone_info(name, ZONE_ID_UNDEFINED,
-			    &zent) != Z_OK) {
-				free(ze);
-				continue;
-			}
-			did = zent.zdid;
-		} else {
-			/* new, full index entry */
-			did = ze->zone_did;
-		}
-		free(ze);
-
-		if (did == mydid) {
+		free(name);
+		if (zent.zdid == mydid) {
 			fix = B_TRUE;
 			break;
 		}
@@ -2930,7 +3007,6 @@
 	int status;
 	boolean_t do_postinstall = B_FALSE;
 	boolean_t brand_help = B_FALSE;
-	boolean_t do_dataset = B_TRUE;
 	char opts[128];
 
 	if (target_zone == NULL) {
@@ -3006,12 +3082,6 @@
 			}
 			/* Ignore unknown options - may be brand specific. */
 			break;
-		case 'x':
-			if (strcmp(optarg, "nodataset") == 0) {
-				do_dataset = B_FALSE;
-				continue; /* internal arg, don't pass thru */
-			}
-			break;
 		default:
 			/* Ignore unknown options - may be brand specific. */
 			break;
@@ -3064,8 +3134,7 @@
 			goto done;
 		}
 
-		if (do_dataset)
-			create_zfs_zonepath(zonepath);
+		create_zfs_zonepath(zonepath);
 	}
 
 	status = do_subproc(cmdbuf);
@@ -5029,7 +5098,6 @@
 		if (zonecfg_ping_zoneadmd(target_zone) == Z_OK) {
 			zone_cmd_arg_t zarg;
 			zarg.cmd = Z_NOTE_UNINSTALLING;
-			zarg.debug = B_FALSE;
 			/* we don't care too much if this fails, just plow on */
 			(void) zonecfg_call_zoneadmd(target_zone, &zarg, locale,
 			    B_TRUE);
@@ -5145,7 +5213,6 @@
 		return (Z_ERR);
 
 	zarg.cmd = force ? Z_FORCEMOUNT : Z_MOUNT;
-	zarg.debug = B_FALSE;
 	zarg.bootbuf[0] = '\0';
 	if (zonecfg_call_zoneadmd(target_zone, &zarg, locale, B_TRUE) != 0) {
 		zerror(gettext("call to %s failed"), "zoneadmd");
@@ -5167,7 +5234,6 @@
 		return (Z_ERR);
 
 	zarg.cmd = Z_UNMOUNT;
-	zarg.debug = B_FALSE;
 	if (zonecfg_call_zoneadmd(target_zone, &zarg, locale, B_TRUE) != 0) {
 		zerror(gettext("call to %s failed"), "zoneadmd");
 		return (Z_ERR);
--- old/usr/src/cmd/zoneadmd/Makefile	Wed Oct  5 00:33:11 2016
+++ new/usr/src/cmd/zoneadmd/Makefile	Wed Oct  5 00:33:11 2016
@@ -18,7 +18,10 @@
 #
 # CDDL HEADER END
 
+
 #
+
+#
 # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
 # Copyright 2014 Nexenta Systems, Inc. All rights reserved.
 # Copyright (c) 2011, Joyent, Inc. All rights reserved.
@@ -27,45 +30,46 @@
 PROG= zoneadmd
 
 include ../Makefile.cmd
-include ../Makefile.ctf
 
-$(64ONLY)SUBDIRS= $(MACH)
-$(BUILD64)SUBDIRS += $(MACH64)
+ROOTCMDDIR=	$(ROOTLIB)/zones
 
-all	:=	TARGET = all
-install	:=	TARGET = install
-clean	:=	TARGET = clean
-clobber	:=	TARGET = clobber
-lint	:=	TARGET = lint
+OBJS= zoneadmd.o zcons.o vplat.o mcap.o zfd.o
+SRCS = $(OBJS:.o=.c)
+POFILE=zoneadmd_all.po
+POFILES= $(OBJS:%.o=%.po)
 
+CFLAGS += $(CCVERBOSE)
+CERRWARN += -_gcc=-Wno-switch
+CERRWARN += -_gcc=-Wno-parentheses
+CERRWARN += -_gcc=-Wno-uninitialized
+
+LDLIBS += -lsocket -lzonecfg -lnsl -ldevinfo -ldevice -lnvpair \
+	-lgen -lbsm -lcontract -lzfs -luuid -lbrand -ldladm -ltsnet -ltsol \
+	-linetutil -lscf -lproc
 XGETFLAGS += -a -x zoneadmd.xcl
 
-ROOTUSRLIBZONES			= $(ROOT)/usr/lib/zones
-
 .KEEP_STATE:
 
 .PARALLEL:
 
-all: $(SUBDIRS)
+all: $(PROG)
 
 $(PROG): $(OBJS)
 	$(LINK.c) -o $@ $(OBJS) $(LDLIBS)
 	$(POST_PROCESS)
 
-install: $(SUBDIRS)
-	-$(RM) $(ROOTUSRLIBZONES)/$(PROG)
-	-$(LN) $(ISAEXEC) $(ROOTUSRLIBZONES)/$(PROG)
+install: all $(ROOTCMD)
 
-$(POFILE):
+$(POFILE): $(POFILES)
+	$(RM) $@
+	$(CAT) $(POFILES) > $@
 
-clean clobebr lint:	$(SUBDIRS)
+clean:
+	$(RM) $(OBJS)
 
+lint:	lint_SRCS
+
 check:
-	$(CSTYLE) -p -P *.c
+	$(CSTYLE) -p -P $(SRCS:%=%)
 
-$(SUBDIRS):	FRC
-	@cd $@; pwd; $(MAKE) $(TARGET)
-
-FRC:
-
 include ../Makefile.targ
--- old/usr/src/cmd/zoneadmd/mcap.c	Wed Oct  5 00:33:11 2016
+++ new/usr/src/cmd/zoneadmd/mcap.c	Wed Oct  5 00:33:11 2016
@@ -130,6 +130,15 @@
 #define	TUNE_NPFTHROT	"phys-mcap-no-pf-throttle"
 
 /*
+ * The large mapping value was derived empirically by seeing that mappings
+ * much bigger than 16mb sometimes take a relatively long time to invalidate
+ * (significant fraction of a second).
+ */
+#define	SEC_INTERIM	4	/* num secs to pause after stopped too long */
+#define	MSEC_TOO_LONG	100	/* release proc. after stopped for 100ms */
+#define	LARGE_MAPPING	16384	/* >= 16MB in KB - pageout in chunks */
+
+/*
  * These are only used in get_mem_info but global. We always need scale_rss and
  * prev_fast_rss to be persistent but we also have the other two global so we
  * can easily see these with mdb.
@@ -153,8 +162,6 @@
 static boolean_t skip_pageout = B_FALSE;
 static boolean_t skip_pf_throttle = B_FALSE;
 
-static zlog_t	*logp;
-
 static int64_t check_suspend();
 static void get_mcap_tunables();
 
@@ -379,7 +386,6 @@
 	int			psfd;
 	prmap_t			*pmap;
 	proc_map_t		cur;
-	int			res;
 	int64_t			sum_d_rss, d_rss;
 	int64_t			old_rss;
 	int			map_cnt;
@@ -431,9 +437,10 @@
 	sum_d_rss = 0;
 	while (excess > 0 && pmap != NULL && !shutting_down) {
 		/* invalidate the entire mapping */
-		if ((res = pageout_mapping(pid, pmap)) < 0)
+		if (pageout_mapping(pid, pmap) < 0)
 			debug("pid %ld: mapping 0x%p %ldkb unpageable (%d)\n",
-			    pid, pmap->pr_vaddr, pmap->pr_size / 1024, errno);
+			    pid, (void *)pmap->pr_vaddr,
+			    (long)pmap->pr_size / 1024L, errno);
 
 		map_cnt++;
 
@@ -1147,7 +1154,6 @@
 
 	shutting_down = 0;
 	zid = id;
-	logp = zlogp;
 
 	/* all but the lx brand currently use /proc */
 	if (strcmp(brand_name, "lx") == 0) {
--- old/usr/src/cmd/zoneadmd/vplat.c	Wed Oct  5 00:33:11 2016
+++ new/usr/src/cmd/zoneadmd/vplat.c	Wed Oct  5 00:33:11 2016
@@ -21,8 +21,8 @@
 
 /*
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2016, Joyent Inc.
  * Copyright (c) 2015 by Delphix. All rights reserved.
+ * Copyright 2016, Joyent Inc.
  */
 
 /*
@@ -136,9 +136,6 @@
 #define	DFSTYPES	"/etc/dfs/fstypes"
 #define	MAXTNZLEN	2048
 
-/* Number of times to retry unmounting if it fails */
-#define	UMOUNT_RETRIES	30
-
 /* a reasonable estimate for the number of lwps per process */
 #define	LWPS_PER_PROCESS	10
 
@@ -180,7 +177,6 @@
 
 /* from zoneadmd */
 extern char query_hook[];
-extern char post_statechg_hook[];
 
 /*
  * For each "net" resource configured in zonecfg, we track a zone_addr_list_t
@@ -217,7 +213,7 @@
 	/*
 	 * Ask autofs to unmount all trigger nodes in the given zone.
 	 */
-	return (_autofssys(AUTOFS_UNMOUNTALL, (void *)((uintptr_t)zoneid)));
+	return (_autofssys(AUTOFS_UNMOUNTALL, (void *)zoneid));
 }
 
 static void
@@ -608,24 +604,6 @@
 }
 
 /*
- * Perform brand-specific cleanup if we are unable to unmount a FS.
- */
-static void
-brand_umount_cleanup(zlog_t *zlogp, char *path)
-{
-	char cmdbuf[2 * MAXPATHLEN];
-
-	if (post_statechg_hook[0] == '\0')
-		return;
-
-	if (snprintf(cmdbuf, sizeof (cmdbuf), "%s %d %d %s", post_statechg_hook,
-	    ZONE_STATE_DOWN, Z_UNMOUNT, path) > sizeof (cmdbuf))
-		return;
-
-	(void) do_subproc(zlogp, cmdbuf, NULL, B_FALSE);
-}
-
-/*
  * The general strategy for unmounting filesystems is as follows:
  *
  * - Remote filesystems may be dead, and attempting to contact them as
@@ -658,7 +636,6 @@
 unmount_filesystems(zlog_t *zlogp, zoneid_t zoneid, boolean_t unmount_cmd)
 {
 	int error = 0;
-	int fail = 0;
 	FILE *mnttab;
 	struct mnttab *mnts;
 	uint_t nmnt;
@@ -746,39 +723,18 @@
 				if (umount2(path, MS_FORCE) == 0) {
 					unmounted = B_TRUE;
 					stuck = B_FALSE;
-					fail = 0;
 				} else {
 					/*
-					 * We may hit a failure here if there
-					 * is an app in the GZ with an open
-					 * pipe into the zone (commonly into
-					 * the zone's /var/run).  This type
-					 * of app will notice the closed
-					 * connection and cleanup, but it may
-					 * take a while and we have no easy
-					 * way to notice that.  To deal with
-					 * this case, we will wait and retry
-					 * a few times before we give up.
+					 * The first failure indicates a
+					 * mount we won't be able to get
+					 * rid of automatically, so we
+					 * bail.
 					 */
-					fail++;
-					if (fail < (UMOUNT_RETRIES - 1)) {
-						zerror(zlogp, B_FALSE,
-						    "unable to unmount '%s', "
-						    "retrying in 2 seconds",
-						    path);
-						(void) sleep(2);
-					} else if (fail > UMOUNT_RETRIES) {
-						error++;
-						zerror(zlogp, B_FALSE,
-						    "unmount of '%s' failed",
-						    path);
-						free_mnttable(mnts, nmnt);
-						goto out;
-					} else {
-						/* Try the hook 2 times */
-						brand_umount_cleanup(zlogp,
-						    path);
-					}
+					error++;
+					zerror(zlogp, B_FALSE,
+					    "unable to unmount '%s'", path);
+					free_mnttable(mnts, nmnt);
+					goto out;
 				}
 			}
 			/*
@@ -1116,10 +1072,23 @@
 int
 vplat_get_iptype(zlog_t *zlogp, zone_iptype_t *iptypep)
 {
-	if (zonecfg_get_iptype(snap_hndl, iptypep) != Z_OK) {
+	zone_dochandle_t handle;
+
+	if ((handle = zonecfg_init_handle()) == NULL) {
+		zerror(zlogp, B_TRUE, "getting zone configuration handle");
+		return (-1);
+	}
+	if (zonecfg_get_snapshot_handle(zone_name, handle) != Z_OK) {
+		zerror(zlogp, B_FALSE, "invalid configuration");
+		zonecfg_fini_handle(handle);
+		return (-1);
+	}
+	if (zonecfg_get_iptype(handle, iptypep) != Z_OK) {
 		zerror(zlogp, B_FALSE, "invalid ip-type configuration");
+		zonecfg_fini_handle(handle);
 		return (-1);
 	}
+	zonecfg_fini_handle(handle);
 	return (0);
 }
 
@@ -1132,6 +1101,7 @@
 mount_one_dev(zlog_t *zlogp, char *devpath, zone_mnt_t mount_cmd)
 {
 	char			brand[MAXNAMELEN];
+	zone_dochandle_t	handle = NULL;
 	brand_handle_t		bh = NULL;
 	struct zone_devtab	ztab;
 	di_prof_t		prof = NULL;
@@ -1138,7 +1108,7 @@
 	int			err;
 	int			retval = -1;
 	zone_iptype_t		iptype;
-	const char 		*curr_iptype = NULL;
+	const char 		*curr_iptype;
 
 	if (di_prof_init(devpath, &prof)) {
 		zerror(zlogp, B_TRUE, "failed to initialize profile");
@@ -1173,8 +1143,6 @@
 		curr_iptype = "exclusive";
 		break;
 	}
-	if (curr_iptype == NULL)
-		abort();
 
 	if (brand_platform_iter_devices(bh, zone_name,
 	    mount_one_dev_device_cb, prof, curr_iptype) != 0) {
@@ -1189,12 +1157,21 @@
 	}
 
 	/* Add user-specified devices and directories */
-	if ((err = zonecfg_setdevent(snap_hndl)) != 0) {
+	if ((handle = zonecfg_init_handle()) == NULL) {
+		zerror(zlogp, B_FALSE, "can't initialize zone handle");
+		goto cleanup;
+	}
+	if ((err = zonecfg_get_handle(zone_name, handle)) != 0) {
+		zerror(zlogp, B_FALSE, "can't get handle for zone "
+		    "%s: %s", zone_name, zonecfg_strerror(err));
+		goto cleanup;
+	}
+	if ((err = zonecfg_setdevent(handle)) != 0) {
 		zerror(zlogp, B_FALSE, "%s: %s", zone_name,
 		    zonecfg_strerror(err));
 		goto cleanup;
 	}
-	while (zonecfg_getdevent(snap_hndl, &ztab) == Z_OK) {
+	while (zonecfg_getdevent(handle, &ztab) == Z_OK) {
 		if (di_prof_add_dev(prof, ztab.zone_dev_match)) {
 			zerror(zlogp, B_TRUE, "failed to add "
 			    "user-specified device");
@@ -1201,7 +1178,7 @@
 			goto cleanup;
 		}
 	}
-	(void) zonecfg_enddevent(snap_hndl);
+	(void) zonecfg_enddevent(handle);
 
 	/* Send profile to kernel */
 	if (di_prof_commit(prof)) {
@@ -1214,6 +1191,8 @@
 cleanup:
 	if (bh != NULL)
 		brand_close(bh);
+	if (handle != NULL)
+		zonecfg_fini_handle(handle);
 	if (prof)
 		di_prof_fini(prof);
 	return (retval);
@@ -1707,6 +1686,7 @@
 	char luroot[MAXPATHLEN];
 	int i, num_fs = 0;
 	struct zone_fstab *fs_ptr = NULL;
+	zone_dochandle_t handle = NULL;
 	zone_state_t zstate;
 	brand_handle_t bh;
 	plat_gmount_cb_data_t cb;
@@ -1725,7 +1705,12 @@
 		goto bad;
 	}
 
-	if (zonecfg_setfsent(snap_hndl) != Z_OK) {
+	if ((handle = zonecfg_init_handle()) == NULL) {
+		zerror(zlogp, B_TRUE, "getting zone configuration handle");
+		goto bad;
+	}
+	if (zonecfg_get_snapshot_handle(zone_name, handle) != Z_OK ||
+	    zonecfg_setfsent(handle) != Z_OK) {
 		zerror(zlogp, B_FALSE, "invalid configuration");
 		goto bad;
 	}
@@ -1743,6 +1728,7 @@
 	/* Get a handle to the brand info for this zone */
 	if ((bh = brand_open(brand)) == NULL) {
 		zerror(zlogp, B_FALSE, "unable to determine zone brand");
+		zonecfg_fini_handle(handle);
 		return (-1);
 	}
 
@@ -1757,6 +1743,7 @@
 	    plat_gmount_cb, &cb) != 0) {
 		zerror(zlogp, B_FALSE, "unable to mount filesystems");
 		brand_close(bh);
+		zonecfg_fini_handle(handle);
 		return (-1);
 	}
 	brand_close(bh);
@@ -1767,10 +1754,13 @@
 	 * higher level directories (e.g., /usr) get mounted before
 	 * any beneath them (e.g., /usr/local).
 	 */
-	if (mount_filesystems_fsent(snap_hndl, zlogp, &fs_ptr, &num_fs,
+	if (mount_filesystems_fsent(handle, zlogp, &fs_ptr, &num_fs,
 	    mount_cmd) != 0)
 		goto bad;
 
+	zonecfg_fini_handle(handle);
+	handle = NULL;
+
 	/*
 	 * Normally when we mount a zone all the zone filesystems
 	 * get mounted relative to rootpath, which is usually
@@ -1866,6 +1856,8 @@
 	return (0);
 
 bad:
+	if (handle != NULL)
+		zonecfg_fini_handle(handle);
 	free_fs_data(fs_ptr, num_fs);
 	return (-1);
 }
@@ -2221,7 +2213,13 @@
 	if (ioctl(s, SIOCLIFADDIF, (caddr_t)&lifr) < 0) {
 		/*
 		 * Here, we know that the interface can't be brought up.
+		 * A similar warning message was already printed out to
+		 * the console by zoneadm(1M) so instead we log the
+		 * message to syslog and continue.
 		 */
+		zerror(&logsys, B_TRUE, "WARNING: skipping network interface "
+		    "'%s' which may not be present/plumbed in the "
+		    "global zone.", lifr.lifr_name);
 		(void) close(s);
 		return (Z_OK);
 	}
@@ -2434,6 +2432,7 @@
 static int
 configure_shared_network_interfaces(zlog_t *zlogp)
 {
+	zone_dochandle_t handle;
 	struct zone_nwiftab nwiftab, loopback_iftab;
 	zoneid_t zoneid;
 
@@ -2442,19 +2441,29 @@
 		return (-1);
 	}
 
-	if (zonecfg_setnwifent(snap_hndl) == Z_OK) {
+	if ((handle = zonecfg_init_handle()) == NULL) {
+		zerror(zlogp, B_TRUE, "getting zone configuration handle");
+		return (-1);
+	}
+	if (zonecfg_get_snapshot_handle(zone_name, handle) != Z_OK) {
+		zerror(zlogp, B_FALSE, "invalid configuration");
+		zonecfg_fini_handle(handle);
+		return (-1);
+	}
+	if (zonecfg_setnwifent(handle) == Z_OK) {
 		for (;;) {
-			if (zonecfg_getnwifent(snap_hndl, &nwiftab) != Z_OK)
+			if (zonecfg_getnwifent(handle, &nwiftab) != Z_OK)
 				break;
-			nwifent_free_attrs(&nwiftab);
 			if (configure_one_interface(zlogp, zoneid, &nwiftab) !=
 			    Z_OK) {
-				(void) zonecfg_endnwifent(snap_hndl);
+				(void) zonecfg_endnwifent(handle);
+				zonecfg_fini_handle(handle);
 				return (-1);
 			}
 		}
-		(void) zonecfg_endnwifent(snap_hndl);
+		(void) zonecfg_endnwifent(handle);
 	}
+	zonecfg_fini_handle(handle);
 	if (is_system_labeled()) {
 		/*
 		 * Labeled zones share the loopback interface
@@ -2901,6 +2910,25 @@
 }
 
 /*
+ * For IP networking, we need to use the illumos-native device tree.  For most
+ * zones, this is $ZONEROOT/dev.  For LX ones, it's $ZONEROOT/native/dev.
+ * Return the appropriate post-$ZONEROOT path.
+ */
+static char *
+get_brand_dev(void)
+{
+	static char *lxpath = "/native/dev";
+	/* Cheesy hard-coding of strlen("/native") */
+	char *default_path = lxpath + 7;
+
+	/* LX zones are the exception... */
+	if (strcmp(brand_name, "lx") == 0)
+		return (lxpath);
+
+	return (default_path);
+}
+
+/*
  * Add the kernel access control information for the interface names.
  * If anything goes wrong, we log a general error message, attempt to tear down
  * whatever we set up, and return an error.
@@ -2908,6 +2936,7 @@
 static int
 configure_exclusive_network_interfaces(zlog_t *zlogp, zoneid_t zoneid)
 {
+	zone_dochandle_t handle;
 	struct zone_nwiftab nwiftab;
 	char rootpath[MAXPATHLEN];
 	char path[MAXPATHLEN];
@@ -2916,26 +2945,39 @@
 	boolean_t added = B_FALSE;
 	zone_addr_list_t *zalist = NULL, *new;
 
-	if (zonecfg_setnwifent(snap_hndl) != Z_OK)
+	if ((handle = zonecfg_init_handle()) == NULL) {
+		zerror(zlogp, B_TRUE, "getting zone configuration handle");
+		return (-1);
+	}
+	if (zonecfg_get_snapshot_handle(zone_name, handle) != Z_OK) {
+		zerror(zlogp, B_FALSE, "invalid configuration");
+		zonecfg_fini_handle(handle);
+		return (-1);
+	}
+
+	if (zonecfg_setnwifent(handle) != Z_OK) {
+		zonecfg_fini_handle(handle);
 		return (0);
+	}
 
 	for (;;) {
-		if (zonecfg_getnwifent(snap_hndl, &nwiftab) != Z_OK)
+		if (zonecfg_getnwifent(handle, &nwiftab) != Z_OK)
 			break;
 
-		nwifent_free_attrs(&nwiftab);
 		if (prof == NULL) {
 			if (zone_get_devroot(zone_name, rootpath,
 			    sizeof (rootpath)) != Z_OK) {
-				(void) zonecfg_endnwifent(snap_hndl);
+				(void) zonecfg_endnwifent(handle);
+				zonecfg_fini_handle(handle);
 				zerror(zlogp, B_TRUE,
 				    "unable to determine dev root");
 				return (-1);
 			}
 			(void) snprintf(path, sizeof (path), "%s%s", rootpath,
-			    "/dev");
+			    get_brand_dev());
 			if (di_prof_init(path, &prof) != 0) {
-				(void) zonecfg_endnwifent(snap_hndl);
+				(void) zonecfg_endnwifent(handle);
+				zonecfg_fini_handle(handle);
 				zerror(zlogp, B_TRUE,
 				    "failed to initialize profile");
 				return (-1);
@@ -2959,11 +3001,10 @@
 		    nwiftab.zone_nwif_physical) == 0) {
 			added = B_TRUE;
 		} else {
-			/*
-			 * Failed to add network device, but the brand hook
-			 * might be doing this for us, so keep silent.
-			 */
-			continue;
+			(void) zonecfg_endnwifent(handle);
+			zonecfg_fini_handle(handle);
+			zerror(zlogp, B_TRUE, "failed to add network device");
+			return (-1);
 		}
 		/* set up the new IP interface, and add them all later */
 		new = malloc(sizeof (*new));
@@ -2970,6 +3011,7 @@
 		if (new == NULL) {
 			zerror(zlogp, B_TRUE, "no memory for %s",
 			    nwiftab.zone_nwif_physical);
+			zonecfg_fini_handle(handle);
 			free_ip_interface(zalist);
 		}
 		bzero(new, sizeof (*new));
@@ -2979,7 +3021,8 @@
 	}
 	if (zalist != NULL) {
 		if ((errno = add_net(zlogp, zoneid, zalist)) != 0) {
-			(void) zonecfg_endnwifent(snap_hndl);
+			(void) zonecfg_endnwifent(handle);
+			zonecfg_fini_handle(handle);
 			zerror(zlogp, B_TRUE, "failed to add address");
 			free_ip_interface(zalist);
 			return (-1);
@@ -2986,7 +3029,8 @@
 		}
 		free_ip_interface(zalist);
 	}
-	(void) zonecfg_endnwifent(snap_hndl);
+	(void) zonecfg_endnwifent(handle);
+	zonecfg_fini_handle(handle);
 
 	if (prof != NULL && added) {
 		if (di_prof_commit(prof) != 0) {
@@ -3122,17 +3166,20 @@
 			/* datalink does not belong to the GZ */
 			continue;
 		}
-		if (dlstatus != DLADM_STATUS_OK)
+		if (dlstatus != DLADM_STATUS_OK) {
 			zerror(zlogp, B_FALSE,
-			    "clear 'protection' link property: %s",
 			    dladm_status2str(dlstatus, dlerr));
-
+			free(dllinks);
+			return (-1);
+		}
 		dlstatus = dladm_set_linkprop(dld_handle, *dllink,
 		    "allowed-ips", NULL, 0, DLADM_OPT_ACTIVE);
-		if (dlstatus != DLADM_STATUS_OK)
+		if (dlstatus != DLADM_STATUS_OK) {
 			zerror(zlogp, B_FALSE,
-			    "clear 'allowed-ips' link property: %s",
 			    dladm_status2str(dlstatus, dlerr));
+			free(dllinks);
+			return (-1);
+		}
 	}
 	free(dllinks);
 	return (0);
@@ -3139,6 +3186,28 @@
 }
 
 static int
+unconfigure_exclusive_network_interfaces(zlog_t *zlogp, zoneid_t zoneid)
+{
+	int dlnum = 0;
+
+	/*
+	 * The kernel shutdown callback for the dls module should have removed
+	 * all datalinks from this zone.  If any remain, then there's a
+	 * problem.
+	 */
+	if (zone_list_datalink(zoneid, &dlnum, NULL) != 0) {
+		zerror(zlogp, B_TRUE, "unable to list network interfaces");
+		return (-1);
+	}
+	if (dlnum != 0) {
+		zerror(zlogp, B_FALSE,
+		    "datalinks remain in zone after shutdown");
+		return (-1);
+	}
+	return (0);
+}
+
+static int
 tcp_abort_conn(zlog_t *zlogp, zoneid_t zoneid,
     const struct sockaddr_storage *local, const struct sockaddr_storage *remote)
 {
@@ -3220,14 +3289,26 @@
 get_privset(zlog_t *zlogp, priv_set_t *privs, zone_mnt_t mount_cmd)
 {
 	int error = -1;
+	zone_dochandle_t handle;
 	char *privname = NULL;
 
+	if ((handle = zonecfg_init_handle()) == NULL) {
+		zerror(zlogp, B_TRUE, "getting zone configuration handle");
+		return (-1);
+	}
+	if (zonecfg_get_snapshot_handle(zone_name, handle) != Z_OK) {
+		zerror(zlogp, B_FALSE, "invalid configuration");
+		zonecfg_fini_handle(handle);
+		return (-1);
+	}
+
 	if (ALT_MOUNT(mount_cmd)) {
 		zone_iptype_t	iptype;
-		const char	*curr_iptype = NULL;
+		const char	*curr_iptype;
 
-		if (zonecfg_get_iptype(snap_hndl, &iptype) != Z_OK) {
+		if (zonecfg_get_iptype(handle, &iptype) != Z_OK) {
 			zerror(zlogp, B_TRUE, "unable to determine ip-type");
+			zonecfg_fini_handle(handle);
 			return (-1);
 		}
 
@@ -3240,15 +3321,17 @@
 			break;
 		}
 
-		if (zonecfg_default_privset(privs, curr_iptype) == Z_OK)
+		if (zonecfg_default_privset(privs, curr_iptype) == Z_OK) {
+			zonecfg_fini_handle(handle);
 			return (0);
-
+		}
 		zerror(zlogp, B_FALSE,
 		    "failed to determine the zone's default privilege set");
+		zonecfg_fini_handle(handle);
 		return (-1);
 	}
 
-	switch (zonecfg_get_privset(snap_hndl, privs, &privname)) {
+	switch (zonecfg_get_privset(handle, privs, &privname)) {
 	case Z_OK:
 		error = 0;
 		break;
@@ -3271,6 +3354,7 @@
 	}
 
 	free(privname);
+	zonecfg_fini_handle(handle);
 	return (error);
 }
 
@@ -3296,6 +3380,7 @@
 	nvlist_t **nvlv = NULL;
 	int rctlcount = 0;
 	int error = -1;
+	zone_dochandle_t handle;
 	struct zone_rctltab rctltab;
 	rctlblk_t *rctlblk = NULL;
 	uint64_t maxlwps;
@@ -3305,6 +3390,16 @@
 	*bufp = NULL;
 	*bufsizep = 0;
 
+	if ((handle = zonecfg_init_handle()) == NULL) {
+		zerror(zlogp, B_TRUE, "getting zone configuration handle");
+		return (-1);
+	}
+	if (zonecfg_get_snapshot_handle(zone_name, handle) != Z_OK) {
+		zerror(zlogp, B_FALSE, "invalid configuration");
+		zonecfg_fini_handle(handle);
+		return (-1);
+	}
+
 	rctltab.zone_rctl_valptr = NULL;
 	if (nvlist_alloc(&nvl, NV_UNIQUE_NAME, 0) != 0) {
 		zerror(zlogp, B_TRUE, "%s failed", "nvlist_alloc");
@@ -3337,7 +3432,7 @@
 		}
 	}
 
-	if (zonecfg_setrctlent(snap_hndl) != Z_OK) {
+	if (zonecfg_setrctlent(handle) != Z_OK) {
 		zerror(zlogp, B_FALSE, "%s failed", "zonecfg_setrctlent");
 		goto out;
 	}
@@ -3346,7 +3441,7 @@
 		zerror(zlogp, B_TRUE, "memory allocation failed");
 		goto out;
 	}
-	while (zonecfg_getrctlent(snap_hndl, &rctltab) == Z_OK) {
+	while (zonecfg_getrctlent(handle, &rctltab) == Z_OK) {
 		struct zone_rctlvaltab *rctlval;
 		uint_t i, count;
 		const char *name = rctltab.zone_rctl_name;
@@ -3449,7 +3544,7 @@
 		nvlv = NULL;
 		rctlcount++;
 	}
-	(void) zonecfg_endrctlent(snap_hndl);
+	(void) zonecfg_endrctlent(handle);
 
 	if (rctlcount == 0) {
 		error = 0;
@@ -3473,6 +3568,8 @@
 	nvlist_free(nvl);
 	if (nvlv != NULL)
 		free(nvlv);
+	if (handle != NULL)
+		zonecfg_fini_handle(handle);
 	return (error);
 }
 
@@ -3488,7 +3585,7 @@
 	    > sizeof (cmdbuf))
 		return (-1);
 
-	if (do_subproc(zlogp, cmdbuf, retstr, B_FALSE) != 0)
+	if (do_subproc(zlogp, cmdbuf, retstr) != 0)
 		return (-1);
 
 	return (0);
@@ -3497,6 +3594,7 @@
 static int
 get_datasets(zlog_t *zlogp, char **bufp, size_t *bufsizep)
 {
+	zone_dochandle_t handle;
 	struct zone_dstab dstab;
 	size_t total, offset, len;
 	int error = -1;
@@ -3507,20 +3605,30 @@
 	*bufp = NULL;
 	*bufsizep = 0;
 
+	if ((handle = zonecfg_init_handle()) == NULL) {
+		zerror(zlogp, B_TRUE, "getting zone configuration handle");
+		return (-1);
+	}
+	if (zonecfg_get_snapshot_handle(zone_name, handle) != Z_OK) {
+		zerror(zlogp, B_FALSE, "invalid configuration");
+		zonecfg_fini_handle(handle);
+		return (-1);
+	}
+
 	if (get_implicit_datasets(zlogp, &implicit_datasets) != 0) {
 		zerror(zlogp, B_FALSE, "getting implicit datasets failed");
 		goto out;
 	}
 
-	if (zonecfg_setdsent(snap_hndl) != Z_OK) {
+	if (zonecfg_setdsent(handle) != Z_OK) {
 		zerror(zlogp, B_FALSE, "%s failed", "zonecfg_setdsent");
 		goto out;
 	}
 
 	total = 0;
-	while (zonecfg_getdsent(snap_hndl, &dstab) == Z_OK)
+	while (zonecfg_getdsent(handle, &dstab) == Z_OK)
 		total += strlen(dstab.zone_dataset_name) + 1;
-	(void) zonecfg_enddsent(snap_hndl);
+	(void) zonecfg_enddsent(handle);
 
 	if (implicit_datasets != NULL)
 		implicit_len = strlen(implicit_datasets);
@@ -3537,12 +3645,12 @@
 		goto out;
 	}
 
-	if (zonecfg_setdsent(snap_hndl) != Z_OK) {
+	if (zonecfg_setdsent(handle) != Z_OK) {
 		zerror(zlogp, B_FALSE, "%s failed", "zonecfg_setdsent");
 		goto out;
 	}
 	offset = 0;
-	while (zonecfg_getdsent(snap_hndl, &dstab) == Z_OK) {
+	while (zonecfg_getdsent(handle, &dstab) == Z_OK) {
 		len = strlen(dstab.zone_dataset_name);
 		(void) strlcpy(str + offset, dstab.zone_dataset_name,
 		    total - offset);
@@ -3550,7 +3658,7 @@
 		if (offset < total - 1)
 			str[offset++] = ',';
 	}
-	(void) zonecfg_enddsent(snap_hndl);
+	(void) zonecfg_enddsent(handle);
 
 	if (implicit_len > 0)
 		(void) strlcpy(str + offset, implicit_datasets, total - offset);
@@ -3562,6 +3670,8 @@
 out:
 	if (error != 0 && str != NULL)
 		free(str);
+	if (handle != NULL)
+		zonecfg_fini_handle(handle);
 	if (implicit_datasets != NULL)
 		free(implicit_datasets);
 
@@ -3571,26 +3681,40 @@
 static int
 validate_datasets(zlog_t *zlogp)
 {
+	zone_dochandle_t handle;
 	struct zone_dstab dstab;
 	zfs_handle_t *zhp;
 	libzfs_handle_t *hdl;
 
-	if (zonecfg_setdsent(snap_hndl) != Z_OK) {
+	if ((handle = zonecfg_init_handle()) == NULL) {
+		zerror(zlogp, B_TRUE, "getting zone configuration handle");
+		return (-1);
+	}
+	if (zonecfg_get_snapshot_handle(zone_name, handle) != Z_OK) {
 		zerror(zlogp, B_FALSE, "invalid configuration");
+		zonecfg_fini_handle(handle);
 		return (-1);
 	}
 
+	if (zonecfg_setdsent(handle) != Z_OK) {
+		zerror(zlogp, B_FALSE, "invalid configuration");
+		zonecfg_fini_handle(handle);
+		return (-1);
+	}
+
 	if ((hdl = libzfs_init()) == NULL) {
 		zerror(zlogp, B_FALSE, "opening ZFS library");
+		zonecfg_fini_handle(handle);
 		return (-1);
 	}
 
-	while (zonecfg_getdsent(snap_hndl, &dstab) == Z_OK) {
+	while (zonecfg_getdsent(handle, &dstab) == Z_OK) {
 
 		if ((zhp = zfs_open(hdl, dstab.zone_dataset_name,
 		    ZFS_TYPE_FILESYSTEM)) == NULL) {
 			zerror(zlogp, B_FALSE, "cannot open ZFS dataset '%s'",
 			    dstab.zone_dataset_name);
+			zonecfg_fini_handle(handle);
 			libzfs_fini(hdl);
 			return (-1);
 		}
@@ -3605,6 +3729,7 @@
 			zerror(zlogp, B_FALSE, "cannot set 'zoned' "
 			    "property for ZFS dataset '%s'\n",
 			    dstab.zone_dataset_name);
+			zonecfg_fini_handle(handle);
 			zfs_close(zhp);
 			libzfs_fini(hdl);
 			return (-1);
@@ -3612,8 +3737,9 @@
 
 		zfs_close(zhp);
 	}
-	(void) zonecfg_enddsent(snap_hndl);
+	(void) zonecfg_enddsent(handle);
 
+	zonecfg_fini_handle(handle);
 	libzfs_fini(hdl);
 
 	return (0);
@@ -4350,10 +4476,22 @@
 	int res;
 	uint64_t tmp;
 	char sched[MAXNAMELEN];
+	zone_dochandle_t handle = NULL;
 	char pool_err[128];
 
+	if ((handle = zonecfg_init_handle()) == NULL) {
+		zerror(zlogp, B_TRUE, "getting zone configuration handle");
+		return (Z_BAD_HANDLE);
+	}
+
+	if ((res = zonecfg_get_snapshot_handle(zone_name, handle)) != Z_OK) {
+		zerror(zlogp, B_FALSE, "invalid configuration");
+		zonecfg_fini_handle(handle);
+		return (res);
+	}
+
 	/* Get the scheduling class set in the zone configuration. */
-	if (zonecfg_get_sched_class(snap_hndl, sched, sizeof (sched)) == Z_OK &&
+	if (zonecfg_get_sched_class(handle, sched, sizeof (sched)) == Z_OK &&
 	    strlen(sched) > 0) {
 		if (zone_setattr(zoneid, ZONE_ATTR_SCHED_CLASS, sched,
 		    strlen(sched)) == -1)
@@ -4398,7 +4536,7 @@
 		 */
 		char class_name[PC_CLNMSZ];
 
-		if (zonecfg_get_dflt_sched_class(snap_hndl, class_name,
+		if (zonecfg_get_dflt_sched_class(handle, class_name,
 		    sizeof (class_name)) != Z_OK) {
 			zerror(zlogp, B_FALSE, "WARNING: unable to determine "
 			    "the zone's scheduling class");
@@ -4431,7 +4569,7 @@
 	 * right thing in all cases (reuse or create) based on the current
 	 * zonecfg.
 	 */
-	if ((res = zonecfg_bind_tmp_pool(snap_hndl, zoneid, pool_err,
+	if ((res = zonecfg_bind_tmp_pool(handle, zoneid, pool_err,
 	    sizeof (pool_err))) != Z_OK) {
 		if (res == Z_POOL || res == Z_POOL_CREATE || res == Z_POOL_BIND)
 			zerror(zlogp, B_FALSE, "%s: %s\ndedicated-cpu setting "
@@ -4440,6 +4578,7 @@
 		else
 			zerror(zlogp, B_FALSE, "could not bind zone to "
 			    "temporary pool: %s", zonecfg_strerror(res));
+		zonecfg_fini_handle(handle);
 		return (Z_POOL_BIND);
 	}
 
@@ -4446,7 +4585,7 @@
 	/*
 	 * Check if we need to warn about poold not being enabled.
 	 */
-	if (zonecfg_warn_poold(snap_hndl)) {
+	if (zonecfg_warn_poold(handle)) {
 		zerror(zlogp, B_FALSE, "WARNING: A range of dedicated-cpus has "
 		    "been specified\nbut the dynamic pool service is not "
 		    "enabled.\nThe system will not dynamically adjust the\n"
@@ -4456,7 +4595,7 @@
 	}
 
 	/* The following is a warning, not an error. */
-	if ((res = zonecfg_bind_pool(snap_hndl, zoneid, pool_err,
+	if ((res = zonecfg_bind_pool(handle, zoneid, pool_err,
 	    sizeof (pool_err))) != Z_OK) {
 		if (res == Z_POOL_BIND)
 			zerror(zlogp, B_FALSE, "WARNING: unable to bind to "
@@ -4470,9 +4609,10 @@
 	}
 
 	/* Update saved pool name in case it has changed */
-	(void) zonecfg_get_poolname(snap_hndl, zone_name, pool_name,
+	(void) zonecfg_get_poolname(handle, zone_name, pool_name,
 	    sizeof (pool_name));
 
+	zonecfg_fini_handle(handle);
 	return (Z_OK);
 }
 
@@ -4573,28 +4713,33 @@
 }
 
 static int
-setup_zone_attrs(zlog_t *zlogp, zoneid_t zoneid)
+setup_zone_attrs(zlog_t *zlogp, char *zone_namep, zoneid_t zoneid)
 {
+	zone_dochandle_t handle;
 	int res = Z_OK;
 
-	if ((res = setup_zone_hostid(snap_hndl, zlogp, zoneid)) != Z_OK)
+	if ((handle = zonecfg_init_handle()) == NULL) {
+		zerror(zlogp, B_TRUE, "getting zone configuration handle");
+		return (Z_BAD_HANDLE);
+	}
+	if ((res = zonecfg_get_snapshot_handle(zone_namep, handle)) != Z_OK) {
+		zerror(zlogp, B_FALSE, "invalid configuration");
 		goto out;
+	}
 
-	if ((res = setup_zone_fs_allowed(snap_hndl, zlogp, zoneid)) != Z_OK)
+	if ((res = setup_zone_hostid(handle, zlogp, zoneid)) != Z_OK)
 		goto out;
 
+	if ((res = setup_zone_fs_allowed(handle, zlogp, zoneid)) != Z_OK)
+		goto out;
+
 out:
+	zonecfg_fini_handle(handle);
 	return (res);
 }
 
-/*
- * The zone_did is a persistent debug ID.  Each zone should have a unique ID
- * in the kernel.  This is used for things like DTrace which want to monitor
- * zones across reboots.  They can't use the zoneid since that changes on
- * each boot.
- */
 zoneid_t
-vplat_create(zlog_t *zlogp, zone_mnt_t mount_cmd, zoneid_t zone_did)
+vplat_create(zlog_t *zlogp, zone_mnt_t mount_cmd)
 {
 	zoneid_t rval = -1;
 	priv_set_t *privs;
@@ -4610,7 +4755,7 @@
 	tsol_zcent_t *zcent = NULL;
 	int match = 0;
 	int doi = 0;
-	int flags = -1;
+	int flags;
 	zone_iptype_t iptype;
 
 	if (zone_get_rootpath(zone_name, rootpath, sizeof (rootpath)) != Z_OK) {
@@ -4632,8 +4777,6 @@
 		flags = ZCF_NET_EXCL;
 		break;
 	}
-	if (flags == -1)
-		abort();
 
 	if ((privs = priv_allocset()) == NULL) {
 		zerror(zlogp, B_TRUE, "%s failed", "priv_allocset");
@@ -4737,7 +4880,7 @@
 	xerr = 0;
 	if ((zoneid = zone_create(kzone, rootpath, privs, rctlbuf,
 	    rctlbufsz, zfsbuf, zfsbufsz, &xerr, match, doi, zlabel,
-	    flags, zone_did)) == -1) {
+	    flags)) == -1) {
 		if (xerr == ZE_AREMOUNTS) {
 			if (zonecfg_find_mounts(rootpath, NULL, NULL) < 1) {
 				zerror(zlogp, B_FALSE,
@@ -4783,7 +4926,7 @@
 		struct brand_attr attr;
 		char modname[MAXPATHLEN];
 
-		if (setup_zone_attrs(zlogp, zoneid) != Z_OK)
+		if (setup_zone_attrs(zlogp, zone_name, zoneid) != Z_OK)
 			goto error;
 
 		if ((bh = brand_open(brand_name)) == NULL) {
@@ -4841,8 +4984,6 @@
 	}
 	if (rctlbuf != NULL)
 		free(rctlbuf);
-	if (zfsbuf != NULL)
-		free(zfsbuf);
 	priv_freeset(privs);
 	if (fp != NULL)
 		zonecfg_close_scratch(fp);
@@ -4981,8 +5122,6 @@
 				return (-1);
 			}
 			break;
-		default:
-			abort();
 		}
 	}
 
@@ -5058,8 +5197,7 @@
 }
 
 int
-vplat_teardown(zlog_t *zlogp, boolean_t unmount_cmd, boolean_t rebooting,
-    boolean_t debug)
+vplat_teardown(zlog_t *zlogp, boolean_t unmount_cmd, boolean_t rebooting)
 {
 	char *kzone;
 	zoneid_t zoneid;
@@ -5097,12 +5235,16 @@
 		goto error;
 	}
 
-	if (remove_datalink_pool(zlogp, zoneid) != 0)
+	if (remove_datalink_pool(zlogp, zoneid) != 0) {
 		zerror(zlogp, B_FALSE, "unable clear datalink pool property");
+		goto error;
+	}
 
-	if (remove_datalink_protect(zlogp, zoneid) != 0)
+	if (remove_datalink_protect(zlogp, zoneid) != 0) {
 		zerror(zlogp, B_FALSE,
 		    "unable clear datalink protect property");
+		goto error;
+	}
 
 	/*
 	 * The datalinks assigned to the zone will be removed from the NGZ as
@@ -5136,7 +5278,7 @@
 	brand_close(bh);
 
 	if ((strlen(cmdbuf) > EXEC_LEN) &&
-	    (do_subproc(zlogp, cmdbuf, NULL, debug) != Z_OK)) {
+	    (do_subproc(zlogp, cmdbuf, NULL) != Z_OK)) {
 		zerror(zlogp, B_FALSE, "%s failed", cmdbuf);
 		goto error;
 	}
@@ -5168,6 +5310,12 @@
 			}
 			break;
 		case ZS_EXCLUSIVE:
+			if (unconfigure_exclusive_network_interfaces(zlogp,
+			    zoneid) != 0) {
+				zerror(zlogp, B_FALSE, "unable to unconfigure "
+				    "network interfaces in zone");
+				goto error;
+			}
 			status = dladm_zone_halt(dld_handle, zoneid);
 			if (status != DLADM_STATUS_OK) {
 				zerror(zlogp, B_FALSE, "unable to notify "
@@ -5204,9 +5352,14 @@
 
 		if (rebooting) {
 			struct zone_psettab pset_tab;
+			zone_dochandle_t handle;
 
-			if (zonecfg_lookup_pset(snap_hndl, &pset_tab) == Z_OK)
+			if ((handle = zonecfg_init_handle()) != NULL &&
+			    zonecfg_get_handle(zone_name, handle) == Z_OK &&
+			    zonecfg_lookup_pset(handle, &pset_tab) == Z_OK)
 				destroy_tmp_pool = B_FALSE;
+
+			zonecfg_fini_handle(handle);
 		}
 
 		if (destroy_tmp_pool) {
--- old/usr/src/cmd/zoneadmd/zcons.c	Wed Oct  5 00:33:12 2016
+++ new/usr/src/cmd/zoneadmd/zcons.c	Wed Oct  5 00:33:12 2016
@@ -326,7 +326,7 @@
  * interfaces to instantiate a new zone console node.  We do a lot of
  * sanity checking, and are careful to reuse a console if one exists.
  *
- * Once the device is in the device tree, we kick devfsadm via di_devlink_init()
+ * Once the device is in the device tree, we kick devfsadm via di_init_devs()
  * to ensure that the appropriate symlinks (to the master and slave console
  * devices) are placed in /dev in the global zone.
  */
@@ -420,18 +420,11 @@
 	 */
 	(void) snprintf(conspath, sizeof (conspath), "/dev/zcons/%s/%s",
 	    zone_name, ZCONS_MASTER_NAME);
-	for (i = 0; i < ZCONS_RETRY; i++) {
-		masterfd = open(conspath, O_RDWR | O_NOCTTY);
-		if (masterfd >= 0 || errno != ENOENT)
-			break;
-		(void) sleep(1);
-	}
-	if (masterfd == -1) {
+	if ((masterfd = open(conspath, O_RDWR | O_NOCTTY)) == -1) {
 		zerror(zlogp, B_TRUE, "ERROR: could not open master side of "
 		    "zone console for %s to acquire slave handle", zone_name);
 		master_zcons_failed = B_TRUE;
 	}
-
 	(void) snprintf(conspath, sizeof (conspath), "/dev/zcons/%s/%s",
 	    zone_name, ZCONS_SLAVE_NAME);
 	for (i = 0; i < ZCONS_RETRY; i++) {
--- old/usr/src/cmd/zoneadmd/zfd.c	Wed Oct  5 00:33:12 2016
+++ new/usr/src/cmd/zoneadmd/zfd.c	Wed Oct  5 00:33:12 2016
@@ -1208,7 +1208,7 @@
 	 * This thread should receive SIGHUP so that it can close the log
 	 * file, and reopen it, during log rotation.
 	 */
-	sigset(SIGHUP, hup_handler);
+	(void) sigset(SIGHUP, hup_handler);
 	(void) sigfillset(&blockset);
 	(void) sigdelset(&blockset, SIGHUP);
 	(void) thr_sigsetmask(SIG_BLOCK, &blockset, NULL);
@@ -1384,6 +1384,7 @@
 	zonecfg_fini_handle(handle);
 }
 
+/* ARGSUSED -- "id" might be used in the future. */
 void
 create_log_thread(zlog_t *logp, zoneid_t id)
 {
--- old/usr/src/cmd/zoneadmd/zoneadmd.c	Wed Oct  5 00:33:12 2016
+++ new/usr/src/cmd/zoneadmd/zoneadmd.c	Wed Oct  5 00:33:12 2016
@@ -120,11 +120,10 @@
 boolean_t zone_islabeled;
 boolean_t shutdown_in_progress;
 static zoneid_t zone_id;
-static zoneid_t zone_did = 0;
 dladm_handle_t dld_handle = NULL;
 
-char pre_statechg_hook[2 * MAXPATHLEN];
-char post_statechg_hook[2 * MAXPATHLEN];
+static char pre_statechg_hook[2 * MAXPATHLEN];
+static char post_statechg_hook[2 * MAXPATHLEN];
 char query_hook[2 * MAXPATHLEN];
 
 zlog_t logsys;
@@ -294,7 +293,7 @@
 {
 	int argc = 0, argc_save;
 	int i;
-	int err = Z_OK;
+	int err;
 	char *arg, *lasts, **argv = NULL, **argv_save;
 	char zonecfg_args[BOOTARGS_MAX];
 	char scratchargs[BOOTARGS_MAX], *sargs;
@@ -309,10 +308,25 @@
 	 * and use them if applicable.
 	 */
 	if (inargs == NULL || inargs[0] == '\0')  {
+		zone_dochandle_t handle;
+		if ((handle = zonecfg_init_handle()) == NULL) {
+			zerror(zlogp, B_TRUE,
+			    "getting zone configuration handle");
+			return (Z_BAD_HANDLE);
+		}
+		err = zonecfg_get_snapshot_handle(zone_name, handle);
+		if (err != Z_OK) {
+			zerror(zlogp, B_FALSE,
+			    "invalid configuration snapshot");
+			zonecfg_fini_handle(handle);
+			return (Z_BAD_HANDLE);
+		}
+
 		bzero(zonecfg_args, sizeof (zonecfg_args));
-		(void) zonecfg_get_bootargs(snap_hndl, zonecfg_args,
+		(void) zonecfg_get_bootargs(handle, zonecfg_args,
 		    sizeof (zonecfg_args));
 		inargs = zonecfg_args;
+		zonecfg_fini_handle(handle);
 	}
 
 	if (strlen(inargs) >= BOOTARGS_MAX) {
@@ -462,7 +476,7 @@
  * Run the brand's pre-state change callback, if it exists.
  */
 static int
-brand_prestatechg(zlog_t *zlogp, int state, int cmd, boolean_t debug)
+brand_prestatechg(zlog_t *zlogp, int state, int cmd)
 {
 	char cmdbuf[2 * MAXPATHLEN];
 	const char *altroot;
@@ -475,7 +489,7 @@
 	    state, cmd, altroot) > sizeof (cmdbuf))
 		return (-1);
 
-	if (do_subproc(zlogp, cmdbuf, NULL, debug) != 0)
+	if (do_subproc(zlogp, cmdbuf, NULL) != 0)
 		return (-1);
 
 	return (0);
@@ -485,7 +499,7 @@
  * Run the brand's post-state change callback, if it exists.
  */
 static int
-brand_poststatechg(zlog_t *zlogp, int state, int cmd, boolean_t debug)
+brand_poststatechg(zlog_t *zlogp, int state, int cmd)
 {
 	char cmdbuf[2 * MAXPATHLEN];
 	const char *altroot;
@@ -498,7 +512,7 @@
 	    state, cmd, altroot) > sizeof (cmdbuf))
 		return (-1);
 
-	if (do_subproc(zlogp, cmdbuf, NULL, debug) != 0)
+	if (do_subproc(zlogp, cmdbuf, NULL) != 0)
 		return (-1);
 
 	return (0);
@@ -535,51 +549,39 @@
  * Bring a zone up to the pre-boot "ready" stage.  The mount_cmd argument is
  * 'true' if this is being invoked as part of the processing for the "mount"
  * subcommand.
- *
- * If a scratch zone mount (ALT_MOUNT) is being performed then do not
- * call the state change hooks.
  */
 static int
-zone_ready(zlog_t *zlogp, zone_mnt_t mount_cmd, int zstate, boolean_t debug)
+zone_ready(zlog_t *zlogp, zone_mnt_t mount_cmd, int zstate)
 {
 	int err;
-	boolean_t snapped = B_FALSE;
 
-	if ((snap_hndl = zonecfg_init_handle()) == NULL) {
-		zerror(zlogp, B_TRUE, "getting zone configuration handle");
-		goto bad;
-	}
+	if (!ALT_MOUNT(mount_cmd) &&
+	    brand_prestatechg(zlogp, zstate, Z_READY) != 0)
+		return (-1);
+
 	if ((err = zonecfg_create_snapshot(zone_name)) != Z_OK) {
 		zerror(zlogp, B_FALSE, "unable to create snapshot: %s",
 		    zonecfg_strerror(err));
 		goto bad;
 	}
-	snapped = B_TRUE;
 
-	if (zonecfg_get_snapshot_handle(zone_name, snap_hndl) != Z_OK) {
-		zerror(zlogp, B_FALSE, "invalid configuration snapshot");
+	if ((zone_id = vplat_create(zlogp, mount_cmd)) == -1) {
+		if ((err = zonecfg_destroy_snapshot(zone_name)) != Z_OK)
+			zerror(zlogp, B_FALSE, "destroying snapshot: %s",
+			    zonecfg_strerror(err));
 		goto bad;
 	}
-
-	if (zone_did == 0)
-		zone_did = zone_get_did(zone_name);
-
-	if (!ALT_MOUNT(mount_cmd) &&
-	    brand_prestatechg(zlogp, zstate, Z_READY, debug) != 0)
-		goto bad;
-
-	if ((zone_id = vplat_create(zlogp, mount_cmd, zone_did)) == -1)
-		goto bad;
-
 	if (vplat_bringup(zlogp, mount_cmd, zone_id) != 0) {
 		bringup_failure_recovery = B_TRUE;
-		(void) vplat_teardown(NULL, (mount_cmd != Z_MNT_BOOT), B_FALSE,
-		    debug);
+		(void) vplat_teardown(NULL, (mount_cmd != Z_MNT_BOOT), B_FALSE);
+		if ((err = zonecfg_destroy_snapshot(zone_name)) != Z_OK)
+			zerror(zlogp, B_FALSE, "destroying snapshot: %s",
+			    zonecfg_strerror(err));
 		goto bad;
 	}
 
 	if (!ALT_MOUNT(mount_cmd) &&
-	    brand_poststatechg(zlogp, zstate, Z_READY, debug) != 0)
+	    brand_poststatechg(zlogp, zstate, Z_READY) != 0)
 		goto bad;
 
 	return (0);
@@ -590,15 +592,7 @@
 	 * state, READY, and then invoke the hook as if we're halting.
 	 */
 	if (!ALT_MOUNT(mount_cmd))
-		(void) brand_poststatechg(zlogp, ZONE_STATE_READY, Z_HALT,
-		    debug);
-
-	if (snapped)
-		if ((err = zonecfg_destroy_snapshot(zone_name)) != Z_OK)
-			zerror(zlogp, B_FALSE, "destroying snapshot: %s",
-			    zonecfg_strerror(err));
-	zonecfg_fini_handle(snap_hndl);
-	snap_hndl = NULL;
+		(void) brand_poststatechg(zlogp, ZONE_STATE_READY, Z_HALT);
 	return (-1);
 }
 
@@ -779,8 +773,7 @@
 
 /*
  * env variable name format
- *	_ZONECFG_{resource name}_{identifying attr. name}_{property name}
- * Any dashes (-) in the property names are replaced with underscore (_).
+ *	_ZONECFG;{resource name};{identifying attr. name};{property name}
  */
 static void
 set_zonecfg_env(char *rsrc, char *attr, char *name, char *val)
@@ -811,24 +804,25 @@
  * We could export more of the config in the future, as necessary.
  */
 static int
-setup_subproc_env(boolean_t debug)
+setup_subproc_env()
 {
 	int res;
+	zone_dochandle_t handle;
 	struct zone_nwiftab ntab;
 	struct zone_devtab dtab;
-	struct zone_attrtab atab;
 	char net_resources[MAXNAMELEN * 2];
 	char dev_resources[MAXNAMELEN * 2];
 
-	/* snap_hndl is null when called through the set_brand_env code path */
-	if (snap_hndl == NULL)
-		return (Z_OK);
+	if ((handle = zonecfg_init_handle()) == NULL)
+		exit(Z_NOMEM);
 
-	net_resources[0] = '\0';
-	if ((res = zonecfg_setnwifent(snap_hndl)) != Z_OK)
+	if ((res = zonecfg_get_handle(zone_name, handle)) != Z_OK)
 		goto done;
 
-	while (zonecfg_getnwifent(snap_hndl, &ntab) == Z_OK) {
+	if ((res = zonecfg_setnwifent(handle)) != Z_OK)
+		goto done;
+
+	while (zonecfg_getnwifent(handle, &ntab) == Z_OK) {
 		struct zone_res_attrtab *rap;
 		char *phys;
 
@@ -855,17 +849,14 @@
 		    rap = rap->zone_res_attr_next)
 			set_zonecfg_env(RSRC_NET, phys, rap->zone_res_attr_name,
 			    rap->zone_res_attr_value);
-		nwifent_free_attrs(&ntab);
 	}
 
-	(void) setenv("_ZONECFG_net_resources", net_resources, 1);
+	(void) zonecfg_endnwifent(handle);
 
-	(void) zonecfg_endnwifent(snap_hndl);
-
-	if ((res = zonecfg_setdevent(snap_hndl)) != Z_OK)
+	if ((res = zonecfg_setdevent(handle)) != Z_OK)
 		goto done;
 
-	while (zonecfg_getdevent(snap_hndl, &dtab) == Z_OK) {
+	while (zonecfg_getdevent(handle, &dtab) == Z_OK) {
 		struct zone_res_attrtab *rap;
 		char *match;
 
@@ -880,42 +871,15 @@
 			    rap->zone_res_attr_name, rap->zone_res_attr_value);
 	}
 
-	(void) zonecfg_enddevent(snap_hndl);
+	(void) zonecfg_enddevent(handle);
 
-	if ((res = zonecfg_setattrent(snap_hndl)) != Z_OK)
-		goto done;
-
-	while (zonecfg_getattrent(snap_hndl, &atab) == Z_OK) {
-		set_zonecfg_env("attr", NULL, atab.zone_attr_name,
-		    atab.zone_attr_value);
-	}
-
-	(void) zonecfg_endattrent(snap_hndl);
-
-	if (debug)
-		(void) setenv("_ZONEADMD_brand_debug", "1", 1);
-	else
-		(void) setenv("_ZONEADMD_brand_debug", "", 1);
-
 	res = Z_OK;
 
 done:
+	zonecfg_fini_handle(handle);
 	return (res);
 }
 
-void
-nwifent_free_attrs(struct zone_nwiftab *np)
-{
-	struct zone_res_attrtab *rap;
-
-	for (rap = np->zone_nwif_attrp; rap != NULL; ) {
-		struct zone_res_attrtab *tp = rap;
-
-		rap = rap->zone_res_attr_next;
-		free(tp);
-	}
-}
-
 /*
  * If retstr is not NULL, the output of the subproc is returned in the str,
  * otherwise it is output using zerror().  Any memory allocated for retstr
@@ -922,7 +886,7 @@
  * should be freed by the caller.
  */
 int
-do_subproc(zlog_t *zlogp, char *cmdbuf, char **retstr, boolean_t debug)
+do_subproc(zlog_t *zlogp, char *cmdbuf, char **retstr)
 {
 	char buf[1024];		/* arbitrary large amount */
 	char *inbuf;
@@ -941,7 +905,7 @@
 		inbuf = buf;
 	}
 
-	if (setup_subproc_env(debug) != Z_OK) {
+	if (setup_subproc_env() != Z_OK) {
 		zerror(zlogp, B_FALSE, "failed to setup environment");
 		return (-1);
 	}
@@ -954,13 +918,8 @@
 
 	while (fgets(inbuf, 1024, file) != NULL) {
 		if (retstr == NULL) {
-			if (zlogp != &logsys) {
-				int last = strlen(inbuf) - 1;
-
-				if (inbuf[last] == '\n')
-					inbuf[last] = '\0';
+			if (zlogp != &logsys)
 				zerror(zlogp, B_FALSE, "%s", inbuf);
-			}
 		} else {
 			char *p;
 
@@ -991,57 +950,16 @@
 }
 
 /*
- * Get the path for this zone's init(1M) (or equivalent) process. First look
- * for a zone-specific init-name attr, then get it from the brand.
- */
-static int
-get_initname(brand_handle_t bh, char *initname, int len)
-{
-	struct zone_attrtab a;
-
-	bzero(&a, sizeof (a));
-	(void) strlcpy(a.zone_attr_name, "init-name",
-	    sizeof (a.zone_attr_name));
-
-	if (zonecfg_lookup_attr(snap_hndl, &a) == Z_OK) {
-		(void) strlcpy(initname, a.zone_attr_value, len);
-		return (0);
-	}
-
-	return (brand_get_initname(bh, initname, len));
-}
-
-/*
- * Get the restart-init flag for this zone's init(1M) (or equivalent) process.
- * First look for a zone-specific restart-init attr, then get it from the brand.
- */
-static boolean_t
-restartinit(brand_handle_t bh)
-{
-	struct zone_attrtab a;
-
-	bzero(&a, sizeof (a));
-	(void) strlcpy(a.zone_attr_name, "restart-init",
-	    sizeof (a.zone_attr_name));
-
-	if (zonecfg_lookup_attr(snap_hndl, &a) == Z_OK) {
-		if (strcmp(a.zone_attr_value, "false") == 0)
-			return (B_FALSE);
-		return (B_TRUE);
-	}
-
-	return (brand_restartinit(bh));
-}
-
-/*
  * Get the app-svc-dependent flag for this zone's init process. This is a
  * zone-specific attr which controls the type of contract we create for the
  * zone's init. When true, the contract will include CT_PR_EV_EXIT in the fatal
  * set, so that when any service which is in the same contract exits, the init
  * application will be terminated.
+ *
+ * We use the global "snap_hndl", so no parameters get passed here.
  */
 static boolean_t
-is_app_svc_dep(brand_handle_t bh)
+is_app_svc_dep(void)
 {
 	struct zone_attrtab a;
 
@@ -1058,7 +976,7 @@
 }
 
 static int
-zone_bootup(zlog_t *zlogp, const char *bootargs, int zstate, boolean_t debug)
+zone_bootup(zlog_t *zlogp, const char *bootargs, int zstate)
 {
 	zoneid_t zoneid;
 	struct stat st;
@@ -1074,7 +992,7 @@
 	boolean_t restart_init;
 	boolean_t app_svc_dep;
 
-	if (brand_prestatechg(zlogp, zstate, Z_BOOT, debug) != 0)
+	if (brand_prestatechg(zlogp, zstate, Z_BOOT) != 0)
 		return (-1);
 
 	if ((zoneid = getzoneidbyname(zone_name)) == -1) {
@@ -1117,7 +1035,7 @@
 	}
 
 	/* Get the path for this zone's init(1M) (or equivalent) process.  */
-	if (get_initname(bh, init_file, MAXPATHLEN) != 0) {
+	if (brand_get_initname(bh, init_file, MAXPATHLEN) != 0) {
 		zerror(zlogp, B_FALSE,
 		    "unable to determine zone's init(1M) location");
 		brand_close(bh);
@@ -1124,14 +1042,14 @@
 		goto bad;
 	}
 
-	/* See if we should restart init if it dies. */
-	restart_init = restartinit(bh);
+	/* See if this zone's brand should restart init if it dies. */
+	restart_init = brand_restartinit(bh);
 
 	/*
 	 * See if we need to setup contract dependencies between the zone's
 	 * primary application and any of its services.
 	 */
-	app_svc_dep = is_app_svc_dep(bh);
+	app_svc_dep = is_app_svc_dep();
 
 	brand_close(bh);
 
@@ -1157,9 +1075,11 @@
 		goto bad;
 	}
 
-	if ((st.st_mode & S_IFMT) == S_IFLNK) {
-		/* symlink, we'll have to wait and resolve when we boot */
-	} else if ((st.st_mode & S_IXUSR) == 0) {
+	/*
+	 * If a symlink, we'll have to wait and resolve when we boot,
+	 * otherwise check the executable bits now.
+	 */
+	if ((st.st_mode & S_IFMT) != S_IFLNK && (st.st_mode & S_IXUSR) == 0) {
 		zerror(zlogp, B_FALSE, "%s is not executable", initpath);
 		goto bad;
 	}
@@ -1185,7 +1105,7 @@
 	 * is booted.
 	 */
 	if ((strlen(cmdbuf) > EXEC_LEN) &&
-	    (do_subproc(zlogp, cmdbuf, NULL, debug) != Z_OK)) {
+	    (do_subproc(zlogp, cmdbuf, NULL) != Z_OK)) {
 		zerror(zlogp, B_FALSE, "%s failed", cmdbuf);
 		goto bad;
 	}
@@ -1223,7 +1143,7 @@
 		goto bad;
 	}
 
-	if (brand_poststatechg(zlogp, zstate, Z_BOOT, debug) != 0)
+	if (brand_poststatechg(zlogp, zstate, Z_BOOT) != 0)
 		goto bad;
 
 	/* Startup a thread to perform zfd logging/tty svc for the zone. */
@@ -1239,29 +1159,24 @@
 	 * If something goes wrong, we up the zones's state to the target
 	 * state, RUNNING, and then invoke the hook as if we're halting.
 	 */
-	(void) brand_poststatechg(zlogp, ZONE_STATE_RUNNING, Z_HALT, debug);
+	(void) brand_poststatechg(zlogp, ZONE_STATE_RUNNING, Z_HALT);
 
 	return (-1);
 }
 
 static int
-zone_halt(zlog_t *zlogp, boolean_t unmount_cmd, boolean_t rebooting, int zstate,
-    boolean_t debug)
+zone_halt(zlog_t *zlogp, boolean_t unmount_cmd, boolean_t rebooting, int zstate)
 {
 	int err;
 
-	/*
-	 * If performing a scratch zone unmount then do not call the
-	 * state change hooks.
-	 */
 	if (unmount_cmd == B_FALSE &&
-	    brand_prestatechg(zlogp, zstate, Z_HALT, debug) != 0)
+	    brand_prestatechg(zlogp, zstate, Z_HALT) != 0)
 		return (-1);
 
 	/* Shutting down, stop the memcap thread */
 	destroy_mcap_thread();
 
-	if (vplat_teardown(zlogp, unmount_cmd, rebooting, debug) != 0) {
+	if (vplat_teardown(zlogp, unmount_cmd, rebooting) != 0) {
 		if (!bringup_failure_recovery)
 			zerror(zlogp, B_FALSE, "unable to destroy zone");
 		destroy_log_thread();
@@ -1272,7 +1187,7 @@
 	destroy_log_thread();
 
 	if (unmount_cmd == B_FALSE &&
-	    brand_poststatechg(zlogp, zstate, Z_HALT, debug) != 0)
+	    brand_poststatechg(zlogp, zstate, Z_HALT) != 0)
 		return (-1);
 
 	if ((err = zonecfg_destroy_snapshot(zone_name)) != Z_OK)
@@ -1279,9 +1194,6 @@
 		zerror(zlogp, B_FALSE, "destroying snapshot: %s",
 		    zonecfg_strerror(err));
 
-	zonecfg_fini_handle(snap_hndl);
-	snap_hndl = NULL;
-
 	return (0);
 }
 
@@ -1497,11 +1409,10 @@
 
 	zone_state_t zstate;
 	zone_cmd_t cmd;
-	boolean_t debug;
 	int init_status;
 	zone_cmd_arg_t *zargp;
 
-	boolean_t kernelcall = B_TRUE;
+	boolean_t kernelcall;
 
 	int rval = -1;
 	uint64_t uniqid;
@@ -1551,7 +1462,6 @@
 		goto out;
 	}
 	cmd = zargp->cmd;
-	debug = zargp->debug;
 	init_status = zargp->status;
 
 	if (door_ucred(&uc) != 0) {
@@ -1659,7 +1569,7 @@
 	case ZONE_STATE_INSTALLED:
 		switch (cmd) {
 		case Z_READY:
-			rval = zone_ready(zlogp, Z_MNT_BOOT, zstate, debug);
+			rval = zone_ready(zlogp, Z_MNT_BOOT, zstate);
 			if (rval == 0)
 				eventstream_write(Z_EVT_ZONE_READIED);
 			zcons_statechanged();
@@ -1667,10 +1577,10 @@
 		case Z_BOOT:
 		case Z_FORCEBOOT:
 			eventstream_write(Z_EVT_ZONE_BOOTING);
-			if ((rval = zone_ready(zlogp, Z_MNT_BOOT, zstate,
-			    debug)) == 0) {
+			if ((rval = zone_ready(zlogp, Z_MNT_BOOT, zstate))
+			    == 0) {
 				rval = zone_bootup(zlogp, zargp->bootbuf,
-				    zstate, debug);
+				    zstate);
 			}
 			audit_put_record(zlogp, uc, rval, "boot");
 			zcons_statechanged();
@@ -1677,7 +1587,7 @@
 			if (rval != 0) {
 				bringup_failure_recovery = B_TRUE;
 				(void) zone_halt(zlogp, B_FALSE, B_FALSE,
-				    zstate, debug);
+				    zstate);
 				eventstream_write(Z_EVT_ZONE_BOOTFAILED);
 			}
 			break;
@@ -1729,7 +1639,7 @@
 
 			rval = zone_ready(zlogp,
 			    strcmp(zargp->bootbuf, "-U") == 0 ?
-			    Z_MNT_UPDATE : Z_MNT_SCRATCH, zstate, debug);
+			    Z_MNT_UPDATE : Z_MNT_SCRATCH, zstate);
 			if (rval != 0)
 				break;
 
@@ -1791,18 +1701,16 @@
 			rval = 0;
 			break;
 		case Z_BOOT:
-		case Z_FORCEBOOT:
 			(void) strlcpy(boot_args, zargp->bootbuf,
 			    sizeof (boot_args));
 			eventstream_write(Z_EVT_ZONE_BOOTING);
-			rval = zone_bootup(zlogp, zargp->bootbuf, zstate,
-			    debug);
+			rval = zone_bootup(zlogp, zargp->bootbuf, zstate);
 			audit_put_record(zlogp, uc, rval, "boot");
 			zcons_statechanged();
 			if (rval != 0) {
 				bringup_failure_recovery = B_TRUE;
 				(void) zone_halt(zlogp, B_FALSE, B_TRUE,
-				    zstate, debug);
+				    zstate);
 				eventstream_write(Z_EVT_ZONE_BOOTFAILED);
 			}
 			boot_args[0] = '\0';
@@ -1810,8 +1718,8 @@
 		case Z_HALT:
 			if (kernelcall)	/* Invalid; can't happen */
 				abort();
-			if ((rval = zone_halt(zlogp, B_FALSE, B_FALSE, zstate,
-			    debug)) != 0)
+			if ((rval = zone_halt(zlogp, B_FALSE, B_FALSE, zstate))
+			    != 0)
 				break;
 			zcons_statechanged();
 			eventstream_write(Z_EVT_ZONE_HALTED);
@@ -1820,7 +1728,6 @@
 		case Z_REBOOT:
 		case Z_NOTE_UNINSTALLING:
 		case Z_MOUNT:
-		case Z_FORCEMOUNT:
 		case Z_UNMOUNT:
 			if (kernelcall)	/* Invalid; can't happen */
 				abort();
@@ -1837,7 +1744,7 @@
 		case Z_UNMOUNT:
 			if (kernelcall)	/* Invalid; can't happen */
 				abort();
-			rval = zone_halt(zlogp, B_TRUE, B_FALSE, zstate, debug);
+			rval = zone_halt(zlogp, B_TRUE, B_FALSE, zstate);
 			if (rval == 0) {
 				eventstream_write(Z_EVT_ZONE_HALTED);
 				(void) sema_post(&scratch_sem);
@@ -1859,18 +1766,16 @@
 	case ZONE_STATE_DOWN:
 		switch (cmd) {
 		case Z_READY:
-			if ((rval = zone_halt(zlogp, B_FALSE, B_TRUE, zstate,
-			    debug)) != 0)
+			if ((rval = zone_halt(zlogp, B_FALSE, B_TRUE, zstate))
+			    != 0)
 				break;
 			zcons_statechanged();
-			if ((rval = zone_ready(zlogp, Z_MNT_BOOT, zstate,
-			    debug)) == 0)
+			if ((rval = zone_ready(zlogp, Z_MNT_BOOT, zstate)) == 0)
 				eventstream_write(Z_EVT_ZONE_READIED);
 			else
 				eventstream_write(Z_EVT_ZONE_HALTED);
 			break;
 		case Z_BOOT:
-		case Z_FORCEBOOT:
 			/*
 			 * We could have two clients racing to boot this
 			 * zone; the second client loses, but his request
@@ -1886,8 +1791,8 @@
 			} else {
 				log_init_exit(-1);
 			}
-			if ((rval = zone_halt(zlogp, B_FALSE, B_FALSE, zstate,
-			    debug)) != 0)
+			if ((rval = zone_halt(zlogp, B_FALSE, B_FALSE, zstate))
+			    != 0)
 				break;
 			eventstream_write(Z_EVT_ZONE_HALTED);
 			zcons_statechanged();
@@ -1896,25 +1801,24 @@
 			(void) strlcpy(boot_args, zargp->bootbuf,
 			    sizeof (boot_args));
 			eventstream_write(Z_EVT_ZONE_REBOOTING);
-			if ((rval = zone_halt(zlogp, B_FALSE, B_TRUE, zstate,
-			    debug)) != 0) {
+			if ((rval = zone_halt(zlogp, B_FALSE, B_TRUE, zstate))
+			    != 0) {
 				eventstream_write(Z_EVT_ZONE_BOOTFAILED);
 				boot_args[0] = '\0';
 				break;
 			}
 			zcons_statechanged();
-			if ((rval = zone_ready(zlogp, Z_MNT_BOOT, zstate,
-			    debug)) != 0) {
+			if ((rval = zone_ready(zlogp, Z_MNT_BOOT, zstate)) !=
+			    0) {
 				eventstream_write(Z_EVT_ZONE_BOOTFAILED);
 				boot_args[0] = '\0';
 				break;
 			}
-			rval = zone_bootup(zlogp, zargp->bootbuf, zstate,
-			    debug);
+			rval = zone_bootup(zlogp, zargp->bootbuf, zstate);
 			audit_put_record(zlogp, uc, rval, "reboot");
 			if (rval != 0) {
 				(void) zone_halt(zlogp, B_FALSE, B_TRUE,
-				    zstate, debug);
+				    zstate);
 				eventstream_write(Z_EVT_ZONE_BOOTFAILED);
 			}
 			boot_args[0] = '\0';
@@ -1926,7 +1830,6 @@
 			break;
 		case Z_NOTE_UNINSTALLING:
 		case Z_MOUNT:
-		case Z_FORCEMOUNT:
 		case Z_UNMOUNT:
 			zerror(zlogp, B_FALSE, "%s operation is invalid "
 			    "for zones in state '%s'", z_cmd_name(cmd),
@@ -2135,52 +2038,6 @@
 }
 
 /*
- * Run the query hook with the 'env' parameter.  It should return a
- * string of tab-delimited key-value pairs, each of which should be set
- * in the environment.
- *
- * Because the env_vars string values become part of the environment, the
- * string is static and we don't free it.
- *
- * This function is always called before zoneadmd forks and makes itself
- * exclusive, so it is possible there could more than one instance of zoneadmd
- * running in parallel at this point. Thus, we have no zonecfg snapshot and
- * shouldn't take one yet (i.e. snap_hndl is NULL). Thats ok, since we don't
- * need any zonecfg info to query for a brand-specific env value.
- */
-static int
-set_brand_env(zlog_t *zlogp)
-{
-	int ret = 0;
-	static char *env_vars = NULL;
-	char buf[2 * MAXPATHLEN];
-
-	if (query_hook[0] == '\0' || env_vars != NULL)
-		return (0);
-
-	if (snprintf(buf, sizeof (buf), "%s env", query_hook) > sizeof (buf))
-		return (-1);
-
-	if (do_subproc(zlogp, buf, &env_vars, B_FALSE) != 0)
-		return (-1);
-
-	if (env_vars != NULL) {
-		char *sp;
-
-		sp = strtok(env_vars, "\t");
-		while (sp != NULL) {
-			if (putenv(sp) != 0) {
-				ret = -1;
-				break;
-			}
-			sp = strtok(NULL, "\t");
-		}
-	}
-
-	return (ret);
-}
-
-/*
  * Setup the brand's pre and post state change callbacks, as well as the
  * query callback, if any of these exist.
  */
@@ -2416,11 +2273,6 @@
 	}
 	priv_freeset(privset);
 
-	if (set_brand_env(zlogp) != 0) {
-		zerror(zlogp, B_FALSE, "Unable to setup brand's environment");
-		return (1);
-	}
-
 	if (mkzonedir(zlogp) != 0)
 		return (1);
 
--- old/usr/src/cmd/zoneadmd/zoneadmd.h	Wed Oct  5 00:33:12 2016
+++ new/usr/src/cmd/zoneadmd/zoneadmd.h	Wed Oct  5 00:33:12 2016
@@ -70,7 +70,7 @@
 #define	DEFAULT_DIR_USER -1	/* user ID for chown: -1 means don't change */
 #define	DEFAULT_DIR_GROUP -1	/* grp ID for chown: -1 means don't change */
 
-#define	ALT_MOUNT(mount_cmd) 	((mount_cmd) != Z_MNT_BOOT)
+#define	ALT_MOUNT(mount_cmd)	((mount_cmd) != Z_MNT_BOOT)
 
 typedef struct zlog {
 	FILE *logfile;	/* file to log to */
@@ -104,7 +104,6 @@
 
 extern void zerror(zlog_t *, boolean_t, const char *, ...);
 extern char *localize_msg(char *locale, const char *msg);
-extern void nwifent_free_attrs(struct zone_nwiftab *);
 
 /*
  * Eventstream interfaces.
@@ -138,9 +137,9 @@
 /*
  * Virtual platform interfaces.
  */
-extern zoneid_t vplat_create(zlog_t *, zone_mnt_t, zoneid_t);
+extern zoneid_t vplat_create(zlog_t *, zone_mnt_t);
 extern int vplat_bringup(zlog_t *, zone_mnt_t, zoneid_t);
-extern int vplat_teardown(zlog_t *, boolean_t, boolean_t, boolean_t);
+extern int vplat_teardown(zlog_t *, boolean_t, boolean_t);
 extern int vplat_get_iptype(zlog_t *, zone_iptype_t *);
 
 /*
@@ -179,7 +178,7 @@
 /*
  * Routine to manage child processes.
  */
-extern int do_subproc(zlog_t *, char *, char **, boolean_t);
+extern int do_subproc(zlog_t *, char *, char **);
 
 #ifdef __cplusplus
 }
--- old/usr/src/cmd/zonecfg/zonecfg.c	Wed Oct  5 00:33:12 2016
+++ new/usr/src/cmd/zonecfg/zonecfg.c	Wed Oct  5 00:33:12 2016
@@ -80,7 +80,6 @@
 #include <libinetutil.h>
 #include <pwd.h>
 #include <inet/ip.h>
-#include <uuid/uuid.h>
 
 #include <libzonecfg.h>
 #include "zonecfg.h"
@@ -128,7 +127,7 @@
 #define	SHELP_REMOVE	"remove [-F] <resource-type> " \
 	"[ <property-name>=<property-value> ]*\n" \
 	"\t(global scope)\n" \
-	"remove [-F] <property-name> <property-value>\n" \
+	"remove <property-name> <property-value>\n" \
 	"\t(resource scope)"
 #define	SHELP_REVERT	"revert [-F]"
 #define	SHELP_SELECT	"select <resource-type> { <property-name>=" \
@@ -189,8 +188,6 @@
 	"admin",
 	"fs-allowed",
 	ALIAS_MAXPROCS,
-	ALIAS_ZFSPRI,
-	"uuid",
 	NULL
 };
 
@@ -243,7 +240,6 @@
 	"vlan-id",
 	"global-nic",
 	"property",
-	"uuid",
 	NULL
 };
 
@@ -309,7 +305,6 @@
 	"clear " ALIAS_MAXSEMIDS,
 	"clear " ALIAS_SHARES,
 	"clear " ALIAS_MAXPROCS,
-	"clear " ALIAS_ZFSPRI,
 	NULL
 };
 
@@ -360,8 +355,6 @@
 	"set hostid=",
 	"set fs-allowed=",
 	"set " ALIAS_MAXPROCS "=",
-	"set " ALIAS_ZFSPRI "=",
-	"set uuid=",
 	NULL
 };
 
@@ -394,7 +387,6 @@
 	"info admin",
 	"info fs-allowed",
 	"info max-processes",
-	"info uuid",
 	NULL
 };
 
@@ -551,7 +543,6 @@
 /* used all over the place */
 static char zone[ZONENAME_MAX];
 static char revert_zone[ZONENAME_MAX];
-static char new_uuid[UUID_PRINTABLE_STRING_LENGTH];
 
 /* global brand operations */
 static brand_handle_t brand;
@@ -558,7 +549,6 @@
 
 /* set in modifying functions, checked in read_input() */
 static boolean_t need_to_commit = B_FALSE;
-static boolean_t is_create = B_FALSE;
 boolean_t saw_error;
 
 /* set in yacc parser, checked in read_input() */
@@ -1000,8 +990,7 @@
 }
 
 static FILE *
-pager_open(void)
-{
+pager_open(void) {
 	FILE *newfp;
 	char *pager, *space;
 
@@ -1027,8 +1016,7 @@
 }
 
 static void
-pager_close(FILE *fp)
-{
+pager_close(FILE *fp) {
 	int status;
 
 	status = pclose(fp);
@@ -1283,13 +1271,11 @@
 	if (flags & HELP_USAGE) {
 		(void) fprintf(fp, "%s:\t%s %s\n", gettext("usage"),
 		    execname, cmd_to_str(CMD_HELP));
-		(void) fprintf(fp, "\t%s {-z <zone>|-u <uuid>}\t\t\t(%s)\n",
+		(void) fprintf(fp, "\t%s -z <zone>\t\t\t(%s)\n",
 		    execname, gettext("interactive"));
-		(void) fprintf(fp, "\t%s {-z <zone>|-u <uuid>} <command>\n",
+		(void) fprintf(fp, "\t%s -z <zone> <command>\n", execname);
+		(void) fprintf(fp, "\t%s -z <zone> -f <command-file>\n",
 		    execname);
-		(void) fprintf(fp,
-		    "\t%s {-z <zone>|-u <uuid>} -f <command-file>\n",
-		    execname);
 	}
 	if (flags & HELP_SUBCMDS) {
 		(void) fprintf(fp, "%s:\n\n", gettext("Commands"));
@@ -1377,10 +1363,6 @@
 		    pt_to_str(PT_MAXSEMIDS));
 		(void) fprintf(fp, "\t%s\t%s\n", gettext("(global)"),
 		    pt_to_str(PT_SHARES));
-		(void) fprintf(fp, "\t%s\t%s\n", gettext("(global)"),
-		    pt_to_str(PT_UUID));
-		(void) fprintf(fp, "\t%s\t%s\n", gettext("(global)"),
-		    pt_to_str(PT_ZFSPRI));
 		(void) fprintf(fp, "\t%s\t\t%s, %s, %s, %s, %s\n",
 		    rt_to_str(RT_FS), pt_to_str(PT_DIR),
 		    pt_to_str(PT_SPECIAL), pt_to_str(PT_RAW),
@@ -1717,7 +1699,6 @@
 	boolean_t force = B_FALSE;
 	boolean_t attach = B_FALSE;
 	boolean_t arg_err = B_FALSE;
-	uuid_t uuid;
 
 	assert(cmd != NULL);
 
@@ -1725,7 +1706,7 @@
 	(void) strlcpy(zone_template, "SUNWdefault", sizeof (zone_template));
 
 	optind = 0;
-	while ((arg = getopt(cmd->cmd_argc, cmd->cmd_argv, "?a:bFt:X"))
+	while ((arg = getopt(cmd->cmd_argc, cmd->cmd_argv, "?a:bFt:"))
 	    != EOF) {
 		switch (arg) {
 		case '?':
@@ -1815,14 +1796,9 @@
 	}
 
 	need_to_commit = B_TRUE;
-	is_create = B_TRUE;
 	zonecfg_fini_handle(handle);
 	handle = tmphandle;
 	got_handle = B_TRUE;
-
-	/* Allocate a new uuid for this new zone */
-	uuid_generate(uuid);
-	uuid_unparse(uuid, new_uuid);
 }
 
 /*
@@ -1883,7 +1859,6 @@
 	FILE *of;
 	boolean_t autoboot;
 	zone_iptype_t iptype;
-	uuid_t uuid;
 	boolean_t need_to_close = B_FALSE;
 	boolean_t arg_err = B_FALSE;
 
@@ -1994,14 +1969,6 @@
 		    pt_to_str(PT_FS_ALLOWED), fsallowedp);
 	}
 
-	if (zonecfg_get_uuid(zone, uuid) == Z_OK && !uuid_is_null(uuid)) {
-		char suuid[UUID_PRINTABLE_STRING_LENGTH];
-
-		uuid_unparse(uuid, suuid);
-		(void) fprintf(of, "%s %s=%s\n", cmd_to_str(CMD_SET),
-		    pt_to_str(PT_UUID), suuid);
-	}
-
 	if ((err = zonecfg_setfsent(handle)) != Z_OK) {
 		zone_perror(zone, err, B_FALSE);
 		goto done;
@@ -2469,13 +2436,8 @@
 				    pt_to_str(PT_NAME));
 				goto bad;
 			}
-			if (strlcpy(np->zone_res_attr_name, cp->cp_value,
-			    sizeof (np->zone_res_attr_name)) >=
-			    sizeof (np->zone_res_attr_name)) {
-				zerr(gettext("Input for %s is too long"),
-				    pt_to_str(PT_NAME));
-				goto bad;
-			}
+			(void) strlcpy(np->zone_res_attr_name, cp->cp_value,
+			    sizeof (np->zone_res_attr_name));
 			seen_name = B_TRUE;
 			break;
 		case PT_VALUE:
@@ -2484,14 +2446,8 @@
 				    pt_to_str(PT_VALUE));
 				goto bad;
 			}
-			if (strlcpy(np->zone_res_attr_value, cp->cp_value,
-			    sizeof (np->zone_res_attr_value)) >=
-			    sizeof (np->zone_res_attr_value)) {
-				zerr(gettext("Input for %s is too long"),
-				    pt_to_str(PT_VALUE));
-				goto bad;
-			}
-
+			(void) strlcpy(np->zone_res_attr_value, cp->cp_value,
+			    sizeof (np->zone_res_attr_value));
 			seen_value = B_TRUE;
 			break;
 		default:
@@ -2667,7 +2623,7 @@
 gz_invalid_rt_property(int type)
 {
 	return (global_zone && (type == RT_ZONENAME || type == RT_ZONEPATH ||
-	    type == RT_AUTOBOOT || type == RT_LIMITPRIV || type == RT_UUID ||
+	    type == RT_AUTOBOOT || type == RT_LIMITPRIV ||
 	    type == RT_BOOTARGS || type == RT_BRAND || type == RT_SCHED ||
 	    type == RT_IPTYPE || type == RT_HOSTID || type == RT_FS_ALLOWED));
 }
@@ -2676,7 +2632,7 @@
 gz_invalid_property(int type)
 {
 	return (global_zone && (type == PT_ZONENAME || type == PT_ZONEPATH ||
-	    type == PT_AUTOBOOT || type == PT_LIMITPRIV || type == PT_UUID ||
+	    type == PT_AUTOBOOT || type == PT_LIMITPRIV ||
 	    type == PT_BOOTARGS || type == PT_BRAND || type == PT_SCHED ||
 	    type == PT_IPTYPE || type == PT_HOSTID || type == PT_FS_ALLOWED));
 }
@@ -2894,32 +2850,6 @@
 	return (zonecfg_lookup_filesystem(handle, fstab));
 }
 
-/*
- * Turn an addr that looks like f:2:0:44:5:6C into 0f:02:00:44:05:6c
- * We're expecting a dst of at least MAXMACADDRLEN size here.
- */
-static void
-normalize_mac_addr(char *dst, const char *src, int len)
-{
-	char *p, *e, *sep = "";
-	long n;
-	char buf[MAXMACADDRLEN], tmp[4];
-
-	*dst = '\0';
-	(void) strlcpy(buf, src, sizeof (buf));
-	p = strtok(buf, ":");
-	while (p != NULL) {
-		n = strtol(p, &e, 16);
-		if (*e != NULL || n > 0xff)
-			return;
-		(void) snprintf(tmp, sizeof (tmp), "%s%02x", sep, n);
-		(void) strlcat(dst, tmp, len);
-
-		sep = ":";
-		p = strtok(NULL, ":");
-	}
-}
-
 static int
 fill_in_nwiftab(cmd_t *cmd, struct zone_nwiftab *nwiftab,
     boolean_t fill_in_only)
@@ -2954,7 +2884,7 @@
 			    sizeof (nwiftab->zone_nwif_physical));
 			break;
 		case PT_MAC:
-			normalize_mac_addr(nwiftab->zone_nwif_mac,
+			(void) strlcpy(nwiftab->zone_nwif_mac,
 			    pp->pv_simple,
 			    sizeof (nwiftab->zone_nwif_mac));
 			break;
@@ -3218,8 +3148,6 @@
 	num = zonecfg_num_resources(handle, rsrc);
 
 	if (num == 0) {
-		if (force)
-			return (B_TRUE);
 		z_cmd_rt_perror(CMD_REMOVE, cmd->cmd_res_type, Z_NO_ENTRY,
 		    B_TRUE);
 		return (B_FALSE);
@@ -3248,7 +3176,7 @@
 }
 
 static void
-remove_fs(cmd_t *cmd, boolean_t force)
+remove_fs(cmd_t *cmd)
 {
 	int err;
 
@@ -3257,16 +3185,13 @@
 		struct zone_fstab fstab;
 
 		if ((err = fill_in_fstab(cmd, &fstab, B_FALSE)) != Z_OK) {
-			if (!force)
-				z_cmd_rt_perror(CMD_REMOVE, RT_FS, err, B_TRUE);
+			z_cmd_rt_perror(CMD_REMOVE, RT_FS, err, B_TRUE);
 			return;
 		}
-		if ((err = zonecfg_delete_filesystem(handle, &fstab)) != Z_OK) {
-			if (!force)
-				z_cmd_rt_perror(CMD_REMOVE, RT_FS, err, B_TRUE);
-		} else {
+		if ((err = zonecfg_delete_filesystem(handle, &fstab)) != Z_OK)
+			z_cmd_rt_perror(CMD_REMOVE, RT_FS, err, B_TRUE);
+		else
 			need_to_commit = B_TRUE;
-		}
 		zonecfg_free_fs_option_list(fstab.zone_fs_options);
 		return;
 	}
@@ -3285,7 +3210,7 @@
 }
 
 static void
-remove_net(cmd_t *cmd, boolean_t force)
+remove_net(cmd_t *cmd)
 {
 	int err;
 
@@ -3294,18 +3219,13 @@
 		struct zone_nwiftab nwiftab;
 
 		if ((err = fill_in_nwiftab(cmd, &nwiftab, B_FALSE)) != Z_OK) {
-			if (!force)
-				z_cmd_rt_perror(CMD_REMOVE, RT_NET, err,
-				    B_TRUE);
+			z_cmd_rt_perror(CMD_REMOVE, RT_NET, err, B_TRUE);
 			return;
 		}
-		if ((err = zonecfg_delete_nwif(handle, &nwiftab)) != Z_OK) {
-			if (!force)
-				z_cmd_rt_perror(CMD_REMOVE, RT_NET, err,
-				    B_TRUE);
-		} else {
+		if ((err = zonecfg_delete_nwif(handle, &nwiftab)) != Z_OK)
+			z_cmd_rt_perror(CMD_REMOVE, RT_NET, err, B_TRUE);
+		else
 			need_to_commit = B_TRUE;
-		}
 		return;
 	}
 
@@ -3323,7 +3243,7 @@
 }
 
 static void
-remove_device(cmd_t *cmd, boolean_t force)
+remove_device(cmd_t *cmd)
 {
 	int err;
 
@@ -3332,18 +3252,13 @@
 		struct zone_devtab devtab;
 
 		if ((err = fill_in_devtab(cmd, &devtab, B_FALSE)) != Z_OK) {
-			if (!force)
-				z_cmd_rt_perror(CMD_REMOVE, RT_DEVICE, err,
-				    B_TRUE);
+			z_cmd_rt_perror(CMD_REMOVE, RT_DEVICE, err, B_TRUE);
 			return;
 		}
-		if ((err = zonecfg_delete_dev(handle, &devtab)) != Z_OK) {
-			if (!force)
-				z_cmd_rt_perror(CMD_REMOVE, RT_DEVICE, err,
-				    B_TRUE);
-		} else {
+		if ((err = zonecfg_delete_dev(handle, &devtab)) != Z_OK)
+			z_cmd_rt_perror(CMD_REMOVE, RT_DEVICE, err, B_TRUE);
+		else
 			need_to_commit = B_TRUE;
-		}
 		return;
 	}
 
@@ -3361,7 +3276,7 @@
 }
 
 static void
-remove_attr(cmd_t *cmd, boolean_t force)
+remove_attr(cmd_t *cmd)
 {
 	int err;
 
@@ -3370,18 +3285,13 @@
 		struct zone_attrtab attrtab;
 
 		if ((err = fill_in_attrtab(cmd, &attrtab, B_FALSE)) != Z_OK) {
-			if (!force)
-				z_cmd_rt_perror(CMD_REMOVE, RT_ATTR, err,
-				    B_TRUE);
+			z_cmd_rt_perror(CMD_REMOVE, RT_ATTR, err, B_TRUE);
 			return;
 		}
-		if ((err = zonecfg_delete_attr(handle, &attrtab)) != Z_OK) {
-			if (!force)
-				z_cmd_rt_perror(CMD_REMOVE, RT_ATTR, err,
-				    B_TRUE);
-		} else {
+		if ((err = zonecfg_delete_attr(handle, &attrtab)) != Z_OK)
+			z_cmd_rt_perror(CMD_REMOVE, RT_ATTR, err, B_TRUE);
+		else
 			need_to_commit = B_TRUE;
-		}
 		return;
 	}
 
@@ -3399,7 +3309,7 @@
 }
 
 static void
-remove_dataset(cmd_t *cmd, boolean_t force)
+remove_dataset(cmd_t *cmd)
 {
 	int err;
 
@@ -3408,18 +3318,13 @@
 		struct zone_dstab dstab;
 
 		if ((err = fill_in_dstab(cmd, &dstab, B_FALSE)) != Z_OK) {
-			if (!force)
-				z_cmd_rt_perror(CMD_REMOVE, RT_DATASET, err,
-				    B_TRUE);
+			z_cmd_rt_perror(CMD_REMOVE, RT_DATASET, err, B_TRUE);
 			return;
 		}
-		if ((err = zonecfg_delete_ds(handle, &dstab)) != Z_OK) {
-			if (!force)
-				z_cmd_rt_perror(CMD_REMOVE, RT_DATASET, err,
-				    B_TRUE);
-		} else {
+		if ((err = zonecfg_delete_ds(handle, &dstab)) != Z_OK)
+			z_cmd_rt_perror(CMD_REMOVE, RT_DATASET, err, B_TRUE);
+		else
 			need_to_commit = B_TRUE;
-		}
 		return;
 	}
 
@@ -3437,7 +3342,7 @@
 }
 
 static void
-remove_rctl(cmd_t *cmd, boolean_t force)
+remove_rctl(cmd_t *cmd)
 {
 	int err;
 
@@ -3446,18 +3351,13 @@
 		struct zone_rctltab rctltab;
 
 		if ((err = fill_in_rctltab(cmd, &rctltab, B_FALSE)) != Z_OK) {
-			if (!force)
-				z_cmd_rt_perror(CMD_REMOVE, RT_RCTL, err,
-				    B_TRUE);
+			z_cmd_rt_perror(CMD_REMOVE, RT_RCTL, err, B_TRUE);
 			return;
 		}
-		if ((err = zonecfg_delete_rctl(handle, &rctltab)) != Z_OK) {
-			if (!force)
-				z_cmd_rt_perror(CMD_REMOVE, RT_RCTL, err,
-				    B_TRUE);
-		} else {
+		if ((err = zonecfg_delete_rctl(handle, &rctltab)) != Z_OK)
+			z_cmd_rt_perror(CMD_REMOVE, RT_RCTL, err, B_TRUE);
+		else
 			need_to_commit = B_TRUE;
-		}
 		zonecfg_free_rctl_value_list(rctltab.zone_rctl_valptr);
 		return;
 	}
@@ -3476,50 +3376,42 @@
 }
 
 static void
-remove_pset(boolean_t force)
+remove_pset()
 {
 	int err;
 	struct zone_psettab psettab;
 
 	if ((err = zonecfg_lookup_pset(handle, &psettab)) != Z_OK) {
-		if (!force)
-			z_cmd_rt_perror(CMD_REMOVE, RT_DCPU, err, B_TRUE);
+		z_cmd_rt_perror(CMD_REMOVE, RT_DCPU, err, B_TRUE);
 		return;
 	}
-	if ((err = zonecfg_delete_pset(handle)) != Z_OK) {
-		if (!force)
-			z_cmd_rt_perror(CMD_REMOVE, RT_DCPU, err, B_TRUE);
-	} else {
+	if ((err = zonecfg_delete_pset(handle)) != Z_OK)
+		z_cmd_rt_perror(CMD_REMOVE, RT_DCPU, err, B_TRUE);
+	else
 		need_to_commit = B_TRUE;
-	}
 }
 
 static void
-remove_pcap(boolean_t force)
+remove_pcap()
 {
 	int err;
 	uint64_t tmp;
 
 	if (zonecfg_get_aliased_rctl(handle, ALIAS_CPUCAP, &tmp) != Z_OK) {
-		if (!force) {
-			zerr("%s %s: %s", cmd_to_str(CMD_REMOVE),
-			    rt_to_str(RT_PCAP),
-			    zonecfg_strerror(Z_NO_RESOURCE_TYPE));
-			saw_error = B_TRUE;
-		}
+		zerr("%s %s: %s", cmd_to_str(CMD_REMOVE), rt_to_str(RT_PCAP),
+		    zonecfg_strerror(Z_NO_RESOURCE_TYPE));
+		saw_error = B_TRUE;
 		return;
 	}
 
-	if ((err = zonecfg_rm_aliased_rctl(handle, ALIAS_CPUCAP)) != Z_OK) {
-		if (!force)
-			z_cmd_rt_perror(CMD_REMOVE, RT_PCAP, err, B_TRUE);
-	} else {
+	if ((err = zonecfg_rm_aliased_rctl(handle, ALIAS_CPUCAP)) != Z_OK)
+		z_cmd_rt_perror(CMD_REMOVE, RT_PCAP, err, B_TRUE);
+	else
 		need_to_commit = B_TRUE;
-	}
 }
 
 static void
-remove_mcap(boolean_t force)
+remove_mcap()
 {
 	int err, res1, res2, res3;
 	uint64_t tmp;
@@ -3531,22 +3423,16 @@
 
 	/* if none of these exist, there is no resource to remove */
 	if (res1 != Z_OK && res2 != Z_OK && res3 != Z_OK) {
-		if (!force) {
-			zerr("%s %s: %s", cmd_to_str(CMD_REMOVE),
-			    rt_to_str(RT_MCAP),
-			    zonecfg_strerror(Z_NO_RESOURCE_TYPE));
-			saw_error = B_TRUE;
-		}
+		zerr("%s %s: %s", cmd_to_str(CMD_REMOVE), rt_to_str(RT_MCAP),
+		    zonecfg_strerror(Z_NO_RESOURCE_TYPE));
+		saw_error = B_TRUE;
 		return;
 	}
 	if (res1 == Z_OK) {
 		if ((err = zonecfg_rm_aliased_rctl(handle, ALIAS_MAXPHYSMEM))
 		    != Z_OK) {
-			if (!force) {
-				z_cmd_rt_perror(CMD_REMOVE, RT_MCAP, err,
-				    B_TRUE);
-				revert = B_TRUE;
-			}
+			z_cmd_rt_perror(CMD_REMOVE, RT_MCAP, err, B_TRUE);
+			revert = B_TRUE;
 		} else {
 			need_to_commit = B_TRUE;
 		}
@@ -3555,11 +3441,8 @@
 	if (res2 == Z_OK) {
 		if ((err = zonecfg_rm_aliased_rctl(handle, ALIAS_MAXSWAP))
 		    != Z_OK) {
-			if (!force) {
-				z_cmd_rt_perror(CMD_REMOVE, RT_MCAP, err,
-				    B_TRUE);
-				revert = B_TRUE;
-			}
+			z_cmd_rt_perror(CMD_REMOVE, RT_MCAP, err, B_TRUE);
+			revert = B_TRUE;
 		} else {
 			need_to_commit = B_TRUE;
 		}
@@ -3567,11 +3450,8 @@
 	if (res3 == Z_OK) {
 		if ((err = zonecfg_rm_aliased_rctl(handle, ALIAS_MAXLOCKEDMEM))
 		    != Z_OK) {
-			if (!force) {
-				z_cmd_rt_perror(CMD_REMOVE, RT_MCAP, err,
-				    B_TRUE);
-				revert = B_TRUE;
-			}
+			z_cmd_rt_perror(CMD_REMOVE, RT_MCAP, err, B_TRUE);
+			revert = B_TRUE;
 		} else {
 			need_to_commit = B_TRUE;
 		}
@@ -3582,7 +3462,7 @@
 }
 
 static void
-remove_admin(cmd_t *cmd, boolean_t force)
+remove_admin(cmd_t *cmd)
 {
 	int err;
 
@@ -3591,33 +3471,34 @@
 		struct zone_admintab admintab;
 
 		if ((err = fill_in_admintab(cmd, &admintab, B_FALSE)) != Z_OK) {
-			if (!force)
-				z_cmd_rt_perror(CMD_REMOVE, RT_ADMIN, err,
-				    B_TRUE);
+			z_cmd_rt_perror(CMD_REMOVE, RT_ADMIN,
+			    err, B_TRUE);
 			return;
 		}
 		if ((err = zonecfg_delete_admin(handle, &admintab,
-		    zone)) != Z_OK) {
-			if (!force)
-				z_cmd_rt_perror(CMD_REMOVE, RT_ADMIN, err,
-				    B_TRUE);
-		} else {
+		    zone))
+		    != Z_OK)
+			z_cmd_rt_perror(CMD_REMOVE, RT_ADMIN,
+			    err, B_TRUE);
+		else
 			need_to_commit = B_TRUE;
-		}
 		return;
-	}
+	} else {
+		/*
+		 * unqualified admin removal.
+		 * remove all admins but prompt if more
+		 * than one.
+		 */
+		if (!prompt_remove_resource(cmd, "admin"))
+			return;
 
-	/*
-	 * unqualified admin removal.
-	 * remove all admins but prompt if more than one.
-	 */
-	if (!prompt_remove_resource(cmd, "admin"))
-		return;
-
-	if ((err = zonecfg_delete_admins(handle, zone)) != Z_OK)
-		z_cmd_rt_perror(CMD_REMOVE, RT_ADMIN, err, B_TRUE);
-	else
-		need_to_commit = B_TRUE;
+		if ((err = zonecfg_delete_admins(handle, zone))
+		    != Z_OK)
+			z_cmd_rt_perror(CMD_REMOVE, RT_ADMIN,
+			    err, B_TRUE);
+		else
+			need_to_commit = B_TRUE;
+	}
 }
 
 static void
@@ -3626,7 +3507,6 @@
 	int type;
 	int arg;
 	boolean_t arg_err = B_FALSE;
-	boolean_t force = B_FALSE;
 
 	if ((type = cmd->cmd_res_type) == RT_UNKNOWN) {
 		long_usage(CMD_REMOVE, B_TRUE);
@@ -3641,7 +3521,6 @@
 			arg_err = B_TRUE;
 			break;
 		case 'F':
-			force = B_TRUE;
 			break;
 		default:
 			short_usage(CMD_REMOVE);
@@ -3657,34 +3536,34 @@
 
 	switch (type) {
 	case RT_FS:
-		remove_fs(cmd, force);
+		remove_fs(cmd);
 		return;
 	case RT_NET:
-		remove_net(cmd, force);
+		remove_net(cmd);
 		return;
 	case RT_DEVICE:
-		remove_device(cmd, force);
+		remove_device(cmd);
 		return;
 	case RT_RCTL:
-		remove_rctl(cmd, force);
+		remove_rctl(cmd);
 		return;
 	case RT_ATTR:
-		remove_attr(cmd, force);
+		remove_attr(cmd);
 		return;
 	case RT_DATASET:
-		remove_dataset(cmd, force);
+		remove_dataset(cmd);
 		return;
 	case RT_DCPU:
-		remove_pset(force);
+		remove_pset();
 		return;
 	case RT_PCAP:
-		remove_pcap(force);
+		remove_pcap();
 		return;
 	case RT_MCAP:
-		remove_mcap(force);
+		remove_mcap();
 		return;
 	case RT_ADMIN:
-		remove_admin(cmd, force);
+		remove_admin(cmd);
 		return;
 	default:
 		zone_perror(rt_to_str(type), Z_NO_RESOURCE_TYPE, B_TRUE);
@@ -3703,26 +3582,7 @@
 	struct zone_rctlvaltab *rctlvaltab;
 	struct zone_res_attrtab *np;
 	complex_property_ptr_t cx;
-	int arg;
-	boolean_t force = B_FALSE;
-	boolean_t arg_err = B_FALSE;
 
-	optind = 0;
-	while ((arg = getopt(cmd->cmd_argc, cmd->cmd_argv, "F")) != EOF) {
-		switch (arg) {
-		case 'F':
-			force = B_TRUE;
-			break;
-		default:
-			arg_err = B_TRUE;
-			break;
-		}
-	}
-	if (arg_err) {
-		saw_error = B_TRUE;
-		return;
-	}
-
 	res_type = resource_scope;
 	prop_type = cmd->cmd_prop_name[0];
 	if (res_type == RT_UNKNOWN || prop_type == PT_UNKNOWN) {
@@ -3763,7 +3623,7 @@
 			prop_id = pp->pv_simple;
 			err = zonecfg_remove_fs_option(&in_progress_fstab,
 			    prop_id);
-			if (err != Z_OK && !force)
+			if (err != Z_OK)
 				zone_perror(pt_to_str(prop_type), err, B_TRUE);
 		} else {
 			list_property_ptr_t list;
@@ -3775,7 +3635,7 @@
 					break;
 				err = zonecfg_remove_fs_option(
 				    &in_progress_fstab, prop_id);
-				if (err != Z_OK && !force)
+				if (err != Z_OK)
 					zone_perror(pt_to_str(prop_type), err,
 					    B_TRUE);
 			}
@@ -3828,7 +3688,7 @@
 			err = zonecfg_remove_res_attr(
 			    &(in_progress_devtab.zone_dev_attrp), np);
 		}
-		if (err != Z_OK && !force)
+		if (err != Z_OK)
 			zone_perror(pt_to_str(prop_type), err, B_TRUE);
 		return;
 	case RT_RCTL:
@@ -3879,7 +3739,7 @@
 		rctlvaltab->zone_rctlval_next = NULL;
 		err = zonecfg_remove_rctl_value(&in_progress_rctltab,
 		    rctlvaltab);
-		if (err != Z_OK && !force)
+		if (err != Z_OK)
 			zone_perror(pt_to_str(prop_type), err, B_TRUE);
 		zonecfg_free_rctl_value_list(rctlvaltab);
 		return;
@@ -4004,8 +3864,6 @@
 		/* FALLTHRU */
 	case PT_ZONEPATH:
 		/* FALLTHRU */
-	case PT_UUID:
-		/* FALLTHRU */
 	case PT_BRAND:
 		zone_perror(pt_to_str(type), Z_CLEAR_DISALLOW, B_TRUE);
 		return;
@@ -4068,9 +3926,6 @@
 	case PT_SHARES:
 		remove_aliased_rctl(PT_SHARES, ALIAS_SHARES);
 		return;
-	case PT_ZFSPRI:
-		remove_aliased_rctl(PT_ZFSPRI, ALIAS_ZFSPRI);
-		return;
 	case PT_HOSTID:
 		if ((err = zonecfg_set_hostid(handle, NULL)) != Z_OK)
 			z_cmd_rt_perror(CMD_CLEAR, RT_HOSTID, err, B_TRUE);
@@ -4561,10 +4416,6 @@
 			res_type = RT_HOSTID;
 		} else if (prop_type == PT_FS_ALLOWED) {
 			res_type = RT_FS_ALLOWED;
-		} else if (prop_type == PT_ZFSPRI) {
-			res_type = RT_ZFSPRI;
-		} else if (prop_type == PT_UUID) {
-			res_type = RT_UUID;
 		} else {
 			zerr(gettext("Cannot set a resource-specific property "
 			    "from the global scope."));
@@ -4772,9 +4623,6 @@
 	case RT_SHARES:
 		set_aliased_rctl(ALIAS_SHARES, prop_type, prop_id);
 		return;
-	case RT_ZFSPRI:
-		set_aliased_rctl(ALIAS_ZFSPRI, prop_type, prop_id);
-		return;
 	case RT_HOSTID:
 		if ((err = zonecfg_set_hostid(handle, prop_id)) != Z_OK) {
 			if (err == Z_TOO_BIG) {
@@ -4788,15 +4636,6 @@
 		}
 		need_to_commit = B_TRUE;
 		return;
-	case RT_UUID:
-		/*
-		 * We can't set here.  We have to wait until commit since the
-		 * uuid will be updating the index file and we may not have
-		 * created the zone yet.
-		 */
-		(void) strlcpy(new_uuid, prop_id, sizeof (new_uuid));
-		need_to_commit = B_TRUE;
-		return;
 	case RT_FS_ALLOWED:
 		if ((err = zonecfg_set_fs_allowed(handle, prop_id)) != Z_OK)
 			zone_perror(zone, err, B_TRUE);
@@ -4872,7 +4711,7 @@
 			    sizeof (in_progress_nwiftab.zone_nwif_physical));
 			break;
 		case PT_MAC:
-			normalize_mac_addr(in_progress_nwiftab.zone_nwif_mac,
+			(void) strlcpy(in_progress_nwiftab.zone_nwif_mac,
 			    prop_id,
 			    sizeof (in_progress_nwiftab.zone_nwif_mac));
 			break;
@@ -5397,23 +5236,6 @@
 }
 
 static void
-info_uuid(FILE *fp)
-{
-	uuid_t uuid;
-	char suuid[UUID_PRINTABLE_STRING_LENGTH];
-
-	if (new_uuid[0] != '\0') {
-		(void) fprintf(fp, "%s: %s\n", pt_to_str(PT_UUID), new_uuid);
-	} else if (zonecfg_get_uuid(zone, uuid) == Z_OK &&
-	    !uuid_is_null(uuid)) {
-		uuid_unparse(uuid, suuid);
-		(void) fprintf(fp, "%s: %s\n", pt_to_str(PT_UUID), suuid);
-	} else {
-		(void) fprintf(fp, "%s:\n", pt_to_str(PT_UUID));
-	}
-}
-
-static void
 info_fs_allowed(zone_dochandle_t handle, FILE *fp)
 {
 	char fsallowedp[ZONE_FS_ALLOWED_MAX];
@@ -5923,7 +5745,6 @@
 	uint64_t swap_limit;
 	uint64_t locked_limit;
 	uint64_t phys_limit;
-	struct stat statbuf;
 
 	assert(cmd != NULL);
 
@@ -6013,7 +5834,6 @@
 			info_iptype(handle, fp);
 			info_hostid(handle, fp);
 			info_fs_allowed(handle, fp);
-			info_uuid(fp);
 		}
 		info_aliased_rctl(handle, fp, ALIAS_MAXLWPS);
 		info_aliased_rctl(handle, fp, ALIAS_MAXPROCS);
@@ -6022,7 +5842,6 @@
 		info_aliased_rctl(handle, fp, ALIAS_MAXMSGIDS);
 		info_aliased_rctl(handle, fp, ALIAS_MAXSEMIDS);
 		info_aliased_rctl(handle, fp, ALIAS_SHARES);
-		info_aliased_rctl(handle, fp, ALIAS_ZFSPRI);
 		if (!global_zone) {
 			info_fs(handle, fp, cmd);
 			info_net(handle, fp, cmd);
@@ -6086,9 +5905,6 @@
 	case RT_SHARES:
 		info_aliased_rctl(handle, fp, ALIAS_SHARES);
 		break;
-	case RT_ZFSPRI:
-		info_aliased_rctl(handle, fp, ALIAS_ZFSPRI);
-		break;
 	case RT_FS:
 		info_fs(handle, fp, cmd);
 		break;
@@ -6119,9 +5935,6 @@
 	case RT_HOSTID:
 		info_hostid(handle, fp);
 		break;
-	case RT_UUID:
-		info_uuid(fp);
-		break;
 	case RT_ADMIN:
 		info_auth(handle, fp, cmd);
 		break;
@@ -6613,24 +6426,7 @@
 				need_to_commit = B_FALSE;
 				(void) strlcpy(revert_zone, zone,
 				    sizeof (revert_zone));
-
-				if (is_create) {
-					zonecfg_notify_create(handle);
-					is_create = B_FALSE;
-				}
 			}
-
-			/*
-			 * Commit a new uuid at this point since we now know the
-			 * zone index entry will exist.
-			 */
-			if (new_uuid[0] != '\0') {
-				if ((err = zonecfg_set_uuid(zone, zonepath,
-				    new_uuid)) != Z_OK)
-					zone_perror(zone, err, B_FALSE);
-				else
-					new_uuid[0] = '\0';
-			}
 		} else {
 			zerr(gettext("Zone %s failed to verify"), zone);
 		}
@@ -7680,10 +7476,8 @@
 int
 main(int argc, char *argv[])
 {
-	int err, arg, uflag = 0, zflag = 0;
+	int err, arg;
 	struct stat st;
-	uuid_t uuidin;
-	char zonename[ZONENAME_MAX + 1];
 
 	/* This must be before anything goes to stdout. */
 	setbuf(stdout, NULL);
@@ -7710,7 +7504,7 @@
 		exit(Z_OK);
 	}
 
-	while ((arg = getopt(argc, argv, "?f:R:z:u:")) != EOF) {
+	while ((arg = getopt(argc, argv, "?f:R:z:")) != EOF) {
 		switch (arg) {
 		case '?':
 			if (optopt == '?')
@@ -7737,21 +7531,6 @@
 			}
 			zonecfg_set_root(optarg);
 			break;
-		case 'u':
-			if (uuid_parse((char *)optarg, uuidin) == -1)
-				return (Z_INVALID_PROPERTY);
-
-			if (zonecfg_get_name_by_uuid(uuidin, zonename,
-			    ZONENAME_MAX) != Z_OK) {
-				zone_perror(optarg, Z_BOGUS_ZONE_NAME, B_TRUE);
-				usage(B_FALSE, HELP_SYNTAX);
-				exit(Z_USAGE);
-			}
-
-			(void) strlcpy(zone, zonename, sizeof (zone));
-			(void) strlcpy(revert_zone, zonename, sizeof (zone));
-			uflag = 1;
-			break;
 		case 'z':
 			if (strcmp(optarg, GLOBAL_ZONENAME) == 0) {
 				global_zone = B_TRUE;
@@ -7762,7 +7541,6 @@
 			}
 			(void) strlcpy(zone, optarg, sizeof (zone));
 			(void) strlcpy(revert_zone, optarg, sizeof (zone));
-			zflag = 1;
 			break;
 		default:
 			usage(B_FALSE, HELP_USAGE);
@@ -7770,7 +7548,7 @@
 		}
 	}
 
-	if (optind > argc || strcmp(zone, "") == 0 || (uflag && zflag)) {
+	if (optind > argc || strcmp(zone, "") == 0) {
 		usage(B_FALSE, HELP_USAGE);
 		exit(Z_USAGE);
 	}
--- old/usr/src/cmd/zonecfg/zonecfg.h	Wed Oct  5 00:33:13 2016
+++ new/usr/src/cmd/zonecfg/zonecfg.h	Wed Oct  5 00:33:13 2016
@@ -21,7 +21,6 @@
 
 /*
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011, Joyent Inc. All rights reserved.
  */
 
 #ifndef _ZONECFG_H
@@ -91,11 +90,9 @@
 #define	RT_ADMIN	26
 #define	RT_FS_ALLOWED	27
 #define	RT_MAXPROCS	28	/* really a rctl alias property, but for info */
-#define	RT_ZFSPRI	29	/* really a rctl alias property, but for info */
-#define	RT_UUID		30	/* really a property, but for info */
 
 #define	RT_MIN		RT_UNKNOWN
-#define	RT_MAX		RT_UUID
+#define	RT_MAX		RT_MAXPROCS
 
 /* property types: increment PT_MAX when expanding this list */
 #define	PT_UNKNOWN	0
@@ -145,10 +142,9 @@
 #define	PT_VLANID	44
 #define	PT_GNIC		45
 #define	PT_NPROP	46
-#define	PT_UUID		47
 
 #define	PT_MIN		PT_UNKNOWN
-#define	PT_MAX		PT_UUID
+#define	PT_MAX		PT_NPROP
 
 #define	MAX_EQ_PROP_PAIRS	3
 
--- old/usr/src/cmd/zonecfg/zonecfg_grammar.y	Wed Oct  5 00:33:13 2016
+++ new/usr/src/cmd/zonecfg/zonecfg_grammar.y	Wed Oct  5 00:33:13 2016
@@ -22,7 +22,6 @@
 
 /*
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2013, Joyent Inc. All rights reserved.
  */
 
 /*
@@ -137,7 +136,7 @@
 %token OPEN_PAREN CLOSE_PAREN COMMA DATASET LIMITPRIV BOOTARGS BRAND PSET PCAP
 %token MCAP NCPUS IMPORTANCE SHARES MAXLWPS MAXSHMMEM MAXSHMIDS MAXMSGIDS
 %token MAXSEMIDS LOCKED SWAP SCHED CLEAR DEFROUTER ADMIN USER AUTHS MAXPROCS
-%token ZFSPRI MAC VLANID GNIC NPROP UUID
+%token ZFSPRI MAC VLANID GNIC NPROP
 
 %type <strval> TOKEN EQUAL OPEN_SQ_BRACKET CLOSE_SQ_BRACKET
     property_value OPEN_PAREN CLOSE_PAREN COMMA simple_prop_val
@@ -147,7 +146,7 @@
 %type <ival> property_name SPECIAL RAW DIR OPTIONS TYPE ADDRESS PHYSICAL NAME
     MATCH ZONENAME ZONEPATH AUTOBOOT POOL LIMITPRIV BOOTARGS VALUE PRIV LIMIT
     ACTION BRAND SCHED IPTYPE DEFROUTER HOSTID USER AUTHS FS_ALLOWED
-    ALLOWED_ADDRESS MAC VLANID GNIC NPROP UUID
+    ALLOWED_ADDRESS MAC VLANID GNIC NPROP
 %type <cmd> command
 %type <cmd> add_command ADD
 %type <cmd> cancel_command CANCEL
@@ -652,24 +651,6 @@
 		$$->cmd_res_type = RT_FS_ALLOWED;
 		$$->cmd_prop_nv_pairs = 0;
 	}
-	|	INFO UUID
-	{
-		if (($$ = alloc_cmd()) == NULL)
-			YYERROR;
-		cmd = $$;
-		$$->cmd_handler = &info_func;
-		$$->cmd_res_type = RT_UUID;
-		$$->cmd_prop_nv_pairs = 0;
-	}
-	|	INFO ZFSPRI
-	{
-		if (($$ = alloc_cmd()) == NULL)
-			YYERROR;
-		cmd = $$;
-		$$->cmd_handler = &info_func;
-		$$->cmd_res_type = RT_ZFSPRI;
-		$$->cmd_prop_nv_pairs = 0;
-	}
 	|	INFO resource_type property_name EQUAL property_value
 	{
 		if (($$ = alloc_cmd()) == NULL)
@@ -754,19 +735,6 @@
 		$$->cmd_prop_name[0] = $2;
 		$$->cmd_property_ptr[0] = &property[0];
 	}
-	| REMOVE TOKEN property_name property_value
-	{
-		if (($$ = alloc_cmd()) == NULL)
-			YYERROR;
-		cmd = $$;
-		$$->cmd_handler = &remove_func;
-		$$->cmd_argc = 1;
-		$$->cmd_argv[0] = claim_token($2);
-		$$->cmd_argv[1] = NULL;
-		$$->cmd_prop_nv_pairs = 1;
-		$$->cmd_prop_name[0] = $3;
-		$$->cmd_property_ptr[0] = &property[0];
-	}
 	| REMOVE resource_type property_name EQUAL property_value
 	{
 		if (($$ = alloc_cmd()) == NULL)
@@ -778,20 +746,6 @@
 		$$->cmd_prop_name[0] = $3;
 		$$->cmd_property_ptr[0] = &property[0];
 	}
-	| REMOVE TOKEN resource_type property_name EQUAL property_value
-	{
-		if (($$ = alloc_cmd()) == NULL)
-			YYERROR;
-		cmd = $$;
-		$$->cmd_handler = &remove_func;
-		$$->cmd_res_type = $3;
-		$$->cmd_argc = 1;
-		$$->cmd_argv[0] = claim_token($2);
-		$$->cmd_argv[1] = NULL;
-		$$->cmd_prop_nv_pairs = 1;
-		$$->cmd_prop_name[0] = $4;
-		$$->cmd_property_ptr[0] = &property[0];
-	}
 	| REMOVE resource_type property_name EQUAL property_value property_name EQUAL property_value
 	{
 		if (($$ = alloc_cmd()) == NULL)
@@ -805,22 +759,6 @@
 		$$->cmd_prop_name[1] = $6;
 		$$->cmd_property_ptr[1] = &property[1];
 	}
-	| REMOVE TOKEN resource_type property_name EQUAL property_value property_name EQUAL property_value
-	{
-		if (($$ = alloc_cmd()) == NULL)
-			YYERROR;
-		cmd = $$;
-		$$->cmd_handler = &remove_func;
-		$$->cmd_res_type = $3;
-		$$->cmd_argc = 1;
-		$$->cmd_argv[0] = claim_token($2);
-		$$->cmd_argv[1] = NULL;
-		$$->cmd_prop_nv_pairs = 2;
-		$$->cmd_prop_name[0] = $4;
-		$$->cmd_property_ptr[0] = &property[0];
-		$$->cmd_prop_name[1] = $7;
-		$$->cmd_property_ptr[1] = &property[1];
-	}
 	| REMOVE resource_type property_name EQUAL property_value property_name EQUAL property_value property_name EQUAL property_value
 	{
 		if (($$ = alloc_cmd()) == NULL)
@@ -836,24 +774,6 @@
 		$$->cmd_prop_name[2] = $9;
 		$$->cmd_property_ptr[2] = &property[2];
 	}
-	| REMOVE TOKEN resource_type property_name EQUAL property_value property_name EQUAL property_value property_name EQUAL property_value
-	{
-		if (($$ = alloc_cmd()) == NULL)
-			YYERROR;
-		cmd = $$;
-		$$->cmd_handler = &remove_func;
-		$$->cmd_res_type = $3;
-		$$->cmd_argc = 1;
-		$$->cmd_argv[0] = claim_token($2);
-		$$->cmd_argv[1] = NULL;
-		$$->cmd_prop_nv_pairs = 3;
-		$$->cmd_prop_name[0] = $4;
-		$$->cmd_property_ptr[0] = &property[0];
-		$$->cmd_prop_name[1] = $7;
-		$$->cmd_property_ptr[1] = &property[1];
-		$$->cmd_prop_name[2] = $10;
-		$$->cmd_property_ptr[2] = &property[2];
-	}
 
 revert_command: REVERT
 	{
@@ -1084,8 +1004,6 @@
 	| USER		{ $$ = PT_USER; }
 	| AUTHS 	{ $$ = PT_AUTHS; }
 	| FS_ALLOWED	{ $$ = PT_FS_ALLOWED; }
-	| UUID		{ $$ = PT_UUID; }
-	| ZFSPRI	{ $$ = PT_ZFSPRI; }
 
 /*
  * The grammar builds data structures from the bottom up.  Thus various
--- old/usr/src/cmd/zonecfg/zonecfg_lex.l	Wed Oct  5 00:33:13 2016
+++ new/usr/src/cmd/zonecfg/zonecfg_lex.l	Wed Oct  5 00:33:13 2016
@@ -22,7 +22,6 @@
 
 /*
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011, Joyent Inc. All rights reserved.
  */
 
 #include <assert.h>
@@ -322,12 +321,6 @@
 <TSTATE>fs-allowed	{ return FS_ALLOWED; }
 <CSTATE>fs-allowed	{ return FS_ALLOWED; }
 
-<TSTATE>uuid	{ return UUID; }
-<CSTATE>uuid	{ return UUID; }
-
-<TSTATE>zfs-io-priority	{ return ZFSPRI; }
-<CSTATE>zfs-io-priority	{ return ZFSPRI; }
-
 <TSTATE>=	{ return EQUAL; }
 <LSTATE>=	{ return EQUAL; }
 <CSTATE>=	{ return EQUAL; }
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/common/list/list.c	Wed Oct  5 00:33:14 2016
+++ new/usr/src/common/list/list.c	Wed Oct  5 00:33:14 2016
@@ -38,7 +38,17 @@
 #endif
 
 #ifdef lint
-extern list_node_t *list_d2l(list_t *list, void *obj);
+static list_node_t *
+list_d2l(list_t *list, void *obj)
+{
+	/* Pretty version for lint... */
+	uint64_t *offset = (uint64_t *)obj;
+
+	if (!IS_P2ALIGNED(obj, 8))
+		return (NULL);
+
+	return ((list_node_t *)(offset + (list->list_offset >> 3)));
+}
 #else
 #define	list_d2l(a, obj) ((list_node_t *)(((char *)obj) + (a)->list_offset))
 #endif
--- old/usr/src/head/libzonecfg.h	Wed Oct  5 00:33:14 2016
+++ new/usr/src/head/libzonecfg.h	Wed Oct  5 00:33:14 2016
@@ -21,7 +21,6 @@
 
 /*
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2015, Joyent, Inc.
  */
 
 #ifndef _LIBZONECFG_H
@@ -120,8 +119,6 @@
 
 #define	ZONE_STATE_MAXSTRLEN	14
 
-#define	ZONE_PROP_MAXSTRLEN	1024
-
 #define	LIBZONECFG_PATH		"libzonecfg.so.1"
 
 #define	ZONE_CONFIG_ROOT	"/etc/zones"
@@ -170,11 +167,6 @@
  */
 #define	ZONE_DRY_RUN		0x01
 
-typedef enum zone_iptype {
-	ZS_SHARED,
-	ZS_EXCLUSIVE
-} zone_iptype_t;
-
 /*
  * The integer field expresses the current values on a get.
  * On a put, it represents the new values if >= 0 or "don't change" if < 0.
@@ -185,9 +177,6 @@
 	char	zone_path[MAXPATHLEN];		/* path to zone storage */
 	uuid_t	zone_uuid;			/* unique ID for zone */
 	char	zone_newname[ZONENAME_MAX];	/* for doing renames */
-	char	zone_brand[MAXNAMELEN];		/* zone's brand */
-	zone_iptype_t zone_iptype;		/* zone's IP type */
-	zoneid_t zone_did;			/* persistent debug ID */
 };
 
 typedef struct zone_dochandle *zone_dochandle_t;	/* opaque handle */
@@ -213,7 +202,7 @@
  */
 struct zone_res_attrtab {
 	char	zone_res_attr_name[MAXNAMELEN];
-	char	zone_res_attr_value[ZONE_PROP_MAXSTRLEN];
+	char	zone_res_attr_value[MAXNAMELEN];
 	struct zone_res_attrtab *zone_res_attr_next;
 };
 
@@ -291,6 +280,11 @@
 	char		*zpe_vers;
 } zone_pkg_entry_t;
 
+typedef enum zone_iptype {
+	ZS_SHARED,
+	ZS_EXCLUSIVE
+} zone_iptype_t;
+
 /*
  * Basic configuration management routines.
  */
@@ -318,7 +312,6 @@
 extern	int	zonecfg_str_to_bytes(char *, uint64_t *);
 extern	boolean_t zonecfg_valid_memlimit(char *, uint64_t *);
 extern	boolean_t zonecfg_valid_alias_limit(char *, char *, uint64_t *);
-extern	void	zonecfg_notify_create(zone_dochandle_t);
 
 /*
  * Zone name, path to zone directory, autoboot setting, pool, boot
@@ -544,7 +537,6 @@
 extern	char	*zone_state_str(zone_state_t);
 extern	int	zonecfg_get_name_by_uuid(const uuid_t, char *, size_t);
 extern	int	zonecfg_get_uuid(const char *, uuid_t);
-extern	int	zonecfg_set_uuid(const char *, const char *, const char *);
 extern	int	zonecfg_default_brand(char *, size_t);
 extern	int	zonecfg_fix_obsolete(zone_dochandle_t);
 
No differences encountered
No differences encountered
--- old/usr/src/head/zone.h	Wed Oct  5 00:33:14 2016
+++ new/usr/src/head/zone.h	Wed Oct  5 00:33:14 2016
@@ -60,7 +60,7 @@
 /* System call API */
 extern zoneid_t	zone_create(const char *, const char *,
     const struct priv_set *, const char *, size_t, const char *, size_t, int *,
-    int, int, const bslabel_t *, int, zoneid_t);
+    int, int, const bslabel_t *, int);
 extern int	zone_boot(zoneid_t);
 extern int	zone_destroy(zoneid_t);
 extern ssize_t	zone_getattr(zoneid_t, int, void *, size_t);
--- old/usr/src/lib/Makefile	Wed Oct  5 00:33:14 2016
+++ new/usr/src/lib/Makefile	Wed Oct  5 00:33:14 2016
@@ -22,12 +22,11 @@
 #
 # Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
 # Copyright (c) 2012 by Delphix. All rights reserved.
-# Copyright 2015, Joyent, Inc.
+# Copyright (c) 2012, Joyent, Inc. All rights reserved.
 # Copyright (c) 2013 Gary Mills
 # Copyright 2014 Garrett D'Amore <garrett@damore.org>
 # Copyright (c) 2015 Gary Mills
 # Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
-# Copyright 2016 Toomas Soome <tsoome@me.com>
 #
 
 include ../Makefile.master
@@ -92,7 +91,6 @@
 	libbrand	\
 	libbsdmalloc	\
 	libbsm		\
-	libbunyan	\
 	libc_db		\
 	libcfgadm	\
 	libcmd		\
@@ -119,7 +117,6 @@
 	libdscfg	\
 	libdtrace	\
 	libdtrace_jni	\
-	libdwarf	\
 	libefi		\
 	libelfsign	\
 	libeti		\
@@ -127,7 +124,6 @@
 	libexacct/demo	\
 	libfakekernel	\
 	libfcoe		\
-	libficl		\
 	libfru		\
 	libfruutils	\
 	libfsmgt	\
@@ -137,7 +133,6 @@
 	libgss		\
 	libhotplug	\
 	libidmap	\
-	libidspace	\
 	libilb		\
 	libima		\
 	libinetsvc	\
@@ -185,11 +180,9 @@
 	libraidcfg	\
 	librcm		\
 	librdc		\
-	librename	\
 	libreparse	\
 	libresolv	\
 	libresolv2	\
-	libresolv2_joy	\
 	librestart	\
 	librpcsvc	\
 	librsm		\
@@ -207,7 +200,6 @@
 	libsip		\
 	libsldap	\
 	libslp		\
-	libsmartsshd	\
 	libsmbfs	\
 	libsmbios	\
 	libsmedia	\
@@ -231,7 +223,6 @@
 	libunistat	\
 	libuuid		\
 	libuutil	\
-	libvnd		\
 	libvolmgt	\
 	libvrrpadm	\
 	libvscan	\
@@ -242,7 +233,6 @@
 	libxcurses	\
 	libxcurses2	\
 	libxnet		\
-	libzdoor	\
 	libzfs		\
 	libzfs_core	\
 	libzfs_jni	\
@@ -250,6 +240,7 @@
 	libzoneinfo	\
 	libzonestat	\
 	libzpool	\
+	lvm		\
 	madv		\
 	mpapi		\
 	mpss		\
@@ -261,6 +252,9 @@
 	pkcs11		\
 	policykit	\
 	print		\
+	pylibbe		\
+	pysolaris	\
+	pyzfs		\
 	raidcfg_plugins	\
 	rpcsec_gss	\
 	sasl_plugins	\
@@ -270,7 +264,6 @@
 	sun_fc		\
 	sun_sas		\
 	udapl		\
-	varpd		\
 	watchmalloc	\
 	$($(MACH)_SUBDIRS)
 
@@ -297,7 +290,8 @@
 #
 NOWAIT_SUBDIRS= $(SUBDIRS:.WAIT=)
 
-DCSUBDIRS =
+DCSUBDIRS =		\
+	lvm
 
 MSGSUBDIRS=		\
 	abi		\
@@ -343,7 +337,6 @@
 	libshell	\
 	libsldap	\
 	libslp		\
-	libsmartsshd	\
 	libsmbfs	\
 	libsmedia	\
 	libsum		\
@@ -355,10 +348,11 @@
 	libwanbootutil	\
 	libzfs		\
 	libzonecfg	\
-	libzdoor	\
+	lvm		\
 	madv		\
 	mpss		\
 	pam_modules	\
+	pyzfs		\
 	rpcsec_gss	\
 	$($(MACH)_MSGSUBDIRS)
 
@@ -378,7 +372,6 @@
 	libast		\
 	libbrand	\
 	libbsm		\
-	libbunyan	\
 	libc		\
 	libcmd		\
 	libcmdutils	\
@@ -395,7 +388,6 @@
 	libdhcputil	\
 	libdisasm	\
 	libdiskmgt	\
-	libdwarf	\
 	libdladm	\
 	libdll		\
 	libdlpi		\
@@ -412,7 +404,6 @@
 	libgen		\
 	libgrubmgmt	\
 	libidmap	\
-	libidspace	\
 	libilb		\
 	libima		\
 	libinetsvc	\
@@ -448,7 +439,6 @@
 	libraidcfg	\
 	librcm		\
 	librdc		\
-	librename	\
 	libreparse	\
 	librestart	\
 	librpcsvc	\
@@ -482,7 +472,6 @@
 	libumem		\
 	libunistat	\
 	libuutil	\
-	libvnd		\
 	libvolmgt	\
 	libvrrpadm	\
 	libvscan	\
@@ -495,6 +484,7 @@
 	libzfs_jni	\
 	libzoneinfo	\
 	libzonestat	\
+	lvm		\
 	mpapi		\
 	passwdutil	\
 	pkcs11		\
@@ -588,16 +578,14 @@
 gss_mechs/mech_spnego: gss_mechs/mech_krb5
 krb5:		gss_mechs/mech_krb5 libtecla libldap5
 libadt_jni:	libbsm
-libadutils:	libldap5 libresolv2
-libbe:		libzfs libinstzones libuuid libgen libdevinfo libefi libficl
+libadutils: 	libldap5 libresolv2
+libbe: 		libzfs libinstzones libuuid libgen libdevinfo libefi
 libbsm:		libinetutil libscf libsecdb libtsol
-libbunyan:	libnvpair
 libcfgadm:	libdevinfo
-libcmd:		libsum libast
+libcmd: 	libsum libast
 libcmdutils:	libavl
 libcpc:		libpctx
 libcrypt:	libgen
-libctf:		libdwarf
 libdevid:	libdevinfo
 libdevinfo:	libsec libgen
 libdhcpagent:	libdhcputil libuuid libdlpi libcontract
@@ -605,7 +593,7 @@
 libdiskmgt:	libdevid libdevinfo libadm libefi libkstat libsysevent
 $(INTEL_BLD)libdiskmgt: libfdisk
 libdladm:	libdevinfo libinetutil libscf librcm libexacct libkstat \
-		libpool varpd
+		libpool
 libdll: 	libast
 libdlpi:	libinetutil libdladm
 libds:		libsysevent
@@ -618,13 +606,11 @@
 libexacct/demo:	libexacct libproject
 libfakekernel:	libumem libcryptoutil
 libfcoe:	libdladm
-libficl:	libumem
 libfru:		libfruutils
 libfsmgt:	libkstat
 libgrubmgmt:	libdevinfo libzfs libfstyp libefi
 $(INTEL_BLD)libgrubmgmt: libfdisk
 libidmap:	libavl libuutil
-libidspace:	libumem
 libinetsvc:	libscf
 libinstzones:	libzonecfg libcontract
 libipadm:	libinetutil libdlpi libdhcpagent libdladm libsecdb
@@ -659,7 +645,6 @@
 libshell:	libast libcmd libdll libsecdb
 libsip:		libmd5
 libsldap:	libldap5 libscf
-libsmartsshd:	libc libcontract
 libsmbfs:	libkrb5 libsec libidmap pkcs11
 libsrpt:	libstmf
 libstmf:	libscf
@@ -679,7 +664,6 @@
 libvrrpadm:	libdladm libscf
 libvscan:	libscf libsecdb
 libwanboot:	libresolv2 libdevinfo libinetutil libdhcputil
-libzdoor:	libc libzonecfg libcontract
 libzfs:		libdevid libgen libuutil libadm libavl libefi libidmap \
 		libumem libtsol libzfs_core
 libzfs_jni:	libdiskmgt libzfs
@@ -691,8 +675,7 @@
 madv:		libgen
 mpapi:		libpthread libdevinfo libsysevent
 mpss:		libgen
-nsswitch:	libadutils libidmap libdns_sd libscf libldap5 libsldap \
-		libresolv2_joy
+nsswitch:	libadutils libidmap libdns_sd libscf libldap5 libsldap
 pam_modules:	libproject passwdutil smbsrv libtsnet libpam libbsm libsecdb
 passwdutil:	libsldap
 pkcs11:		libcryptoutil libgen libuuid
@@ -712,8 +695,6 @@
 sun_fc:		libdevinfo libsysevent
 sun_sas:	libdevinfo libsysevent libkstat libdevid
 udapl:		libdevinfo libdladm
-varpd:		libavl libidspace libumem libnsl libnvpair libmd5 librename \
-		libbunyan libcmdutils
 
 #
 # The reason this rule checks for the existence of the
--- old/usr/src/lib/Makefile.lib	Wed Oct  5 00:33:14 2016
+++ new/usr/src/lib/Makefile.lib	Wed Oct  5 00:33:14 2016
@@ -21,7 +21,7 @@
 # Copyright 2015 Gary Mills
 # Copyright 2015 Igor Kozhukhov <ikozhukhov@gmail.com>
 # Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
-# Copyright (c) 2015, Joyent, Inc.
+# Copyright (c) 2014, Joyent, Inc.
 #
 #
 # Definitions common to libraries.
@@ -272,15 +272,3 @@
 # shouldn't override this - they should override $(CLOBBERFILES) instead.
 #
 CLOBBERTARGFILES= $(LIBS) $(DYNLIB) $(CLOBBERFILES)
-
-#
-# Define the default ctfdiff invocation used to check a list of types
-# supplied by a user of a library. The goal is to validate that a given
-# series of types is the same in both a 32-bit and 64-bit artifact. This
-# is only defined if we have a 64-bit build to do.
-#
-TYPECHECK_LIB32 =		$(TYPECHECK_LIB:%=$(MACH)/%)
-TYPECHECK_LIB64 =		$(TYPECHECK_LIB:%=$(MACH64)/%)
-TYPECHECK_LIST=			$(TYPELIST:%=-T %)
-$(BUILD64)TYPECHECK.lib =	$(CTFDIFF) -t -I $(TYPECHECK_LIST) $(TYPECHECK_LIB32) $(TYPECHECK_LIB64)
-TYPECHECK =			$(TYPECHECK_LIB:%=%.typecheck)
--- old/usr/src/lib/Makefile.targ	Wed Oct  5 00:33:14 2016
+++ new/usr/src/lib/Makefile.targ	Wed Oct  5 00:33:14 2016
@@ -105,9 +105,6 @@
 lintcheck: $$(SRCS)
 	$(LINT.c) $(LINTCHECKFLAGS) $(SRCS) $(LDLIBS)
 
-$(TYPECHECK): $(TYPECHECK_LIB32) $(TYPECHECK_LIB64)
-	$(TYPECHECK.lib)
-
 clobber: clean
 	-$(RM) $(CLOBBERTARGFILES)
 
No differences encountered
--- old/usr/src/lib/brand/Makefile	Wed Oct  5 00:33:15 2016
+++ new/usr/src/lib/brand/Makefile	Wed Oct  5 00:33:15 2016
@@ -33,7 +33,7 @@
 i386_SUBDIRS= lx
 i386_MSGSUBDIRS= lx
 
-SUBDIRS= shared .WAIT sn1 solaris10 ipkg labeled $($(MACH)_SUBDIRS)
+SUBDIRS= shared .WAIT sn1 solaris10 ipkg labeled lipkg $($(MACH)_SUBDIRS)
 MSGSUBDIRS= solaris10 shared $($(MACH)_MSGSUBDIRS)
 
 all :=		TARGET= all
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/lib/brand/lx/librtld_db/common/lx_librtld_db.c	Wed Oct  5 00:33:15 2016
+++ new/usr/src/lib/brand/lx/librtld_db/common/lx_librtld_db.c	Wed Oct  5 00:33:15 2016
@@ -629,6 +629,7 @@
 	for (offs = symtab; offs < strtab; offs += sizeof (Elf32_Sym)) {
 		uint32_t p;
 
+		/* LINTED - "offs" increments always in sizeof (Elf32_Sym). */
 		sym = (Elf32_Sym *)&mem[offs];
 
 		if (sym->st_name > memsz) {
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/lib/brand/lx/lx_brand/Makefile.com	Wed Oct  5 00:33:15 2016
+++ new/usr/src/lib/brand/lx/lx_brand/Makefile.com	Wed Oct  5 00:33:15 2016
@@ -74,7 +74,7 @@
 UTSBASE	=	../../../../../uts
 
 LIBS =		$(DYNLIB)
-LDLIBS +=	-lc -lsocket -lmapmalloc -lproc -lrtld_db -lrpcsvc -lnsl
+LDLIBS +=	-lc -lsocket -lmapmalloc -lrpcsvc -lnsl
 DYNFLAGS +=	$(DYNFLAGS_$(CLASS))
 DYNFLAGS +=	$(BLOCAL) $(ZNOVERSION) -Wl,-e_start -M../common/mapfile
 CFLAGS +=	$(CCVERBOSE)
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/lib/brand/lx/lx_init/Makefile	Wed Oct  5 00:33:19 2016
+++ new/usr/src/lib/brand/lx/lx_init/Makefile	Wed Oct  5 00:33:19 2016
@@ -44,8 +44,9 @@
 UTSBASE =	$(SRC)/uts
 
 CFLAGS +=	$(CCVERBOSE)
-CPPFLAGS +=	-D_REENTRANT -I$(UTSBASE)/common/brand/lx
+CPPFLAGS +=	-D_FILE_OFFSET_BITS=64 -D_REENTRANT -I$(UTSBASE)/common/brand/lx
 LDLIBS +=	-lzonecfg -lipadm -lsocket -linetutil -lnsl -lcmdutils -ldhcpagent
+LINTFLAGS +=	-xerroff=E_NAME_DEF_NOT_USED2
 
 .KEEP_STATE:
 
@@ -54,7 +55,7 @@
 clean:
 	$(RM) $(PROG) $(OBJS)
 
-lint: lint_PROG lint_SRCS
+lint: lint_SRCS
 
 $(PROG): $(OBJS)
 	$(LINK.c) -o $@ $(OBJS) $(LDLIBS)
--- old/usr/src/lib/brand/lx/lx_init/lxinit.c	Wed Oct  5 00:33:19 2016
+++ new/usr/src/lib/brand/lx/lx_init/lxinit.c	Wed Oct  5 00:33:19 2016
@@ -103,7 +103,7 @@
 	 * Since a non-zero exit will cause the zone to reboot, a pause here
 	 * will prevent a mis-configured zone from spinning in a reboot loop.
 	 */
-	pause();
+	(void) pause();
 	exit(1);
 	/*NOTREACHED*/
 }
@@ -202,19 +202,21 @@
 	return (-1);
 }
 
-void
+static void
 lxi_svc_start(char *name, char *path, char *fmri)
 {
 	pid_t pid;
 	int status;
-	char *const argv[] = {
-		name,
+	char *argv[] = {
+		NULL,
 		NULL
 	};
-	char *const envp[] = {
-		fmri,
+	char *envp[] = {
+		NULL,
 		NULL
 	};
+	argv[0] = name;
+	envp[0] = fmri;
 
 	pid = fork();
 	if (pid == -1) {
@@ -233,7 +235,7 @@
 		(void) snprintf(cmd, sizeof (cmd), "%s%s", zroot != NULL ?
 		    zroot : "", path);
 
-		execve(cmd, argv, envp);
+		(void) execve(cmd, argv, envp);
 
 		lxi_err("execve(%s) failed: %s", cmd, strerror(errno));
 		/* NOTREACHED */
@@ -240,9 +242,8 @@
 	}
 
 	/* parent */
-	while (wait(&status) != pid) {
-		/* EMPTY */;
-	}
+	while (wait(&status) != pid)
+		;
 
 	if (WIFEXITED(status)) {
 		if (WEXITSTATUS(status) != 0) {
@@ -494,10 +495,10 @@
     const char *gwaddr)
 {
 	int idx, len, sockfd;
-	char rtbuf[RTMBUFSZ];
+	/* For lint-happy alignment, use a uint32_t array... */
+	uint32_t rtbuf[RTMBUFSZ / sizeof (uint32_t)];
 	struct rt_msghdr *rtm = (struct rt_msghdr *)rtbuf;
-	struct sockaddr_in *dst_sin = (struct sockaddr_in *)
-	    (rtbuf + sizeof (struct rt_msghdr));
+	struct sockaddr_in *dst_sin = (struct sockaddr_in *)(rtm + 1);
 	struct sockaddr_in *gw_sin = (struct sockaddr_in *)(dst_sin + 1);
 	struct sockaddr_in *netmask_sin = (struct sockaddr_in *)(gw_sin + 1);
 
@@ -549,15 +550,15 @@
 
 	if ((len = write(sockfd, rtbuf, rtm->rtm_msglen)) < 0) {
 		lxi_warn("could not write rtmsg: %s", strerror(errno));
-		close(sockfd);
+		(void) close(sockfd);
 		return (-1);
 	} else if (len < rtm->rtm_msglen) {
 		lxi_warn("write() rtmsg incomplete");
-		close(sockfd);
+		(void) close(sockfd);
 		return (-1);
 	}
 
-	close(sockfd);
+	(void) close(sockfd);
 	return (0);
 }
 
@@ -572,56 +573,6 @@
 	(void) lxi_iface_ipv6_link_local(iface);
 }
 
-
-/*
- * This function is used when the "ips" property doesn't exist in a zone's
- * configuration. It may be an older configuration, so we should search for
- * "ip" and "netmask" and convert them into the new format.
- */
-static int
-lxi_get_old_ip(struct zone_res_attrtab *attrs, const char **ipaddrs,
-    char *cidraddr, int len)
-{
-
-	const char *netmask;
-	int prefixlen;
-	struct sockaddr_in mask_sin;
-
-	lxi_warn("Could not find \"ips\" property for zone. Looking "
-	    "for older \"ip\" and \"netmask\" properties, instead.");
-
-	if (zone_find_attr(attrs, "ip", ipaddrs) != 0) {
-		return (-1);
-	}
-
-	if (strcmp(*ipaddrs, "dhcp") == 0) {
-		return (0);
-	}
-
-	if (zone_find_attr(attrs, "netmask", &netmask) != 0) {
-		lxi_err("could not find netmask for interface");
-		/* NOTREACHED */
-	}
-
-	/* Convert the netmask to a number */
-	mask_sin.sin_family = AF_INET;
-	if (inet_pton(AF_INET, netmask, &mask_sin.sin_addr) != 1) {
-		lxi_err("invalid netmask address: %s\n",
-		    strerror(errno));
-		/* NOTREACHED */
-	}
-	prefixlen = mask2plen((struct sockaddr *)&mask_sin);
-
-	/*
-	 * Write out the IP address in the new format and use
-	 * that instead
-	 */
-	(void) snprintf(cidraddr, len, "%s/%d", *ipaddrs, prefixlen);
-
-	*ipaddrs = cidraddr;
-	return (0);
-}
-
 static void
 lxi_net_setup(zone_dochandle_t handle)
 {
@@ -634,17 +585,30 @@
 		const char *iface = lookup.zone_nwif_physical;
 		struct zone_res_attrtab *attrs = lookup.zone_nwif_attrp;
 		const char *ipaddrs, *primary, *gateway;
-		char ipaddrs_copy[MAXNAMELEN], cidraddr[BUFSIZ],
+		char ipaddrs_copy[MAXNAMELEN], /* cidraddr[BUFSIZ], */
 		    *ipaddr, *tmp, *lasts;
 		boolean_t first_ipv4_configured = B_FALSE;
 		boolean_t *ficp = &first_ipv4_configured;
+		boolean_t no_zonecfg;
 
+		/*
+		 * Regardless of whether we're configured in zonecfg(1M), or
+		 * configured by other means, make sure we plumb every
+		 * physical=<foo> for IPv4 and IPv6.
+		 */
 		lxi_net_plumb(iface);
-		if (zone_find_attr(attrs, "ips", &ipaddrs) != 0 &&
-		    lxi_get_old_ip(attrs, &ipaddrs, cidraddr, BUFSIZ) != 0) {
-			lxi_warn("Could not find a valid network configuration "
-			    "for the %s interface", iface);
-			continue;
+
+		if (zone_find_attr(attrs, "ips", &ipaddrs) != 0 /* &&
+		    lxi_get_old_ip(attrs, &ipaddrs, cidraddr, BUFSIZ) != 0*/) {
+			/*
+			 * Do not panic.  This interface has no in-zonecfg(1M)
+			 * configuration.  We keep a warning around for now.
+			 */
+			lxi_warn("Could not find zonecfg(1M) network "
+			    "configuration for the %s interface", iface);
+			no_zonecfg = B_TRUE;
+		} else {
+			no_zonecfg = B_FALSE;
 		}
 
 		if (lxi_iface_ipv6_link_local(iface) != 0) {
@@ -653,8 +617,15 @@
 		}
 
 		/*
-		 * If we're going to be doing DHCP, we have to do it first since
-		 * dhcpagent doesn't like to operate on non-zero logical
+		 * Every thing else below only happens if we have zonecfg(1M)
+		 * network configuration.
+		 */
+		if (no_zonecfg)
+			continue;
+
+		/*
+		 * If we're going to be doing DHCP, we have to do it first
+		 * since dhcpagent doesn't like to operate on non-zero logical
 		 * interfaces.
 		 */
 		if (strstr(ipaddrs, "dhcp") != NULL &&
@@ -687,7 +658,10 @@
 		if (zone_find_attr(attrs, "primary", &primary) == 0 &&
 		    strncmp(primary, "true", MAXNAMELEN) == 0 &&
 		    zone_find_attr(attrs, "gateway", &gateway) == 0) {
-			lxi_iface_gateway(iface, NULL, 0, gateway);
+			if (lxi_iface_gateway(iface, NULL, 0, gateway) != 0) {
+				lxi_err("default route on %s -> %s failed",
+				    iface, gateway);
+			}
 		}
 	}
 
@@ -832,7 +806,7 @@
 	 * treats anything else as 'other' but this is enough to make it
 	 * behave better inside a zone. See 'detect_container' in systemd.
 	 */
-	execve(cmd, argv, envp);
+	(void) execve(cmd, argv, envp);
 	e = errno;
 
 	/*
--- old/usr/src/lib/brand/lx/lx_init/pipe_stream.c	Wed Oct  5 00:33:19 2016
+++ new/usr/src/lib/brand/lx/lx_init/pipe_stream.c	Wed Oct  5 00:33:19 2016
@@ -21,7 +21,6 @@
 #include <poll.h>
 #include <errno.h>
 #include <sys/types.h>
-#include <sys/debug.h>
 #include <sys/list.h>
 
 #include "pipe_stream.h"
@@ -65,7 +64,7 @@
 	VERIFY0(close(psl->psl_port));
 
 	while (!list_is_empty(&psl->psl_pipes)) {
-		pipe_stream_fini(list_head(&psl->psl_pipes));
+		(void)pipe_stream_fini(list_head(&psl->psl_pipes));
 	}
 
 	list_destroy(&psl->psl_pipes);
--- old/usr/src/lib/brand/lx/lx_init/pipe_stream.h	Wed Oct  5 00:33:19 2016
+++ new/usr/src/lib/brand/lx/lx_init/pipe_stream.h	Wed Oct  5 00:33:19 2016
@@ -41,6 +41,13 @@
 extern boolean_t pipe_stream_loop_should_run(pipe_stream_loop_t *);
 extern int pipe_stream_loop_run(pipe_stream_loop_t *);
 
+#include <assert.h>
+/*
+ * Kernel-like macros that don't trigger lint.
+ */
+#define	VERIFY0(stmt) assert((stmt) == 0)
+#define	VERIFY(stmt) assert(stmt)
+
 #ifdef __cplusplus
 }
 #endif
--- old/usr/src/lib/brand/lx/lx_init/run_command.c	Wed Oct  5 00:33:19 2016
+++ new/usr/src/lib/brand/lx/lx_init/run_command.c	Wed Oct  5 00:33:19 2016
@@ -20,7 +20,6 @@
 #include <unistd.h>
 #include <wait.h>
 #include <sys/types.h>
-#include <sys/debug.h>
 #include <libcmdutils.h>
 
 #include "run_command.h"
@@ -118,7 +117,7 @@
 		    STDERR_FILENO));
 		closefrom(3);
 
-		execve(path, argv, envp);
+		(void) execve(path, argv, envp);
 		err(127, "exec(%s) failed", path);
 	}
 
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/lib/brand/lx/testing/Makefile	Wed Oct  5 00:33:21 2016
+++ new/usr/src/lib/brand/lx/testing/Makefile	Wed Oct  5 00:33:21 2016
@@ -10,10 +10,10 @@
 #
 
 #
-# Copyright 2016 Joyent, Inc.
+# Copyright 2015 Joyent, Inc. All rights reserved.
 #
 
-TXTS = ltp_skiplist ltp_tests pts_ignorelist
+TXTS = ltp_skiplist ltp_tests
 
 all:
 
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/lib/brand/lx/zone/Makefile	Wed Oct  5 00:33:21 2016
+++ new/usr/src/lib/brand/lx/zone/Makefile	Wed Oct  5 00:33:21 2016
@@ -22,9 +22,10 @@
 #
 # Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 # Copyright 2015 Joyent, Inc.  All rights reserved.
+# Copyright 2016 OmniTI Computer Consulting, Inc. All rights reserved.
 #
 
-PROGS =	lx_boot
+PROGS =	lx_install lx_boot
 PROGS += lx_boot_zone_redhat lx_boot_zone_ubuntu lx_boot_zone_debian
 PROGS += lx_boot_zone_busybox
 XMLDOCS =	config.xml platform.xml
No differences encountered
No differences encountered
--- old/usr/src/lib/brand/lx/zone/config.xml	Wed Oct  5 00:33:21 2016
+++ new/usr/src/lib/brand/lx/zone/config.xml	Wed Oct  5 00:33:21 2016
@@ -37,8 +37,8 @@
 	<forcedlogin_cmd>/bin/login -h zone:%Z -f %u</forcedlogin_cmd>
 	<user_cmd>/usr/bin/getent passwd %u</user_cmd>
 
-	<install>/usr/lib/brand/lx/lx_install %z %R</install>
-	<installopts>d:hsvX</installopts>
+	<install>/usr/lib/brand/lx/lx_install -z %z -R %R</install>
+	<installopts>s:</installopts>
 	<boot>/usr/lib/brand/lx/lx_boot %z %R</boot>
 	<halt>/usr/lib/brand/lx/lx_support halt %R %z</halt>
 	<verify_cfg>/usr/lib/brand/lx/lx_support verify</verify_cfg>
@@ -70,6 +70,7 @@
 	<privilege set="default" name="proc_chroot" />
 	<privilege set="default" name="sys_audit" />
 	<privilege set="default" name="proc_audit" />
+	<privilege set="default" name="proc_clock_highres" />
 	<privilege set="default" name="proc_lock_memory" />
 	<privilege set="default" name="proc_owner" />
 	<privilege set="default" name="proc_setid" />
No differences encountered
--- old/usr/src/lib/brand/lx/zone/lx_boot_zone_busybox.ksh	Wed Oct  5 00:33:22 2016
+++ new/usr/src/lib/brand/lx/zone/lx_boot_zone_busybox.ksh	Wed Oct  5 00:33:22 2016
@@ -36,11 +36,16 @@
     keyword nojail noprefix novserver
 }
 start() {
+EOF
+# Only alter resolve.conf if we're getting info from zonecfg(1M).
+zonecfg -z $ZONENAME info attr name=resolvers | grep -q resolvers
+if [[ $? == 0 ]]; then
+    cat > $tmpfile <<EOF
     if [ ! -e /etc/resolv.conf ]; then
         echo "# AUTOMATIC ZONE CONFIG" > /etc/resolv.conf
 EOF
-zonecfg -z $ZONENAME info attr name=resolvers |
-awk '
+    zonecfg -z $ZONENAME info attr name=resolvers |
+    awk '
     {
         if ($1 == "value:") {
             nres = split($2, resolvers, ",")
@@ -52,9 +57,9 @@
                 "/etc/resolv.conf")
         }
     }
-' >> $tmpfile
-zonecfg -z $ZONENAME info attr name=dns-domain |
-awk '
+    ' >> $tmpfile
+    zonecfg -z $ZONENAME info attr name=dns-domain |
+    awk '
     {
         if ($1 == "value:") {
             dom = $2
@@ -63,15 +68,24 @@
     END {
         printf("        echo \"search %s\" >> %s\n", dom, "/etc/resolv.conf")
     }
-' >> $tmpfile
-cat >> $tmpfile <<EOF
+    ' >> $tmpfile
+    cat >> $tmpfile <<EOF
     fi
     return 0
-}
-stop() {
+    }
+EOF
+else
+    cat >> $tmpfile <<EOF
     return 0
-}
+    }
 EOF
+fi
+
+cat >> $tmpfile <<EOF
+    stop() {
+        return 0
+    }
+EOF
 fnm=$ZONEROOT/etc/init.d/networking
 if [[ -f $fnm || -h $fnm ]]; then
 	mv -f $tmpfile $fnm
--- old/usr/src/lib/brand/lx/zone/lx_boot_zone_debian.ksh	Wed Oct  5 00:33:22 2016
+++ new/usr/src/lib/brand/lx/zone/lx_boot_zone_debian.ksh	Wed Oct  5 00:33:22 2016
@@ -36,29 +36,32 @@
 safe_dir /etc/rcS.d
 safe_opt_dir /etc/selinux
 
-# Populate resolve.conf setup files
-zonecfg -z $ZONENAME info attr name=resolvers | awk '
-BEGIN {
+# Populate resolve.conf setup files IF we have resolvers information.
+zonecfg -z $ZONENAME info attr name=resolvers | grep -q resolvers
+if [[ $? == 0 ]]; then
+    zonecfg -z $ZONENAME info attr name=resolvers | awk '
+    BEGIN {
 	print("# AUTOMATIC ZONE CONFIG")
-}
-$1 == "value:" {
+    }
+    $1 == "value:" {
 	nres = split($2, resolvers, ",");
 	for (i = 1; i <= nres; i++) {
 		print("nameserver", resolvers[i]);
 	}
-}
-' > $tmpfile
-zonecfg -z $ZONENAME info attr name=dns-domain | awk '
-$1 == "value:" {
+    }
+    ' > $tmpfile
+    zonecfg -z $ZONENAME info attr name=dns-domain | awk '
+    $1 == "value:" {
 	dom = $2
-}
-END {
+    }
+    END {
 	print("search", dom);
-}
-' >> $tmpfile
-fnm=$ZONEROOT/etc/resolv.conf
-if [[ -f $fnm || -h $fnm ]]; then
+    }
+    ' >> $tmpfile
+    fnm=$ZONEROOT/etc/resolv.conf
+    if [[ -f $fnm || -h $fnm ]]; then
 	mv -f $tmpfile $fnm
+    fi
 fi
 
 # Override network configuration
--- old/usr/src/lib/brand/lx/zone/lx_boot_zone_redhat.ksh	Wed Oct  5 00:33:22 2016
+++ new/usr/src/lib/brand/lx/zone/lx_boot_zone_redhat.ksh	Wed Oct  5 00:33:22 2016
@@ -12,7 +12,7 @@
 
 #
 # Copyright 2015 Joyent, Inc.
-# Copyright 2015 OmniTI Computer Consulting, Inc. All rights reserved.
+# Copyright 2016 OmniTI Computer Consulting, Inc. All rights reserved.
 #
 
 #
@@ -57,6 +57,12 @@
     start)
     [ "\$EUID" != "0" ] && exit 4
 
+EOF
+
+# Alter resolv.conf if we're pulling resolver information from zonecfg(1M).
+zonecfg -z $ZONENAME info attr name=resolvers | grep -q resolvers
+if [[ $? == 0 ]]; then
+    cat >> $tmpfile <<EOF
     if [ ! -e /etc/resolv.conf ]; then
         if [ -h /etc/resolv.conf ]; then
             rm -f /etc/resolv.conf
@@ -63,8 +69,8 @@
         fi
         echo "# AUTOMATIC ZONE CONFIG" > /etc/resolv.conf
 EOF
-zonecfg -z $ZONENAME info attr name=resolvers |
-awk '
+    zonecfg -z $ZONENAME info attr name=resolvers |
+    awk '
     {
         if ($1 == "value:") {
             nres = split($2, resolvers, ",")
@@ -76,9 +82,9 @@
                 "/etc/resolv.conf")
         }
     }
-' >> $tmpfile
-zonecfg -z $ZONENAME info attr name=dns-domain |
-awk '
+    ' >> $tmpfile
+    zonecfg -z $ZONENAME info attr name=dns-domain |
+    awk '
     {
         if ($1 == "value:") {
             dom = $2
@@ -87,9 +93,11 @@
     END {
         printf("        echo \"search %s\" >> %s\n", dom, "/etc/resolv.conf")
     }
-' >> $tmpfile
+    ' >> $tmpfile
+    echo fi >> $tmpfile
+fi
+
 cat >> $tmpfile <<EOF
-    fi
     touch /var/lock/subsys/network
     rc=0
     ;;
--- old/usr/src/lib/brand/lx/zone/lx_boot_zone_ubuntu.ksh	Wed Oct  5 00:33:22 2016
+++ new/usr/src/lib/brand/lx/zone/lx_boot_zone_ubuntu.ksh	Wed Oct  5 00:33:22 2016
@@ -29,29 +29,32 @@
 safe_dir /etc/network/interfaces.d
 safe_dir /etc/network/interfaces.d/smartos
 
-# Populate resolve.conf setup files
-zonecfg -z $ZONENAME info attr name=resolvers | awk '
-BEGIN {
+# Populate resolve.conf setup files IF we have resolvers information.
+zonecfg -z $ZONENAME info attr name=resolvers | grep -q resolvers
+if [[ $? == 0 ]]; then
+    zonecfg -z $ZONENAME info attr name=resolvers | awk '
+    BEGIN {
 	print("# AUTOMATIC ZONE CONFIG")
-}
-$1 == "value:" {
+    }
+    $1 == "value:" {
 	nres = split($2, resolvers, ",");
 	for (i = 1; i <= nres; i++) {
 		print("nameserver", resolvers[i]);
 	}
-}
-' > $tmpfile
-zonecfg -z $ZONENAME info attr name=dns-domain | awk '
-$1 == "value:" {
+    }
+    ' > $tmpfile
+    zonecfg -z $ZONENAME info attr name=dns-domain | awk '
+    $1 == "value:" {
 	dom = $2
-}
-END {
+    }
+    END {
 	print("search", dom);
-}
-' >> $tmpfile
-fnm=$ZONEROOT/etc/resolvconf/resolv.conf.d/tail
-if [[ -f $fnm || -h $fnm || ! -e $fnm ]]; then
+    }
+    ' >> $tmpfile
+    fnm=$ZONEROOT/etc/resolvconf/resolv.conf.d/tail
+    if [[ -f $fnm || -h $fnm || ! -e $fnm ]]; then
 	mv -f $tmpfile $fnm
+    fi
 fi
 
 # Override network configuration
--- old/usr/src/lib/brand/lx/zone/lx_install.ksh	Wed Oct  5 00:33:22 2016
+++ new/usr/src/lib/brand/lx/zone/lx_install.ksh	Wed Oct  5 00:33:22 2016
@@ -10,185 +10,128 @@
 # http://www.illumos.org/license/CDDL.
 #
 # Copyright 2016 Joyent, Inc.  All rights reserved.
+# Copyright 2016 OmniTI Computer Consulting, Inc.  All rights reserved.
 #
 
-#
-# This is only an example install script. It is not currently used for anything.
-#
-
 PATH=/bin:/usr/bin:/usr/sbin
 export PATH
 
-fullpath()
-{
-	typeset path="$1"
+. /usr/lib/brand/shared/common.ksh
 
-	echo $path | egrep -s "^/" || path="${PWD:=$(pwd)}/$path"
-	echo $path
-}
+ZFS_SEED=""
+TAR_SEED=""
 
-makedir()
-{
-	typeset dirname=$(fullpath "$1")
-	typeset mode=""
-
-	[[ $# -eq 2 ]] && mode="-m $2"
-
-	[[ -d "$dirname" ]] && return
-
-	if ! mkdir $mode -p "$dirname"; then
-		echo $(gettext "Aborting installation...")
-		exit 255
-	fi
+bad_usage() {
+	echo "LX zone install bad option"
+	echo "Available options are:"
+	echo "	-s <absolute-pathname>	Path to ZFS send stream or gzip thereof"
+	echo "	-t <absolute-pathname>	Path to tar archive or gzip thereof"
+	exit $ZONE_SUBPROC_USAGE
 }
 
-symlink()
-{
-	typeset src="$1"
-	typeset dst=$(fullpath "$2")
+while getopts "R:s:t:z:" opt
+do
+	case "$opt" in
+		R)	ZONEPATH="$OPTARG";;
+		z)	ZONENAME="$OPTARG";;
+		s)	ZFS_SEED="$OPTARG";;
+		t)	TAR_SEED="$OPTARG";;
+		*)	bad_usage ;;
+	esac
+done
+shift OPTIND-1
 
-	[[ -e "$dst" || -h "$dst" ]] && rm -f "$dst"
-	
-	if ! ln -s "$src" "$dst"; then
-		echo $(gettext "Aborting installation...")
-		exit 255
-	fi
-}
+if [[ $ZFS_SEED == "" && $TAR_SEED == "" ]]; then
+    echo "The -s <absolute-pathname> argument or the -t <absolute-pathname>"
+    echo "argument is required for LX installation."
+    bad_usage
+fi
 
-install_ln()
-{
-	typeset source="$1"
-	typeset target=$(fullpath "$2")
+if [[ $ZFS_SEED != "" && $TAR_SEED != "" ]]; then
+    echo "You must only specify one of -s or -t for LX installation."
+    bad_usage
+fi
 
-	log "    Installing \"$target\""
+# Set the ZONEPATH_DS variable so we know the zone's dataset.
+get_zonepath_ds $ZONEPATH
 
-	mv -f "$target" "$target.$tag" 2>/dev/null
+# Do something based on whatever ZFS_SEED is.
 
-	if ! ln -s "$source" "$target"; then
-		return 1
+if [[ -f $TAR_SEED ]]; then
+    type=`file -b $TAR_SEED | awk '{print $1}'`
+    if [[ $type == "gzip" ]]; then
+	args="-xzf"
+    else
+	args="-xf"
+    fi
+    cd $ZONEPATH
+    # Be very precise about permissions and ownership.
+    mkdir -m 0755 dev
+    chgrp sys dev
+    mkdir -m 0755 root
+    chgrp root sys
+    cd root
+    gtar $args $TAR_SEED
+    exit 0
+elif [[ ! -f $ZFS_SEED ]]; then
+    # Try and eat a snapshot or a filesystem.
+    outstr=`zfs list -Ht filesystem $ZFS_SEED 2>/dev/null | awk '{print $1}'`
+    if [[ $outstr == $ZFS_SEED ]]; then
+	# We have a zfs filesystem name.
+	# Snapshot it using today's date/time
+	snapname=`date -u "+%Y-%m-%d:%H:%M:%S"`
+	ZFS_SEED=$ZFS_SEED@$snapname
+	zfs snapshot $ZFS_SEED
+	if [[ $? != 0 ]]; then
+	    echo "ZFS snapshot ($ZFS_SEED) command failed ($?)."
+	    exit $ZONE_SUBPROC_FATAL
 	fi
+	# else continue on with the new snapshot...
+    fi
 
-	return 0
-}
-
-# If we weren't passed 3 arguments, exit now.
-[[ $# -lt 3 ]] && exit 254
-
-# Extract the brand directory name from the path.
-branddir=$(dirname "$0")
-zonename="$1"
-zoneroot="$2"
-install_src="3"
-install_root="$zoneroot/root"
-ZPOOL=`df $ZONEROOT | awk -F '[()]' '{split($2, field, "/"); print field[1]; }'`
-if [ -z "$ZPOOL" ]; then
-	ROOTDEV="none"
+    outstr=`zfs list -Ht snapshot $ZFS_SEED 2>/dev/null | awk '{print $1}'`
+    if [[ $outstr == $ZFS_SEED ]]; then
+	# Hmmm, we found a snapshot name!
+	echo "Cloning from snapshot $ZFS_SEED"
+	# zoneadm already created $ZONEPATH_DS, destroy it before we clone.
+	zfs destroy $ZONEPATH_DS
+	zfs clone $ZFS_SEED $ZONEPATH_DS
+	if [[ $? != 0 ]]; then
+	    echo "ZFS clone ($ZFS_SEED to $ZONEPATH_DS) failed ($?)."
+	    exit $ZONE_SUBPROC_FAIL
+	fi
+	# zfs promote $ZONEPATH_DS
+	# if [[ $? != 0 ]]; then
+	#    echo "ZFS promote ($ZONEPATH_DS) failed ($?)."
+	#    exit $ZONE_SUBPROC_FAIL
+	# fi
+    else 
+	echo "Seed file $ZFS_SEED $TAR_SEED not found."
+	bad_usage
+    fi
 else
-	ROOTDEV="/dev/$ZPOOL"
-fi
+    type=`file -b $ZFS_SEED | awk '{print $1}'`
 
-if [[ ! -f "$install_src" ]]; then
-	echo "$install_src: file not found\n"
-	exit 254
-fi
+    # For now, we are dependent on the output of file(1).
+    # I'm being cheesy in checking the first word of file(1)'s output.
+    if [[ $type == "ZFS" ]]; then
+	zfs recv -F $ZONEPATH_DS < $ZFS_SEED
+    elif [[ $type == "gzip" ]]; then
+	gunzip -c $ZFS_SEED | zfs recv -F $ZONEPATH_DS
+    else
+	echo "Seed file $ZFS_SEED not a ZFS receive (or compressed) one."
+	bad_usage
+    fi
 
-if [[ ! -d "$install_root" ]]; then
-	if ! mkdir -p "$install_root" 2>/dev/null; then
-		echo "Could not create install directory $install_root"
-		exit 254
-	fi
+    if [[ $? != 0 ]]; then
+	echo "ZFS receive command failed ($?)."
+	exit $ZONE_SUBPROC_FATAL
+    fi
 fi
 
-if ! ( cd "$install_root" && gtar -xzf "$install_src" ) ; then
-	echo "Error: extraction from tar archive failed"
-	exit 255
-fi
+# One Joyent-ism we need to clean up.
+rmdir $ZONEPATH/cores
+# And one we should probably adopt.
+zfs set devices=off $ZONEPATH_DS
 
-tag="lxsave_$(date +%m.%d.%Y@%T)"
-
-if [[ ! -d "$install_root" ]]; then
-	exit 255
-fi
-
-cd "$install_root"
-
-makedir native/dev
-makedir native/etc/default
-makedir native/etc/svc/volatile
-makedir native/lib
-makedir native/proc
-makedir native/tmp 1777
-makedir native/usr
-makedir native/var
-
-makedir mnt
-makedir opt
-makedir usr/local/bin
-makedir usr/local/include
-makedir usr/local/lib
-makedir usr/local/sbin
-makedir usr/local/share
-makedir usr/local/src
-
-makedir dev 0755
-makedir tmp 1777
-makedir proc 0555
-makedir boot 0755
-
-symlink /bin/sh sbin/sh
-symlink /bin/su usr/bin/su
-symlink /native/usr/lib/ld.so.1 usr/lib/ld.so.1
-
-libpam_so="$(echo lib/libpam.so.0.*)"
-libpam_misc="$(echo lib/libpam_misc.so.0.*)"
-libpamc_so="$(echo lib/libpamc.so.0.*)"
-
-symlink "/$libpam_so" lib/libpam.so.0
-symlink "/$libpam_misc" lib/libpam_misc.so.0
-symlink "/$libpamc_so" lib/libpamc.so.0
-
-makedir var/ld
-
-if ! crle -c var/ld/ld.config -l /native/lib:/native/usr/lib \
-     -s /native/lib/secure:/native/usr/lib/secure; then
-	exit 255
-fi
-
-mv -f etc/fstab etc/fstab.$tag 2>/dev/null
-
-cat > etc/fstab <<- EOF
-	$ROOTDEV	/			zfs	defaults	1 1
-	proc		/proc			proc	defaults	0 0
-EOF
-
-if [[ $? -ne 0 ]]; then
-	exit 255
-fi
-
-if [[ ! -e "$install_root/etc/hosts" ]]; then
-	cat > "$install_root/etc/hosts" <<-_EOF_
-		127.0.0.1		localhost
-	_EOF_
-fi
-
-#
-# Perform distribution-specific changes.
-#
-distro=""
-if [[ -f etc/redhat-release ]]; then
-	distro="redhat"
-elif [[ -f etc/lsb-release ]]; then
-	if egrep -s Ubuntu etc/lsb-release; then
-		distro="ubuntu"
-	elif [[ -f etc/debian_version ]]; then
-		distro="debian"
-	fi
-elif [[ -f etc/debian_version ]]; then
-	distro="debian"
-fi
-
-if [[ -z $distro ]]; then
-	exit 255
-fi
-
 exit 0
No differences encountered
--- old/usr/src/lib/brand/shared/zone/common.ksh	Wed Oct  5 00:33:22 2016
+++ new/usr/src/lib/brand/shared/zone/common.ksh	Wed Oct  5 00:33:22 2016
@@ -350,12 +350,10 @@
 	#
 	# Check if the image was created with a valid libc.so.1.
 	#
-	if [[ -f $ZONEROOT/lib/libc.so.1 ]]; then
-		hwcap=`moe -v -32 $ZONEROOT/lib/libc.so.1 2>&1`
-		if (( $? != 0 )); then
-			vlog "$f_hwcap_info" "$hwcap"
-			fail_fatal "$f_sanity_hwcap"
-		fi
+	hwcap=`moe -v -32 $ZONEROOT/lib/libc.so.1 2>&1`
+	if (( $? != 0 )); then
+		vlog "$f_hwcap_info" "$hwcap"
+		fail_fatal "$f_sanity_hwcap"
 	fi
 
 	( cd "$ZONEROOT" && \
@@ -1022,36 +1020,41 @@
 	return 0
 }
 
-e_cannot_wrap="%s: error: wrapper file already exists"
-e_baddir="Invalid '%s' directory within the zone"
-e_badfile="Invalid '%s' file within the zone"
-e_path_abs="Pathname specified to -a '%s' must be absolute."
-e_not_found="%s: error: file or directory not found."
-e_install_abort="Installation aborted."
-e_not_readable="Cannot read directory '%s'"
-e_not_dir="Error: must be a directory"
-e_unknown_archive="Error: Unknown archive format. Must be a flash archive, a cpio archive (can also be gzipped or bzipped), a pax XUSTAR archive, or a level 0 ufsdump archive."
-e_absolute_archive="Error: archive contains absolute paths instead of relative paths."
-e_mismatch_archive="Error: the archive top-level directory (%s) does not match the zonepath (%s)."
-e_tmpfile="Unable to create temporary file"
-e_root_full="Zonepath root %s exists and contains data; remove or move aside prior to install."
-f_mkdir="Unable to create directory %s."
-f_chmod="Unable to chmod directory %s."
-f_chown="Unable to chown directory %s."
-f_hwcap_info="HWCAP: %s\n"
-f_sanity_hwcap="The image was created with an incompatible libc.so.1 hwcap lofs mount.\n"\
+# Setup i18n output
+TEXTDOMAIN="SUNW_OST_OSCMD"
+export TEXTDOMAIN
+
+e_cannot_wrap=$(gettext "%s: error: wrapper file already exists")
+e_baddir=$(gettext "Invalid '%s' directory within the zone")
+e_badfile=$(gettext "Invalid '%s' file within the zone")
+e_path_abs=$(gettext "Pathname specified to -a '%s' must be absolute.")
+e_not_found=$(gettext "%s: error: file or directory not found.")
+e_install_abort=$(gettext "Installation aborted.")
+e_not_readable=$(gettext "Cannot read directory '%s'")
+e_not_dir=$(gettext "Error: must be a directory")
+e_unknown_archive=$(gettext "Error: Unknown archive format. Must be a flash archive, a cpio archive (can also be gzipped or bzipped), a pax XUSTAR archive, or a level 0 ufsdump archive.")
+e_absolute_archive=$(gettext "Error: archive contains absolute paths instead of relative paths.")
+e_mismatch_archive=$(gettext "Error: the archive top-level directory (%s) does not match the zonepath (%s).")
+e_tmpfile=$(gettext "Unable to create temporary file")
+e_root_full=$(gettext "Zonepath root %s exists and contains data; remove or move aside prior to install.")
+f_mkdir=$(gettext "Unable to create directory %s.")
+f_chmod=$(gettext "Unable to chmod directory %s.")
+f_chown=$(gettext "Unable to chown directory %s.")
+f_hwcap_info=$(gettext "HWCAP: %s\n")
+f_sanity_hwcap=$(gettext \
+"The image was created with an incompatible libc.so.1 hwcap lofs mount.\n"\
 "       The zone will not boot on this platform.  See the zone's\n"\
-"       documentation for the recommended way to create the archive."
+"       documentation for the recommended way to create the archive.")
 
-m_analyse_archive="Analysing the archive"
+m_analyse_archive=$(gettext "Analysing the archive")
 
-not_readable="Cannot read file '%s'"
-not_flar="Input is not a flash archive"
-bad_flar="Flash archive is a corrupt"
-bad_zfs_flar="Flash archive contains a ZFS send stream.\n\tRecreate the flar using the -L option with cpio or pax."
-f_unpack_failed="Unpacking the archive failed"
-unknown_archiver="Archiver %s is not supported"
-cmd_not_exec="Required command '%s' not executable!"
+not_readable=$(gettext "Cannot read file '%s'")
+not_flar=$(gettext "Input is not a flash archive")
+bad_flar=$(gettext "Flash archive is a corrupt")
+bad_zfs_flar=$(gettext "Flash archive contains a ZFS send stream.\n\tRecreate the flar using the -L option with cpio or pax.")
+f_unpack_failed=$(gettext "Unpacking the archive failed")
+unknown_archiver=$(gettext "Archiver %s is not supported")
+cmd_not_exec=$(gettext "Required command '%s' not executable!")
 
 #
 # Exit values used by the script, as #defined in <sys/zone.h>
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/lib/libbrand/common/libbrand.c	Wed Oct  5 00:33:23 2016
+++ new/usr/src/lib/libbrand/common/libbrand.c	Wed Oct  5 00:33:23 2016
@@ -323,7 +323,6 @@
     const char *curr_zone)
 {
 	int dst, src;
-	static char *env_pool = NULL;
 
 	/*
 	 * Walk through the characters, substituting values as needed.
@@ -340,13 +339,6 @@
 		case '%':
 			dst += strlcpy(dbuf + dst, "%", dbuf_size - dst);
 			break;
-		case 'P':
-			if (env_pool == NULL)
-				env_pool = getenv("_ZONEADMD_ZPOOL");
-			if (env_pool == NULL)
-				break;
-			dst += strlcpy(dbuf + dst, env_pool, dbuf_size - dst);
-			break;
 		case 'R':
 			if (zonepath == NULL)
 				break;
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/lib/libc/port/sys/zone.c	Wed Oct  5 00:33:24 2016
+++ new/usr/src/lib/libc/port/sys/zone.c	Wed Oct  5 00:33:24 2016
@@ -22,7 +22,6 @@
 /*
  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
- * Copyright 2011 Joyent Inc.  All rights reserved.
  */
 
 #include "lint.h"
@@ -41,8 +40,7 @@
 zoneid_t
 zone_create(const char *name, const char *root, const struct priv_set *privs,
     const char *rctls, size_t rctlsz, const char *zfs, size_t zfssz,
-    int *extended_error, int match, int doi, const bslabel_t *label, int flags,
-    zoneid_t req_zoneid)
+    int *extended_error, int match, int doi, const bslabel_t *label, int flags)
 {
 	zone_def  zd;
 	priv_data_t *d;
@@ -62,7 +60,6 @@
 	zd.doi = doi;
 	zd.label = label;
 	zd.flags = flags;
-	zd.zoneid = req_zoneid;
 
 	return ((zoneid_t)syscall(SYS_zone, ZONE_CREATE, &zd));
 }
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/lib/libdladm/common/linkprop.c	Wed Oct  5 00:33:25 2016
+++ new/usr/src/lib/libdladm/common/linkprop.c	Wed Oct  5 00:33:25 2016
@@ -154,13 +154,11 @@
 			get_bridge_pvid, get_protection, get_rxrings,
 			get_txrings, get_cntavail, get_secondary_macs,
 			get_allowedips, get_allowedcids, get_pool,
-			get_rings_range, get_linkmode_prop,
-			get_promisc_filtered;
+			get_rings_range, get_linkmode_prop;
 
 static pd_setf_t	set_zone, set_rate, set_powermode, set_radio,
 			set_public_prop, set_resource, set_stp_prop,
-			set_bridge_forward, set_bridge_pvid, set_secondary_macs,
-			set_promisc_filtered;
+			set_bridge_forward, set_bridge_pvid, set_secondary_macs;
 
 static pd_checkf_t	check_zone, check_autopush, check_rate, check_hoplimit,
 			check_encaplim, check_uint32, check_maxbw, check_cpus,
@@ -384,8 +382,6 @@
 
 	{ MAC_PROP_IB_LINKMODE,	sizeof (uint32_t),	"linkmode"},
 
-	{ MAC_PROP_VN_PROMISC_FILTERED,	sizeof (boolean_t), "promisc-filtered"},
-
 	{ MAC_PROP_SECONDARY_ADDRS, sizeof (mac_secondary_addr_t),
 	    "secondary-macs"},
 
@@ -443,11 +439,6 @@
 	{ "dhcp-nospoof",	MPT_DHCPNOSPOOF	},
 };
 
-static  val_desc_t	link_promisc_filtered_vals[] = {
-	{ "off",	B_FALSE },
-	{ "on",		B_TRUE },
-};
-
 static val_desc_t	dladm_wlan_radio_vals[] = {
 	{ "on",		DLADM_WLAN_RADIO_ON	},
 	{ "off",	DLADM_WLAN_RADIO_OFF	}
@@ -764,12 +755,6 @@
 	    set_resource, NULL, get_protection, check_prop, 0,
 	    DATALINK_CLASS_ALL, DATALINK_ANY_MEDIATYPE },
 
-	{ "promisc-filtered", { "on", 1 },
-	    link_promisc_filtered_vals, VALCNT(link_promisc_filtered_vals),
-	    set_promisc_filtered, NULL, get_promisc_filtered, check_prop, 0,
-	    DATALINK_CLASS_VNIC, DATALINK_ANY_MEDIATYPE },
-
-
 	{ "allowed-ips", { "--", 0 },
 	    NULL, 0, set_resource, NULL,
 	    get_allowedips, check_allowedips, PD_CHECK_ALLOC,
@@ -1511,12 +1496,17 @@
 }
 
 typedef int (*zone_get_devroot_t)(char *, char *, size_t);
+typedef int (*zone_get_brand_t)(char *, char *, size_t);
 
 static int
 i_dladm_get_zone_dev(char *zone_name, char *dev, size_t devlen)
 {
 	char			root[MAXPATHLEN];
+	char			brand[MAXPATHLEN]; /* Overkill, for sure. */
+	static char		*full_native_path = "/native/dev";
+	char			*native_dev_path = full_native_path;
 	zone_get_devroot_t	real_zone_get_devroot;
+	zone_get_brand_t	real_zone_get_brand;
 	void			*dlhandle;
 	void			*sym;
 	int			ret;
@@ -1528,11 +1518,28 @@
 		(void) dlclose(dlhandle);
 		return (-1);
 	}
-
 	real_zone_get_devroot = (zone_get_devroot_t)sym;
 
+	if ((sym = dlsym(dlhandle, "zone_get_brand")) == NULL) {
+		(void) dlclose(dlhandle);
+		return (-1);
+	}
+	real_zone_get_brand = (zone_get_devroot_t)sym;
+
+	/* Have "/dev" be LX-agile for possibility of "/native/dev". */
+	ret = real_zone_get_brand(zone_name, brand, sizeof (brand));
+	if (ret != 0) {
+		(void) dlclose(dlhandle);
+		return (ret);
+	}
+	/* Can use strcmp with constant string... */
+	if (strcmp(brand, "lx") != 0) {
+		/* Non-LX zone, don't use "/native/dev" */
+		native_dev_path += 7;	/* strlen("/native") */
+	}
+
 	if ((ret = real_zone_get_devroot(zone_name, root, sizeof (root))) == 0)
-		(void) snprintf(dev, devlen, "%s%s", root, "/dev");
+		(void) snprintf(dev, devlen, "%s%s", root, native_dev_path);
 	(void) dlclose(dlhandle);
 	return (ret);
 }
@@ -1601,9 +1608,6 @@
 	if (zid_new == zid_old)
 		return (DLADM_STATUS_OK);
 
-	if (flags & DLADM_OPT_TRANSIENT)
-		dzp->diz_transient = B_TRUE;
-
 	if ((status = set_public_prop(handle, pdp, linkid, vdp, val_cnt,
 	    flags, media)) != DLADM_STATUS_OK)
 		return (status);
@@ -4844,51 +4848,4 @@
 
 	*val_cnt = 1;
 	return (DLADM_STATUS_OK);
-}
-
-/*ARGSUSED*/
-static dladm_status_t
-get_promisc_filtered(dladm_handle_t handle, prop_desc_t *pdp,
-    datalink_id_t linkid, char **prop_val, uint_t *val_cnt,
-    datalink_media_t media, uint_t flags, uint_t *perm_flags)
-{
-	char			*s;
-	dladm_status_t		status;
-	boolean_t		filt;
-
-	status = i_dladm_get_public_prop(handle, linkid, pdp->pd_name, flags,
-	    perm_flags, &filt, sizeof (filt));
-	if (status != DLADM_STATUS_OK)
-		return (status);
-
-	if (filt != 0)
-		s = link_promisc_filtered_vals[1].vd_name;
-	else
-		s = link_promisc_filtered_vals[0].vd_name;
-	(void) snprintf(prop_val[0], DLADM_STRSIZE, "%s", s);
-
-	*val_cnt = 1;
-	return (DLADM_STATUS_OK);
-}
-
-/* ARGSUSED */
-static dladm_status_t
-set_promisc_filtered(dladm_handle_t handle, prop_desc_t *pdp,
-    datalink_id_t linkid, val_desc_t *vdp, uint_t val_cnt, uint_t flags,
-    datalink_media_t media)
-{
-	dld_ioc_macprop_t	*dip;
-	dladm_status_t		status = DLADM_STATUS_OK;
-
-	dip = i_dladm_buf_alloc_by_name(0, linkid, pdp->pd_name,
-	    0, &status);
-
-	if (dip == NULL)
-		return (status);
-
-	(void) memcpy(dip->pr_val, &vdp->vd_val, dip->pr_valsize);
-	status = i_dladm_macprop(handle, dip, B_TRUE);
-
-	free(dip);
-	return (status);
 }
--- old/usr/src/lib/libdtrace/common/dt_open.c	Wed Oct  5 00:33:25 2016
+++ new/usr/src/lib/libdtrace/common/dt_open.c	Wed Oct  5 00:33:25 2016
@@ -21,7 +21,7 @@
 
 /*
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2015, Joyent, Inc.
+ * Copyright (c) 2013, Joyent, Inc. All rights reserved.
  * Copyright (c) 2012, 2016 by Delphix. All rights reserved.
  */
 
@@ -1147,13 +1147,13 @@
 	 * Add intrinsic pointer types that are needed to initialize printf
 	 * format dictionary types (see table in dt_printf.c).
 	 */
-	(void) ctf_add_pointer(dmp->dm_ctfp, CTF_ADD_ROOT, NULL,
+	(void) ctf_add_pointer(dmp->dm_ctfp, CTF_ADD_ROOT,
 	    ctf_lookup_by_name(dmp->dm_ctfp, "void"));
 
-	(void) ctf_add_pointer(dmp->dm_ctfp, CTF_ADD_ROOT, NULL,
+	(void) ctf_add_pointer(dmp->dm_ctfp, CTF_ADD_ROOT,
 	    ctf_lookup_by_name(dmp->dm_ctfp, "char"));
 
-	(void) ctf_add_pointer(dmp->dm_ctfp, CTF_ADD_ROOT, NULL,
+	(void) ctf_add_pointer(dmp->dm_ctfp, CTF_ADD_ROOT,
 	    ctf_lookup_by_name(dmp->dm_ctfp, "int"));
 
 	if (ctf_update(dmp->dm_ctfp) != 0) {
@@ -1213,11 +1213,11 @@
 	ctc.ctc_argc = 0;
 	ctc.ctc_flags = 0;
 
-	dtp->dt_type_func = ctf_add_funcptr(dmp->dm_ctfp,
+	dtp->dt_type_func = ctf_add_function(dmp->dm_ctfp,
 	    CTF_ADD_ROOT, &ctc, NULL);
 
-	dtp->dt_type_fptr = ctf_add_pointer(dmp->dm_ctfp, CTF_ADD_ROOT, NULL,
-	    dtp->dt_type_func);
+	dtp->dt_type_fptr = ctf_add_pointer(dmp->dm_ctfp,
+	    CTF_ADD_ROOT, dtp->dt_type_func);
 
 	/*
 	 * We also insert CTF definitions for the special D intrinsic types
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/lib/libproc/common/Pcontrol.h	Wed Oct  5 00:33:26 2016
+++ new/usr/src/lib/libproc/common/Pcontrol.h	Wed Oct  5 00:33:26 2016
@@ -123,7 +123,6 @@
 	size_t	file_shstrsz;	/* section header string table size */
 	uintptr_t *file_saddrs; /* section header addresses */
 	uint_t  file_nsaddrs;   /* number of section header addresses */
-	boolean_t file_cvt;	/* Have we tried to convert this? */
 } file_info_t;
 
 typedef struct map_info {	/* description of an address space mapping */
No differences encountered
No differences encountered
--- old/usr/src/lib/libproc/common/Psymtab.c	Wed Oct  5 00:33:26 2016
+++ new/usr/src/lib/libproc/common/Psymtab.c	Wed Oct  5 00:33:26 2016
@@ -744,58 +744,6 @@
 	return (Plmid_to_loadobj(P, PR_LMID_EVERY, name));
 }
 
-/*
- * We've been given a file_info_t which doesn't have any CTF. However, it may
- * have information that's in a format that we could convert if on the fly.
- * We'll first try to convert the alternate debug file, if present, and then
- * move onto the default file. The reason we prefer the alternate debug file is
- * that if both exist, then it likely has any usable debugging information.
- */
-static ctf_file_t *
-Pconvert_file_ctf(file_info_t *fptr)
-{
-	int err;
-	ctf_file_t *fp;
-	char errmsg[1024];
-
-	/*
-	 * Provide an opt in.
-	 */
-	if (getenv("LIBPROC_CTFCONVERT") == NULL)
-		return (NULL);
-
-	/*
-	 * If we've already attempted to call this, then that's it. No reason to
-	 * pretend we'll be more successful again another time.
-	 */
-	if (fptr->file_cvt == B_TRUE)
-		return (NULL);
-	fptr->file_cvt = B_TRUE;
-
-	fp = NULL;
-	if (fptr->file_dbgelf != NULL) {
-		fp = ctf_elfconvert(fptr->file_fd, fptr->file_dbgelf, NULL, 1,
-		    0, &err, errmsg, sizeof (errmsg));
-		if (fp == NULL) {
-			dprintf("failed to convert %s: %s\n", fptr->file_pname,
-			    err == ECTF_CONVBKERR ? errmsg : ctf_errmsg(err));
-		}
-	}
-	if (fp == NULL) {
-		fp = ctf_elfconvert(fptr->file_fd, fptr->file_elf, NULL, 1,
-		    0, &err, errmsg, sizeof (errmsg));
-		if (fp == NULL) {
-			dprintf("failed to convert %s: %s\n", fptr->file_pname,
-			    err == ECTF_CONVBKERR ? errmsg : ctf_errmsg(err));
-		}
-	}
-	if (fp != NULL) {
-		fptr->file_ctfp = fp;
-	}
-
-	return (NULL);
-}
-
 ctf_file_t *
 Pbuild_file_ctf(struct ps_prochandle *P, file_info_t *fptr)
 {
@@ -808,9 +756,8 @@
 
 	Pbuild_file_symtab(P, fptr);
 
-	if (fptr->file_ctf_size == 0) {
-		return (Pconvert_file_ctf(fptr));
-	}
+	if (fptr->file_ctf_size == 0)
+		return (NULL);
 
 	symp = fptr->file_ctf_dyn ? &fptr->file_dynsym : &fptr->file_symtab;
 	if (symp->sym_data_pri == NULL)
No differences encountered
--- old/usr/src/lib/libzonecfg/common/getzoneent.c	Wed Oct  5 00:33:26 2016
+++ new/usr/src/lib/libzonecfg/common/getzoneent.c	Wed Oct  5 00:33:26 2016
@@ -128,8 +128,6 @@
 			/* skip comment lines */
 			continue;
 		}
-
-		/* zonename */
 		p = gettok(&cp);
 		if (*p == '\0' || strlen(p) >= ZONENAME_MAX) {
 			/*
@@ -139,7 +137,6 @@
 		}
 		(void) strlcpy(ze->zone_name, p, ZONENAME_MAX);
 
-		/* state */
 		p = gettok(&cp);
 		if (*p == '\0') {
 			/* state field should not be empty */
@@ -156,7 +153,6 @@
 			continue;
 		}
 
-		/* zonepath */
 		p = gettok(&cp);
 		if (strlen(p) >= MAXPATHLEN) {
 			/* very long paths are not allowed */
@@ -164,35 +160,10 @@
 		}
 		(void) strlcpy(ze->zone_path, p, MAXPATHLEN);
 
-		/* uuid */
 		p = gettok(&cp);
 		if (uuid_parse(p, ze->zone_uuid) == -1)
 			uuid_clear(ze->zone_uuid);
 
-		/* brand [optional] */
-		p = gettok(&cp);
-		if (strlen(p) >= MAXNAMELEN) {
-			/* very long names are not allowed */
-			continue;
-		}
-		(void) strlcpy(ze->zone_brand, p, MAXNAMELEN);
-
-		/* IP type [optional] */
-		p = gettok(&cp);
-		if (strlen(p) >= MAXNAMELEN) {
-			/* very long names are not allowed */
-			continue;
-		}
-		ze->zone_iptype = ZS_SHARED;
-		if (*p == 'e') {
-			ze->zone_iptype = ZS_EXCLUSIVE;
-		}
-
-		/* debug ID [optional] */
-		p = gettok(&cp);
-		if (*p != '\0')
-			ze->zone_did = atoi(p);
-
 		break;
 	}
 
@@ -323,14 +294,12 @@
 	char buf[MAX_INDEX_LEN];
 	int tmp_file_desc, lock_fd, err;
 	boolean_t exist, need_quotes;
-	char *cp, *tmpp;
+	char *cp;
 	char tmp_path[MAXPATHLEN];
 	char path[MAXPATHLEN];
 	char uuidstr[UUID_PRINTABLE_STRING_LENGTH];
 	size_t namelen;
-	const char *zone_name, *zone_state, *zone_path, *zone_uuid,
-	    *zone_brand = "", *zone_iptype;
-	zoneid_t zone_did;
+	const char *zone_name, *zone_state, *zone_path, *zone_uuid;
 
 	assert(ze != NULL);
 
@@ -383,9 +352,6 @@
 	exist = B_FALSE;
 	zone_name = ze->zone_name;
 	namelen = strlen(zone_name);
-	zone_brand = ze->zone_brand;
-	zone_iptype = (ze->zone_iptype == ZS_SHARED ? "sh" : "ex");
-	zone_did = ze->zone_did;
 	for (;;) {
 		if (fgets(buf, sizeof (buf), index_file) == NULL) {
 			if (operation == PZE_ADD && !exist) {
@@ -440,11 +406,6 @@
 		}
 		zone_path = gettok(&cp);
 		zone_uuid = gettok(&cp);
-		zone_brand = gettok(&cp);
-		zone_iptype = gettok(&cp);
-		tmpp = gettok(&cp);
-		if (*tmpp != '\0')
-			zone_did = atoi(tmpp);
 
 		switch (operation) {
 		case PZE_ADD:
@@ -459,6 +420,14 @@
 			 */
 			if (ze->zone_state >= 0) {
 				zone_state = zone_state_str(ze->zone_state);
+
+				/*
+				 * If the caller is uninstalling this zone,
+				 * then wipe out the uuid.  The zone's contents
+				 * are no longer known.
+				 */
+				if (ze->zone_state < ZONE_STATE_INSTALLED)
+					zone_uuid = "";
 			}
 
 			/* If a new name is supplied, use it. */
@@ -467,27 +436,6 @@
 
 			if (ze->zone_path[0] != '\0')
 				zone_path = ze->zone_path;
-
-			/* If new UUID provided, replace it */
-			if (!uuid_is_null(ze->zone_uuid)) {
-				uuid_unparse(ze->zone_uuid, uuidstr);
-				zone_uuid = uuidstr;
-			}
-
-			/* If a brand is supplied, use it. */
-			if (ze->zone_brand[0] != '\0') {
-				zone_brand = ze->zone_brand;
-
-				/*
-				 * Since the brand, iptype and did are optional,
-				 * we we only reset the iptype and did if the
-				 * brand is provided.
-				 */
-				zone_iptype = (ze->zone_iptype == ZS_SHARED ?
-				    "sh" : "ex");
-				zone_did = ze->zone_did;
-			}
-
 			break;
 
 		case PZE_REMOVE:
@@ -519,17 +467,9 @@
 		 * method for escaping them.
 		 */
 		need_quotes = (strchr(zone_path, ':') != NULL);
-
-		if (*zone_brand != '\0') {
-			(void) fprintf(tmp_file, "%s:%s:%s%s%s:%s:%s:%s:%d\n",
-			    zone_name, zone_state, need_quotes ? "\"" : "",
-			    zone_path, need_quotes ? "\"" : "", zone_uuid,
-			    zone_brand, zone_iptype, zone_did);
-		} else {
-			(void) fprintf(tmp_file, "%s:%s:%s%s%s:%s\n", zone_name,
-			    zone_state, need_quotes ? "\"" : "", zone_path,
-			    need_quotes ? "\"" : "", zone_uuid);
-		}
+		(void) fprintf(tmp_file, "%s:%s:%s%s%s:%s\n", zone_name,
+		    zone_state, need_quotes ? "\"" : "", zone_path,
+		    need_quotes ? "\"" : "", zone_uuid);
 		exist = B_TRUE;
 	}
 
--- old/usr/src/lib/libzonecfg/common/libzonecfg.c	Wed Oct  5 00:33:26 2016
+++ new/usr/src/lib/libzonecfg/common/libzonecfg.c	Wed Oct  5 00:33:26 2016
@@ -22,8 +22,8 @@
 /*
  * Copyright 2014 Gary Mills
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2015 Joyent Inc.
  * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2015 Joyent Inc.
  */
 
 #include <libsysevent.h>
@@ -191,7 +191,6 @@
 	{ALIAS_SHARES, "zone.cpu-shares", "privileged", "none", 0},
 	{ALIAS_CPUCAP, "zone.cpu-cap", "privileged", "deny", 0},
 	{ALIAS_MAXPROCS, "zone.max-processes", "privileged", "deny", 100},
-	{ALIAS_ZFSPRI, "zone.zfs-io-priority", "privileged", "none", 0},
 	{NULL, NULL, NULL, NULL, 0}
 };
 
@@ -239,8 +238,6 @@
 static char zoneadm_lock_held[] = LOCK_ENV_VAR"=1";
 static char zoneadm_lock_not_held[] = LOCK_ENV_VAR"=0";
 
-static void zonecfg_notify_delete(const char *);
-
 char *zonecfg_root = "";
 
 /*
@@ -430,10 +427,8 @@
 	 * Treat failure to find the XML file silently, since, well, it's
 	 * gone, and with the index file cleaned up, we're done.
 	 */
-	if (err == Z_OK || err == Z_NO_ZONE) {
-		zonecfg_notify_delete(zonename);
+	if (err == Z_OK || err == Z_NO_ZONE)
 		return (Z_OK);
-	}
 	return (err);
 }
 
@@ -1130,7 +1125,7 @@
  * In general, the operation of this function should succeed or fail as
  * a unit.
  */
-static int
+int
 zonecfg_refresh_index_file(zone_dochandle_t handle)
 {
 	char name[ZONENAME_MAX], zonepath[MAXPATHLEN];
@@ -1152,15 +1147,6 @@
 	(void) strlcpy(ze.zone_path, zonepath + strlen(zonecfg_root),
 	    sizeof (ze.zone_path));
 
-	if ((err = zonecfg_get_brand(handle, ze.zone_brand,
-	    sizeof (ze.zone_brand))) != 0)
-		return (err);
-
-	if ((err = zonecfg_get_iptype(handle, &ze.zone_iptype)) != Z_OK)
-		return (err);
-
-	ze.zone_did = zonecfg_get_did(handle);
-
 	if (is_renaming(handle)) {
 		opcode = PZE_MODIFY;
 		(void) strlcpy(ze.zone_name, handle->zone_dh_delete_name,
@@ -1503,56 +1489,6 @@
 	}
 }
 
-static void
-zonecfg_notify_conf_change(const char *zname, char *os, char *ns)
-{
-	evchan_t *ze_chan;
-	struct timeval now;
-	uint64_t t;
-	nvlist_t *nvl = NULL;
-
-	if (sysevent_evc_bind(ZONE_EVENT_CHANNEL, &ze_chan, 0) != 0)
-		return;
-
-	/* Current time since Jan 1 1970 but consumers expect NS */
-	gettimeofday(&now, NULL);
-	t = (now.tv_sec * NANOSEC) + (now.tv_usec * 1000);
-
-	if (nvlist_alloc(&nvl, NV_UNIQUE_NAME, KM_SLEEP) == 0 &&
-	    nvlist_add_string(nvl, ZONE_CB_NAME, zname) == 0 &&
-	    nvlist_add_string(nvl, ZONE_CB_NEWSTATE, ns) == 0 &&
-	    nvlist_add_string(nvl, ZONE_CB_OLDSTATE, os) == 0 &&
-	    nvlist_add_int32(nvl, ZONE_CB_ZONEID, -1) == 0 &&
-	    nvlist_add_uint64(nvl, ZONE_CB_TIMESTAMP, t) == 0) {
-		(void) sysevent_evc_publish(ze_chan, ZONE_EVENT_STATUS_CLASS,
-		    ZONE_EVENT_STATUS_SUBCLASS, "sun.com", "zonecfg", nvl,
-		    EVCH_SLEEP);
-	}
-
-	nvlist_free(nvl);
-	(void) sysevent_evc_unbind(ze_chan);
-}
-
-void
-zonecfg_notify_create(zone_dochandle_t handle)
-{
-	char zname[ZONENAME_MAX];
-
-	if (zonecfg_check_handle(handle) != Z_OK)
-		return;
-
-	if (zonecfg_get_name(handle, zname, sizeof (zname)) != Z_OK)
-		return;
-
-	zonecfg_notify_conf_change(zname, "", ZONE_STATE_STR_CONFIGURED);
-}
-
-static void
-zonecfg_notify_delete(const char *zname)
-{
-	zonecfg_notify_conf_change(zname, ZONE_STATE_STR_CONFIGURED, "");
-}
-
 /*
  * Special case: if access(2) fails with ENOENT, then try again using
  * ZONE_CONFIG_ROOT instead of config_file_path(zonename).  This is how we
@@ -2143,32 +2079,6 @@
 }
 
 /*
- * Turn an addr that looks like f:2:0:44:5:6C into 0f:02:00:44:05:6c
- * We're expecting a dst of at least MAXMACADDRLEN size here.
- */
-static void
-normalize_mac_addr(char *dst, const char *src, int len)
-{
-	char *p, *e, *sep = "";
-	long n;
-	char buf[MAXMACADDRLEN], tmp[4];
-
-	*dst = '\0';
-	(void) strlcpy(buf, src, sizeof (buf));
-	p = strtok(buf, ":");
-	while (p != NULL) {
-		n = strtol(p, &e, 16);
-		if (*e != NULL || n > 0xff)
-			return;
-		(void) snprintf(tmp, sizeof (tmp), "%s%02x", sep, n);
-		(void) strlcat(dst, tmp, len);
-
-		sep = ":";
-		p = strtok(NULL, ":");
-	}
-}
-
-/*
  * Determines whether there is a net resource with the physical interface, IP
  * address, and default router specified by 'tabptr' in the zone configuration
  * to which 'handle' refers.  'tabptr' must have an interface, an address, a
@@ -2193,7 +2103,6 @@
 	char address[INET6_ADDRSTRLEN];
 	char physical[LIFNAMSIZ];
 	char mac[MAXMACADDRLEN];
-	char norm_mac[MAXMACADDRLEN];
 	char gnic[LIFNAMSIZ];
 	size_t addrspec;		/* nonzero if tabptr has IP addr */
 	size_t physspec;		/* nonzero if tabptr has interface */
@@ -2250,14 +2159,10 @@
 		    physical, sizeof (physical)) != Z_OK ||
 		    strcmp(tabptr->zone_nwif_physical, physical) != 0))
 			continue;
-		if (iptype == ZS_EXCLUSIVE && macspec != 0) {
-			if (fetchprop(cur, DTD_ATTR_MAC, mac, sizeof (mac)) !=
-			    Z_OK)
-				continue;
-			normalize_mac_addr(norm_mac, mac, sizeof (norm_mac));
-			if (strcmp(tabptr->zone_nwif_mac, norm_mac) != 0)
-				continue;
-		}
+		if (iptype == ZS_EXCLUSIVE && macspec != 0 &&
+		    (fetchprop(cur, DTD_ATTR_MAC, mac, sizeof (mac)) != Z_OK ||
+		    strcmp(tabptr->zone_nwif_mac, mac) != 0))
+			continue;
 		if (iptype == ZS_EXCLUSIVE && gnicspec != 0 &&
 		    (fetchprop(cur, DTD_ATTR_GNIC, gnic,
 		    sizeof (gnic)) != Z_OK ||
@@ -2455,7 +2360,7 @@
 		gnic_match = match_prop(cur, DTD_ATTR_GNIC,
 		    tabptr->zone_nwif_gnic);
 
-		if (((addr_match && allowed_addr_match) || mac_match ||
+		if ((addr_match || allowed_addr_match || mac_match ||
 		    gnic_match) && phys_match) {
 			xmlUnlinkNode(cur);
 			xmlFreeNode(cur);
@@ -4867,7 +4772,7 @@
 	pool_conf_t *poolconf;
 	pool_t *pool;
 	pool_elem_t *pe;
-	pool_value_t *pv;
+	pool_value_t *pv = pool_value_alloc();
 	const char *sched_str;
 
 	if (pool_get_status(&status) != PO_SUCCESS || status != POOL_ENABLED)
@@ -4888,23 +4793,15 @@
 		return (Z_NO_POOL);
 	}
 
-	if ((pv = pool_value_alloc()) == NULL) {
-		(void) pool_conf_close(poolconf);
-		pool_conf_free(poolconf);
-		return (Z_NO_POOL);
-	}
-
 	pe = pool_to_elem(poolconf, pool);
 	if (pool_get_property(poolconf, pe, "pool.scheduler", pv) !=
 	    POC_STRING) {
 		(void) pool_conf_close(poolconf);
-		pool_value_free(pv);
 		pool_conf_free(poolconf);
 		return (Z_NO_ENTRY);
 	}
 	(void) pool_value_get_string(pv, &sched_str);
 	(void) pool_conf_close(poolconf);
-	pool_value_free(pv);
 	pool_conf_free(poolconf);
 	if (strlcpy(class, sched_str, clsize) >= clsize)
 		return (Z_TOO_BIG);
@@ -6174,27 +6071,16 @@
 zone_set_state(char *zone, zone_state_t state)
 {
 	struct zoneent ze;
-	int res;
-	zone_state_t oldst = (zone_state_t)-1;
 
 	if (state != ZONE_STATE_CONFIGURED && state != ZONE_STATE_INSTALLED &&
 	    state != ZONE_STATE_INCOMPLETE)
 		return (Z_INVAL);
 
-	(void) zone_get_state(zone, &oldst);
-
 	bzero(&ze, sizeof (ze));
 	(void) strlcpy(ze.zone_name, zone, sizeof (ze.zone_name));
 	ze.zone_state = state;
 	(void) strlcpy(ze.zone_path, "", sizeof (ze.zone_path));
-	res = putzoneent(&ze, PZE_MODIFY);
-
-	if (res == Z_OK) {
-		zonecfg_notify_conf_change(zone, zone_state_str(oldst),
-		    zone_state_str(state));
-	}
-
-	return (res);
+	return (putzoneent(&ze, PZE_MODIFY));
 }
 
 /*
@@ -6343,30 +6229,6 @@
 	}
 }
 
-/*
- * Changes a zone's UUID to the given value. Returns an error if the UUID is
- * malformed or if the zone cannot be located.
- */
-int
-zonecfg_set_uuid(const char *zonename, const char *zonepath,
-    const char *uuid)
-{
-	int err;
-	struct zoneent ze;
-
-	bzero(&ze, sizeof (ze));
-	ze.zone_state = -1;	/* Preserve existing state in index */
-	(void) strlcpy(ze.zone_name, zonename, sizeof (ze.zone_name));
-	(void) strlcpy(ze.zone_path, zonepath, sizeof (ze.zone_path));
-	if (uuid_parse((char *)uuid, ze.zone_uuid) == -1)
-		return (Z_INVALID_PROPERTY);
-
-	if ((err = putzoneent(&ze, PZE_MODIFY)) != Z_OK)
-		return (err);
-
-	return (Z_OK);
-}
-
 /*
  * File-system convenience functions.
  */
--- old/usr/src/lib/libzonecfg/common/mapfile-vers	Wed Oct  5 00:33:27 2016
+++ new/usr/src/lib/libzonecfg/common/mapfile-vers	Wed Oct  5 00:33:27 2016
@@ -20,7 +20,7 @@
 #
 #
 # Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
-# Copyright 2015, Joyent Inc.
+# Copyright (c) 2011, Joyent Inc. All rights reserved.
 #
 
 #
@@ -175,7 +175,6 @@
 	zonecfg_modify_pset;
 	zonecfg_modify_rctl;
 	zonecfg_notify_bind;
-	zonecfg_notify_create;
 	zonecfg_notify_critical_abort;
 	zonecfg_notify_critical_enter;
 	zonecfg_notify_critical_exit;
@@ -215,7 +214,6 @@
 	zonecfg_set_root;
 	zonecfg_set_sched;
 	zonecfg_set_swinv;
-	zonecfg_set_uuid;
 	zonecfg_set_zonepath;
 	zonecfg_strerror;
 	zonecfg_str_to_bytes;
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/man/man1m/zonecfg.1m	Wed Oct  5 00:33:28 2016
+++ new/usr/src/man/man1m/zonecfg.1m	Wed Oct  5 00:33:28 2016
@@ -10,17 +10,17 @@
 .SH SYNOPSIS
 .LP
 .nf
-\fBzonecfg\fR {\fB-z\fR \fIzonename\fR | \fB-u\fR \fIuuid\fR}
+\fBzonecfg\fR \fB-z\fR \fIzonename\fR
 .fi
 
 .LP
 .nf
-\fBzonecfg\fR {\fB-z\fR \fIzonename\fR | \fB-u\fR \fIuuid\fR} \fIsubcommand\fR
+\fBzonecfg\fR \fB-z\fR \fIzonename\fR \fIsubcommand\fR
 .fi
 
 .LP
 .nf
-\fBzonecfg\fR {\fB-z\fR \fIzonename\fR | \fB-u\fR \fIuuid\fR} \fB-f\fR \fIcommand_file\fR
+\fBzonecfg\fR \fB-z\fR \fIzonename\fR \fB-f\fR \fIcommand_file\fR
 .fi
 
 .LP
@@ -42,8 +42,7 @@
 .sp
 .in +2
 .nf
-{\fB-z\fR \fIzonename\fR | \fB-u\fR \fIuuid\fR}
-zonecfg {\fB-z\fR \fIzonename | \fB-u\fR \fIuuid} subcommand\fR
+zonecfg \fB-z\fR \fIzonename subcommand\fR
 .fi
 .in -2
 .sp
@@ -335,16 +334,6 @@
 .sp
 .ne 2
 .na
-\fB(global)\fR
-.ad
-.sp .6
-.RS 4n
-\fBzfs-io-priority\fR
-.RE
-
-.sp
-.ne 2
-.na
 \fB\fBfs\fR\fR
 .ad
 .sp .6
@@ -359,7 +348,7 @@
 .ad
 .sp .6
 .RS 4n
-\fBaddress\fR, \fBallowed-address\fR, \fBdefrouter\fR, \fBglobal-nic\fR, \fBmac-addr\fR, \fBphysical\fR, \fBproperty\fR, \fBvlan-id\fR
+\fBaddress\fR, \fBphysical\fR, \fBdefrouter\fR
 .RE
 
 .sp
@@ -622,20 +611,10 @@
 .sp
 .ne 2
 .na
-\fB\fBinherit-pkg-dir\fR: dir\fR
+\fB\fBnet\fR: address, physical, defrouter\fR
 .ad
 .sp .6
 .RS 4n
-The directory path.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBnet\fR: address, allowed-address, defrouter, global-nic, mac-addr, physical, property, vlan-id\fR
-.ad
-.sp .6
-.RS 4n
 The network address and physical interface name of the network interface. The
 network address is one of:
 .RS +4
@@ -671,10 +650,6 @@
 configured \fBdown\fR in the global zone, and the default router for the
 interface should be specified here.
 .sp
-The global-nic is used for exclusive stack zones which will use a VNIC on-demand.  When the zone boots, a VNIC named using the physical property will be created on the global NIC.  If provided, the mac-addr and vlan-id will be set on this VNIC.
-.sp
-The \fBproperty\fR setting is a resource which can be used to set arbitrary name/value pairs on the network.  These name/value pairs are made available to the zone's brand, which can use them as needed to set up the network interface.
-.sp
 For an exclusive-IP zone, the physical property must be set and the address and
 default router properties cannot be set.
 .RE
@@ -911,16 +886,6 @@
 .RE
 
 .sp
-.ne 2
-.na
-\fBglobal: \fBzfs-io-priority\fR\fR
-.ad
-.sp .6
-.RS 4n
-Specifies a priority for this zone's ZFS I/O. The priority is used by the ZFS I/O scheduler as in input to determine how to schedule I/O across zones. By default all zones have a priority of 1. The value can be increased for zones whose I/O is more critical. This property is the preferred way to set the \fBzone.zfs-io-priority\fR rctl.
-.RE
-
-.sp
 .LP
 The following table summarizes resources, property-names, and types:
 .sp
@@ -943,7 +908,6 @@
 (global)          max-shm-ids     simple
 (global)          max-shm-memory  simple
 (global)          scheduling-class simple
-(global)          zfs-io-priority simple
 fs                dir             simple
                    special         simple
                    raw             simple
@@ -950,15 +914,7 @@
                    type            simple
                    options         list of simple
 net               address         simple
-                   allowed-address simple
-                   defrouter       simple
-                   global-nic      simple
-                   mac-addr        simple
                    physical        simple
-                   property        list of complex
-                    name            simple
-                    value           simple
-                   vlan-id         simple
 device            match           simple
 rctl              name            simple
                    value           list of complex
@@ -1169,16 +1125,6 @@
 cannot be used.
 .RE
 
-.sp
-.ne 2
-.na
-\fB\fB-u\fR \fIuuid\fR\fR
-.ad
-.sp .6
-.RS 4n
-Specify the uuid of a zone instead of the Zone name.
-.RE
-
 .SH SUBCOMMANDS
 .LP
 You can use the \fBadd\fR and \fBselect\fR subcommands to select a specific
@@ -1268,7 +1214,8 @@
 .sp
 .ne 2
 .na
-\fB\fBcreate [\fR\fB-F\fR\fB] [\fR \fB-a\fR \fIpath\fR |\fB-b\fR \fB|\fR \fB-t\fR \fItemplate\fR\fB] [\fR\fB-X\fR\fB]\fR\fR
+\fB\fBcreate [\fR\fB-F\fR\fB] [\fR \fB-a\fR \fIpath\fR |\fB-b\fR \fB|\fR
+\fB-t\fR \fItemplate\fR\fB]\fR\fR
 .ad
 .sp .6
 .RS 4n
@@ -1290,8 +1237,6 @@
 .sp
 Use the \fB-b\fR option to create a blank configuration. Without arguments,
 \fBcreate\fR applies the Sun default settings.
-.sp
-Use the \fB-X\fR option to facilitate creating a zone whose XML definition already exists on the host. The zone will be atomically added to the zone index file.
 .RE
 
 .sp
@@ -1368,21 +1313,18 @@
 .sp
 .ne 2
 .na
-\fB\fBremove\fR [\fR\fB-F\fR\fB] \fIresource-type\fR\fB [\fR\fIproperty-name\fR\fB=\fR\fIproperty-value\fR\fB]* \fR(global scope)\fR
-.br
-\fB\fBremove\fR \fR\fIproperty-name\fR\fB \fR\fIproperty-value\fR\fB \fR(resource scope)\fR
+\fB\fBremove\fR \fIresource-type\fR\fB{\fR\fIproperty-name\fR\fB=\fR\fIproperty
+-value\fR\fB}\fR(global scope)\fR
 .ad
 .sp .6
 .RS 4n
 In the global scope, removes the specified resource. The \fB[]\fR syntax means
-0 or more property name-value pairs. If you want to only remove a
+0 or more of whatever is inside the square braces. If you want only to remove a
 single instance of the resource, you must specify enough property name-value
 pairs for the resource to be uniquely identified. If no property name-value
 pairs are specified, all instances will be removed. If there is more than one
-pair specified, a confirmation is required, unless you use the \fB-F\fR
-option. Likewise, the \fB-F\fR option can be used to remove a resource that
-does not exist (that is, no error will occur). In the resource scope, remove
-the specified name-value pair.
+pair is specified, a confirmation is required, unless you use the \fB-F\fR
+option.
 .RE
 
 .sp
--- old/usr/src/man/man2/meminfo.2	Wed Oct  5 00:33:28 2016
+++ new/usr/src/man/man2/meminfo.2	Wed Oct  5 00:33:28 2016
@@ -156,7 +156,13 @@
 \fBPRIV_PROC_MEMINFO\fR privilege.
 
 .SH RETURN VALUES
+.sp
 .LP
+All but \fBMEMINFO_VLGRP\fR and \fBMEMINFO_VPAGESIZE\fR require the
+\fBPRIV_PROC_MEMINFO\fR privilege.
+
+.SH RETURN VALUES
+.LP
 Upon successful completion \fBmeminfo()\fR returns 0. Otherwise \(mi1 is
 returned and \fBerrno\fR is set to indicate the error.
 .SH ERRORS
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/man/man5/Makefile	Wed Oct  5 00:33:29 2016
+++ new/usr/src/man/man5/Makefile	Wed Oct  5 00:33:29 2016
@@ -81,7 +81,6 @@
 		ms.5			\
 		mutex.5			\
 		nfssec.5		\
-		overlay.5		\
 		pam_allow.5		\
 		pam_authtok_check.5	\
 		pam_authtok_get.5	\
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/man/man7d/Makefile	Wed Oct  5 00:33:30 2016
+++ new/usr/src/man/man7d/Makefile	Wed Oct  5 00:33:30 2016
@@ -11,8 +11,8 @@
 
 #
 # Copyright 2011, Richard Lowe
+# Copyright 2014 Joyent, Inc. All rights reserved.
 # Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
-# Copyright 2016 Joyent, Inc.
 # Copyright 2016 Garrett D'Amore <garrett@damore.org>
 # Copyright 2016 Joyent, Inc.
 #
@@ -144,7 +144,6 @@
 		virtualkm.7d	\
 		vni.7d		\
 		vr.7d		\
-		vnd.7d		\
 		wscons.7d	\
 		xge.7d		\
 		yge.7d		\
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/pkg/manifests/system-header.mf	Wed Oct  5 00:33:30 2016
+++ new/usr/src/pkg/manifests/system-header.mf	Wed Oct  5 00:33:30 2016
@@ -474,7 +474,6 @@
 file path=usr/include/kstat.h
 file path=usr/include/kvm.h
 file path=usr/include/langinfo.h
-file path=usr/include/lastlog.h
 file path=usr/include/lber.h
 file path=usr/include/ldap.h
 file path=usr/include/libcontract.h
@@ -1179,6 +1178,7 @@
 file path=usr/include/sys/ldterm.h
 file path=usr/include/sys/lgrp.h
 file path=usr/include/sys/lgrp_user.h
+file path=usr/include/sys/limits.h
 file path=usr/include/sys/link.h
 file path=usr/include/sys/list.h
 file path=usr/include/sys/list_impl.h
--- old/usr/src/pkg/manifests/system-kernel.mf	Wed Oct  5 00:33:31 2016
+++ new/usr/src/pkg/manifests/system-kernel.mf	Wed Oct  5 00:33:31 2016
@@ -21,6 +21,7 @@
 
 #
 # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright 2012, Nexenta Systems, Inc. All rights reserved.
 # Copyright 2013 Saso Kiselkov. All rights reserved.
 # Copyright 2015 Nexenta Systems, Inc. All rights reserved.
 #
@@ -235,7 +236,9 @@
 driver name=poll perms="* 0666 root sys"
 $(sparc_ONLY)driver name=power alias=ali1535d+-power
 $(i386_ONLY)driver name=power
-driver name=pseudo alias=zconsnex
+driver name=pseudo \
+    alias=zconsnex \
+    alias=zfdnex
 driver name=ptc perms="* 0666 root sys"
 driver name=ptsl perms="* 0666 root sys"
 $(sparc_ONLY)driver name=ramdisk alias=SUNW,ramdisk perms="* 0600 root sys" \
@@ -762,9 +765,13 @@
 $(i386_ONLY)file path=kernel/sched/SDC group=sys mode=0755
 $(i386_ONLY)file path=kernel/sched/TS group=sys mode=0755
 $(i386_ONLY)file path=kernel/sched/TS_DPTBL group=sys mode=0755
+file path=kernel/socketmod/$(ARCH64)/datafilt group=sys mode=0755
+file path=kernel/socketmod/$(ARCH64)/httpfilt group=sys mode=0755
 file path=kernel/socketmod/$(ARCH64)/ksslf group=sys mode=0755
 file path=kernel/socketmod/$(ARCH64)/socksctp group=sys mode=0755
 file path=kernel/socketmod/$(ARCH64)/trill group=sys mode=0755
+$(i386_ONLY)file path=kernel/socketmod/datafilt group=sys mode=0755
+$(i386_ONLY)file path=kernel/socketmod/httpfilt group=sys mode=0755
 $(i386_ONLY)file path=kernel/socketmod/ksslf group=sys mode=0755
 $(i386_ONLY)file path=kernel/socketmod/socksctp group=sys mode=0755
 $(i386_ONLY)file path=kernel/socketmod/trill group=sys mode=0755
--- old/usr/src/pkg/manifests/system-test-ostest.mf	Wed Oct  5 00:33:31 2016
+++ new/usr/src/pkg/manifests/system-test-ostest.mf	Wed Oct  5 00:33:31 2016
@@ -12,7 +12,6 @@
 #
 # Copyright (c) 2012 by Delphix. All rights reserved.
 # Copyright 2014, OmniTI Computer Consulting, Inc. All rights reserved.
-# Copyright 2016, Joyent, Inc.
 #
 
 set name=pkg.fmri value=pkg:/system/test/ostest@$(PKGVERS)
@@ -29,14 +28,16 @@
 dir path=opt/os-tests/tests/sigqueue
 file path=opt/os-tests/README mode=0444
 file path=opt/os-tests/bin/ostest mode=0555
-file path=opt/os-tests/runfiles/default.run mode=0444
+file path=opt/os-tests/runfiles/delphix.run mode=0444
+file path=opt/os-tests/runfiles/omnios.run mode=0444
+file path=opt/os-tests/runfiles/openindiana.run mode=0444
+file path=opt/os-tests/tests/file-locking/acquire-lock.32 mode=0555
+file path=opt/os-tests/tests/file-locking/acquire-lock.64 mode=0555
+file path=opt/os-tests/tests/file-locking/runtests.32 mode=0555
+file path=opt/os-tests/tests/file-locking/runtests.64 mode=0555
 file path=opt/os-tests/tests/poll_test mode=0555
 file path=opt/os-tests/tests/sigqueue/sigqueue_queue_size mode=0555
 file path=opt/os-tests/tests/spoof-ras mode=0555
-file path=opt/os-tests/tests/file-locking/runtests.32 mode=0555
-file path=opt/os-tests/tests/file-locking/runtests.64 mode=0555
-file path=opt/os-tests/tests/file-locking/acquire-lock.32 mode=0555
-file path=opt/os-tests/tests/file-locking/acquire-lock.64 mode=0555
 license cr_Sun license=cr_Sun
 license lic_CDDL license=lic_CDDL
 depend fmri=system/test/testrunner type=require
--- old/usr/src/pkg/manifests/system-zones-brand-lx.mf	Wed Oct  5 00:33:31 2016
+++ new/usr/src/pkg/manifests/system-zones-brand-lx.mf	Wed Oct  5 00:33:31 2016
@@ -39,7 +39,14 @@
 set name=variant.arch value=i386
 dir path=etc group=sys
 dir path=etc/zones group=sys
+dir path=kernel group=sys
+dir path=kernel/fs group=sys
+dir path=kernel/fs/$(ARCH64) group=sys
+dir path=kernel/socketmod group=sys
+dir path=kernel/socketmod/$(ARCH64) group=sys
 dir path=usr group=sys
+dir path=usr/include group=bin
+dir path=usr/include/sys group=bin
 dir path=usr/kernel group=sys
 dir path=usr/kernel/brand group=sys
 dir path=usr/kernel/brand/$(ARCH64) group=sys
@@ -55,59 +62,81 @@
 dir path=usr/lib/brand
 dir path=usr/lib/brand/lx
 dir path=usr/lib/brand/lx/$(ARCH64)
-dir path=usr/lib/brand/lx/distros
+dir path=usr/lib/brand/lx/ld
+dir path=usr/lib/brand/lx/ld/64
 dir path=usr/lib/devfsadm group=sys
 dir path=usr/lib/devfsadm/linkmod group=sys
-driver name=lx_audio
+dir path=usr/share
+dir path=usr/share/man
+dir path=usr/share/man/man3c
+dir path=usr/share/man/man5
+dir path=usr/share/man/man7fs
+driver name=inotify perms="* 0666 root sys"
 driver name=lx_ptm perms="lx_ptmajor 0666 root sys"
 driver name=lx_systrace perms="* 0644 root sys"
+driver name=lxautofs perms="lxautofs 0600 root sys"
 file path=etc/zones/SUNWlx.xml mode=0444
 file path=etc/zones/SUNWlx26.xml mode=0444
+file path=kernel/socketmod/$(ARCH64)/lx_netlink mode=0755
+file path=kernel/socketmod/lx_netlink mode=0755
 file path=usr/kernel/brand/$(ARCH64)/lx_brand group=sys mode=0755
 file path=usr/kernel/brand/lx_brand group=sys mode=0755
-file path=usr/kernel/drv/$(ARCH64)/lx_audio group=sys
-file path=usr/kernel/drv/$(ARCH64)/lx_ptm group=sys
-file path=usr/kernel/drv/$(ARCH64)/lx_systrace group=sys
-file path=usr/kernel/drv/lx_audio group=sys
-file path=usr/kernel/drv/lx_audio.conf group=sys
+file path=usr/kernel/drv/$(ARCH64)/inotify group=sys mode=0755
+file path=usr/kernel/drv/$(ARCH64)/lx_ptm group=sys mode=0755
+file path=usr/kernel/drv/$(ARCH64)/lx_systrace group=sys mode=0755
+file path=usr/kernel/drv/$(ARCH64)/lxautofs group=sys mode=0755
+file path=usr/kernel/drv/inotify group=sys mode=0755
+file path=usr/kernel/drv/inotify.conf group=sys
 file path=usr/kernel/drv/lx_ptm group=sys
 file path=usr/kernel/drv/lx_ptm.conf group=sys
 file path=usr/kernel/drv/lx_systrace group=sys
 file path=usr/kernel/drv/lx_systrace.conf group=sys
-file path=usr/kernel/fs/$(ARCH64)/lx_afs group=sys mode=0755
+file path=usr/kernel/drv/lxautofs group=sys mode=0755
+file path=usr/kernel/drv/lxautofs.conf group=sys
+file path=usr/kernel/fs/$(ARCH64)/lx_cgroup group=sys mode=0755
+file path=usr/kernel/fs/$(ARCH64)/lx_devfs group=sys mode=0755
 file path=usr/kernel/fs/$(ARCH64)/lx_proc group=sys mode=0755
-file path=usr/kernel/fs/lx_afs group=sys mode=0755
+file path=usr/kernel/fs/$(ARCH64)/lx_sysfs group=sys mode=0755
+file path=usr/kernel/fs/lx_cgroup group=sys mode=0755
+file path=usr/kernel/fs/lx_devfs group=sys mode=0755
 file path=usr/kernel/fs/lx_proc group=sys mode=0755
-file path=usr/kernel/strmod/$(ARCH64)/ldlinux group=sys mode=0755
-file path=usr/kernel/strmod/ldlinux group=sys mode=0755
+file path=usr/kernel/fs/lx_sysfs group=sys mode=0755
+#file path=usr/kernel/strmod/$(ARCH64)/ldlinux group=sys mode=0755
+#file path=usr/kernel/strmod/ldlinux group=sys mode=0755
+file path=usr/lib/$(ARCH64)/lx_brand.so.1
 file path=usr/lib/brand/lx/$(ARCH64)/lx_librtld_db.so.1
+file path=usr/lib/brand/lx/$(ARCH64)/lx_vdso.so.1 mode=0755
 file path=usr/lib/brand/lx/config.xml mode=0444
-file path=usr/lib/brand/lx/distros/centos35.distro mode=0444
-file path=usr/lib/brand/lx/distros/centos36.distro mode=0444
-file path=usr/lib/brand/lx/distros/centos37.distro mode=0444
-file path=usr/lib/brand/lx/distros/centos38.distro mode=0444
-file path=usr/lib/brand/lx/distros/rhel35.distro mode=0444
-file path=usr/lib/brand/lx/distros/rhel36.distro mode=0444
-file path=usr/lib/brand/lx/distros/rhel37.distro mode=0444
-file path=usr/lib/brand/lx/distros/rhel38.distro mode=0444
-file path=usr/lib/brand/lx/distros/rhel_centos_common mode=0444
 file path=usr/lib/brand/lx/etc_default_nfs group=sys mode=0444
-file path=usr/lib/brand/lx/lx_distro_install mode=0755
-file path=usr/lib/brand/lx/lxinit mode=0755
-file path=usr/lib/brand/lx/lx_init_zone mode=0755
-file path=usr/lib/brand/lx/lx_init_zone_debian mode=0755
-file path=usr/lib/brand/lx/lx_init_zone_redhat mode=0755
+file path=usr/lib/brand/lx/ld/64/ld.config group=sys
+file path=usr/lib/brand/lx/ld/ld.config group=sys
+file path=usr/lib/brand/lx/ltp_skiplist group=sys mode=0444
+file path=usr/lib/brand/lx/ltp_tests group=sys mode=0444
+file path=usr/lib/brand/lx/lx_boot mode=0755
+file path=usr/lib/brand/lx/lx_boot_zone_busybox mode=0755
+file path=usr/lib/brand/lx/lx_boot_zone_debian mode=0755
+file path=usr/lib/brand/lx/lx_boot_zone_redhat mode=0755
+file path=usr/lib/brand/lx/lx_boot_zone_ubuntu mode=0755
 file path=usr/lib/brand/lx/lx_install mode=0755
 file path=usr/lib/brand/lx/lx_librtld_db.so.1
-file path=usr/lib/brand/lx/lx_native mode=0755
 file path=usr/lib/brand/lx/lx_support mode=0755
+file path=usr/lib/brand/lx/lx_vdso.so.1 mode=0755
+file path=usr/lib/brand/lx/lxinit mode=0555
 file path=usr/lib/brand/lx/platform.xml mode=0444
 file path=usr/lib/devfsadm/linkmod/SUNW_lx_link_$(ARCH).so group=sys
 file path=usr/lib/lx_brand.so.1
+file path=usr/share/man/man3c/inotify_add_watch.3c
+file path=usr/share/man/man3c/inotify_init.3c
+file path=usr/share/man/man3c/inotify_rm_watch.3c
+file path=usr/share/man/man5/inotify.5
+file path=usr/share/man/man5/lx.5
 hardlink path=usr/kernel/dtrace/$(ARCH64)/lx_systrace \
     target=../../../kernel/drv/$(ARCH64)/lx_systrace
 hardlink path=usr/kernel/dtrace/lx_systrace \
     target=../../kernel/drv/lx_systrace
+hardlink path=usr/kernel/fs/$(ARCH64)/lxautofs \
+    target=../../../kernel/drv/$(ARCH64)/lxautofs
+hardlink path=usr/kernel/fs/lxautofs target=../../kernel/drv/lxautofs
 legacy pkg=SUNWlxr arch=$(ARCH) category=system \
     desc="Support for the 'lx' Brand" \
     hotline="Please contact your local service provider" \
--- old/usr/src/pkg/manifests/system-zones.mf	Wed Oct  5 00:33:31 2016
+++ new/usr/src/pkg/manifests/system-zones.mf	Wed Oct  5 00:33:31 2016
@@ -46,6 +46,7 @@
 dir path=usr/lib/$(ARCH64)
 dir path=usr/lib/brand
 dir path=usr/lib/brand/ipkg group=bin
+dir path=usr/lib/brand/lipkg group=bin
 dir path=usr/lib/brand/shared group=sys
 dir path=usr/lib/zones
 dir path=usr/sbin
@@ -59,6 +60,7 @@
 dir path=usr/share/man/man5
 dir path=usr/share/man/man7d
 driver name=zcons
+driver name=zfd
 file path=etc/zones/SUNWblank.xml mode=0444 variant.opensolaris.zone=global
 file path=etc/zones/SUNWdefault.xml mode=0444 variant.opensolaris.zone=global
 file path=etc/zones/index group=sys original_name=SUNWzone:etc/zones/index \
@@ -76,12 +78,16 @@
     variant.opensolaris.zone=global
 file path=usr/bin/zonestat mode=0555
 file path=usr/kernel/drv/$(ARCH64)/zcons group=sys
+file path=usr/kernel/drv/$(ARCH64)/zfd group=sys
 $(i386_ONLY)file path=usr/kernel/drv/zcons group=sys
+$(i386_ONLY)file path=usr/kernel/drv/zfd group=sys mode=0755
 file path=usr/lib/$(ARCH64)/libbrand.so.1
 file path=usr/lib/$(ARCH64)/libzonecfg.so.1
 file path=usr/lib/$(ARCH64)/libzonestat.so.1
 file path=usr/lib/brand/ipkg/config.xml mode=0444
 file path=usr/lib/brand/ipkg/platform.xml mode=0444
+file path=usr/lib/brand/lipkg/config.xml mode=0444
+file path=usr/lib/brand/lipkg/platform.xml mode=0444
 file path=usr/lib/brand/shared/common.ksh mode=0444
 file path=usr/lib/brand/shared/query mode=0755
 file path=usr/lib/brand/shared/uninstall.ksh mode=0444
@@ -103,6 +109,7 @@
 file path=usr/share/man/man5/brands.5
 file path=usr/share/man/man5/zones.5
 file path=usr/share/man/man7d/zcons.7d
+file path=usr/share/man/man7d/zfd.7d
 legacy pkg=SUNWzoner desc="Solaris Zones Configuration Files" \
     name="Solaris Zones (Root)"
 legacy pkg=SUNWzoneu desc="Solaris Zones Configuration and Administration" \
--- /dev/null	Wed Oct  5 00:32:45 2016
+++ new/usr/src/test/os-tests/runfiles/omnios.run	Wed Oct  5 00:33:31 2016
@@ -0,0 +1,35 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+#
+
+[DEFAULT]
+pre =
+verbose = False
+quiet = False
+timeout = 60
+post =
+outputdir = /var/tmp/test_results
+
+[/opt/os-tests/tests/poll_test]
+user = root
+
+[/opt/os-tests/tests/sigqueue]
+tests = ['sigqueue_queue_size']
+
+[/opt/os-tests/tests/tmpfs]
+user = root
+tests = ['tmpfs_badmount', 'tmpfs_enospc']
+
+[/opt/os-tests/tests/file-locking]
+tests = ['runtests.32', 'runtests.64']
--- old/usr/src/test/os-tests/tests/Makefile	Wed Oct  5 00:33:31 2016
+++ new/usr/src/test/os-tests/tests/Makefile	Wed Oct  5 00:33:31 2016
@@ -13,6 +13,6 @@
 # Copyright (c) 2012 by Delphix. All rights reserved.
 #
 
-SUBDIRS = poll sigqueue spoof-ras tmpfs file-locking
+SUBDIRS = poll sigqueue spoof-ras file-locking
 
 include $(SRC)/test/Makefile.com
--- old/usr/src/test/os-tests/tests/file-locking/Makefile	Wed Oct  5 00:33:31 2016
+++ new/usr/src/test/os-tests/tests/file-locking/Makefile	Wed Oct  5 00:33:31 2016
@@ -25,12 +25,10 @@
 C99MODE = -xc99=%all
 
 SRCS = $(PROGS:%=%.c) $(UTILS)
+LINTS = $(SRCS:%.c=%.ln)
 PROGS32 = $(PROGS:%=%.32)
 PROGS64 = $(PROGS:%=%.64)
 
-runtests.32 :=	LDLIBS += -lgen
-runtests.64 :=	LDLIBS64 += -lgen
-
 ROOTOPTDIR = $(ROOT)/opt/os-tests/tests/file-locking
 ROOTOPTPROGS = $(PROGS32:%=$(ROOTOPTDIR)/%) \
 	$(PROGS64:%=$(ROOTOPTDIR)/%)
@@ -47,7 +45,7 @@
 
 all: $(PROGS32) $(PROGS64)
 
-lint: lint_SRCS
+lint: $(LINTS)
 
 clean:
 	-rm $(PROGS32) $(PROGS64)
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/uts/common/Makefile.files	Wed Oct  5 00:33:31 2016
+++ new/usr/src/uts/common/Makefile.files	Wed Oct  5 00:33:31 2016
@@ -24,7 +24,7 @@
 # Copyright (c) 2011, 2014 by Delphix. All rights reserved.
 # Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
 # Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
-# Copyright 2016 Joyent, Inc.
+# Copyright 2015, Joyent, Inc.
 # Copyright 2016 Garrett D'Amore <garrett@damore.org>
 # Copyright 2016 Joyent, Inc.
 # Copyright 2016 OmniTI Computer Consulting, Inc.  All rights reserved.
@@ -284,7 +284,6 @@
 		rctl.o		\
 		rctlsys.o	\
 		readlink.o	\
-		refhash.o	\
 		refstr.o	\
 		rename.o	\
 		resolvepath.o	\
@@ -559,7 +558,6 @@
 		sctp_addr.o tn_ipopt.o tnet.o ip_netinfo.o \
 		sctp_misc.o
 IP_ILB_OBJS =	ilb.o ilb_nat.o ilb_conn.o ilb_alg_hash.o ilb_alg_rr.o
-IP_COMM_OBJS =	inet_hash.o
 
 IP_OBJS +=	igmp.o ipmp.o ip.o ip6.o ip6_asp.o ip6_if.o ip6_ire.o \
 		ip6_rts.o ip_if.o ip_ire.o ip_listutils.o ip_mroute.o \
@@ -576,8 +574,7 @@
 		$(IP_TCP_OBJS) \
 		$(IP_UDP_OBJS) \
 		$(IP_SCTP_OBJS) \
-		$(IP_ILB_OBJS) \
-		$(IP_COMM_OBJS)
+		$(IP_ILB_OBJS)
 
 IP6_OBJS +=	ip6ddi.o
 
@@ -597,6 +594,8 @@
 
 DATAFILT_OBJS += datafilt.o
 
+HTTPFILT_OBJS += httpfilt.o
+
 SPPP_OBJS +=	sppp.o sppp_dlpi.o sppp_mod.o s_common.o
 
 SPPPTUN_OBJS +=	sppptun.o sppptun_mod.o
@@ -694,15 +693,6 @@
 
 VNIC_OBJS +=	vnic_ctl.o vnic_dev.o
 
-OVERLAY_OBJS +=	overlay.o overlay_fm.o overlay_mux.o overlay_plugin.o \
-		overlay_prop.o overlay_target.o
-
-OVERLAY_VXLAN_OBJS +=	overlay_vxlan.o
-
-VND_OBJS +=	vnd.o frameio.o
-
-GSQUEUE_OBJS +=	gsqueue.o
-
 SIMNET_OBJS +=	simnet.o
 
 IB_OBJS +=	ibnex.o ibnex_ioctl.o ibnex_hca.o
@@ -1152,7 +1142,8 @@
 DEV_OBJS  +=	sdev_subr.o	sdev_vfsops.o	sdev_vnops.o	\
 		sdev_ptsops.o	sdev_zvolops.o	sdev_comm.o	\
 		sdev_profile.o	sdev_ncache.o	sdev_netops.o	\
-		sdev_ipnetops.o	sdev_vtops.o	sdev_plugin.o
+		sdev_ipnetops.o	\
+		sdev_vtops.o
 
 CTFS_OBJS +=	ctfs_all.o ctfs_cdir.o ctfs_ctl.o ctfs_event.o \
 		ctfs_latest.o ctfs_root.o ctfs_sym.o ctfs_tdir.o ctfs_tmpl.o
@@ -1169,13 +1160,8 @@
 HSFS_OBJS +=	hsfs_node.o	hsfs_subr.o	hsfs_vfsops.o	hsfs_vnops.o \
 		hsfs_susp.o	hsfs_rrip.o	hsfs_susp_subr.o
 
-HYPRLOFS_OBJS += hyprlofs_dir.o hyprlofs_subr.o \
-		hyprlofs_vnops.o hyprlofs_vfsops.o
-
 LOFS_OBJS +=	lofs_subr.o	lofs_vfsops.o	lofs_vnops.o
 
-LXPROC_OBJS +=	lxpr_subr.o	lxpr_vfsops.o	lxpr_vnops.o
-
 NAMEFS_OBJS +=	namevfs.o	namevno.o
 
 NFS_OBJS +=	nfs_client.o	nfs_common.o	nfs_dump.o \
@@ -1917,7 +1903,7 @@
 
 MXFE_OBJS += mxfe.o
 
-MPTSAS_OBJS += mptsas.o mptsas_impl.o mptsas_init.o \
+MPTSAS_OBJS += mptsas.o mptsas_hash.o mptsas_impl.o mptsas_init.o \
 		mptsas_raid.o mptsas_smhba.o
 
 SFE_OBJS += sfe.o sfe_util.o
@@ -2151,11 +2137,6 @@
 MR_SAS_OBJS = ld_pd_map.o mr_sas.o mr_sas_tbolt.o mr_sas_list.o
 
 #
-#	DR_SAS module
-#
-DR_SAS_OBJS = dr_sas.o
-
-#
 #	CPQARY3 module
 #
 CPQARY3_OBJS =	cpqary3.o cpqary3_noe.o cpqary3_talk2ctlr.o	\
@@ -2164,18 +2145,6 @@
 		cpqary3_bd.o
 
 #
-#	HP Smart Array driver module (smrt)
-#
-SMRT_OBJS =	smrt.o \
-		smrt_device.o \
-		smrt_interrupts.o \
-		smrt_commands.o \
-		smrt_logvol.o \
-		smrt_hba.o \
-		smrt_ciss_simple.o \
-		smrt_ciss.o
-
-#
 #	ISCSI_INITIATOR module
 #
 ISCSI_INITIATOR_OBJS =	chap.o iscsi_io.o iscsi_thread.o	\
@@ -2206,20 +2175,6 @@
 TPM_OBJS =	tpm.o tpm_hcall.o
 
 #
-# USB Fast ethernet drivers
-#
-USBGEM_OBJS = usbgem.o
-AXF_OBJS = axf_usbgem.o
-UDMF_OBJS = udmf_usbgem.o
-URF_OBJS = urf_usbgem.o
-UPF_OBJS = upf_usbgem.o
-
-#
-#	NFP objects
-#
-NFP_OBJS = hostif.o osif.o drvlist.o i21555.o i21285.o i21555d.o
-
-#
 #	BNXE objects
 #
 BNXE_OBJS +=	bnxe_cfg.o		\
--- old/usr/src/uts/common/Makefile.rules	Wed Oct  5 00:33:32 2016
+++ new/usr/src/uts/common/Makefile.rules	Wed Oct  5 00:33:32 2016
@@ -23,7 +23,6 @@
 # Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
 # Copyright 2016 Garrett D'Amore <garrett@damore.org>
 # Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
-# Copyright 2016 Joyent, Inc.
 # Copyright 2013 Saso Kiselkov. All rights reserved.
 # Copyright 2016 Joyent, Inc.
 #
@@ -98,10 +97,6 @@
 	$(COMPILE.c) -o $@ $<
 	$(CTFCONVERT_O)
 
-$(OBJS_DIR)/%.o:		$(COMMONBASE)/inet/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
 $(OBJS_DIR)/%.o:		$(COMMONBASE)/ucode/%.c
 	$(COMPILE.c) -o $@ $<
 	$(CTFCONVERT_O)
@@ -250,18 +245,10 @@
 	$(COMPILE.c) -o $@ $<
 	$(CTFCONVERT_O)
 
-$(OBJS_DIR)/%.o:		$(UTSBASE)/common/fs/hyprlofs/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
 $(OBJS_DIR)/%.o:		$(UTSBASE)/common/fs/lofs/%.c
 	$(COMPILE.c) -o $@ $<
 	$(CTFCONVERT_O)
 
-$(OBJS_DIR)/%.o:		$(UTSBASE)/common/fs/lxproc/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
 $(OBJS_DIR)/%.o:		$(UTSBASE)/common/fs/mntfs/%.c
 	$(COMPILE.c) -o $@ $<
 	$(CTFCONVERT_O)
@@ -773,10 +760,6 @@
 	$(COMPILE.c) -o $@ $<
 	$(CTFCONVERT_O)
 
-$(OBJS_DIR)/%.o:		$(UTSBASE)/common/io/dr_sas/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
 $(OBJS_DIR)/%.o:		$(UTSBASE)/common/io/efe/%.c
 	$(COMPILE.c) -o $@ $<
 	$(CTFCONVERT_O)
@@ -1005,10 +988,6 @@
 	$(COMPILE.c) -o $@ $<
 	$(CTFCONVERT_O)
 
-$(OBJS_DIR)/%.o:		$(UTSBASE)/common/io/nfp/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
 $(OBJS_DIR)/%.o:		$(UTSBASE)/common/io/nge/%.c
 	$(COMPILE.c) -o $@ $<
 	$(CTFCONVERT_O)
@@ -1028,14 +1007,6 @@
 $(OBJS_DIR)/%.o:		$(UTSBASE)/common/io/nxge/%.s
 	$(COMPILE.s) -o $@ $<
 
-$(OBJS_DIR)/%.o:		$(UTSBASE)/common/io/overlay/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
-$(OBJS_DIR)/%.o:		$(UTSBASE)/common/io/overlay/plugins/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
 $(OBJS_DIR)/%.o:		$(UTSBASE)/common/io/pci-ide/%.c
 	$(COMPILE.c) -o $@ $<
 	$(CTFCONVERT_O)
@@ -1132,10 +1103,6 @@
 	$(COMPILE.c) -o $@ $<
 	$(CTFCONVERT_O)
 
-$(OBJS_DIR)/%.o:		$(UTSBASE)/common/io/scsi/adapters/smrt/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
 $(OBJS_DIR)/%.o:		$(UTSBASE)/common/io/fibre-channel/ulp/%.c
 	$(COMPILE.c) -o $@ $<
 	$(CTFCONVERT_O)
@@ -1176,10 +1143,6 @@
 	$(COMPILE.c) -o $@ $<
 	$(CTFCONVERT_O)
 
-$(OBJS_DIR)/%.o:		$(UTSBASE)/common/io/gsqueue/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
 $(OBJS_DIR)/%.o:		$(UTSBASE)/common/io/sfe/%.c
 	$(COMPILE.c) -o $@ $<
 	$(CTFCONVERT_O)
@@ -1192,10 +1155,6 @@
 	$(COMPILE.c) -o $@ $<
 	$(CTFCONVERT_O)
 
-$(OBJS_DIR)/%.o:		$(UTSBASE)/common/io/vnd/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
 $(OBJS_DIR)/%.o:		$(UTSBASE)/common/io/uath/%.c
 	$(COMPILE.c) -o $@ $<
 	$(CTFCONVERT_O)
@@ -1320,30 +1279,6 @@
 	$(COMPILE.c) -o $@ $<
 	$(CTFCONVERT_O)
 
-$(OBJS_DIR)/%.o:		$(UTSBASE)/common/io/usbgem/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
-$(OBJS_DIR)/%.o:		$(UTSBASE)/common/io/axf/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
-$(OBJS_DIR)/%.o:		$(UTSBASE)/common/io/udf/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
-$(OBJS_DIR)/%.o:		$(UTSBASE)/common/io/udmf/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
-$(OBJS_DIR)/%.o:		$(UTSBASE)/common/io/upf/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
-$(OBJS_DIR)/%.o:		$(UTSBASE)/common/io/urf/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
 $(OBJS_DIR)/%.o:		$(UTSBASE)/common/io/vuidmice/%.c
 	$(COMPILE.c) -o $@ $<
 	$(CTFCONVERT_O)
@@ -1536,14 +1471,9 @@
 	$(COMPILE.c) -o $@ $<
 	$(CTFCONVERT_O)
 
-$(OBJS_DIR)/%.o:		$(COMMONBASE)/idspace/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
 $(OBJS_DIR)/%.o:		$(UTSBASE)/common/io/vioif/%.c
 	$(COMPILE.c) -o $@ $<
 	$(CTFCONVERT_O)
-
 #
 # krtld must refer to its own bzero/bcopy until the kernel is fully linked
 #
@@ -1612,10 +1542,6 @@
 	$(COMPILE.c) -o $@ $<
 	$(CTFCONVERT_O)
 
-$(OBJS_DIR)/%.o:		$(UTSBASE)/common/refhash/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
 $(OBJS_DIR)/%.o:		$(UTSBASE)/common/rpc/%.c
 	$(COMPILE.c) -o $@ $<
 	$(CTFCONVERT_O)
@@ -1739,9 +1665,6 @@
 $(LINTS_DIR)/%.ln:		$(COMMONBASE)/avl/%.c
 	@($(LHEAD) $(LINT.c) $< $(LTAIL))
 
-$(LINTS_DIR)/%.ln:		$(COMMONBASE)/inet/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
 $(LINTS_DIR)/%.ln:		$(COMMONBASE)/ucode/%.c
 	@($(LHEAD) $(LINT.c) $< $(LTAIL))
 
@@ -1877,9 +1800,6 @@
 $(LINTS_DIR)/%.ln:		$(UTSBASE)/common/fs/hsfs/%.c
 	@($(LHEAD) $(LINT.c) $< $(LTAIL))
 
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/common/fs/hyprlofs/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
 $(LINTS_DIR)/%.ln:		$(UTSBASE)/common/fs/lofs/%.c
 	@($(LHEAD) $(LINT.c) $< $(LTAIL))
 
@@ -2231,9 +2151,6 @@
 $(LINTS_DIR)/%.ln:		$(UTSBASE)/common/io/drm/%.c
 	@($(LHEAD) $(LINT.c) $< $(LTAIL))
 
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/common/io/dr_sas/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
 $(LINTS_DIR)/%.ln:		$(UTSBASE)/common/io/efe/%.c
 	@($(LHEAD) $(LINT.c) $< $(LTAIL))
 
@@ -2405,9 +2322,6 @@
 $(LINTS_DIR)/%.ln:		$(UTSBASE)/common/io/net80211/%.c
 	@($(LHEAD) $(LINT.c) $< $(LTAIL))
 
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/common/io/nfp/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
 $(LINTS_DIR)/%.ln:              $(UTSBASE)/common/io/nge/%.c
 	@($(LHEAD) $(LINT.c) $< $(LTAIL))
 
@@ -2423,12 +2337,6 @@
 $(LINTS_DIR)/%.ln:		$(UTSBASE)/common/io/nxge/npi/%.c
 	@($(LHEAD) $(LINT.c) $< $(LTAIL))
 
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/common/io/overlay/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/common/io/overlay/plugins/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
 $(LINTS_DIR)/%.ln:		$(UTSBASE)/common/io/pci-ide/%.c
 	@($(LHEAD) $(LINT.c) $< $(LTAIL))
 
@@ -2495,9 +2403,6 @@
 $(LINTS_DIR)/%.ln:		$(UTSBASE)/common/io/scsi/adapters/scsi_vhci/fops/%.c
 	@($(LHEAD) $(LINT.c) $< $(LTAIL))
 
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/common/io/scsi/adapters/smrt/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
 $(LINTS_DIR)/%.ln:		$(UTSBASE)/common/io/fibre-channel/ulp/%.c
 	@($(LHEAD) $(LINT.c) $< $(LTAIL))
 
@@ -2639,21 +2544,6 @@
 $(LINTS_DIR)/%.ln:		$(UTSBASE)/common/io/usb/usba10/%.c
 	@($(LHEAD) $(LINT.c) $< $(LTAIL))
 
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/common/io/usbgem/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/common/io/axf/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/common/io/udmf/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/common/io/upf/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/common/io/urf/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
 $(LINTS_DIR)/%.ln:		$(UTSBASE)/common/io/vuidmice/%.c
 	@($(LHEAD) $(LINT.c) $< $(LTAIL))
 
@@ -2807,9 +2697,6 @@
 $(LINTS_DIR)/%.ln:		$(UTSBASE)/common/pcmcia/pcs/%.c
 	@($(LHEAD) $(LINT.c) $< $(LTAIL))
 
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/common/refhash/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
 $(LINTS_DIR)/%.ln:		$(UTSBASE)/common/rpc/%.c
 	@($(LHEAD) $(LINT.c) $< $(LTAIL))
 
@@ -2902,7 +2789,4 @@
 	@($(LHEAD) $(LINT.c) $< $(LTAIL))
 
 $(LINTS_DIR)/%.ln:		$(COMMONBASE)/fsreparse/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
-$(LINTS_DIR)/%.ln:		$(COMMONBASE)/idspace/%.c
 	@($(LHEAD) $(LINT.c) $< $(LTAIL))
--- old/usr/src/uts/common/brand/lx/autofs/lx_autofs.c	Wed Oct  5 00:33:32 2016
+++ new/usr/src/uts/common/brand/lx/autofs/lx_autofs.c	Wed Oct  5 00:33:32 2016
@@ -88,6 +88,7 @@
 	uint32_t lad_ioctlfd;
 	uint32_t lad_arg1;
 	uint32_t lad_arg2;
+	/* LINTED - C99 construct. */
 	char	lad_path[0];
 } lx_autofs_dv_ioctl_t;
 
@@ -1518,7 +1519,7 @@
 	}
 	mutex_exit(&pidlock);
 
-	switch (cmd) {
+	switch ((unsigned int)cmd) {
 	case LX_AUTOFS_IOC_READY:
 		if ((err = lx_autofs_ack(id, vp->v_vfsp, LXACR_READY)) != 0)
 			return (err);
@@ -1570,7 +1571,8 @@
 		return (ENOTSUP);
 
 	case LX_AUTOFS_IOC_EXPIRE_MULTI:
-		lx_autofs_expire(vp->v_vfsp, cr);
+		/* Should we return lx_autofs_expire()'s value instead? */
+		(void) lx_autofs_expire(vp->v_vfsp, cr);
 		return (EAGAIN);
 
 	default:
@@ -2851,7 +2853,7 @@
 	if (fnd_vfs->vfs_op == lx_autofs_vfsops) {
 		dc->lad_arg2 = LX_AUTOFS_SB_MAGIC;
 	} else {
-		dc->lad_arg2 = ~LX_AUTOFS_SB_MAGIC;
+		dc->lad_arg2 = ~((uint32_t)LX_AUTOFS_SB_MAGIC);
 	}
 
 	VFS_RELE(fnd_vfs);
@@ -2901,7 +2903,12 @@
 lx_autofs_dev_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *credp,
     int *rvalp)
 {
-	switch (cmd) {
+	/*
+	 * Many of these constants are negative for a signed int.
+	 * Cast "cmd" to unsigned to prevent lint errors and not have any
+	 * other problems.
+	 */
+	switch ((unsigned int)cmd) {
 	case LX_AUTOFS_DEV_IOC_VERSION_CMD:
 		return (lx_autofs_dev_vers(arg));
 
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/uts/common/brand/lx/os/lx_syscall.c	Wed Oct  5 00:33:34 2016
+++ new/usr/src/uts/common/brand/lx/os/lx_syscall.c	Wed Oct  5 00:33:34 2016
@@ -263,6 +263,8 @@
 	 * emulated Linux system call:
 	 */
 	lwp->lwp_eosys = JUSTRETURN;
+	curthread->t_post_sys = 1;
+	aston(curthread);
 }
 
 static void
--- old/usr/src/uts/common/brand/lx/procfs/lx_proc.h	Wed Oct  5 00:33:34 2016
+++ new/usr/src/uts/common/brand/lx/procfs/lx_proc.h	Wed Oct  5 00:33:34 2016
@@ -200,7 +200,6 @@
 	LXPR_SWAPS,		/* /proc/swaps		*/
 	LXPR_SYSDIR,		/* /proc/sys/		*/
 	LXPR_SYS_FSDIR,		/* /proc/sys/fs/	*/
-	LXPR_SYS_FS_FILEMAX,	/* /proc/sys/fs/file-max */
 	LXPR_SYS_FS_INOTIFYDIR,	/* /proc/sys/fs/inotify	*/
 	LXPR_SYS_FS_INOTIFY_MAX_QUEUED_EVENTS,	/* inotify/max_queued_events */
 	LXPR_SYS_FS_INOTIFY_MAX_USER_INSTANCES,	/* inotify/max_user_instances */
@@ -228,11 +227,8 @@
 	LXPR_SYS_NET_IPV4_TCP_FIN_TO,	/* /proc/sys/net/ipv4/tcp_fin_timeout */
 	LXPR_SYS_NET_IPV4_TCP_KA_INT,	/* .../net/ipv4/tcp_keepalive_intvl */
 	LXPR_SYS_NET_IPV4_TCP_KA_TIM,	/* .../net/ipv4/tcp_keepalive_time */
-	LXPR_SYS_NET_IPV4_TCP_MAX_SYN_BL, /* .../net/ipv4/tcp_max_syn_backlog */
-	LXPR_SYS_NET_IPV4_TCP_RMEM,	/* /proc/sys/net/ipv4/tcp_rmem */
 	LXPR_SYS_NET_IPV4_TCP_SACK,	/* /proc/sys/net/ipv4/tcp_sack */
 	LXPR_SYS_NET_IPV4_TCP_WINSCALE,	/* .../net/ipv4/tcp_window_scaling */
-	LXPR_SYS_NET_IPV4_TCP_WMEM,	/* /proc/sys/net/ipv4/tcp_wmem */
 	LXPR_SYS_VMDIR,			/* /proc/sys/vm			*/
 	LXPR_SYS_VM_MAX_MAP_CNT,	/* /proc/sys/vm/max_map_count	*/
 	LXPR_SYS_VM_MINFR_KB,		/* /proc/sys/vm/min_free_kbytes	*/
No differences encountered
No differences encountered
--- old/usr/src/uts/common/brand/lx/procfs/lx_prvnops.c	Wed Oct  5 00:33:34 2016
+++ new/usr/src/uts/common/brand/lx/procfs/lx_prvnops.c	Wed Oct  5 00:33:34 2016
@@ -68,7 +68,6 @@
 #include <sys/cred_impl.h>
 #include <sys/tihdr.h>
 #include <sys/corectl.h>
-#include <sys/rctl_impl.h>
 #include <inet/ip.h>
 #include <inet/ip_ire.h>
 #include <inet/ip6.h>
@@ -217,7 +216,6 @@
 static void lxpr_read_net_udp(lxpr_node_t *, lxpr_uiobuf_t *);
 static void lxpr_read_net_udp6(lxpr_node_t *, lxpr_uiobuf_t *);
 static void lxpr_read_net_unix(lxpr_node_t *, lxpr_uiobuf_t *);
-static void lxpr_read_sys_fs_filemax(lxpr_node_t *, lxpr_uiobuf_t *);
 static void lxpr_read_sys_fs_inotify_max_queued_events(lxpr_node_t *,
     lxpr_uiobuf_t *);
 static void lxpr_read_sys_fs_inotify_max_user_instances(lxpr_node_t *,
@@ -243,9 +241,6 @@
 static void lxpr_read_sys_net_ipv4_tcp_fin_to(lxpr_node_t *, lxpr_uiobuf_t *);
 static void lxpr_read_sys_net_ipv4_tcp_ka_int(lxpr_node_t *, lxpr_uiobuf_t *);
 static void lxpr_read_sys_net_ipv4_tcp_ka_tim(lxpr_node_t *, lxpr_uiobuf_t *);
-static void lxpr_read_sys_net_ipv4_tcp_max_syn_bl(lxpr_node_t *,
-    lxpr_uiobuf_t *);
-static void lxpr_read_sys_net_ipv4_tcp_rwmem(lxpr_node_t *, lxpr_uiobuf_t *);
 static void lxpr_read_sys_net_ipv4_tcp_sack(lxpr_node_t *, lxpr_uiobuf_t *);
 static void lxpr_read_sys_net_ipv4_tcp_winscale(lxpr_node_t *, lxpr_uiobuf_t *);
 static void lxpr_read_sys_vm_max_map_cnt(lxpr_node_t *, lxpr_uiobuf_t *);
@@ -266,10 +261,6 @@
     cred_t *, caller_context_t *);
 static int lxpr_write_sys_net_ipv4_tcp_ka_tim(lxpr_node_t *, uio_t *,
     cred_t *, caller_context_t *);
-static int lxpr_write_sys_net_ipv4_tcp_max_syn_bl(lxpr_node_t *, uio_t *,
-    cred_t *, caller_context_t *);
-static int lxpr_write_sys_net_ipv4_tcp_rwmem(lxpr_node_t *, uio_t *,
-    cred_t *, caller_context_t *);
 static int lxpr_write_sys_net_ipv4_tcp_sack(lxpr_node_t *, uio_t *,
     cred_t *, caller_context_t *);
 static int lxpr_write_sys_net_ipv4_tcp_winscale(lxpr_node_t *, uio_t *,
@@ -292,7 +283,6 @@
 extern rctl_hndl_t rc_zone_msgmni;
 extern rctl_hndl_t rc_zone_shmmax;
 extern rctl_hndl_t rc_zone_shmmni;
-#define	ONEGB	1073741824ULL
 #define	FOURGB	4294967295ULL
 
 /*
@@ -495,7 +485,6 @@
  * contents of /proc/sys/fs directory
  */
 static lxpr_dirent_t sys_fsdir[] = {
-	{ LXPR_SYS_FS_FILEMAX,		"file-max" },
 	{ LXPR_SYS_FS_INOTIFYDIR,	"inotify" },
 };
 
@@ -573,11 +562,8 @@
 	{ LXPR_SYS_NET_IPV4_TCP_FIN_TO,	"tcp_fin_timeout" },
 	{ LXPR_SYS_NET_IPV4_TCP_KA_INT,	"tcp_keepalive_intvl" },
 	{ LXPR_SYS_NET_IPV4_TCP_KA_TIM,	"tcp_keepalive_time" },
-	{ LXPR_SYS_NET_IPV4_TCP_MAX_SYN_BL, "tcp_max_syn_backlog" },
-	{ LXPR_SYS_NET_IPV4_TCP_RMEM,	"tcp_rmem" },
 	{ LXPR_SYS_NET_IPV4_TCP_SACK,	"tcp_sack" },
 	{ LXPR_SYS_NET_IPV4_TCP_WINSCALE, "tcp_window_scaling" },
-	{ LXPR_SYS_NET_IPV4_TCP_WMEM,	"tcp_wmem" },
 };
 
 #define	SYS_NET_IPV4DIRFILES \
@@ -615,7 +601,6 @@
 	{LXPR_PID_OOM_SCR_ADJ, NULL},
 	{LXPR_PID_TID_FD_FD, NULL},
 	{LXPR_PID_TID_OOM_SCR_ADJ, NULL},
-	{LXPR_SYS_FS_FILEMAX, NULL},
 	{LXPR_SYS_KERNEL_COREPATT, lxpr_write_sys_kernel_corepatt},
 	{LXPR_SYS_KERNEL_SHMALL, NULL},
 	{LXPR_SYS_KERNEL_SHMMAX, NULL},
@@ -625,12 +610,8 @@
 	{LXPR_SYS_NET_IPV4_TCP_FIN_TO, lxpr_write_sys_net_ipv4_tcp_fin_to},
 	{LXPR_SYS_NET_IPV4_TCP_KA_INT, lxpr_write_sys_net_ipv4_tcp_ka_int},
 	{LXPR_SYS_NET_IPV4_TCP_KA_TIM, lxpr_write_sys_net_ipv4_tcp_ka_tim},
-	{LXPR_SYS_NET_IPV4_TCP_MAX_SYN_BL,
-	    lxpr_write_sys_net_ipv4_tcp_max_syn_bl},
-	{LXPR_SYS_NET_IPV4_TCP_RMEM, lxpr_write_sys_net_ipv4_tcp_rwmem},
 	{LXPR_SYS_NET_IPV4_TCP_SACK, lxpr_write_sys_net_ipv4_tcp_sack},
 	{LXPR_SYS_NET_IPV4_TCP_WINSCALE, lxpr_write_sys_net_ipv4_tcp_winscale},
-	{LXPR_SYS_NET_IPV4_TCP_WMEM, lxpr_write_sys_net_ipv4_tcp_rwmem},
 	{LXPR_SYS_VM_OVERCOMMIT_MEM, NULL},
 	{LXPR_SYS_VM_SWAPPINESS, NULL},
 	{LXPR_INVALID, NULL}
@@ -826,7 +807,6 @@
 	lxpr_read_swaps,		/* /proc/swaps		*/
 	lxpr_read_invalid,		/* /proc/sys		*/
 	lxpr_read_invalid,		/* /proc/sys/fs		*/
-	lxpr_read_sys_fs_filemax,	/* /proc/sys/fs/file-max */
 	lxpr_read_invalid,		/* /proc/sys/fs/inotify	*/
 	lxpr_read_sys_fs_inotify_max_queued_events, /* max_queued_events */
 	lxpr_read_sys_fs_inotify_max_user_instances, /* max_user_instances */
@@ -854,11 +834,8 @@
 	lxpr_read_sys_net_ipv4_tcp_fin_to, /* .../ipv4/tcp_fin_timeout */
 	lxpr_read_sys_net_ipv4_tcp_ka_int, /* .../ipv4/tcp_keepalive_intvl */
 	lxpr_read_sys_net_ipv4_tcp_ka_tim, /* .../ipv4/tcp_keepalive_time */
-	lxpr_read_sys_net_ipv4_tcp_max_syn_bl, /* ../ipv4/tcp_max_syn_backlog */
-	lxpr_read_sys_net_ipv4_tcp_rwmem, /* .../ipv4/tcp_rmem */
 	lxpr_read_sys_net_ipv4_tcp_sack, /* .../ipv4/tcp_sack */
 	lxpr_read_sys_net_ipv4_tcp_winscale, /* .../ipv4/tcp_window_scaling */
-	lxpr_read_sys_net_ipv4_tcp_rwmem, /* .../ipv4/tcp_wmem */
 	lxpr_read_invalid,		/* /proc/sys/vm	*/
 	lxpr_read_sys_vm_max_map_cnt,	/* /proc/sys/vm/max_map_count */
 	lxpr_read_sys_vm_minfr_kb,	/* /proc/sys/vm/min_free_kbytes */
@@ -966,7 +943,6 @@
 	lxpr_lookup_not_a_dir,		/* /proc/swaps		*/
 	lxpr_lookup_sysdir,		/* /proc/sys		*/
 	lxpr_lookup_sys_fsdir,		/* /proc/sys/fs		*/
-	lxpr_lookup_not_a_dir,		/* /proc/sys/fs/file-max */
 	lxpr_lookup_sys_fs_inotifydir,	/* /proc/sys/fs/inotify	*/
 	lxpr_lookup_not_a_dir,		/* .../inotify/max_queued_events */
 	lxpr_lookup_not_a_dir,		/* .../inotify/max_user_instances */
@@ -994,11 +970,8 @@
 	lxpr_lookup_not_a_dir,		/* .../net/ipv4/tcp_fin_timeout */
 	lxpr_lookup_not_a_dir,		/* .../net/ipv4/tcp_keepalive_intvl */
 	lxpr_lookup_not_a_dir,		/* .../net/ipv4/tcp_keepalive_time */
-	lxpr_lookup_not_a_dir,		/* .../net/ipv4/tcp_max_syn_backlog */
-	lxpr_lookup_not_a_dir,		/* .../net/ipv4/tcp_rmem */
 	lxpr_lookup_not_a_dir,		/* .../net/ipv4/tcp_sack */
 	lxpr_lookup_not_a_dir,		/* .../net/ipv4/tcp_window_scaling */
-	lxpr_lookup_not_a_dir,		/* .../net/ipv4/tcp_wmem */
 	lxpr_lookup_sys_vmdir,		/* /proc/sys/vm */
 	lxpr_lookup_not_a_dir,		/* /proc/sys/vm/max_map_count */
 	lxpr_lookup_not_a_dir,		/* /proc/sys/vm/min_free_kbytes */
@@ -1106,7 +1079,6 @@
 	lxpr_readdir_not_a_dir,		/* /proc/swaps		*/
 	lxpr_readdir_sysdir,		/* /proc/sys		*/
 	lxpr_readdir_sys_fsdir,		/* /proc/sys/fs		*/
-	lxpr_readdir_not_a_dir,		/* /proc/sys/fs/file-max */
 	lxpr_readdir_sys_fs_inotifydir,	/* /proc/sys/fs/inotify	*/
 	lxpr_readdir_not_a_dir,		/* .../inotify/max_queued_events */
 	lxpr_readdir_not_a_dir,		/* .../inotify/max_user_instances */
@@ -1134,11 +1106,8 @@
 	lxpr_readdir_not_a_dir,		/* .../net/ipv4/tcp_fin_timeout */
 	lxpr_readdir_not_a_dir,		/* .../net/ipv4/tcp_keepalive_intvl */
 	lxpr_readdir_not_a_dir,		/* .../net/ipv4/tcp_keepalive_time */
-	lxpr_readdir_not_a_dir,		/* .../net/ipv4/tcp_max_syn_backlog */
-	lxpr_readdir_not_a_dir,		/* .../net/ipv4/tcp_rmem */
 	lxpr_readdir_not_a_dir,		/* .../net/ipv4/tcp_sack */
 	lxpr_readdir_not_a_dir,		/* .../net/ipv4/tcp_window_scaling */
-	lxpr_readdir_not_a_dir,		/* .../net/ipv4/tcp_wmem */
 	lxpr_readdir_sys_vmdir,		/* /proc/sys/vm */
 	lxpr_readdir_not_a_dir,		/* /proc/sys/vm/max_map_count */
 	lxpr_readdir_not_a_dir,		/* /proc/sys/vm/min_free_kbytes */
@@ -4384,27 +4353,6 @@
 }
 
 /*
- * lxpr_read_sys_fs_filemax():
- *
- * The zone's total number of open files is not fixed or tunable, but we can
- * provide a number by taking:
- * (zone's proc limit) * (process.max-file-descriptor rctl privileged limit).
- * The privileged rctl limit is the same as rlim_fd_max.
- */
-/* ARGSUSED */
-static void
-lxpr_read_sys_fs_filemax(lxpr_node_t *lxpnp, lxpr_uiobuf_t *uiobuf)
-{
-	uint64_t max_fh, proc_lim;
-
-	ASSERT(lxpnp->lxpr_type == LXPR_SYS_FS_FILEMAX);
-	proc_lim = (uint64_t)(curzone->zone_nprocs_ctl == INT_MAX ?
-	    maxpid : curzone->zone_nprocs_ctl);
-	max_fh = proc_lim * (uint64_t)rlim_fd_max;
-	lxpr_uiobuf_printf(uiobuf, "%llu\n", max_fh);
-}
-
-/*
  * inotify tunables exported via /proc.
  */
 extern int inotify_maxevents;
@@ -4855,77 +4803,6 @@
 }
 
 /*
- * tcp_max_syn_backlog
- *
- * The number of half-open connections that can be kept by the backlog queue.
- * See the Linux tcp(7) man page.
- *
- * illumos: tcp_conn_req_max_q0
- */
-/* ARGSUSED */
-static void
-lxpr_read_sys_net_ipv4_tcp_max_syn_bl(lxpr_node_t *lxpnp, lxpr_uiobuf_t *uiobuf)
-{
-	netstack_t	*ns;
-	tcp_stack_t	*tcps;
-
-	ASSERT(lxpnp->lxpr_type == LXPR_SYS_NET_IPV4_TCP_MAX_SYN_BL);
-
-	ns = netstack_get_current();
-	if (ns == NULL) {
-		lxpr_uiobuf_seterr(uiobuf, ENXIO);
-		return;
-	}
-
-	tcps = ns->netstack_tcp;
-	lxpr_uiobuf_printf(uiobuf, "%d\n", tcps->tcps_conn_req_max_q0);
-	netstack_rele(ns);
-}
-
-/*
- * tcp_rmem and tcp_wmem
- *
- * Display the minimum, default, and maximum TCP receive/transmit window sizes,
- * in bytes. See the Linux tcp(7) man page.
- *
- * In illumos this roughly corresponds to: tcp_recv_hiwat or tcp_xmit_hiwat,
- * and tcp_max_buf.
- *    tcp_recv_hiwat is the default TCP receive window size
- *    tcp_xmit_hiwat is the default TCP send window size
- *    tcp_max_buf is the maximum TCP send and receive buffer size
- */
-/* ARGSUSED */
-static void
-lxpr_read_sys_net_ipv4_tcp_rwmem(lxpr_node_t *lxpnp, lxpr_uiobuf_t *uiobuf)
-{
-	netstack_t	*ns;
-	tcp_stack_t	*tcps;
-	uint_t		min;
-
-	ASSERT(lxpnp->lxpr_type == LXPR_SYS_NET_IPV4_TCP_RMEM ||
-	    lxpnp->lxpr_type == LXPR_SYS_NET_IPV4_TCP_WMEM);
-
-	ns = netstack_get_current();
-	if (ns == NULL) {
-		lxpr_uiobuf_seterr(uiobuf, ENXIO);
-		return;
-	}
-
-	tcps = ns->netstack_tcp;
-
-	/* Linux defaults to a page */
-	min = MIN((lxpnp->lxpr_type == LXPR_SYS_NET_IPV4_TCP_RMEM ?
-	    tcps->tcps_recv_hiwat : tcps->tcps_xmit_hiwat), PAGESIZE);
-
-	lxpr_uiobuf_printf(uiobuf, "%d\t%d\t%d\n",
-	    min,
-	    (lxpnp->lxpr_type == LXPR_SYS_NET_IPV4_TCP_RMEM ?
-	    tcps->tcps_recv_hiwat : tcps->tcps_xmit_hiwat),
-	    tcps->tcps_max_buf);
-	netstack_rele(ns);
-}
-
-/*
  * tcp_sack
  *
  * Enable RFC 2018 TCP Selective Acknowledgements. Boolean, default: enabled
@@ -7034,109 +6911,7 @@
 	return (res);
 }
 
-/*
- * We expect three numbers on a line as input for the range, and we have to
- * set two properties on the netstack_tcp, so we can't reuse
- * lxpr_write_tcp_property.
- *
- * See the Linux tcp(7) man page.
- */
-/* ARGSUSED */
 static int
-lxpr_write_sys_net_ipv4_tcp_rwmem(lxpr_node_t *lxpnp, struct uio *uio,
-    struct cred *cr, caller_context_t *ct)
-{
-	int res;
-	size_t olen;
-	char vals[80];	/* big enough for a line w/ 3 numeric strings */
-	char *ep;
-	long min, def, max, min_limit;
-	netstack_t *ns;
-	tcp_stack_t *tcps;
-	mod_prop_info_t *ptbl;
-	mod_prop_info_t *pinfo;
-	char *attr;
-
-	ASSERT(lxpnp->lxpr_type == LXPR_SYS_NET_IPV4_TCP_RMEM ||
-	    lxpnp->lxpr_type == LXPR_SYS_NET_IPV4_TCP_WMEM);
-
-	if (uio->uio_loffset != 0)
-		return (EINVAL);
-
-	if (uio->uio_resid == 0)
-		return (0);
-
-	olen = uio->uio_resid;
-	if (olen > sizeof (vals) - 1)
-		return (EINVAL);
-
-	bzero(vals, sizeof (vals));
-	res = uiomove(vals, olen, UIO_WRITE, uio);
-	if (res != 0)
-		return (res);
-
-	if (lxpr_tokenize_num(vals, &min, &ep) != 0)
-		return (EINVAL);
-
-	if (lxpr_tokenize_num(ep, &def, &ep) != 0)
-		return (EINVAL);
-
-	if (lxpr_tokenize_num(ep, &max, &ep) != 0)
-		return (EINVAL);
-
-	if (*ep != '\0') {
-		/* make sure no other tokens on the line */
-		*ep++ = '\0';
-		for (; isspace(*ep); ep++)
-			;
-		if (*ep != '\0')
-			return (EINVAL);
-	}
-
-	/*
-	 * Ensure the numbers are valid, low to high.
-	 * Valid ranges from the tunable's guide.
-	 */
-	min_limit = (lxpnp->lxpr_type == LXPR_SYS_NET_IPV4_TCP_RMEM ?
-	    2048 : 4096);
-	if (min > def || def > max || min < min_limit ||
-	    def > ONEGB || max < 8192)
-		return (EINVAL);
-
-	ns = netstack_get_current();
-	if (ns == NULL)
-		return (EINVAL);
-
-	tcps = ns->netstack_tcp;
-
-	/* recv_hiwat and xmit_hiwat are aliased to recv_buf and send_buf. */
-	attr = (lxpnp->lxpr_type == LXPR_SYS_NET_IPV4_TCP_RMEM ?
-	    "recv_buf" : "send_buf");
-
-	(void) snprintf(vals, sizeof (vals), "%ld", def);
-	ptbl = ns->netstack_tcp->tcps_propinfo_tbl;
-	pinfo = mod_prop_lookup(ptbl, attr, MOD_PROTO_TCP);
-	if (pinfo == NULL ||
-	    pinfo->mpi_setf(ns, cr, pinfo, NULL, vals, 0) != 0)
-		res = EINVAL;
-
-	/*
-	 * Don't reduce max for one side (recv or xmit) since that impacts the
-	 * other.
-	 */
-	if (res == 0 && max > tcps->tcps_max_buf) {
-		(void) snprintf(vals, sizeof (vals), "%ld", max);
-		pinfo = mod_prop_lookup(ptbl, "max_buf", MOD_PROTO_TCP);
-		if (pinfo == NULL ||
-		    pinfo->mpi_setf(ns, cr, pinfo, NULL, vals, 0) != 0)
-			res = EINVAL;
-	}
-
-	netstack_rele(ns);
-	return (res);
-}
-
-static int
 lxpr_write_sys_net_ipv4_tcp_fin_to(lxpr_node_t *lxpnp, struct uio *uio,
     struct cred *cr, caller_context_t *ct)
 {
@@ -7163,15 +6938,6 @@
 	    "_keepalive_interval", lxpr_xlate_sec2ms));
 }
 
-static int
-lxpr_write_sys_net_ipv4_tcp_max_syn_bl(lxpr_node_t *lxpnp, struct uio *uio,
-    struct cred *cr, caller_context_t *ct)
-{
-	ASSERT(lxpnp->lxpr_type == LXPR_SYS_NET_IPV4_TCP_MAX_SYN_BL);
-	return (lxpr_write_tcp_property(lxpnp, uio, cr, ct,
-	    "_conn_req_max_q0", NULL));
-}
-
 static int
 lxpr_write_sys_net_ipv4_tcp_sack(lxpr_node_t *lxpnp, struct uio *uio,
     struct cred *cr, caller_context_t *ct)
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/uts/common/brand/lx/syscall/lx_epoll.c	Wed Oct  5 00:33:37 2016
+++ new/usr/src/uts/common/brand/lx/syscall/lx_epoll.c	Wed Oct  5 00:33:37 2016
@@ -191,39 +191,16 @@
 	error = VOP_WRITE(fp->f_vnode, &auio, 1, fp->f_cred, NULL);
 
 	releasef(fd);
-
-	switch (error) {
-	case 0:
-		return (0);
-
-	case EBADF:
-	case EEXIST:
-	case EINVAL:
-	case ENOENT:
-	case ENOMEM:
-	case ENOSPC:
-	case EPERM:
+	if (error == ELOOP) {
 		/*
-		 * Legal errors should pass straight through.
-		 */
-		return (set_errno(error));
-
-	case ELOOP:
-		/*
 		 * In the case of descriptor loops, /dev/poll emits a more
 		 * descriptive error than Linux epoll consumers would expect.
 		 */
 		return (set_errno(EINVAL));
-
-	default:
-		/*
-		 * While devpoll itself should not emit unexpected errors, it
-		 * is possible that a VOP_POLL handler might.  There is little
-		 * choice but to map these unexpected errors to something which
-		 * is valid for epoll_ctl.
-		 */
-		return (set_errno(ENOMEM));
+	} else if (error != 0) {
+		return (set_errno(error));
 	}
+	return (0);
 }
 
 long
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/uts/common/brand/lx/syscall/lx_miscsys.c	Wed Oct  5 00:33:38 2016
+++ new/usr/src/uts/common/brand/lx/syscall/lx_miscsys.c	Wed Oct  5 00:33:38 2016
@@ -278,12 +278,5 @@
 {
 	if (crgetuid(CRED()) != 0)
 		return (set_errno(EPERM));
-
-	/*
-	 * The native vhangup code does nothing except check for the sys_config
-	 * privilege. Eventually we'll first want to check our emulation for the
-	 * Linux CAP_SYS_TTY_CONFIG capability, but currently, since we've
-	 * already checked that our process is root, just succeed.
-	 */
-	return (0);
+	return (vhangup());
 }
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/uts/common/brand/sn1/sn1_brand.c	Wed Oct  5 00:33:40 2016
+++ new/usr/src/uts/common/brand/sn1/sn1_brand.c	Wed Oct  5 00:33:40 2016
@@ -213,6 +213,7 @@
 	brand_solaris_exec(&sn1_brand);
 }
 
+/* ARGSUSED */
 void
 sn1_initlwp(klwp_t *l, void *bd)
 {
No differences encountered
--- old/usr/src/uts/common/brand/solaris10/s10_brand.c	Wed Oct  5 00:33:40 2016
+++ new/usr/src/uts/common/brand/solaris10/s10_brand.c	Wed Oct  5 00:33:40 2016
@@ -368,6 +368,7 @@
 	brand_solaris_exec(&s10_brand);
 }
 
+/* ARGSUSED */
 void
 s10_initlwp(klwp_t *l, void *bd)
 {
@@ -410,6 +411,7 @@
 	kmem_free(zone->zone_brand_data, sizeof (s10_zone_data_t));
 }
 
+/* ARGSUSED */
 void
 s10_init_brand_data(zone_t *zone, kmutex_t *zsl)
 {
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/uts/common/exec/elf/elf.c	Wed Oct  5 00:33:41 2016
+++ new/usr/src/uts/common/exec/elf/elf.c	Wed Oct  5 00:33:41 2016
@@ -529,12 +529,12 @@
 		 *	AT_BASE
 		 *	AT_FLAGS
 		 *	AT_PAGESZ
-		 *	AT_RANDOM	(added in stk_copyout)
+		 *	AT_RANDOM
 		 *	AT_SUN_AUXFLAGS
 		 *	AT_SUN_HWCAP
 		 *	AT_SUN_HWCAP2
-		 *	AT_SUN_PLATFORM	(added in stk_copyout)
-		 *	AT_SUN_EXECNAME	(added in stk_copyout)
+		 *	AT_SUN_PLATFORM (added in stk_copyout)
+		 *	AT_SUN_EXECNAME (added in stk_copyout)
 		 *	AT_NULL
 		 *
 		 * total == 10
@@ -643,8 +643,7 @@
 	aux = bigwad->elfargs;
 	/*
 	 * Move args to the user's stack.
-	 * This can fill in the AT_SUN_PLATFORM, AT_SUN_EXECNAME and AT_RANDOM
-	 * aux entries.
+	 * This can fill in the AT_SUN_PLATFORM and AT_SUN_EXECNAME aux entries.
 	 */
 	if ((error = exec_args(uap, args, idatap, (void **)&aux)) != 0) {
 		if (error == -1) {
@@ -885,8 +884,8 @@
 		int auxf = AF_SUN_HWCAPVERIFY;
 
 		/*
-		 * Note: AT_SUN_PLATFORM, AT_SUN_EXECNAME and AT_RANDOM were
-		 * filled in via exec_args()
+		 * Note: AT_SUN_PLATFORM and AT_RANDOM were filled in via
+		 * exec_args()
 		 */
 		ADDAUX(aux, AT_BASE, voffset)
 		ADDAUX(aux, AT_FLAGS, at_flags)
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/uts/common/fs/dev/sdev_subr.c	Wed Oct  5 00:33:41 2016
+++ new/usr/src/uts/common/fs/dev/sdev_subr.c	Wed Oct  5 00:33:41 2016
@@ -150,6 +150,12 @@
 kmem_cache_t	*sdev_node_cache;	/* sdev_node cache */
 int		devtype;		/* fstype */
 
+/* static */
+static struct vnodeops *sdev_get_vop(struct sdev_node *);
+static void sdev_set_no_negcache(struct sdev_node *);
+static fs_operation_def_t *sdev_merge_vtab(const fs_operation_def_t []);
+static void sdev_free_vtab(fs_operation_def_t *);
+
 static void
 sdev_prof_free(struct sdev_node *dv)
 {
@@ -307,7 +313,6 @@
 	(void) snprintf(dv->sdev_path, len, "%s/%s", ddv->sdev_path, nm);
 	/* overwritten for VLNK nodes */
 	dv->sdev_symlink = NULL;
-	list_link_init(&dv->sdev_plist);
 
 	vp = SDEVTOV(dv);
 	vn_reinit(vp);
@@ -396,7 +401,6 @@
 	} else {
 		dv->sdev_nlink = 1;
 	}
-	sdev_plugin_nodeready(dv);
 
 	if (!(SDEV_IS_GLOBAL(dv))) {
 		dv->sdev_origin = (struct sdev_node *)args;
@@ -493,22 +497,37 @@
 	return (dv);
 }
 
-struct sdev_vop_table vtab[] = {
-	{ "pts", devpts_vnodeops_tbl, &devpts_vnodeops, devpts_validate,
+/* directory dependent vop table */
+struct sdev_vop_table {
+	char *vt_name;				/* subdirectory name */
+	const fs_operation_def_t *vt_service;	/* vnodeops table */
+	struct vnodeops *vt_vops;		/* constructed vop */
+	struct vnodeops **vt_global_vops;	/* global container for vop */
+	int (*vt_vtor)(struct sdev_node *);	/* validate sdev_node */
+	int vt_flags;
+};
+
+/*
+ * A nice improvement would be to provide a plug-in mechanism
+ * for this table instead of a const table.
+ */
+static struct sdev_vop_table vtab[] =
+{
+	{ "pts", devpts_vnodeops_tbl, NULL, &devpts_vnodeops, devpts_validate,
 	SDEV_DYNAMIC | SDEV_VTOR },
 
-	{ "vt", devvt_vnodeops_tbl, &devvt_vnodeops, devvt_validate,
+	{ "vt", devvt_vnodeops_tbl, NULL, &devvt_vnodeops, devvt_validate,
 	SDEV_DYNAMIC | SDEV_VTOR },
 
-	{ "zvol", devzvol_vnodeops_tbl, &devzvol_vnodeops,
+	{ "zvol", devzvol_vnodeops_tbl, NULL, &devzvol_vnodeops,
 	devzvol_validate, SDEV_ZONED | SDEV_DYNAMIC | SDEV_VTOR | SDEV_SUBDIR },
 
-	{ "zcons", NULL, NULL, NULL, SDEV_NO_NCACHE },
+	{ "zcons", NULL, NULL, NULL, NULL, SDEV_NO_NCACHE },
 
-	{ "net", devnet_vnodeops_tbl, &devnet_vnodeops, devnet_validate,
-	SDEV_DYNAMIC | SDEV_VTOR | SDEV_SUBDIR },
+	{ "net", devnet_vnodeops_tbl, NULL, &devnet_vnodeops, devnet_validate,
+	SDEV_DYNAMIC | SDEV_VTOR },
 
-	{ "ipnet", devipnet_vnodeops_tbl, &devipnet_vnodeops,
+	{ "ipnet", devipnet_vnodeops_tbl, NULL, &devipnet_vnodeops,
 	devipnet_validate, SDEV_DYNAMIC | SDEV_VTOR | SDEV_NO_NCACHE },
 
 	/*
@@ -523,16 +542,134 @@
 	 * preventing a mkdir.
 	 */
 
-	{ "lofi", NULL, NULL, NULL,
+	{ "lofi", NULL, NULL, NULL, NULL,
 	    SDEV_ZONED | SDEV_DYNAMIC | SDEV_PERSIST },
-	{ "rlofi", NULL, NULL, NULL,
+	{ "rlofi", NULL, NULL, NULL, NULL,
 	    SDEV_ZONED | SDEV_DYNAMIC | SDEV_PERSIST },
 
-	{ NULL, NULL, NULL, NULL, 0}
+	{ NULL, NULL, NULL, NULL, NULL, 0}
 };
 
+/*
+ * We need to match off of the sdev_path, not the sdev_name. We are only allowed
+ * to exist directly under /dev.
+ */
+struct sdev_vop_table *
+sdev_match(struct sdev_node *dv)
+{
+	int vlen;
+	int i;
+	const char *path;
 
+	if (strlen(dv->sdev_path) <= 5)
+		return (NULL);
+
+	if (strncmp(dv->sdev_path, "/dev/", 5) != 0)
+		return (NULL);
+	path = dv->sdev_path + 5;
+
+	for (i = 0; vtab[i].vt_name; i++) {
+		if (strcmp(vtab[i].vt_name, path) == 0)
+			return (&vtab[i]);
+		if (vtab[i].vt_flags & SDEV_SUBDIR) {
+			vlen = strlen(vtab[i].vt_name);
+			if ((strncmp(vtab[i].vt_name, path,
+			    vlen - 1) == 0) && path[vlen] == '/')
+				return (&vtab[i]);
+		}
+
+	}
+	return (NULL);
+}
+
 /*
+ *  sets a directory's vnodeops if the directory is in the vtab;
+ */
+static struct vnodeops *
+sdev_get_vop(struct sdev_node *dv)
+{
+	struct sdev_vop_table *vtp;
+	char *path;
+
+	path = dv->sdev_path;
+	ASSERT(path);
+
+	/* gets the relative path to /dev/ */
+	path += 5;
+
+	/* gets the vtab entry it matches */
+	if ((vtp = sdev_match(dv)) != NULL) {
+		dv->sdev_flags |= vtp->vt_flags;
+		if (SDEV_IS_PERSIST(dv->sdev_dotdot) &&
+		    (SDEV_IS_PERSIST(dv) || !SDEV_IS_DYNAMIC(dv)))
+			dv->sdev_flags |= SDEV_PERSIST;
+
+		if (vtp->vt_vops) {
+			if (vtp->vt_global_vops)
+				*(vtp->vt_global_vops) = vtp->vt_vops;
+
+			return (vtp->vt_vops);
+		}
+
+		if (vtp->vt_service) {
+			fs_operation_def_t *templ;
+			templ = sdev_merge_vtab(vtp->vt_service);
+			if (vn_make_ops(vtp->vt_name,
+			    (const fs_operation_def_t *)templ,
+			    &vtp->vt_vops) != 0) {
+				cmn_err(CE_PANIC, "%s: malformed vnode ops\n",
+				    vtp->vt_name);
+				/*NOTREACHED*/
+			}
+			if (vtp->vt_global_vops) {
+				*(vtp->vt_global_vops) = vtp->vt_vops;
+			}
+			sdev_free_vtab(templ);
+
+			return (vtp->vt_vops);
+		}
+
+		return (sdev_vnodeops);
+	}
+
+	/* child inherits the persistence of the parent */
+	if (SDEV_IS_PERSIST(dv->sdev_dotdot))
+		dv->sdev_flags |= SDEV_PERSIST;
+
+	return (sdev_vnodeops);
+}
+
+static void
+sdev_set_no_negcache(struct sdev_node *dv)
+{
+	int i;
+	char *path;
+
+	ASSERT(dv->sdev_path);
+	path = dv->sdev_path + strlen("/dev/");
+
+	for (i = 0; vtab[i].vt_name; i++) {
+		if (strcmp(vtab[i].vt_name, path) == 0) {
+			if (vtab[i].vt_flags & SDEV_NO_NCACHE)
+				dv->sdev_flags |= SDEV_NO_NCACHE;
+			break;
+		}
+	}
+}
+
+void *
+sdev_get_vtor(struct sdev_node *dv)
+{
+	struct sdev_vop_table *vtp;
+
+	vtp = sdev_match(dv);
+	if (vtp)
+		return ((void *)vtp->vt_vtor);
+	else
+		return (NULL);
+}
+
+/*
  * Build the base root inode
  */
 ino_t
@@ -810,11 +947,8 @@
 		dv->sdev_path = NULL;
 	}
 
-	if (!SDEV_IS_GLOBAL(dv)) {
+	if (!SDEV_IS_GLOBAL(dv))
 		sdev_prof_free(dv);
-		if (dv->sdev_vnode->v_type != VLNK && dv->sdev_origin != NULL)
-			SDEV_RELE(dv->sdev_origin);
-	}
 
 	if (SDEVTOV(dv)->v_type == VDIR) {
 		ASSERT(SDEV_FIRST_ENTRY(dv) == NULL);
@@ -2811,6 +2945,46 @@
 	return (error);
 }
 
+extern int sdev_vnodeops_tbl_size;
+
+/*
+ * construct a new template with overrides from vtab
+ */
+static fs_operation_def_t *
+sdev_merge_vtab(const fs_operation_def_t tab[])
+{
+	fs_operation_def_t *new;
+	const fs_operation_def_t *tab_entry;
+
+	/* make a copy of standard vnode ops table */
+	new = kmem_alloc(sdev_vnodeops_tbl_size, KM_SLEEP);
+	bcopy((void *)sdev_vnodeops_tbl, new, sdev_vnodeops_tbl_size);
+
+	/* replace the overrides from tab */
+	for (tab_entry = tab; tab_entry->name != NULL; tab_entry++) {
+		fs_operation_def_t *std_entry = new;
+		while (std_entry->name) {
+			if (strcmp(tab_entry->name, std_entry->name) == 0) {
+				std_entry->func = tab_entry->func;
+				break;
+			}
+			std_entry++;
+		}
+		if (std_entry->name == NULL)
+			cmn_err(CE_NOTE, "sdev_merge_vtab: entry %s unused.",
+			    tab_entry->name);
+	}
+
+	return (new);
+}
+
+/* free memory allocated by sdev_merge_vtab */
+static void
+sdev_free_vtab(fs_operation_def_t *new)
+{
+	kmem_free(new, sdev_vnodeops_tbl_size);
+}
+
 /*
  * a generic setattr() function
  *
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/uts/common/fs/lookup.c	Wed Oct  5 00:33:41 2016
+++ new/usr/src/uts/common/fs/lookup.c	Wed Oct  5 00:33:41 2016
@@ -21,7 +21,7 @@
 
 /*
  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
- * Copyright 2016 Joyent, Inc.
+ * Copyright (c) 2015, Joyent, Inc. All rights reserved.
  * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
@@ -979,109 +979,6 @@
 }
 
 /*
- * Clean a stale v_path from a vnode.  This is only performed if the v_path has
- * not been altered since it was found to be stale
- */
-static void
-vnode_clear_vpath(vnode_t *vp, char *vpath_old)
-{
-	mutex_enter(&vp->v_lock);
-	if (vp->v_path != vn_vpath_empty && vp->v_path == vpath_old) {
-		vp->v_path = vn_vpath_empty;
-		mutex_exit(&vp->v_lock);
-		kmem_free(vpath_old, strlen(vpath_old) + 1);
-	} else {
-		mutex_exit(&vp->v_lock);
-	}
-}
-
-/*
- * Validate that a pathname refers to a given vnode.
- */
-static int
-vnode_valid_pn(vnode_t *vp, vnode_t *vrootp, pathname_t *pn, pathname_t *rpn,
-    int flags, cred_t *cr)
-{
-	vnode_t *compvp;
-	/*
-	 * If we are in a zone or a chroot environment, then we have to
-	 * take additional steps, since the path to the root might not
-	 * be readable with the current credentials, even though the
-	 * process can legitmately access the file.  In this case, we
-	 * do the following:
-	 *
-	 * lookuppnvp() with all privileges to get the resolved path.
-	 * call localpath() to get the local portion of the path, and
-	 * continue as normal.
-	 *
-	 * If the the conversion to a local path fails, then we continue
-	 * as normal.  This is a heuristic to make process object file
-	 * paths available from within a zone.  Because lofs doesn't
-	 * support page operations, the vnode stored in the seg_t is
-	 * actually the underlying real vnode, not the lofs node itself.
-	 * Most of the time, the lofs path is the same as the underlying
-	 * vnode (for example, /usr/lib/libc.so.1).
-	 */
-	if (vrootp != rootdir) {
-		char *local = NULL;
-
-		VN_HOLD(rootdir);
-		if (lookuppnvp(pn, rpn, FOLLOW, NULL, &compvp, rootdir,
-		    rootdir, kcred) == 0) {
-			local = localpath(rpn->pn_path, vrootp, kcred);
-			VN_RELE(compvp);
-		}
-
-		/*
-		 * The original pn was changed through lookuppnvp().
-		 * Set it to local for next validation attempt.
-		 */
-		if (local) {
-			(void) pn_set(pn, local);
-		} else {
-			return (1);
-		}
-	}
-
-	/*
-	 * We should have a local path at this point, so start the search from
-	 * the root of the current process.
-	 */
-	VN_HOLD(vrootp);
-	if (vrootp != rootdir)
-		VN_HOLD(vrootp);
-	if (lookuppnvp(pn, rpn, FOLLOW | flags, NULL, &compvp, vrootp, vrootp,
-	    cr) == 0) {
-		/*
-		 * Check to see if the returned vnode is the same as the one we
-		 * expect.
-		 */
-		if (vn_compare(vp, compvp) ||
-		    vnode_match(vp, compvp, cr)) {
-			VN_RELE(compvp);
-			return (0);
-		} else {
-			VN_RELE(compvp);
-		}
-	}
-
-	return (1);
-}
-
-/*
- * Struct for tracking vnodes with invalidated v_path entries during a
- * dirtopath reverse lookup.  By keepeing adequate state, those vnode can be
- * revisted to populate v_path.
- */
-struct dirpath_walk {
-	struct dirpath_walk	*dw_next;
-	vnode_t			*dw_vnode;
-	vnode_t			*dw_pvnode;
-	size_t			dw_len;
-	char			*dw_name;
-};
-
-/*
  * Given a directory, return the full, resolved path.  This looks up "..",
  * searches for the given vnode in the parent, appends the component, etc.  It
  * is used to implement vnodetopath() and getcwd() when the cached path fails.
@@ -1090,14 +987,16 @@
 dirtopath(vnode_t *vrootp, vnode_t *vp, char *buf, size_t buflen, int flags,
     cred_t *cr)
 {
-	pathname_t	pn, rpn, emptypn;
-	vnode_t		*pvp = NULL, *startvp = vp;
-	int		err = 0;
-	size_t		complen;
-	dirent64_t	*dp;
-	char		*bufloc, *dbuf;
-	const size_t	dlen = DIRENT64_RECLEN(MAXPATHLEN);
-	struct dirpath_walk *dw_chain = NULL, *dw_entry;
+	pathname_t pn, rpn, emptypn;
+	vnode_t *cmpvp, *pvp = NULL;
+	vnode_t *startvp = vp;
+	int err = 0, vprivs;
+	size_t complen;
+	char *dbuf;
+	dirent64_t *dp;
+	char		*bufloc;
+	size_t		dlen = DIRENT64_RECLEN(MAXPATHLEN);
+	refstr_t	*mntpt;
 
 	/* Operation only allowed on directories */
 	ASSERT(vp->v_type == VDIR);
@@ -1122,9 +1021,6 @@
 	VN_HOLD(vp);
 
 	for (;;) {
-		int vprivs;
-		hrtime_t cached_stamp;
-
 		/*
 		 * Return if we've reached the root.  If the buffer is empty,
 		 * return '/'.  We explicitly don't use vn_compare(), since it
@@ -1149,33 +1045,85 @@
 		}
 
 		/*
+		 * Shortcut: see if this vnode is a mountpoint.  If so,
+		 * grab the path information from the vfs_t.
+		 */
+		if (vp->v_flag & VROOT) {
+
+			mntpt = vfs_getmntpoint(vp->v_vfsp);
+			if ((err = pn_set(&pn, (char *)refstr_value(mntpt)))
+			    == 0) {
+				refstr_rele(mntpt);
+				rpn.pn_path = rpn.pn_buf;
+
+				/*
+				 * Ensure the mountpoint still exists.
+				 */
+				VN_HOLD(vrootp);
+				if (vrootp != rootdir)
+					VN_HOLD(vrootp);
+				if (lookuppnvp(&pn, &rpn, flags, NULL,
+				    &cmpvp, vrootp, vrootp, cr) == 0) {
+
+					if (VN_CMP(vp, cmpvp)) {
+						VN_RELE(cmpvp);
+
+						complen = strlen(rpn.pn_path);
+						bufloc -= complen;
+						if (bufloc < buf) {
+							err = ERANGE;
+							goto out;
+						}
+						bcopy(rpn.pn_path, bufloc,
+						    complen);
+						break;
+					} else {
+						VN_RELE(cmpvp);
+					}
+				}
+			} else {
+				refstr_rele(mntpt);
+			}
+		}
+
+		/*
 		 * Shortcut: see if this vnode has correct v_path. If so,
 		 * we have the work done.
 		 */
 		mutex_enter(&vp->v_lock);
-		if (vp->v_path != vn_vpath_empty &&
-		    pn_set(&pn, vp->v_path) == 0) {
-			cached_stamp = vp->v_path_stamp;
-			mutex_exit(&vp->v_lock);
-			rpn.pn_path = rpn.pn_buf;
+		if (vp->v_path != NULL) {
 
-			/* Ensure the v_path pointing to correct vnode */
-			if (vnode_valid_pn(vp, vrootp, &pn, &rpn, flags,
-			    cr) == 0) {
-				complen = strlen(rpn.pn_path);
-				bufloc -= complen;
-				if (bufloc < buf) {
-					err = ERANGE;
-					goto out;
-				}
-				bcopy(rpn.pn_path, bufloc, complen);
-				break;
-			} else {
+			if ((err = pn_set(&pn, vp->v_path)) == 0) {
+				mutex_exit(&vp->v_lock);
+				rpn.pn_path = rpn.pn_buf;
+
 				/*
-				 * Immediately nuke cached v_path entries known
-				 * to be invalid.
+				 * Ensure the v_path pointing to correct vnode
 				 */
-				vn_clearpath(vp, cached_stamp);
+				VN_HOLD(vrootp);
+				if (vrootp != rootdir)
+					VN_HOLD(vrootp);
+				if (lookuppnvp(&pn, &rpn, flags, NULL,
+				    &cmpvp, vrootp, vrootp, cr) == 0) {
+
+					if (VN_CMP(vp, cmpvp)) {
+						VN_RELE(cmpvp);
+
+						complen = strlen(rpn.pn_path);
+						bufloc -= complen;
+						if (bufloc < buf) {
+							err = ERANGE;
+							goto out;
+						}
+						bcopy(rpn.pn_path, bufloc,
+						    complen);
+						break;
+					} else {
+						VN_RELE(cmpvp);
+					}
+				}
+			} else {
+				mutex_exit(&vp->v_lock);
 			}
 		} else {
 			mutex_exit(&vp->v_lock);
@@ -1220,6 +1168,38 @@
 		}
 
 		/*
+		 * Try to obtain the path component from dnlc cache
+		 * before searching through the directory.
+		 */
+		if ((cmpvp = dnlc_reverse_lookup(vp, dbuf, dlen)) != NULL) {
+			/*
+			 * If we got parent vnode as a result,
+			 * then the answered path is correct.
+			 */
+			if (VN_CMP(cmpvp, pvp)) {
+				VN_RELE(cmpvp);
+				complen = strlen(dbuf);
+				bufloc -= complen;
+				if (bufloc <= buf) {
+					err = ENAMETOOLONG;
+					goto out;
+				}
+				bcopy(dbuf, bufloc, complen);
+
+				/* Prepend a slash to the current path */
+				*--bufloc = '/';
+
+				/* And continue with the next component */
+				VN_RELE(vp);
+				vp = pvp;
+				pvp = NULL;
+				continue;
+			} else {
+				VN_RELE(cmpvp);
+			}
+		}
+
+		/*
 		 * Search the parent directory for the entry corresponding to
 		 * this vnode.
 		 */
@@ -1237,19 +1217,6 @@
 		/* Prepend a slash to the current path.  */
 		*--bufloc = '/';
 
-		/*
-		 * Record the name and directory for later reconstruction and
-		 * link it up with the others.
-		 */
-		dw_entry = kmem_alloc(sizeof (*dw_entry), KM_SLEEP);
-		dw_entry->dw_name = kmem_alloc(complen + 1, KM_SLEEP);
-		VN_HOLD(dw_entry->dw_vnode = vp);
-		VN_HOLD(dw_entry->dw_pvnode = pvp);
-		bcopy(dp->d_name, dw_entry->dw_name, complen + 1);
-		dw_entry->dw_len = complen;
-		dw_entry->dw_next = dw_chain;
-		dw_chain = dw_entry;
-
 		/* And continue with the next component */
 		VN_RELE(vp);
 		vp = pvp;
@@ -1264,37 +1231,6 @@
 
 out:
 	/*
-	 * Walk over encountered directory entries which were afflicted with a
-	 * stale or absent v_path.  If the dirtopath was successful, we should
-	 * possess the necessary information to populate all of them with a
-	 * valid v_path.
-	 *
-	 * While processing this list, it is safe to call vn_setpath despite
-	 * the fact that racing vnode actions may have altered v_path entries
-	 * while the above loopwas still executing.  Any updated entries will
-	 * have a newer v_path_stamp value which prevents an invalid overwrite.
-	 *
-	 * If an error was encountered during the search, freeing the chain is
-	 * still required.
-	 */
-	dw_entry = dw_chain;
-	while (dw_entry != NULL) {
-		struct dirpath_walk *next = dw_entry->dw_next;
-
-		if (err == 0) {
-			vn_setpath(NULL, dw_entry->dw_pvnode,
-			    dw_entry->dw_vnode, dw_entry->dw_name,
-			    dw_entry->dw_len);
-		}
-
-		VN_RELE(dw_entry->dw_vnode);
-		VN_RELE(dw_entry->dw_pvnode);
-		kmem_free(dw_entry->dw_name, dw_entry->dw_len + 1);
-		kmem_free(dw_entry, sizeof (*dw_entry));
-		dw_entry = next;
-	}
-
-	/*
 	 * If the error was ESTALE and the current directory to look in
 	 * was the root for this lookup, the root for a mounted file
 	 * system, or the starting directory for lookups, then
@@ -1334,10 +1270,12 @@
 vnodetopath_common(vnode_t *vrootp, vnode_t *vp, char *buf, size_t buflen,
     cred_t *cr, int flags)
 {
-	pathname_t pn;
-	int ret = 0;
-	vnode_t *realvp;
-	boolean_t doclose = B_FALSE;
+	pathname_t pn, rpn;
+	int ret, len;
+	vnode_t *compvp, *pvp, *realvp;
+	proc_t *p = curproc;
+	char path[MAXNAMELEN];
+	int doclose = 0;
 
 	/*
 	 * If vrootp is NULL, get the root for curproc.  Callers with any other
@@ -1344,8 +1282,6 @@
 	 * requirements should pass in a different vrootp.
 	 */
 	if (vrootp == NULL) {
-		proc_t *p = curproc;
-
 		mutex_enter(&p->p_lock);
 		if ((vrootp = PTOU(p)->u_rdir) == NULL)
 			vrootp = rootdir;
@@ -1367,59 +1303,163 @@
 	    realvp != vp) {
 		VN_HOLD(vp);
 		if (VOP_OPEN(&vp, FREAD, cr, NULL) == 0)
-			doclose = B_TRUE;
+			doclose = 1;
 		else
 			VN_RELE(vp);
 	}
 
+	pn_alloc(&pn);
+
 	/*
-	 * Check to see if we have a valid cached path in the vnode.
+	 * Check to see if we have a cached path in the vnode.
 	 */
-	pn_alloc(&pn);
 	mutex_enter(&vp->v_lock);
-	if (vp->v_path != vn_vpath_empty) {
-		hrtime_t cached_stamp;
-		pathname_t rpn;
-
-		cached_stamp = vp->v_path_stamp;
+	if (vp->v_path != NULL) {
 		(void) pn_set(&pn, vp->v_path);
 		mutex_exit(&vp->v_lock);
 
+		pn_alloc(&rpn);
+
 		/* We should only cache absolute paths */
 		ASSERT(pn.pn_buf[0] == '/');
 
-		pn_alloc(&rpn);
-		if (vnode_valid_pn(vp, vrootp, &pn, &rpn, flags, cr) == 0) {
-			/* Return the result, if we're able. */
-			if (buflen > rpn.pn_pathlen) {
-				bcopy(rpn.pn_path, buf, rpn.pn_pathlen + 1);
+		/*
+		 * If we are in a zone or a chroot environment, then we have to
+		 * take additional steps, since the path to the root might not
+		 * be readable with the current credentials, even though the
+		 * process can legitmately access the file.  In this case, we
+		 * do the following:
+		 *
+		 * lookuppnvp() with all privileges to get the resolved path.
+		 * call localpath() to get the local portion of the path, and
+		 * continue as normal.
+		 *
+		 * If the the conversion to a local path fails, then we continue
+		 * as normal.  This is a heuristic to make process object file
+		 * paths available from within a zone.  Because lofs doesn't
+		 * support page operations, the vnode stored in the seg_t is
+		 * actually the underlying real vnode, not the lofs node itself.
+		 * Most of the time, the lofs path is the same as the underlying
+		 * vnode (for example, /usr/lib/libc.so.1).
+		 */
+		if (vrootp != rootdir) {
+			char *local = NULL;
+			VN_HOLD(rootdir);
+			if (lookuppnvp(&pn, &rpn, FOLLOW,
+			    NULL, &compvp, rootdir, rootdir, kcred) == 0) {
+				local = localpath(rpn.pn_path, vrootp,
+				    kcred);
+				VN_RELE(compvp);
+			}
+
+			/*
+			 * The original pn was changed through lookuppnvp().
+			 * Set it to local for next validation attempt.
+			 */
+			if (local) {
+				(void) pn_set(&pn, local);
 			} else {
-				ret = ENAMETOOLONG;
+				goto notcached;
 			}
+		}
+
+		/*
+		 * We should have a local path at this point, so start the
+		 * search from the root of the current process.
+		 */
+		VN_HOLD(vrootp);
+		if (vrootp != rootdir)
+			VN_HOLD(vrootp);
+		ret = lookuppnvp(&pn, &rpn, FOLLOW | flags, NULL,
+		    &compvp, vrootp, vrootp, cr);
+		if (ret == 0) {
+			/*
+			 * Check to see if the returned vnode is the same as
+			 * the one we expect.  If not, give up.
+			 */
+			if (!vn_compare(vp, compvp) &&
+			    !vnode_match(vp, compvp, cr)) {
+				VN_RELE(compvp);
+				goto notcached;
+			}
+
+			VN_RELE(compvp);
+
+			/*
+			 * Return the result.
+			 */
+			if (buflen <= rpn.pn_pathlen)
+				goto notcached;
+
+			bcopy(rpn.pn_path, buf, rpn.pn_pathlen + 1);
 			pn_free(&pn);
 			pn_free(&rpn);
-			goto out;
+			VN_RELE(vrootp);
+			if (doclose) {
+				(void) VOP_CLOSE(vp, FREAD, 1, 0, cr, NULL);
+				VN_RELE(vp);
+			}
+			return (0);
 		}
+
+notcached:
 		pn_free(&rpn);
-		vn_clearpath(vp, cached_stamp);
 	} else {
 		mutex_exit(&vp->v_lock);
 	}
+
 	pn_free(&pn);
 
-	if (vp->v_type != VDIR) {
+	if (PROC_IS_BRANDED(curproc)) {
 		/*
-		 * The reverse lookup tricks used by dirtopath aren't possible
-		 * for non-directory entries.  The best which can be done is
-		 * clearing any stale v_path so later lookups can potentially
-		 * repopulate it with a valid path.
+		 * If v_path doesn't work out and we're in a branded zone,
+		 * we're not going to bother doing more work here:  because
+		 * directories from the global can be lofs mounted into odd
+		 * locations (e.g., /native in an lx zone), it is likely that
+		 * the DNLC reverse lookup will yield nothing.  Indeed, the
+		 * only certainty is that the DNLC reverse lookup will be
+		 * exceedingly painful; we save ourselves the substantial
+		 * grief of scanning the entire DNLC and kick out with ENOENT
+		 * in this case.
 		 */
 		ret = ENOENT;
-	} else {
+	} else if (vp->v_type != VDIR) {
+		/*
+		 * If we don't have a directory, try to find it in the dnlc via
+		 * reverse lookup.  Once this is found, we can use the regular
+		 * directory search to find the full path.
+		 */
+		if ((pvp = dnlc_reverse_lookup(vp, path, MAXNAMELEN)) != NULL) {
+			/*
+			 * Check if we have read privilege so, that
+			 * we can lookup the path in the directory
+			 */
+			ret = 0;
+			if ((flags & LOOKUP_CHECKREAD)) {
+				ret = VOP_ACCESS(pvp, VREAD, 0, cr, NULL);
+			}
+			if (ret == 0) {
+				ret = dirtopath(vrootp, pvp, buf, buflen,
+				    flags, cr);
+			}
+			if (ret == 0) {
+				len = strlen(buf);
+				if (len + strlen(path) + 1 >= buflen) {
+					ret = ENAMETOOLONG;
+				} else {
+					if (buf[len - 1] != '/')
+						buf[len++] = '/';
+					bcopy(path, buf + len,
+					    strlen(path) + 1);
+				}
+			}
+
+			VN_RELE(pvp);
+		} else
+			ret = ENOENT;
+	} else
 		ret = dirtopath(vrootp, vp, buf, buflen, flags, cr);
-	}
 
-out:
 	VN_RELE(vrootp);
 	if (doclose) {
 		(void) VOP_CLOSE(vp, FREAD, 1, 0, cr, NULL);
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/uts/common/fs/sockfs/sockcommon_sops.c	Wed Oct  5 00:33:43 2016
+++ new/usr/src/uts/common/fs/sockfs/sockcommon_sops.c	Wed Oct  5 00:33:43 2016
@@ -24,7 +24,7 @@
  */
 
 /*
- * Copyright (c) 2015, Joyent, Inc.  All rights reserved.
+ * Copyright (c) 2014, Joyent, Inc.  All rights reserved.
  */
 
 #include <sys/types.h>
@@ -1324,26 +1324,6 @@
 		}
 	}
 
-	mutex_enter(&so->so_lock);
-	if (so->so_krecv_cb != NULL) {
-		boolean_t cont;
-		so_krecv_f func = so->so_krecv_cb;
-		void *arg = so->so_krecv_arg;
-
-		mutex_exit(&so->so_lock);
-		cont = func(so, mp, msg_size, flags & MSG_OOB, arg);
-		mutex_enter(&so->so_lock);
-		if (cont == B_TRUE) {
-			space_left = so->so_rcvbuf;
-		} else {
-			so->so_rcv_queued = so->so_rcvlowat;
-			*errorp = ENOSPC;
-			space_left = -1;
-		}
-		goto done_unlock;
-	}
-	mutex_exit(&so->so_lock);
-
 	if (flags & MSG_OOB) {
 		so_queue_oob(so, mp, msg_size);
 		mutex_enter(&so->so_lock);
@@ -1622,13 +1602,6 @@
 		return (ENOTCONN);
 	}
 
-	mutex_enter(&so->so_lock);
-	if (so->so_krecv_cb != NULL) {
-		mutex_exit(&so->so_lock);
-		return (EOPNOTSUPP);
-	}
-	mutex_exit(&so->so_lock);
-
 	if (msg->msg_flags & MSG_PEEK)
 		msg->msg_flags &= ~MSG_WAITALL;
 
--- old/usr/src/uts/common/fs/sockfs/sockcommon_subr.c	Wed Oct  5 00:33:43 2016
+++ new/usr/src/uts/common/fs/sockfs/sockcommon_subr.c	Wed Oct  5 00:33:43 2016
@@ -24,7 +24,6 @@
  */
 /*
  * Copyright 2014, OmniTI Computer Consulting, Inc. All rights reserved.
- * Copyright 2015 Joyent, Inc.
  */
 
 #include <sys/types.h>
@@ -2292,9 +2291,9 @@
 	fbfunc = sp->sp_smod_info->smod_proto_fallback_func;
 
 	/*
-	 * Cannot fallback if the socket has active filters or a krecv callback.
+	 * Cannot fallback if the socket has active filters
 	 */
-	if (so->so_filter_active > 0 || so->so_krecv_cb != NULL)
+	if (so->so_filter_active > 0)
 		return (EINVAL);
 
 	switch (so->so_family) {
@@ -2471,51 +2470,4 @@
 		freemsg(arg.soqa_urgmark_mp);
 
 	return (error);
-}
-
-int
-so_krecv_set(sonode_t *so, so_krecv_f cb, void *arg)
-{
-	int ret;
-
-	if (cb == NULL && arg != NULL)
-		return (EINVAL);
-
-	SO_BLOCK_FALLBACK(so, so_krecv_set(so, cb, arg));
-
-	mutex_enter(&so->so_lock);
-	if (so->so_state & SS_FALLBACK_COMP) {
-		mutex_exit(&so->so_lock);
-		SO_UNBLOCK_FALLBACK(so);
-		return (ENOTSUP);
-	}
-
-	ret = so_lock_read(so, 0);
-	VERIFY(ret == 0);
-	/*
-	 * Other consumers may actually care about getting extant data delivered
-	 * to them, when they come along, they should figure out the best API
-	 * for that.
-	 */
-	so_rcv_flush(so);
-
-	so->so_krecv_cb = cb;
-	so->so_krecv_arg = arg;
-
-	so_unlock_read(so);
-	mutex_exit(&so->so_lock);
-	SO_UNBLOCK_FALLBACK(so);
-
-	return (0);
-}
-
-void
-so_krecv_unblock(sonode_t *so)
-{
-	mutex_enter(&so->so_lock);
-	VERIFY(so->so_krecv_cb != NULL);
-
-	so->so_rcv_queued = 0;
-	(void) so_check_flow_control(so);
-	mutex_exit(&so->so_lock);
 }
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/uts/common/fs/tmpfs/tmp_subr.c	Wed Oct  5 00:33:44 2016
+++ new/usr/src/uts/common/fs/tmpfs/tmp_subr.c	Wed Oct  5 00:33:44 2016
@@ -20,7 +20,7 @@
  */
 /*
  * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2016 Joyent, Inc.
+ * Copyright 2015 Joyent, Inc.
  */
 
 #include <sys/types.h>
@@ -43,7 +43,6 @@
 #include <sys/fs/tmpnode.h>
 #include <sys/ddi.h>
 #include <sys/sunddi.h>
-#include <vm/anon.h>
 
 #define	KILOBYTE	1024
 #define	MEGABYTE	(1024 * KILOBYTE)
@@ -55,80 +54,6 @@
 
 extern pgcnt_t swapfs_minfree;
 
-void *
-tmp_kmem_zalloc(struct tmount *tm, size_t size, int flag)
-{
-	void *buf;
-	zone_t *zone;
-	size_t pages;
-
-	mutex_enter(&tm->tm_contents);
-	zone = tm->tm_vfsp->vfs_zone;
-	if (tm->tm_anonmem + size > tm->tm_anonmax ||
-	    tm->tm_anonmem + size < tm->tm_anonmem ||
-	    size + ptob(tmpfs_minfree) <= size ||
-	    !anon_checkspace(size + ptob(tmpfs_minfree), zone)) {
-		mutex_exit(&tm->tm_contents);
-		return (NULL);
-	}
-
-	/*
-	 * Only make anonymous memory reservations when a page boundary is
-	 * crossed.  This is necessary since the anon_resv functions rounds up
-	 * to PAGESIZE internally.
-	 */
-	pages = btopr(tm->tm_allocmem + size);
-	pages -= btopr(tm->tm_allocmem);
-	if (pages > 0 && anon_try_resv_zone(ptob(pages), zone) == 0) {
-		mutex_exit(&tm->tm_contents);
-		return (NULL);
-	}
-
-	tm->tm_allocmem += size;
-	tm->tm_anonmem += size;
-	mutex_exit(&tm->tm_contents);
-
-	buf = kmem_zalloc(size, flag);
-	if (buf == NULL) {
-		mutex_enter(&tm->tm_contents);
-		ASSERT(tm->tm_anonmem > tm->tm_anonmem - size);
-		tm->tm_anonmem -= size;
-		if (pages > 0) {
-			/*
-			 * Re-chasing the zone pointer is necessary since a
-			 * forced umount could have been performed while the
-			 * tm_contents lock was dropped during allocation.
-			 */
-			anon_unresv_zone(ptob(pages), tm->tm_vfsp->vfs_zone);
-		}
-		mutex_exit(&tm->tm_contents);
-	}
-
-	return (buf);
-}
-
-void
-tmp_kmem_free(struct tmount *tm, void *buf, size_t size)
-{
-	size_t pages;
-
-	kmem_free(buf, size);
-	mutex_enter(&tm->tm_contents);
-	ASSERT(tm->tm_anonmem > tm->tm_anonmem - size);
-	tm->tm_anonmem -= size;
-	pages = btopr(tm->tm_allocmem);
-	tm->tm_allocmem -= size;
-	pages -= btopr(tm->tm_allocmem);
-	/*
-	 * Like the tmp_kmem_zalloc case, only unreserve anonymous memory when
-	 * a page boundary has been crossed.
-	 */
-	if (pages > 0) {
-		anon_unresv_zone(size, tm->tm_vfsp->vfs_zone);
-	}
-	mutex_exit(&tm->tm_contents);
-}
-
 int
 tmp_taccess(void *vtp, int mode, struct cred *cred)
 {
@@ -159,7 +84,7 @@
  */
 int
 tmp_sticky_remove_access(struct tmpnode *dir, struct tmpnode *entry,
-    struct cred *cr)
+	struct cred *cr)
 {
 	uid_t uid = crgetuid(cr);
 
@@ -174,8 +99,42 @@
 }
 
 /*
- * Convert a string containing a number (number of bytes) to a size_t,
- * containing the corresponding number of bytes. On 32-bit kernels, the
+ * Allocate zeroed memory if tmpfs_maxkmem has not been exceeded
+ * or the 'musthave' flag is set.  'musthave' allocations should
+ * always be subordinate to normal allocations so that tmpfs_maxkmem
+ * can't be exceeded by more than a few KB.  Example: when creating
+ * a new directory, the tmpnode is a normal allocation; if that
+ * succeeds, the dirents for "." and ".." are 'musthave' allocations.
+ */
+void *
+tmp_memalloc(size_t size, int musthave)
+{
+	static time_t last_warning;
+	time_t now;
+
+	if (atomic_add_long_nv(&tmp_kmemspace, size) < tmpfs_maxkmem ||
+	    musthave)
+		return (kmem_zalloc(size, KM_SLEEP));
+
+	atomic_add_long(&tmp_kmemspace, -size);
+	now = gethrestime_sec();
+	if (last_warning != now) {
+		last_warning = now;
+		cmn_err(CE_WARN, "tmp_memalloc: tmpfs over memory limit");
+	}
+	return (NULL);
+}
+
+void
+tmp_memfree(void *cp, size_t size)
+{
+	kmem_free(cp, size);
+	atomic_add_long(&tmp_kmemspace, -size);
+}
+
+/*
+ * Convert a string containing a number (number of bytes) to a pgcnt_t,
+ * containing the corresponding number of pages. On 32-bit kernels, the
  * maximum value encoded in 'str' is PAGESIZE * ULONG_MAX, while the value
  * returned in 'maxpg' is at most ULONG_MAX.
  *
@@ -193,12 +152,14 @@
  * error.
  */
 int
-tmp_convnum(char *str, size_t *maxbytes)
+tmp_convnum(char *str, pgcnt_t *maxpg)
 {
 	u_longlong_t num = 0;
-	u_longlong_t max_bytes = (uint64_t)SIZE_MAX;
-	size_t pages;
-
+#ifdef _LP64
+	u_longlong_t max_bytes = ULONG_MAX;
+#else
+	u_longlong_t max_bytes = PAGESIZE * (uint64_t)ULONG_MAX;
+#endif
 	char *c;
 	const struct convchar {
 		char *cc_char;
@@ -288,23 +249,14 @@
 	}
 
 done:
-
 	/*
-	 * We've been given a size in bytes; however, we want to make sure that
-	 * we have at least one page worth no matter what. Therefore we use
-	 * btopr to round up. However, this may cause an overflow only if 'num'
-	 * is between (max_bytes - PAGESIZE) and (max_bytes). In this case the
-	 * resulting number is zero, which is what we check for below. Note, we
-	 * require at least one page, so if pages is zero, well, it wasn't going
-	 * to work anyways.
+	 * Since btopr() rounds up to page granularity, this round-up can
+	 * cause an overflow only if 'num' is between (max_bytes - PAGESIZE)
+	 * and (max_bytes). In this case the resulting number is zero, which
+	 * is what we check for below.
 	 */
-	pages = btopr(num);
-	if (pages == 0) {
+	if ((*maxpg = (pgcnt_t)btopr(num)) == 0 && num != 0)
 		return (EINVAL);
-	}
-
-	*maxbytes = ptob(pages);
-
 	return (0);
 }
 
--- old/usr/src/uts/common/fs/tmpfs/tmp_vfsops.c	Wed Oct  5 00:33:44 2016
+++ new/usr/src/uts/common/fs/tmpfs/tmp_vfsops.c	Wed Oct  5 00:33:44 2016
@@ -20,7 +20,7 @@
  */
 /*
  * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2016 Joyent, Inc.
+ * Copyright 2015 Joyent, Inc.
  */
 
 #include <sys/types.h>
@@ -56,15 +56,6 @@
 static int tmpfsfstype;
 
 /*
- * tmpfs_mountcount is used to prevent module unloads while there is still
- * state from a former mount hanging around. With forced umount support, the
- * filesystem module must not be allowed to go away before the last
- * VFS_FREEVFS() call has been made. Since this is just an atomic counter,
- * there's no need for locking.
- */
-static uint32_t	tmpfs_mountcount;
-
-/*
  * tmpfs vfs operations.
  */
 static int tmpfsinit(int, char *);
@@ -74,7 +65,6 @@
 static int tmp_root(struct vfs *, struct vnode **);
 static int tmp_statvfs(struct vfs *, struct statvfs64 *);
 static int tmp_vget(struct vfs *, struct vnode **, struct fid *);
-static void tmp_freevfs(vfs_t *vfsp);
 
 /*
  * Loadable module wrapper
@@ -133,14 +123,6 @@
 {
 	int error;
 
-	/*
-	 * If a forceably unmounted instance is still hanging around, we cannot
-	 * allow the module to be unloaded because that would cause panics once
-	 * the VFS framework decides it's time to call into VFS_FREEVFS().
-	 */
-	if (tmpfs_mountcount)
-		return (EBUSY);
-
 	error = mod_remove(&modlinkage);
 	if (error)
 		return (error);
@@ -159,6 +141,14 @@
 }
 
 /*
+ * The following are patchable variables limiting the amount of system
+ * resources tmpfs can use.
+ *
+ * tmpfs_maxkmem limits the amount of kernel kmem_alloc memory
+ * tmpfs can use for it's data structures (e.g. tmpnodes, directory entries)
+ * It is not determined by setting a hard limit but rather as a percentage of
+ * physical memory which is determined when tmpfs is first used in the system.
+ *
  * tmpfs_minfree is the minimum amount of swap space that tmpfs leaves for
  * the rest of the system.  In other words, if the amount of free swap space
  * in the system (i.e. anoninfo.ani_free) drops below tmpfs_minfree, tmpfs
@@ -167,7 +157,9 @@
  * There is also a per mount limit on the amount of swap space
  * (tmount.tm_anonmax) settable via a mount option.
  */
+size_t tmpfs_maxkmem = 0;
 size_t tmpfs_minfree = 0;
+size_t tmp_kmemspace;		/* bytes of kernel heap used by all tmpfs */
 
 static major_t tmpfs_major;
 static minor_t tmpfs_minor;
@@ -186,7 +178,6 @@
 		VFSNAME_ROOT,		{ .vfs_root = tmp_root },
 		VFSNAME_STATVFS,	{ .vfs_statvfs = tmp_statvfs },
 		VFSNAME_VGET,		{ .vfs_vget = tmp_vget },
-		VFSNAME_FREEVFS,	{ .vfs_freevfs = tmp_freevfs },
 		NULL,			NULL
 	};
 	int error;
@@ -221,12 +212,18 @@
 		tmpfs_minfree = btopr(TMPMINFREE);
 	}
 
+	/*
+	 * The maximum amount of space tmpfs can allocate is
+	 * TMPMAXPROCKMEM percent of kernel memory
+	 */
+	if (tmpfs_maxkmem == 0)
+		tmpfs_maxkmem = MAX(PAGESIZE, kmem_maxavail() / TMPMAXFRACKMEM);
+
 	if ((tmpfs_major = getudev()) == (major_t)-1) {
 		cmn_err(CE_WARN, "tmpfsinit: Can't get unique device number.");
 		tmpfs_major = 0;
 	}
 	mutex_init(&tmpfs_minor_lock, NULL, MUTEX_DEFAULT, NULL);
-	tmpfs_mountcount = 0;
 	return (0);
 }
 
@@ -237,7 +234,7 @@
 	struct tmpnode *tp;
 	struct pathname dpn;
 	int error;
-	size_t anonmax;
+	pgcnt_t anonmax;
 	struct vattr rattr;
 	int got_attrs;
 	boolean_t mode_arg = B_FALSE;
@@ -281,7 +278,7 @@
 		if ((error = tmp_convnum(argstr, &anonmax)) != 0)
 			goto out;
 	} else {
-		anonmax = SIZE_MAX;
+		anonmax = ULONG_MAX;
 	}
 
 	/*
@@ -314,8 +311,7 @@
 		goto out;
 	}
 
-	if ((tm = kmem_zalloc(sizeof (struct tmount),
-	    KM_NOSLEEP | KM_NORMALPRI)) == NULL) {
+	if ((tm = tmp_memalloc(sizeof (struct tmount), 0)) == NULL) {
 		pn_free(&dpn);
 		error = ENOMEM;
 		goto out;
@@ -347,20 +343,10 @@
 	vfsp->vfs_bsize = PAGESIZE;
 	vfsp->vfs_flag |= VFS_NOTRUNC;
 	vfs_make_fsid(&vfsp->vfs_fsid, tm->tm_dev, tmpfsfstype);
-	tm->tm_mntpath = kmem_zalloc(dpn.pn_pathlen + 1, KM_SLEEP);
+	tm->tm_mntpath = tmp_memalloc(dpn.pn_pathlen + 1, TMP_MUSTHAVE);
 	(void) strcpy(tm->tm_mntpath, dpn.pn_path);
 
 	/*
-	 * Preemptively set vfs_zone before any of the tmp_kmem_* functions are
-	 * called.  That field is not populated until after a successful
-	 * VFS_MOUNT when domount() sets vfsp metadata via vfs_add().  An
-	 * accurate value is required for proper swap usage accounting.
-	 */
-	ASSERT0(uap->flags & MS_REMOUNT);
-	ASSERT(vfsp->vfs_zone == NULL);
-	vfsp->vfs_zone = curproc->p_zone;
-
-	/*
 	 * allocate and initialize root tmpnode structure
 	 */
 	bzero(&rattr, sizeof (struct vattr));
@@ -367,17 +353,7 @@
 	rattr.va_mode = (mode_t)(S_IFDIR | root_mode);
 	rattr.va_type = VDIR;
 	rattr.va_rdev = 0;
-	tp = tmp_kmem_zalloc(tm, sizeof (struct tmpnode), KM_SLEEP);
-	if (tp == NULL) {
-		kmem_free(tm->tm_mntpath, strlen(tm->tm_mntpath) + 1);
-		mutex_destroy(&tm->tm_contents);
-		mutex_destroy(&tm->tm_renamelck);
-		kmem_free(tm, sizeof (struct tmount));
-
-		pn_free(&dpn);
-		error = ENOMEM;
-		goto out;
-	}
+	tp = tmp_memalloc(sizeof (struct tmpnode), TMP_MUSTHAVE);
 	tmpnode_init(tm, tp, &rattr, cr);
 
 	/*
@@ -416,34 +392,12 @@
 	tp->tn_nlink = 0;
 	tm->tm_rootnode = tp;
 
-	if (tdirinit(tp, tp) != 0) {
-		/*
-		 * While we would normally let our VOP_INACTIVE function take
-		 * care of cleaning up here, we're in a bit of a delicate
-		 * situation, so we do so manually. While it's tempting to try
-		 * and rely upon tmpfs_freevfs() and others, it's probably safer
-		 * for the time to do this manually at the cost of duplication.
-		 */
-		vn_invalid(TNTOV(tp));
-		rw_destroy(&tp->tn_rwlock);
-		mutex_destroy(&tp->tn_tlock);
-		vn_free(TNTOV(tp));
-		tmp_kmem_free(tm, tp, sizeof (struct tmpnode));
+	tdirinit(tp, tp);
 
-		kmem_free(tm->tm_mntpath, strlen(tm->tm_mntpath) + 1);
-		mutex_destroy(&tm->tm_contents);
-		mutex_destroy(&tm->tm_renamelck);
-		kmem_free(tm, sizeof (struct tmount));
-		pn_free(&dpn);
-		error = ENOMEM;
-		goto out;
-	}
-
 	rw_exit(&tp->tn_rwlock);
 
 	pn_free(&dpn);
 	error = 0;
-	atomic_inc_32(&tmpfs_mountcount);
 
 out:
 	if (error == 0)
@@ -459,107 +413,36 @@
 	struct tmpnode *tnp, *cancel;
 	struct vnode	*vp;
 	int error;
-	uint_t cnt;
-	int i;
 
 	if ((error = secpolicy_fs_unmount(cr, vfsp)) != 0)
 		return (error);
 
+	/*
+	 * forced unmount is not supported by this file system
+	 * and thus, ENOTSUP, is being returned.
+	 */
+	if (flag & MS_FORCE)
+		return (ENOTSUP);
+
 	mutex_enter(&tm->tm_contents);
 
 	/*
-	 * In the normal unmount case (non-forced unmount), if there are no
-	 * open files, only the root node should have a reference count.
-	 *
+	 * If there are no open files, only the root node should have
+	 * a reference count.
 	 * With tm_contents held, nothing can be added or removed.
 	 * There may be some dirty pages.  To prevent fsflush from
 	 * disrupting the unmount, put a hold on each node while scanning.
 	 * If we find a previously referenced node, undo the holds we have
 	 * placed and fail EBUSY.
-	 *
-	 * However, in the case of a forced umount, things are a bit different.
-	 * An additional VFS_HOLD is added for each outstanding VN_HOLD to
-	 * ensure that the file system is not cleaned up (tmp_freevfs) until
-	 * the last vfs hold is dropped. This happens in tmp_inactive as the
-	 * vnodes are released. Also, we can't add an additional VN_HOLD in
-	 * this case since that would prevent tmp_inactive from ever being
-	 * called. Finally, we do need to drop the zone ref now (zone_rele_ref)
-	 * so that the zone is not blocked waiting for the final file system
-	 * cleanup.
 	 */
 	tnp = tm->tm_rootnode;
-
-	vp = TNTOV(tnp);
-	mutex_enter(&vp->v_lock);
-	cnt = vp->v_count;
-	if (flag & MS_FORCE) {
-		vfsp->vfs_flag |= VFS_UNMOUNTED;
-		/* Extra hold which we rele below when we drop the zone ref */
-		VFS_HOLD(vfsp);
-
-		for (i = 1; i < cnt; i++)
-			VFS_HOLD(vfsp);
-
-		/* drop the mutex now because no one can find this mount */
+	if (TNTOV(tnp)->v_count > 1) {
 		mutex_exit(&tm->tm_contents);
-	} else if (cnt > 1) {
-		mutex_exit(&vp->v_lock);
-		mutex_exit(&tm->tm_contents);
 		return (EBUSY);
 	}
-	mutex_exit(&vp->v_lock);
 
-	/*
-	 * Check for open files. An open file causes everything to unwind
-	 * unless this is a forced umount.
-	 */
 	for (tnp = tnp->tn_forw; tnp; tnp = tnp->tn_forw) {
-		vp = TNTOV(tnp);
-		mutex_enter(&vp->v_lock);
-		cnt = vp->v_count;
-		if (flag & MS_FORCE) {
-			for (i = 0; i < cnt; i++)
-				VFS_HOLD(vfsp);
-
-			/*
-			 * In the case of a forced umount don't add an
-			 * additional VN_HOLD on the already held vnodes, like
-			 * we do in the non-forced unmount case. If the
-			 * cnt > 0, then the vnode already has at least one
-			 * hold and we need tmp_inactive to get called when the
-			 * last pre-existing hold on the node is released so
-			 * that we can VFS_RELE the VFS holds we just added.
-			 */
-			if (cnt == 0) {
-				/* directly add VN_HOLD since have the lock */
-				vp->v_count++;
-			}
-
-			mutex_exit(&vp->v_lock);
-
-			/*
-			 * If the tmpnode has any pages associated with it
-			 * (i.e. if it's a normal file with non-zero size), the
-			 * tmpnode could still be discovered by pageout or
-			 * fsflush via the page vnode pointers. To prevent this
-			 * from interfering with the tmp_freevfs, truncate the
-			 * tmpnode now.
-			 */
-			if (tnp->tn_size != 0 && tnp->tn_type == VREG) {
-				rw_enter(&tnp->tn_rwlock, RW_WRITER);
-				rw_enter(&tnp->tn_contents, RW_WRITER);
-
-				(void) tmpnode_trunc(tm, tnp, 0);
-
-				rw_exit(&tnp->tn_contents);
-				rw_exit(&tnp->tn_rwlock);
-
-				ASSERT(tnp->tn_size == 0);
-				ASSERT(tnp->tn_nblocks == 0);
-			}
-		} else if (cnt > 0) {
-			/* An open file; unwind the holds we've been adding. */
-			mutex_exit(&vp->v_lock);
+		if ((vp = TNTOV(tnp))->v_count > 0) {
 			cancel = tm->tm_rootnode->tn_forw;
 			while (cancel != tnp) {
 				vp = TNTOV(cancel);
@@ -569,51 +452,15 @@
 			}
 			mutex_exit(&tm->tm_contents);
 			return (EBUSY);
-		} else {
-			/* directly add a VN_HOLD since we have the lock */
-			vp->v_count++;
-			mutex_exit(&vp->v_lock);
 		}
+		VN_HOLD(vp);
 	}
 
-	if (flag & MS_FORCE) {
-		/*
-		 * Drop the zone ref now since we don't know how long it will
-		 * be until the final vfs_rele is called by tmp_inactive.
-		 */
-		if (vfsp->vfs_zone) {
-			zone_rele_ref(&vfsp->vfs_implp->vi_zone_ref,
-			    ZONE_REF_VFS);
-			vfsp->vfs_zone = 0;
-		}
-		/* We can now drop the extra hold we added above. */
-		VFS_RELE(vfsp);
-	} else {
-		/*
-		 * For the non-forced case, we can drop the mutex now because
-		 * no one can find this mount anymore
-		 */
-		vfsp->vfs_flag |= VFS_UNMOUNTED;
-		mutex_exit(&tm->tm_contents);
-	}
+	/*
+	 * We can drop the mutex now because no one can find this mount
+	 */
+	mutex_exit(&tm->tm_contents);
 
-	return (0);
-}
-
-/*
- * Implementation of VFS_FREEVFS() to support forced umounts. This is called by
- * the vfs framework after umount and the last VFS_RELE, to trigger the release
- * of any resources still associated with the given vfs_t. We only add
- * additional VFS_HOLDs during the forced umount case, so this is normally
- * called immediately after tmp_umount.
- */
-void
-tmp_freevfs(vfs_t *vfsp)
-{
-	struct tmount *tm = (struct tmount *)VFSTOTM(vfsp);
-	struct tmpnode *tnp;
-	struct vnode	*vp;
-
 	/*
 	 * Free all kmemalloc'd and anonalloc'd memory associated with
 	 * this filesystem.  To do this, we go through the file list twice,
@@ -622,17 +469,7 @@
 	 * tmpnode_free which assumes that the directory entry has been
 	 * removed before the file.
 	 */
-
 	/*
-	 * Now that we are tearing ourselves down we need to remove the
-	 * UNMOUNTED flag. If we don't, we'll later hit a VN_RELE when we remove
-	 * files from the system causing us to have a negative value. Doing this
-	 * seems a bit better than trying to set a flag on the tmount that says
-	 * we're tearing down.
-	 */
-	vfsp->vfs_flag &= ~VFS_UNMOUNTED;
-
-	/*
 	 * Remove all directory entries
 	 */
 	for (tnp = tm->tm_rootnode; tnp; tnp = tnp->tn_forw) {
@@ -698,16 +535,15 @@
 
 	ASSERT(tm->tm_mntpath);
 
-	kmem_free(tm->tm_mntpath, strlen(tm->tm_mntpath) + 1);
+	tmp_memfree(tm->tm_mntpath, strlen(tm->tm_mntpath) + 1);
 
 	ASSERT(tm->tm_anonmem == 0);
 
 	mutex_destroy(&tm->tm_contents);
 	mutex_destroy(&tm->tm_renamelck);
-	kmem_free(tm, sizeof (struct tmount));
+	tmp_memfree(tm, sizeof (struct tmount));
 
-	/* Allow _fini() to succeed now */
-	atomic_dec_32(&tmpfs_mountcount);
+	return (0);
 }
 
 /*
@@ -769,12 +605,11 @@
 	 * If tm_anonmax for this mount is less than the available swap space
 	 * (minus the amount tmpfs can't use), use that instead
 	 */
-	if (blocks > tmpfs_minfree && tm->tm_anonmax > tm->tm_anonmem) {
+	if (blocks > tmpfs_minfree)
 		sbp->f_bfree = MIN(blocks - tmpfs_minfree,
-		    btop(tm->tm_anonmax) - btopr(tm->tm_anonmem));
-	} else {
+		    tm->tm_anonmax - tm->tm_anonmem);
+	else
 		sbp->f_bfree = 0;
-	}
 
 	sbp->f_bavail = sbp->f_bfree;
 
@@ -781,7 +616,7 @@
 	/*
 	 * Total number of blocks is what's available plus what's been used
 	 */
-	sbp->f_blocks = (fsblkcnt64_t)(sbp->f_bfree + btopr(tm->tm_anonmem));
+	sbp->f_blocks = (fsblkcnt64_t)(sbp->f_bfree + tm->tm_anonmem);
 
 	if (eff_zid != GLOBAL_ZONEUNIQID &&
 	    zp->zone_max_swap_ctl != UINT64_MAX) {
@@ -811,7 +646,13 @@
 	 * available to tmpfs.  This is fairly inaccurate since it doesn't
 	 * take into account the names stored in the directory entries.
 	 */
-	sbp->f_ffree = sbp->f_files = ptob(availrmem) /
+	if (tmpfs_maxkmem > tmp_kmemspace)
+		sbp->f_ffree = (tmpfs_maxkmem - tmp_kmemspace) /
+		    (sizeof (struct tmpnode) + sizeof (struct tdirent));
+	else
+		sbp->f_ffree = 0;
+
+	sbp->f_files = tmpfs_maxkmem /
 	    (sizeof (struct tmpnode) + sizeof (struct tdirent));
 	sbp->f_favail = (fsfilcnt64_t)(sbp->f_ffree);
 	(void) cmpldev(&d32, vfsp->vfs_dev);
--- old/usr/src/uts/common/fs/tmpfs/tmp_vnops.c	Wed Oct  5 00:33:44 2016
+++ new/usr/src/uts/common/fs/tmpfs/tmp_vnops.c	Wed Oct  5 00:33:44 2016
@@ -25,7 +25,7 @@
  */
 
 /*
- * Copyright 2016 Joyent, Inc.
+ * Copyright 2016, Joyent, Inc.
  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  * Copyright 2016 RackTop Systems.
  */
@@ -585,10 +585,6 @@
 	struct tmount *tm = (struct tmount *)VTOTM(vp);
 	int error;
 
-	/* If the filesystem was umounted by force, return immediately. */
-	if (vp->v_vfsp->vfs_flag & VFS_UNMOUNTED)
-		return (EIO);
-
 	/*
 	 * We don't currently support reading non-regular files
 	 */
@@ -618,10 +614,6 @@
 	struct tmount *tm = (struct tmount *)VTOTM(vp);
 	int error;
 
-	/* If the filesystem was umounted by force, return immediately. */
-	if (vp->v_vfsp->vfs_flag & VFS_UNMOUNTED)
-		return (EIO);
-
 	/*
 	 * We don't currently support writing to non-regular files
 	 */
@@ -847,9 +839,6 @@
 	struct tmpnode *ntp = NULL;
 	int error;
 
-	/* If the filesystem was umounted by force, return immediately. */
-	if (dvp->v_vfsp->vfs_flag & VFS_UNMOUNTED)
-		return (EIO);
 
 	/* allow cd into @ dir */
 	if (flags & LOOKUP_XATTR) {
@@ -868,8 +857,6 @@
 
 		rw_enter(&tp->tn_rwlock, RW_WRITER);
 		if (tp->tn_xattrdp == NULL) {
-			int err;
-
 			if (!(flags & CREATE_XATTR_DIR)) {
 				rw_exit(&tp->tn_rwlock);
 				return (ENOENT);
@@ -890,13 +877,9 @@
 				return (error);
 			}
 
+			xdp = tmp_memalloc(sizeof (struct tmpnode),
+			    TMP_MUSTHAVE);
 			tm = VTOTM(dvp);
-			xdp = tmp_kmem_zalloc(tm, sizeof (struct tmpnode),
-			    KM_SLEEP);
-			if (xdp == NULL) {
-				rw_exit(&tp->tn_rwlock);
-				return (ENOSPC);
-			}
 			tmpnode_init(tm, xdp, &tp->tn_attr, NULL);
 			/*
 			 * Fix-up fields unique to attribute directories.
@@ -914,16 +897,7 @@
 			}
 			xdp->tn_vnode->v_type = VDIR;
 			xdp->tn_vnode->v_flag |= V_XATTRDIR;
-			if ((err = tdirinit(tp, xdp)) != 0) {
-				rw_exit(&tp->tn_rwlock);
-				/*
-				 * This never got properly initialized so we can
-				 * just clean it up.
-				 */
-				xdp->tn_vnode->v_flag &= V_XATTRDIR;
-				tmpnode_cleanup(tp);
-				return (err);
-			}
+			tdirinit(tp, xdp);
 			tp->tn_xattrdp = xdp;
 		} else {
 			VN_HOLD(tp->tn_xattrdp->tn_vnode);
@@ -1505,10 +1479,6 @@
 	int reclen;
 	caddr_t outbuf;
 
-	/* If the filesystem was umounted by force, return immediately. */
-	if (vp->v_vfsp->vfs_flag & VFS_UNMOUNTED)
-		return (EIO);
-
 	if (uiop->uio_loffset >= MAXOFF_T) {
 		if (eofp)
 			*eofp = 1;
@@ -1642,12 +1612,12 @@
 	rw_exit(&parent->tn_rwlock);
 
 	if (error) {
-		if (self != NULL)
+		if (self)
 			tmpnode_rele(self);
 		return (error);
 	}
 	len = strlen(tnm) + 1;
-	cp = tmp_kmem_zalloc(tm, len, KM_NOSLEEP | KM_NORMALPRI);
+	cp = tmp_memalloc(len, 0);
 	if (cp == NULL) {
 		tmpnode_rele(self);
 		return (ENOSPC);
@@ -1712,27 +1682,10 @@
 	 * there's little to do -- just drop our hold.
 	 */
 	if (vp->v_count > 1 || tp->tn_nlink != 0) {
-		if (vp->v_vfsp->vfs_flag & VFS_UNMOUNTED) {
-			/*
-			 * Since the file system was forcibly unmounted, we can
-			 * have a case (v_count == 1, tn_nlink != 0) where this
-			 * file was open so we didn't add an extra hold on the
-			 * file in tmp_unmount. We are counting on the
-			 * interaction of the hold made in tmp_unmount and
-			 * rele-ed in tmp_vfsfree so we need to be sure we
-			 * don't decrement in this case.
-			 */
-			if (vp->v_count > 1)
-				vp->v_count--;
-		} else {
-			vp->v_count--;
-		}
+		vp->v_count--;
 		mutex_exit(&vp->v_lock);
 		mutex_exit(&tp->tn_tlock);
 		rw_exit(&tp->tn_rwlock);
-		/* If the filesystem was umounted by force, rele the vfs ref */
-		if (tm->tm_vfsp->vfs_flag & VFS_UNMOUNTED)
-			VFS_RELE(tm->tm_vfsp);
 		return;
 	}
 
@@ -1757,7 +1710,7 @@
 			goto top;
 		}
 		if (tp->tn_type == VLNK)
-			tmp_kmem_free(tm, tp->tn_symlink, tp->tn_size + 1);
+			tmp_memfree(tp->tn_symlink, tp->tn_size + 1);
 	}
 
 	/*
@@ -1791,11 +1744,7 @@
 	rw_destroy(&tp->tn_rwlock);
 	mutex_destroy(&tp->tn_tlock);
 	vn_free(TNTOV(tp));
-	tmp_kmem_free(tm, tp, sizeof (struct tmpnode));
-
-	/* If the filesystem was umounted by force, rele the vfs ref */
-	if (tm->tm_vfsp->vfs_flag & VFS_UNMOUNTED)
-		VFS_RELE(tm->tm_vfsp);
+	tmp_memfree(tp, sizeof (struct tmpnode));
 }
 
 /* ARGSUSED2 */
@@ -1917,10 +1866,6 @@
 	struct vnode *pvp;
 	u_offset_t poff;
 
-	/* If the filesystem was umounted by force, return immediately. */
-	if (vp->v_vfsp->vfs_flag & VFS_UNMOUNTED)
-		return (EIO);
-
 	if (protp != NULL)
 		*protp = PROT_ALL;
 again:
@@ -2142,10 +2087,6 @@
 	u_offset_t offset;
 	u_offset_t tmpoff;
 
-	/* If the filesystem was umounted by force, return immediately. */
-	if (vp->v_vfsp->vfs_flag & VFS_UNMOUNTED)
-		return (EIO);
-
 	ASSERT(PAGE_LOCKED(pp));
 
 	/* Kluster in tmp_klustsize chunks */
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/uts/common/fs/vnode.c	Wed Oct  5 00:33:45 2016
+++ new/usr/src/uts/common/fs/vnode.c	Wed Oct  5 00:33:45 2016
@@ -21,7 +21,7 @@
 
 /*
  * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2016, Joyent, Inc.
+ * Copyright (c) 2014, Joyent, Inc. All rights reserved.
  */
 
 /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
@@ -66,8 +66,6 @@
 #include <fs/fs_subr.h>
 #include <sys/taskq.h>
 #include <fs/fs_reparse.h>
-#include <sys/time.h>
-#include <sys/sdt.h>
 
 /* Determine if this vnode is a file that is read-only */
 #define	ISROFILE(vp)	\
@@ -104,9 +102,6 @@
 /* Global variable which enables/disables the vopstats collection */
 int vopstats_enabled = 1;
 
-/* Global used for empty/invalid v_path */
-char *vn_vpath_empty = "";
-
 /*
  * forward declarations for internal vnode specific data (vsd)
  */
@@ -208,7 +203,6 @@
 #define	VOP_LATENCY_10MS	10000000
 #define	VOP_LATENCY_100MS	100000000
 #define	VOP_LATENCY_1S		1000000000
-#define	VOP_LATENCY_10S		10000000000
 
 /*
  * Convert stat(2) formats to vnode types and vice versa.  (Knows about
@@ -1653,7 +1647,7 @@
 
 int
 vn_renameat(vnode_t *fdvp, char *fname, vnode_t *tdvp,
-    char *tname, enum uio_seg seg)
+		char *tname, enum uio_seg seg)
 {
 	int error;
 	struct vattr vattr;
@@ -2294,8 +2288,7 @@
 	cv_init(&vp->v_cv, NULL, CV_DEFAULT, NULL);
 	rw_init(&vp->v_nbllock, NULL, RW_DEFAULT, NULL);
 	vp->v_femhead = NULL;	/* Must be done before vn_reinit() */
-	vp->v_path = vn_vpath_empty;
-	vp->v_path_stamp = 0;
+	vp->v_path = NULL;
 	vp->v_mpssdata = NULL;
 	vp->v_vsd = NULL;
 	vp->v_fopdata = NULL;
@@ -2342,7 +2335,6 @@
 vn_recycle(vnode_t *vp)
 {
 	ASSERT(vp->v_pages == NULL);
-	VERIFY(vp->v_path != NULL);
 
 	/*
 	 * XXX - This really belongs in vn_reinit(), but we have some issues
@@ -2365,11 +2357,10 @@
 		kmem_free(vp->v_femhead, sizeof (*(vp->v_femhead)));
 		vp->v_femhead = NULL;
 	}
-	if (vp->v_path != vn_vpath_empty) {
+	if (vp->v_path) {
 		kmem_free(vp->v_path, strlen(vp->v_path) + 1);
-		vp->v_path = vn_vpath_empty;
+		vp->v_path = NULL;
 	}
-	vp->v_path_stamp = 0;
 
 	if (vp->v_fopdata != NULL) {
 		free_fopdata(vp);
@@ -2440,10 +2431,9 @@
 	 */
 	ASSERT((vp->v_count == 0) || (vp->v_count == 1));
 	ASSERT(vp->v_count_dnlc == 0);
-	VERIFY(vp->v_path != NULL);
-	if (vp->v_path != vn_vpath_empty) {
+	if (vp->v_path != NULL) {
 		kmem_free(vp->v_path, strlen(vp->v_path) + 1);
-		vp->v_path = vn_vpath_empty;
+		vp->v_path = NULL;
 	}
 
 	/* If FEM was in use, make sure everything gets cleaned up */
@@ -2977,239 +2967,125 @@
 }
 
 /*
- * The value stored in v_path is relative to rootdir, located in the global
- * zone.  Zones or chroot environments which reside deeper inside the VFS
- * hierarchy will have a relative view of MAXPATHLEN since they are unaware of
- * what lies below their perceived root.  In order to keep v_path usable for
- * these child environments, its allocations are allowed to exceed MAXPATHLEN.
- *
- * An upper bound of max_vnode_path is placed upon v_path allocations to
- * prevent the system from going too wild at the behest of pathological
- * behavior from the operator.
+ * Given a starting vnode and a path, updates the path in the target vnode in
+ * a safe manner.  If the vnode already has path information embedded, then the
+ * cached path is left untouched.
  */
+
 size_t max_vnode_path = 4 * MAXPATHLEN;
 
-
 void
-vn_clearpath(vnode_t *vp, hrtime_t compare_stamp)
+vn_setpath(vnode_t *rootvp, struct vnode *startvp, struct vnode *vp,
+    const char *path, size_t plen)
 {
-	char *buf;
+	char	*rpath;
+	vnode_t	*base;
+	size_t	rpathlen, rpathalloc;
+	int	doslash = 1;
 
-	mutex_enter(&vp->v_lock);
+	if (*path == '/') {
+		base = rootvp;
+		path++;
+		plen--;
+	} else {
+		base = startvp;
+	}
+
 	/*
-	 * If the snapshot of v_path_stamp passed in via compare_stamp does not
-	 * match the present value on the vnode, it indicates that subsequent
-	 * changes have occurred.  The v_path value is not cleared in this case
-	 * since the new value may be valid.
+	 * We cannot grab base->v_lock while we hold vp->v_lock because of
+	 * the potential for deadlock.
 	 */
-	if (compare_stamp != 0 && vp->v_path_stamp != compare_stamp) {
-		mutex_exit(&vp->v_lock);
+	mutex_enter(&base->v_lock);
+	if (base->v_path == NULL) {
+		mutex_exit(&base->v_lock);
 		return;
 	}
-	buf = vp->v_path;
-	vp->v_path = vn_vpath_empty;
-	vp->v_path_stamp = 0;
-	mutex_exit(&vp->v_lock);
-	if (buf != vn_vpath_empty) {
-		kmem_free(buf, strlen(buf) + 1);
-	}
-}
 
-static void
-vn_setpath_common(vnode_t *pvp, vnode_t *vp, const char *name, size_t len,
-    boolean_t is_rename)
-{
-	char *buf, *oldbuf;
-	hrtime_t pstamp;
-	size_t baselen, buflen = 0;
+	rpathlen = strlen(base->v_path);
+	rpathalloc = rpathlen + plen + 1;
+	/* Avoid adding a slash if there's already one there */
+	if (base->v_path[rpathlen-1] == '/')
+		doslash = 0;
+	else
+		rpathalloc++;
 
-	/* Handle the vn_setpath_str case. */
-	if (pvp == NULL) {
-		if (len + 1 > max_vnode_path) {
-			DTRACE_PROBE4(vn__setpath__too__long, vnode_t *, pvp,
-			    vnode_t *, vp, char *, name, size_t, len + 1);
-			return;
-		}
-		buf = kmem_alloc(len + 1, KM_SLEEP);
-		bcopy(name, buf, len);
-		buf[len] = '\0';
+	/*
+	 * We don't want to call kmem_alloc(KM_SLEEP) with kernel locks held,
+	 * so we must do this dance.  If, by chance, something changes the path,
+	 * just give up since there is no real harm.
+	 */
+	mutex_exit(&base->v_lock);
 
-		mutex_enter(&vp->v_lock);
-		oldbuf = vp->v_path;
-		vp->v_path = buf;
-		vp->v_path_stamp = gethrtime();
-		mutex_exit(&vp->v_lock);
-		if (oldbuf != vn_vpath_empty) {
-			kmem_free(oldbuf, strlen(oldbuf) + 1);
-		}
+	/* Paths should stay within reason */
+	if (rpathalloc > max_vnode_path)
 		return;
-	}
 
-	/* Take snapshot of parent dir */
-	mutex_enter(&pvp->v_lock);
-retrybuf:
-	if (pvp->v_path == vn_vpath_empty) {
-		/*
-		 * Without v_path from the parent directory, generating a child
-		 * path from the name is impossible.
-		 */
-		if (len > 0) {
-			pstamp = pvp->v_path_stamp;
-			mutex_exit(&pvp->v_lock);
-			vn_clearpath(vp, pstamp);
-			return;
-		}
+	rpath = kmem_alloc(rpathalloc, KM_SLEEP);
 
-		/*
-		 * The only feasible case here is where a NUL lookup is being
-		 * performed on rootdir prior to its v_path being populated.
-		 */
-		ASSERT(pvp->v_path_stamp = 0);
-		baselen = 0;
-		pstamp = 0;
-	} else {
-		pstamp = pvp->v_path_stamp;
-		baselen = strlen(pvp->v_path);
-		/* ignore a trailing slash if present */
-		if (pvp->v_path[baselen - 1] == '/') {
-			/* This should only the be case for rootdir */
-			ASSERT(baselen == 1 && pvp == rootdir);
-			baselen--;
-		}
-	}
-	mutex_exit(&pvp->v_lock);
-
-	if (buflen != 0) {
-		/* Free the existing (mis-sized) buffer in case of retry */
-		kmem_free(buf, buflen);
-	}
-	/* base, '/', name and trailing NUL */
-	buflen = baselen + len + 2;
-	if (buflen > max_vnode_path) {
-		DTRACE_PROBE4(vn__setpath_too__long, vnode_t *, pvp,
-		    vnode_t *, vp, char *, name, size_t, buflen);
+	mutex_enter(&base->v_lock);
+	if (base->v_path == NULL || strlen(base->v_path) != rpathlen) {
+		mutex_exit(&base->v_lock);
+		kmem_free(rpath, rpathalloc);
 		return;
 	}
-	buf = kmem_alloc(buflen, KM_SLEEP);
+	bcopy(base->v_path, rpath, rpathlen);
+	mutex_exit(&base->v_lock);
 
-	mutex_enter(&pvp->v_lock);
-	if (pvp->v_path_stamp != pstamp) {
-		size_t vlen;
+	if (doslash)
+		rpath[rpathlen++] = '/';
+	bcopy(path, rpath + rpathlen, plen);
+	rpath[rpathlen + plen] = '\0';
 
-		/*
-		 * Since v_path_stamp changed on the parent, it is likely that
-		 * v_path has been altered as well.  If the length does not
-		 * exactly match what was previously measured, the buffer
-		 * allocation must be repeated for proper sizing.
-		 */
-		if (pvp->v_path == vn_vpath_empty) {
-			/* Give up if parent lack v_path */
-			mutex_exit(&pvp->v_lock);
-			kmem_free(buf, buflen);
-			return;
-		}
-		vlen = strlen(pvp->v_path);
-		if (pvp->v_path[vlen - 1] == '/') {
-			vlen--;
-		}
-		if (vlen != baselen) {
-			goto retrybuf;
-		}
-	}
-	bcopy(pvp->v_path, buf, baselen);
-	mutex_exit(&pvp->v_lock);
-
-	buf[baselen] = '/';
-	baselen++;
-	bcopy(name, &buf[baselen], len + 1);
-
 	mutex_enter(&vp->v_lock);
-	if (vp->v_path_stamp == 0) {
-		/* never-visited vnode can inherit stamp from parent */
-		ASSERT(vp->v_path == vn_vpath_empty);
-		vp->v_path_stamp = pstamp;
-		vp->v_path = buf;
+	if (vp->v_path != NULL) {
 		mutex_exit(&vp->v_lock);
-	} else if (vp->v_path_stamp < pstamp || is_rename) {
-		/*
-		 * Install the updated path and stamp, ensuring that the v_path
-		 * pointer is valid at all times for dtrace.
-		 */
-		oldbuf = vp->v_path;
-		vp->v_path = buf;
-		vp->v_path_stamp = gethrtime();
-		mutex_exit(&vp->v_lock);
-		kmem_free(oldbuf, strlen(oldbuf) + 1);
+		kmem_free(rpath, rpathalloc);
 	} else {
-		/*
-		 * If the timestamp matches or is greater, it means another
-		 * thread performed the update first while locks were dropped
-		 * here to make the allocation.  We defer to the newer value.
-		 */
+		vp->v_path = rpath;
 		mutex_exit(&vp->v_lock);
-		kmem_free(buf, buflen);
 	}
-	ASSERT(MUTEX_NOT_HELD(&vp->v_lock));
 }
 
+/*
+ * Sets the path to the vnode to be the given string, regardless of current
+ * context.  The string must be a complete path from rootdir.  This is only used
+ * by fsop_root() for setting the path based on the mountpoint.
+ */
 void
-vn_updatepath(vnode_t *pvp, vnode_t *vp, const char *name)
+vn_setpath_str(struct vnode *vp, const char *str, size_t len)
 {
-	size_t len;
+	char *buf = kmem_alloc(len + 1, KM_SLEEP);
 
-	/*
-	 * If the parent is older or empty, there's nothing further to do.
-	 */
-	if (pvp->v_path == vn_vpath_empty ||
-	    pvp->v_path_stamp <= vp->v_path_stamp) {
+	mutex_enter(&vp->v_lock);
+	if (vp->v_path != NULL) {
+		mutex_exit(&vp->v_lock);
+		kmem_free(buf, len + 1);
 		return;
 	}
 
-	/*
-	 * Given the lack of appropriate context, meaningful updates to v_path
-	 * cannot be made for during lookups for the '.' or '..' entries.
-	 */
-	len = strlen(name);
-	if (len == 0 || (len == 1 && name[0] == '.') ||
-	    (len == 2 && name[0] == '.' && name[1] == '.')) {
-		return;
-	}
+	vp->v_path = buf;
+	bcopy(str, vp->v_path, len);
+	vp->v_path[len] = '\0';
 
-	vn_setpath_common(pvp, vp, name, len, B_FALSE);
+	mutex_exit(&vp->v_lock);
 }
 
 /*
- * Given a starting vnode and a path, updates the path in the target vnode in
- * a safe manner.  If the vnode already has path information embedded, then the
- * cached path is left untouched.
- */
-/* ARGSUSED */
-void
-vn_setpath(vnode_t *rootvp, vnode_t *pvp, vnode_t *vp, const char *name,
-    size_t len)
-{
-	vn_setpath_common(pvp, vp, name, len, B_FALSE);
-}
-
-/*
- * Sets the path to the vnode to be the given string, regardless of current
- * context.  The string must be a complete path from rootdir.  This is only used
- * by fsop_root() for setting the path based on the mountpoint.
- */
-void
-vn_setpath_str(vnode_t *vp, const char *str, size_t len)
-{
-	vn_setpath_common(NULL, vp, str, len, B_FALSE);
-}
-
-/*
  * Called from within filesystem's vop_rename() to handle renames once the
  * target vnode is available.
  */
 void
-vn_renamepath(vnode_t *pvp, vnode_t *vp, const char *name, size_t len)
+vn_renamepath(vnode_t *dvp, vnode_t *vp, const char *nm, size_t len)
 {
-	vn_setpath_common(pvp, vp, name, len, B_TRUE);
+	char *tmp;
+
+	mutex_enter(&vp->v_lock);
+	tmp = vp->v_path;
+	vp->v_path = NULL;
+	mutex_exit(&vp->v_lock);
+	vn_setpath(rootdir, dvp, vp, nm, len);
+	if (tmp != NULL)
+		kmem_free(tmp, strlen(tmp) + 1);
 }
 
 /*
@@ -3220,42 +3096,37 @@
 vn_copypath(struct vnode *src, struct vnode *dst)
 {
 	char *buf;
-	hrtime_t stamp;
-	size_t buflen;
+	int alloc;
 
 	mutex_enter(&src->v_lock);
-	if (src->v_path == vn_vpath_empty) {
+	if (src->v_path == NULL) {
 		mutex_exit(&src->v_lock);
 		return;
 	}
-	buflen = strlen(src->v_path) + 1;
-	mutex_exit(&src->v_lock);
+	alloc = strlen(src->v_path) + 1;
 
-	buf = kmem_alloc(buflen, KM_SLEEP);
-
+	/* avoid kmem_alloc() with lock held */
+	mutex_exit(&src->v_lock);
+	buf = kmem_alloc(alloc, KM_SLEEP);
 	mutex_enter(&src->v_lock);
-	if (src->v_path == vn_vpath_empty ||
-	    strlen(src->v_path) + 1 != buflen) {
+	if (src->v_path == NULL || strlen(src->v_path) + 1 != alloc) {
 		mutex_exit(&src->v_lock);
-		kmem_free(buf, buflen);
+		kmem_free(buf, alloc);
 		return;
 	}
-	bcopy(src->v_path, buf, buflen);
-	stamp = src->v_path_stamp;
+	bcopy(src->v_path, buf, alloc);
 	mutex_exit(&src->v_lock);
 
 	mutex_enter(&dst->v_lock);
-	if (dst->v_path != vn_vpath_empty) {
+	if (dst->v_path != NULL) {
 		mutex_exit(&dst->v_lock);
-		kmem_free(buf, buflen);
+		kmem_free(buf, alloc);
 		return;
 	}
 	dst->v_path = buf;
-	dst->v_path_stamp = stamp;
 	mutex_exit(&dst->v_lock);
 }
 
-
 /*
  * XXX Private interface for segvn routines that handle vnode
  * large page segments.
@@ -3444,15 +3315,10 @@
 			else if (lat < VOP_LATENCY_1S) {
 				atomic_inc_64(&zvp->zv_10ms_ops.value.ui64);
 				atomic_inc_64(&zvp->zv_100ms_ops.value.ui64);
-			} else if (lat < VOP_LATENCY_10S) {
-				atomic_inc_64(&zvp->zv_10ms_ops.value.ui64);
-				atomic_inc_64(&zvp->zv_100ms_ops.value.ui64);
-				atomic_inc_64(&zvp->zv_1s_ops.value.ui64);
 			} else {
 				atomic_inc_64(&zvp->zv_10ms_ops.value.ui64);
 				atomic_inc_64(&zvp->zv_100ms_ops.value.ui64);
 				atomic_inc_64(&zvp->zv_1s_ops.value.ui64);
-				atomic_inc_64(&zvp->zv_10s_ops.value.ui64);
 			}
 		}
 	}
@@ -3512,15 +3378,10 @@
 			else if (lat < VOP_LATENCY_1S) {
 				atomic_inc_64(&zvp->zv_10ms_ops.value.ui64);
 				atomic_inc_64(&zvp->zv_100ms_ops.value.ui64);
-			} else if (lat < VOP_LATENCY_10S) {
-				atomic_inc_64(&zvp->zv_10ms_ops.value.ui64);
-				atomic_inc_64(&zvp->zv_100ms_ops.value.ui64);
-				atomic_inc_64(&zvp->zv_1s_ops.value.ui64);
 			} else {
 				atomic_inc_64(&zvp->zv_10ms_ops.value.ui64);
 				atomic_inc_64(&zvp->zv_100ms_ops.value.ui64);
 				atomic_inc_64(&zvp->zv_1s_ops.value.ui64);
-				atomic_inc_64(&zvp->zv_10s_ops.value.ui64);
 			}
 		}
 	}
@@ -3688,7 +3549,9 @@
 	}
 	if (ret == 0 && *vpp) {
 		VOPSTATS_UPDATE(*vpp, lookup);
-		vn_updatepath(dvp, *vpp, nm);
+		if ((*vpp)->v_path == NULL) {
+			vn_setpath(rootdir, dvp, *vpp, nm, strlen(nm));
+		}
 	}
 
 	return (ret);
@@ -3728,7 +3591,9 @@
 	    (dvp, name, vap, excl, mode, vpp, cr, flags, ct, vsecp);
 	if (ret == 0 && *vpp) {
 		VOPSTATS_UPDATE(*vpp, create);
-		vn_updatepath(dvp, *vpp, name);
+		if ((*vpp)->v_path == NULL) {
+			vn_setpath(rootdir, dvp, *vpp, name, strlen(name));
+		}
 	}
 
 	return (ret);
@@ -3848,7 +3713,10 @@
 	    (dvp, dirname, vap, vpp, cr, ct, flags, vsecp);
 	if (ret == 0 && *vpp) {
 		VOPSTATS_UPDATE(*vpp, mkdir);
-		vn_updatepath(dvp, *vpp, dirname);
+		if ((*vpp)->v_path == NULL) {
+			vn_setpath(rootdir, dvp, *vpp, dirname,
+			    strlen(dirname));
+		}
 	}
 
 	return (ret);
--- old/usr/src/uts/common/fs/zfs/zfs_vnops.c	Wed Oct  5 00:33:46 2016
+++ new/usr/src/uts/common/fs/zfs/zfs_vnops.c	Wed Oct  5 00:33:46 2016
@@ -686,17 +686,6 @@
 	if (limit == RLIM64_INFINITY || limit > MAXOFFSET_T)
 		limit = MAXOFFSET_T;
 
-	/*
-	 * Pre-fault the pages to ensure slow (eg NFS) pages
-	 * don't hold up txg.
-	 * Skip this if uio contains loaned arc_buf.
-	 */
-	if ((uio->uio_extflg == UIO_XUIO) &&
-	    (((xuio_t *)uio)->xu_type == UIOTYPE_ZEROCOPY))
-		xuio = (xuio_t *)uio;
-	else
-		uio_prefaultpages(n, uio);
-
 	ZFS_ENTER(zfsvfs);
 	ZFS_VERIFY_ZP(zp);
 
@@ -749,6 +738,17 @@
 	}
 
 	/*
+	 * Pre-fault the pages to ensure slow (eg NFS) pages
+	 * don't hold up txg.
+	 * Skip this if uio contains loaned arc_buf.
+	 */
+	if ((uio->uio_extflg == UIO_XUIO) &&
+	    (((xuio_t *)uio)->xu_type == UIOTYPE_ZEROCOPY))
+		xuio = (xuio_t *)uio;
+	else
+		uio_prefaultpages(MIN(n, max_blksz), uio);
+
+	/*
 	 * If in append mode, set the io offset pointer to eof.
 	 */
 	if (ioflag & FAPPEND) {
@@ -992,6 +992,9 @@
 			break;
 		ASSERT(tx_bytes == nbytes);
 		n -= nbytes;
+
+		if (!xuio && n > 0)
+			uio_prefaultpages(MIN(n, max_blksz), uio);
 	}
 
 	zfs_range_unlock(rl);
@@ -4258,8 +4261,6 @@
 		    &zp->z_pflags, 8);
 		zfs_tstamp_update_setup(zp, CONTENT_MODIFIED, mtime, ctime,
 		    B_TRUE);
-		err = sa_bulk_update(zp->z_sa_hdl, bulk, count, tx);
-
 		zfs_log_write(zfsvfs->z_log, tx, TX_WRITE, zp, off, len, 0);
 	}
 	dmu_tx_commit(tx);
@@ -4795,6 +4796,10 @@
 	ASSERT3U(VTOZ(vp)->z_mapcnt, >=, pages);
 	atomic_add_64(&VTOZ(vp)->z_mapcnt, -pages);
 
+	if ((flags & MAP_SHARED) && (prot & PROT_WRITE) &&
+	    vn_has_cached_data(vp))
+		(void) VOP_PUTPAGE(vp, off, len, B_ASYNC, cr, ct);
+
 	return (0);
 }
 
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/uts/common/inet/ip/ipclassifier.c	Wed Oct  5 00:33:46 2016
+++ new/usr/src/uts/common/inet/ip/ipclassifier.c	Wed Oct  5 00:33:46 2016
@@ -920,7 +920,6 @@
 void
 ipcl_hash_insert_wildcard(connf_t *connfp, conn_t *connp)
 {
-	conn_t **list, *prev, *next;
 	conn_t *pconnp = NULL, *nconnp;
 	boolean_t isv4mapped = IN6_IS_ADDR_V4MAPPED(&connp->conn_laddr_v6);
 
No differences encountered
No differences encountered
--- old/usr/src/uts/common/inet/sockmods/datafilt.c	Wed Oct  5 00:33:47 2016
+++ new/usr/src/uts/common/inet/sockmods/datafilt.c	Wed Oct  5 00:33:47 2016
@@ -1,26 +1,27 @@
 /*
- * This file and its contents are supplied under the terms of the
- * Common Development and Distribution License ("CDDL"), version 1.0.
- * You may only use this file in accordance with the terms of version
- * 1.0 of the CDDL.
+ * CDDL HEADER START
  *
- * A full copy of the text of the CDDL should have accompanied this
- * source.  A copy of the CDDL is also available via the Internet at
- * http://www.illumos.org/license/CDDL.
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
  */
-
 /*
  * Copyright (c) 2012, OmniTI Computer Consulting, Inc. All rights reserved.
  */
 
-/*
- * This file implements a socketfilter used to deter TCP connections.
- * To defer a connection means to delay the return of accept(3SOCKET)
- * until at least one byte is ready to be read(2). This filter may be
- * applied automatically or programmatically through the use of
- * soconfig(1M) and setsockopt(3SOCKET).
- */
-
 #include <sys/kmem.h>
 #include <sys/systm.h>
 #include <sys/stropts.h>
@@ -30,8 +31,6 @@
 #include <sys/note.h>
 #include <sys/taskq.h>
 
-#define	DATAFILT_MODULE "datafilt"
-
 static struct modlmisc dataf_modlmisc = {
 	&mod_miscops,
 	"Kernel data-ready socket filter"
@@ -43,37 +42,39 @@
 	NULL
 };
 
-static sof_rval_t
+#define	DATAFILT_MODULE "datafilt"
+
+/* ARGSUSED */
+sof_rval_t
 dataf_attach_passive_cb(sof_handle_t handle, sof_handle_t ph,
     void *parg, struct sockaddr *laddr, socklen_t laddrlen,
     struct sockaddr *faddr, socklen_t faddrlen, void **cookiep)
 {
-	_NOTE(ARGUNUSED(handle, ph, parg, laddr, laddrlen, faddr, faddrlen,
-	cookiep));
 	return (SOF_RVAL_DEFER);
 }
 
-static void
+void
 dataf_detach_cb(sof_handle_t handle, void *cookie, cred_t *cr)
 {
 	_NOTE(ARGUNUSED(handle, cookie, cr));
 }
 
-static mblk_t *
+/*
+ * Called for each incoming segment.
+ */
+mblk_t *
 dataf_data_in_cb(sof_handle_t handle, void *cookie, mblk_t *mp, int flags,
     size_t *lenp)
 {
 	_NOTE(ARGUNUSED(cookie, flags, lenp));
 
-	if (mp != NULL && MBLKL(mp) > 0) {
+	if (mp != NULL && MBLKL(mp) > 0)
 		sof_newconn_ready(handle);
-		sof_bypass(handle);
-	}
 
 	return (mp);
 }
 
-static sof_ops_t dataf_ops = {
+sof_ops_t dataf_ops = {
 	.sofop_attach_passive = dataf_attach_passive_cb,
 	.sofop_detach = dataf_detach_cb,
 	.sofop_data_in = dataf_data_in_cb
@@ -82,29 +83,29 @@
 int
 _init(void)
 {
-	int err;
+	int error;
 
 	/*
 	 * This module is safe to attach even after some preliminary socket
 	 * setup calls have taken place. See the comment for SOF_ATT_SAFE.
 	 */
-	err = sof_register(SOF_VERSION, DATAFILT_MODULE, &dataf_ops,
+	error = sof_register(SOF_VERSION, DATAFILT_MODULE, &dataf_ops,
 	    SOF_ATT_SAFE);
-	if (err != 0)
-		return (err);
-	if ((err = mod_install(&dataf_modlinkage)) != 0)
+	if (error != 0)
+		return (error);
+	if ((error = mod_install(&dataf_modlinkage)) != 0)
 		(void) sof_unregister(DATAFILT_MODULE);
 
-	return (err);
+	return (error);
 }
 
 int
 _fini(void)
 {
-	int err;
+	int error;
 
-	if ((err = sof_unregister(DATAFILT_MODULE)) != 0)
-		return (err);
+	if ((error = sof_unregister(DATAFILT_MODULE)) != 0)
+		return (error);
 
 	return (mod_remove(&dataf_modlinkage));
 }
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/uts/common/inet/tcp_impl.h	Wed Oct  5 00:33:48 2016
+++ new/usr/src/uts/common/inet/tcp_impl.h	Wed Oct  5 00:33:48 2016
@@ -61,9 +61,9 @@
  * by setting it to 0.
  */
 #define	TCP_XMIT_LOWATER	4096
-#define	TCP_XMIT_HIWATER	128000
+#define	TCP_XMIT_HIWATER	49152
 #define	TCP_RECV_LOWATER	2048
-#define	TCP_RECV_HIWATER	1048576
+#define	TCP_RECV_HIWATER	128000
 
 /*
  * Bind hash list size and has function.  It has to be a power of 2 for
--- old/usr/src/uts/common/inet/udp/udp.c	Wed Oct  5 00:33:48 2016
+++ new/usr/src/uts/common/inet/udp/udp.c	Wed Oct  5 00:33:48 2016
@@ -22,7 +22,6 @@
  * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
  * Copyright 2014, OmniTI Computer Consulting, Inc. All rights reserved.
- * Copyright 2015, Joyent, Inc.
  */
 /* Copyright (c) 1990 Mentat Inc. */
 
@@ -77,8 +76,7 @@
 #include <inet/ipclassifier.h>
 #include <sys/squeue_impl.h>
 #include <inet/ipnet.h>
-#include <sys/vxlan.h>
-#include <inet/inet_hash.h>
+#include <sys/ethernet.h>
 
 #include <sys/tsol/label.h>
 #include <sys/tsol/tnet.h>
@@ -348,89 +346,6 @@
 typedef union T_primitives *t_primp_t;
 
 /*
- * Various protocols that encapsulate UDP have no real use for the source port.
- * Instead, they want to vary the source port to provide better equal-cost
- * multipathing and other systems that use fanout. Consider something like
- * VXLAN. If you're actually sending multiple different streams to a single
- * host, if you don't vary the source port, then the tuple of ( SRC IP, DST IP,
- * SRC Port, DST Port) will always be the same.
- *
- * Here, we return a port to hash this to, if we know how to hash it. If for
- * some reason we can't perform an L4 hash, then we just return the default
- * value, usually the default port. After we determine the hash we transform it
- * so that it's in the range of [ min, max ].
- *
- * We'd like to avoid a pull up for the sake of performing the hash. If the
- * first mblk_t doesn't have the full protocol header, then we just send it to
- * the default. If for some reason we have an encapsulated packet that has its
- * protocol header in different parts of an mblk_t, then we'll go with the
- * default port. This means that that if a driver isn't consistent about how it
- * generates the frames for a given flow, it will not always be consistently
- * hashed. That should be an uncommon event.
- */
-uint16_t
-udp_srcport_hash(mblk_t *mp, int type, uint16_t min, uint16_t max,
-    uint16_t def)
-{
-	size_t szused = 0;
-	struct ether_header *ether;
-	struct ether_vlan_header *vether;
-	ip6_t *ip6h;
-	ipha_t *ipha;
-	uint16_t sap;
-	uint64_t hash;
-	uint32_t mod;
-
-	ASSERT(min <= max);
-
-	if (type != UDP_HASH_VXLAN)
-		return (def);
-
-	if (!IS_P2ALIGNED(mp->b_rptr, sizeof (uint16_t)))
-		return (def);
-
-	/*
-	 * The following logic is VXLAN specific to get at the header, if we
-	 * have formats, eg. GENEVE, then we should ignore this.
-	 *
-	 * The kernel overlay device often puts a first mblk_t for the data
-	 * which is just the encap. If so, then we're going to use that and try
-	 * to avoid a pull up.
-	 */
-	if (MBLKL(mp) == VXLAN_HDR_LEN) {
-		if (mp->b_cont == NULL)
-			return (def);
-		mp = mp->b_cont;
-		ether = (struct ether_header *)mp->b_rptr;
-	} else if (MBLKL(mp) < VXLAN_HDR_LEN) {
-		return (def);
-	} else {
-		szused = VXLAN_HDR_LEN;
-		ether = (struct ether_header *)((uintptr_t)mp->b_rptr + szused);
-	}
-
-	/* Can we hold a MAC header? */
-	if (MBLKL(mp) + szused < sizeof (struct ether_header))
-		return (def);
-
-	/*
-	 * We need to lie about the starting offset into the message block for
-	 * convenience. Undo it at the end. We know that inet_pkt_hash() won't
-	 * modify the mblk_t.
-	 */
-	mp->b_rptr += szused;
-	hash = inet_pkt_hash(DL_ETHER, mp, INET_PKT_HASH_L2 |
-	    INET_PKT_HASH_L3 | INET_PKT_HASH_L4);
-	mp->b_rptr -= szused;
-
-	if (hash == 0)
-		return (def);
-
-	mod = max - min + 1;
-	return ((hash % mod) + min);
-}
-
-/*
  * Return the next anonymous port in the privileged port range for
  * bind checking.
  *
@@ -1668,11 +1583,6 @@
 			*i1 = udp->udp_rcvhdr ? 1 : 0;
 			mutex_exit(&connp->conn_lock);
 			return (sizeof (int));
-		case UDP_SRCPORT_HASH:
-			mutex_enter(&connp->conn_lock);
-			*i1 = udp->udp_vxlanhash;
-			mutex_exit(&connp->conn_lock);
-			return (sizeof (int));
 		case UDP_SND_TO_CONNECTED:
 			mutex_enter(&connp->conn_lock);
 			*i1 = udp->udp_snd_to_conn ? 1 : 0;
@@ -1813,26 +1723,6 @@
 			udp->udp_rcvhdr = onoff;
 			mutex_exit(&connp->conn_lock);
 			return (0);
-		case UDP_SRCPORT_HASH:
-			/*
-			 * This should have already been verified, but double
-			 * check.
-			 */
-			if ((error = secpolicy_ip_config(cr, B_FALSE)) != 0) {
-				return (error);
-			}
-
-			/* First see if the val is something we understand */
-			if (*i1 != UDP_HASH_DISABLE && *i1 != UDP_HASH_VXLAN)
-				return (EINVAL);
-
-			if (!checkonly) {
-				mutex_enter(&connp->conn_lock);
-				udp->udp_vxlanhash = *i1;
-				mutex_exit(&connp->conn_lock);
-			}
-			/* Fully handled this option. */
-			return (0);
 		case UDP_SND_TO_CONNECTED:
 			mutex_enter(&connp->conn_lock);
 			udp->udp_snd_to_conn = onoff;
@@ -2121,9 +2011,7 @@
 	uint32_t	cksum;
 	udp_t		*udp = connp->conn_udp;
 	boolean_t	insert_spi = udp->udp_nat_t_endpoint;
-	boolean_t	hash_srcport = udp->udp_vxlanhash;
 	uint_t		ulp_hdr_len;
-	uint16_t	srcport;
 
 	data_len = msgdsize(data_mp);
 	ulp_hdr_len = UDPH_SIZE;
@@ -2130,16 +2018,6 @@
 	if (insert_spi)
 		ulp_hdr_len += sizeof (uint32_t);
 
-	/*
-	 * If we have source port hashing going on, determine the hash before
-	 * we modify the mblk_t.
-	 */
-	if (hash_srcport == B_TRUE) {
-		srcport = udp_srcport_hash(mp, UDP_HASH_VXLAN,
-		    IPPORT_DYNAMIC_MIN, IPPORT_DYNAMIC_MAX,
-		    ntohs(connp->conn_lport));
-	}
-
 	mp = conn_prepend_hdr(ixa, ipp, v6src, v6dst, IPPROTO_UDP, flowinfo,
 	    ulp_hdr_len, data_mp, data_len, us->us_wroff_extra, &cksum, errorp);
 	if (mp == NULL) {
@@ -2151,11 +2029,7 @@
 	ixa->ixa_pktlen = data_len + ixa->ixa_ip_hdr_length;
 
 	udpha = (udpha_t *)(mp->b_rptr + ixa->ixa_ip_hdr_length);
-	if (hash_srcport == B_TRUE) {
-		udpha->uha_src_port = htons(srcport);
-	} else {
-		udpha->uha_src_port = connp->conn_lport;
-	}
+	udpha->uha_src_port = connp->conn_lport;
 	udpha->uha_dst_port = dstport;
 	udpha->uha_checksum = 0;
 	udpha->uha_length = htons(data_len);
@@ -3330,7 +3204,6 @@
 	udp_t		*udp = connp->conn_udp;
 	udp_stack_t	*us = udp->udp_us;
 	boolean_t	insert_spi = udp->udp_nat_t_endpoint;
-	boolean_t	hash_srcport = udp->udp_vxlanhash;
 	uint_t		pktlen;
 	uint_t		alloclen;
 	uint_t		copylen;
@@ -3339,21 +3212,10 @@
 	udpha_t		*udpha;
 	uint32_t	cksum;
 	ip_pkt_t	*ipp;
-	uint16_t	srcport;
 
 	ASSERT(MUTEX_HELD(&connp->conn_lock));
 
 	/*
-	 * If we have source port hashing going on, determine the hash before
-	 * we modify the mblk_t.
-	 */
-	if (hash_srcport == B_TRUE) {
-		srcport = udp_srcport_hash(mp, UDP_HASH_VXLAN,
-		    IPPORT_DYNAMIC_MIN, IPPORT_DYNAMIC_MAX,
-		    ntohs(connp->conn_lport));
-	}
-
-	/*
 	 * Copy the header template and leave space for an SPI
 	 */
 	copylen = connp->conn_ht_iphc_len;
@@ -3451,9 +3313,6 @@
 		*((uint32_t *)(udpha + 1)) = 0;
 
 	udpha->uha_dst_port = dstport;
-	if (hash_srcport == B_TRUE)
-		udpha->uha_src_port = htons(srcport);
-
 	return (mp);
 }
 
@@ -6061,6 +5920,7 @@
 	ushort_t	ipversion;
 	pid_t		pid = curproc->p_pid;
 	ip_xmit_attr_t	*ixa;
+	boolean_t	snd_to_conn;
 
 	ASSERT(DB_TYPE(mp) == M_DATA);
 
@@ -6105,7 +5965,10 @@
 	 * historically we've returned an error if already connected. The
 	 * client can allow this via a sockopt.
 	 */
-	if (udp->udp_state == TS_DATA_XFER && !udp->udp_snd_to_conn) {
+	mutex_enter(&connp->conn_lock);
+	snd_to_conn = (udp->udp_snd_to_conn != 0);
+	mutex_exit(&connp->conn_lock);
+	if (udp->udp_state == TS_DATA_XFER && !snd_to_conn) {
 		UDPS_BUMP_MIB(us, udpOutErrors);
 		return (EISCONN);
 	}
--- old/usr/src/uts/common/inet/udp/udp_opt_data.c	Wed Oct  5 00:33:48 2016
+++ new/usr/src/uts/common/inet/udp/udp_opt_data.c	Wed Oct  5 00:33:48 2016
@@ -21,7 +21,6 @@
 /*
  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
- * Copyright 2015, Joyent, Inc.
  */
 
 #include <sys/types.h>
@@ -293,7 +292,6 @@
 	},
 { UDP_NAT_T_ENDPOINT, IPPROTO_UDP, OA_RW, OA_RW, OP_PRIVPORT, 0, sizeof (int),
 	0 },
-{ UDP_SRCPORT_HASH, IPPROTO_UDP, OA_R, OA_RW, OP_CONFIG, 0, sizeof (int), 0 },
 { UDP_SND_TO_CONNECTED, IPPROTO_UDP, OA_R, OA_RW, OP_CONFIG, 0, sizeof (int),
 	0 }
 };
--- old/usr/src/uts/common/inet/udp_impl.h	Wed Oct  5 00:33:48 2016
+++ new/usr/src/uts/common/inet/udp_impl.h	Wed Oct  5 00:33:48 2016
@@ -20,7 +20,6 @@
  */
 /*
  * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2015, Joyent, Inc.
  */
 
 #ifndef	_UDP_IMPL_H
@@ -179,12 +178,9 @@
 		udp_issocket : 1,	/* socket mode; sockfs is on top */
 		udp_nat_t_endpoint : 1,	/* UDP_NAT_T_ENDPOINT option */
 		udp_rcvhdr : 1,		/* UDP_RCVHDR option */
-		udp_vxlanhash: 1,	/* UDP_SRCPORT_HASH option */
-					/* Because there's only VXLAN, cheat */
-					/* and only use a single bit */
 		udp_snd_to_conn: 1,	/* UDP_SND_TO_CONNECTED option */
 
-		udp_pad_to_bit_31 : 27;
+		udp_pad_to_bit_31 : 28;
 
 	/* Following 2 fields protected by the uf_lock */
 	struct udp_s	*udp_bind_hash; /* Bind hash chain */
No differences encountered
No differences encountered
--- old/usr/src/uts/common/io/devpoll.c	Wed Oct  5 00:33:49 2016
+++ new/usr/src/uts/common/io/devpoll.c	Wed Oct  5 00:33:49 2016
@@ -675,18 +675,6 @@
 	pollfdnum = uiosize / size;
 
 	/*
-	 * For epoll-enabled handles, restrict the allowed write size to 2.
-	 * This corresponds to an epoll_ctl(3C) performing an EPOLL_CTL_MOD
-	 * operation which is expanded into two operations (DEL and ADD).
-	 *
-	 * All other operations performed through epoll_ctl(3C) will consist of
-	 * a single entry.
-	 */
-	if (is_epoll && pollfdnum > 2) {
-		return (EINVAL);
-	}
-
-	/*
 	 * We want to make sure that pollfdnum isn't large enough to DoS us,
 	 * but we also don't want to grab p_lock unnecessarily -- so we
 	 * perform the full check against our resource limits if and only if
@@ -745,21 +733,6 @@
 	while ((dpep->dpe_flag & DP_WRITER_PRESENT) != 0) {
 		ASSERT(dpep->dpe_refcnt != 0);
 
-		/*
-		 * The epoll API does not allow EINTR as a result when making
-		 * modifications to the set of polled fds.  Given that write
-		 * activity is relatively quick and the size of accepted writes
-		 * is limited above to two entries, a signal-ignorant wait is
-		 * used here to avoid the EINTR.
-		 */
-		if (is_epoll) {
-			cv_wait(&dpep->dpe_cv, &dpep->dpe_lock);
-			continue;
-		}
-
-		/*
-		 * Non-epoll writers to /dev/poll handles can tolerate EINTR.
-		 */
 		if (!cv_wait_sig_swap(&dpep->dpe_cv, &dpep->dpe_lock)) {
 			dpep->dpe_writerwait--;
 			mutex_exit(&dpep->dpe_lock);
No differences encountered
--- old/usr/src/uts/common/io/inotify.c	Wed Oct  5 00:33:49 2016
+++ new/usr/src/uts/common/io/inotify.c	Wed Oct  5 00:33:49 2016
@@ -505,7 +505,7 @@
 	event->ine_event.len = len;
 
 	if (name != NULL)
-		strcpy(event->ine_event.name, name);
+		(void) strcpy(event->ine_event.name, name);
 
 	if (tail != NULL) {
 		tail->ine_next = event;
@@ -629,7 +629,8 @@
 		watch->inw_mask &= IN_CHILD_EVENTS;
 		watch->inw_parent = parent;
 		watch->inw_name = kmem_alloc(strlen(name) + 1, KM_SLEEP);
-		strcpy(watch->inw_name, name);
+		/* strcpy() is safe, because strlen(name) bounds us. */
+		(void) strcpy(watch->inw_name, name);
 
 		avl_add(&parent->inw_children, watch);
 	}
No differences encountered
No differences encountered
--- old/usr/src/uts/common/io/pseudonex.c	Wed Oct  5 00:33:49 2016
+++ new/usr/src/uts/common/io/pseudonex.c	Wed Oct  5 00:33:49 2016
@@ -385,6 +385,7 @@
 	return (-1);
 }
 
+/* ARGSUSED */
 static int
 pseudonex_fm_init(dev_info_t *dip, dev_info_t *tdip, int cap,
     ddi_iblock_cookie_t *ibc)
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/uts/common/io/zfd.c	Wed Oct  5 00:33:49 2016
+++ new/usr/src/uts/common/io/zfd.c	Wed Oct  5 00:33:49 2016
@@ -890,6 +890,8 @@
 			}
 
 			/* Get the primary slave minor device number */
+			ASSERT(IS_P2ALIGNED(mp->b_cont->b_rptr, 4));
+			/* LINTED - b_rptr will always be aligned. */
 			to = *(int *)mp->b_cont->b_rptr;
 			instance = ZFD_INSTANCE(to);
 
@@ -942,6 +944,8 @@
 			prim_zfds = zfds->zfd_inst_pri;
 
 			/* Get the flow control setting */
+			ASSERT(IS_P2ALIGNED(mp->b_cont->b_rptr, 4));
+			/* LINTED - b_rptr will always be aligned. */
 			val = *(int *)mp->b_cont->b_rptr;
 			if (val != 0 && val != 1) {
 				miocack(qp, mp, 0, EINVAL);
--- old/usr/src/uts/common/netinet/udp.h	Wed Oct  5 00:33:49 2016
+++ new/usr/src/uts/common/netinet/udp.h	Wed Oct  5 00:33:49 2016
@@ -18,6 +18,9 @@
 #ifndef	_NETINET_UDP_H
 #define	_NETINET_UDP_H
 
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+/* udp.h 1.7 88/08/19 SMI; from UCB 7.1 6/5/86	*/
+
 #ifdef	__cplusplus
 extern "C" {
 #endif
@@ -34,17 +37,9 @@
 #define	UDP_EXCLBIND		0x0101		/* for internal use only */
 #define	UDP_RCVHDR		0x0102		/* for internal use only */
 #define	UDP_NAT_T_ENDPOINT	0x0103		/* for internal use only */
-#define	UDP_SRCPORT_HASH	0x0104		/* for internal use only */
 #define	UDP_SND_TO_CONNECTED	0x0105		/* for internal use only */
 
 /*
- * Hash definitions for UDP_SRCPORT_HASH that effectively tell UDP how to go
- * handle UDP_SRCPORT_HASH.
- */
-#define	UDP_HASH_DISABLE	0x0000		/* for internal use only */
-#define	UDP_HASH_VXLAN		0x0001		/* for internal use only */
-
-/*
  * Following option in UDP_ namespace required to be exposed through
  * <xti.h> (It also requires exposing options not implemented). The options
  * with potential for conflicts use #ifndef guards.
No differences encountered
No differences encountered
--- old/usr/src/uts/common/os/exec.c	Wed Oct  5 00:33:50 2016
+++ new/usr/src/uts/common/os/exec.c	Wed Oct  5 00:33:50 2016
@@ -1564,8 +1564,6 @@
 static int
 stk_byte_add(uarg_t *args, const uint8_t *sp, size_t len)
 {
-	int error;
-
 	if (STK_AVAIL(args) < sizeof (int))
 		return (E2BIG);
 	*--args->stk_offp = args->stk_strp - args->stk_base;
--- old/usr/src/uts/common/os/exit.c	Wed Oct  5 00:33:50 2016
+++ new/usr/src/uts/common/os/exit.c	Wed Oct  5 00:33:50 2016
@@ -21,7 +21,7 @@
 
 /*
  * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2015 Joyent, Inc. All rights reserved.
+ * Copyright 2014 Joyent, Inc. All rights reserved.
  */
 
 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
No differences encountered
No differences encountered
--- old/usr/src/uts/common/os/grow.c	Wed Oct  5 00:33:50 2016
+++ new/usr/src/uts/common/os/grow.c	Wed Oct  5 00:33:50 2016
@@ -503,10 +503,30 @@
 choose_addr(struct as *as, caddr_t *addrp, size_t len, offset_t off,
     int vacalign, uint_t flags)
 {
+#if defined(__amd64)
+	proc_t *p = curproc;
+#endif
 	caddr_t basep = (caddr_t)(uintptr_t)((uintptr_t)*addrp & PAGEMASK);
-	size_t lenp = len;
+	size_t lenp;
 
 	ASSERT(AS_ISCLAIMGAP(as));	/* searches should be serialized */
+
+	/*
+	 * If we have been provided a hint, we should still expand the lenp
+	 * to be the rest of the address space.  This will allow us to
+	 * treat the hint as a strong desire to be "nearby" the provided
+	 * address.  If we can't satisfy the hint, as_gap() will walk forward.
+	 */
+	if (flags & _MAP_LOW32)
+		lenp = (caddr_t)USERLIMIT32 - basep;
+#if defined(__amd64)
+	else if (p->p_model == DATAMODEL_NATIVE)
+		lenp = p->p_usrstack - basep -
+		    ((p->p_stk_ctl + PAGEOFFSET) & PAGEMASK);
+#endif
+	else
+		lenp = as->a_userlimit - basep;
+
 	if (flags & MAP_FIXED) {
 		(void) as_unmap(as, *addrp, len);
 		return (0);
No differences encountered
No differences encountered
--- old/usr/src/uts/common/os/kmem.c	Wed Oct  5 00:33:51 2016
+++ new/usr/src/uts/common/os/kmem.c	Wed Oct  5 00:33:51 2016
@@ -20,7 +20,6 @@
  */
 /*
  * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2015 Joyent, Inc.  All rights reserved.
  * Copyright (c) 2012, 2016 by Delphix. All rights reserved.
  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  */
@@ -160,22 +159,10 @@
  *               find known objects and is about to free it, or
  *            c) the client has freed the object.
  *            In all these cases (a, b, and c) kmem frees the new object (the
- *            unused copy destination).  In the first case, the object is in
- *            use and the correct action is that for LATER; in the latter two
- *            cases, we know that the object is either freed or about to be
- *            freed, in which case it is either already in a magazine or about
- *            to be in one.  In these cases, we know that the object will either
- *            be reallocated and reused, or it will end up in a full magazine
- *            that will be reaped (thereby liberating the slab).  Because it
- *            is prohibitively expensive to differentiate these cases, and
- *            because the defrag code is executed when we're low on memory
- *            (thereby biasing the system to reclaim full magazines) we treat
- *            all DONT_KNOW cases as LATER and rely on cache reaping to
- *            generally clean up full magazines.  While we take the same action
- *            for these cases, we maintain their semantic distinction:  if
- *            defragmentation is not occurring, it is useful to know if this
- *            is due to objects in use (LATER) or objects in an unknown state
- *            of transition (DONT_KNOW).
+ *            unused copy destination) and searches for the old object in the
+ *            magazine layer. If found, the object is removed from the magazine
+ *            layer and freed to the slab layer so it will no longer hold the
+ *            slab hostage.
  *
  * 2.3 Object States
  *
@@ -298,10 +285,10 @@
  * view of the slab layer, making it a candidate for the move callback. Most
  * objects unrecognized by the client in the move callback fall into this
  * category and are cheaply distinguished from known objects by the test
- * described earlier. Because searching magazines is prohibitively expensive
- * for kmem, clients that do not mark freed objects (and therefore return
- * KMEM_CBRC_DONT_KNOW for large numbers of objects) may find defragmentation
- * efficacy reduced.
+ * described earlier. Since recognition is cheap for the client, and searching
+ * magazines is expensive for kmem, kmem defers searching until the client first
+ * returns KMEM_CBRC_DONT_KNOW. As long as the needed effort is reasonable, kmem
+ * elsewhere does what it can to avoid bothering the client unnecessarily.
  *
  * Invalidating the designated pointer member before freeing the object marks
  * the object to be avoided in the callback, and conversely, assigning a valid
@@ -1011,7 +998,6 @@
 size_t kmem_content_log_size;	/* content log size [2% of memory] */
 size_t kmem_failure_log_size;	/* failure log [4 pages per CPU] */
 size_t kmem_slab_log_size;	/* slab create log [4 pages per CPU] */
-size_t kmem_zerosized_log_size;	/* zero-sized log [4 pages per CPU] */
 size_t kmem_content_maxsave = 256; /* KMF_CONTENTS max bytes to log */
 size_t kmem_lite_minsize = 0;	/* minimum buffer size for KMF_LITE */
 size_t kmem_lite_maxalign = 1024; /* maximum buffer alignment for KMF_LITE */
@@ -1019,14 +1005,6 @@
 size_t kmem_maxverify;		/* maximum bytes to inspect in debug routines */
 size_t kmem_minfirewall;	/* hardware-enforced redzone threshold */
 
-#ifdef DEBUG
-int kmem_warn_zerosized = 1;	/* whether to warn on zero-sized KM_SLEEP */
-#else
-int kmem_warn_zerosized = 0;	/* whether to warn on zero-sized KM_SLEEP */
-#endif
-
-int kmem_panic_zerosized = 0;	/* whether to panic on zero-sized KM_SLEEP */
-
 #ifdef _LP64
 size_t	kmem_max_cached = KMEM_BIG_MAXBUF;	/* maximum kmem_alloc cache */
 #else
@@ -1060,8 +1038,22 @@
 static vmem_t		*kmem_firewall_va_arena;
 static vmem_t		*kmem_firewall_arena;
 
-static int		kmem_zerosized;		/* # of zero-sized allocs */
+/*
+ * Define KMEM_STATS to turn on statistic gathering. By default, it is only
+ * turned on when DEBUG is also defined.
+ */
+#ifdef	DEBUG
+#define	KMEM_STATS
+#endif	/* DEBUG */
 
+#ifdef	KMEM_STATS
+#define	KMEM_STAT_ADD(stat)			((stat)++)
+#define	KMEM_STAT_COND_ADD(cond, stat)		((void) (!(cond) || (stat)++))
+#else
+#define	KMEM_STAT_ADD(stat)			/* nothing */
+#define	KMEM_STAT_COND_ADD(cond, stat)		/* nothing */
+#endif	/* KMEM_STATS */
+
 /*
  * kmem slab consolidator thresholds (tunables)
  */
@@ -1079,6 +1071,47 @@
  */
 size_t kmem_reclaim_scan_range = 12;
 
+#ifdef	KMEM_STATS
+static struct {
+	uint64_t kms_callbacks;
+	uint64_t kms_yes;
+	uint64_t kms_no;
+	uint64_t kms_later;
+	uint64_t kms_dont_need;
+	uint64_t kms_dont_know;
+	uint64_t kms_hunt_found_mag;
+	uint64_t kms_hunt_found_slab;
+	uint64_t kms_hunt_alloc_fail;
+	uint64_t kms_hunt_lucky;
+	uint64_t kms_notify;
+	uint64_t kms_notify_callbacks;
+	uint64_t kms_disbelief;
+	uint64_t kms_already_pending;
+	uint64_t kms_callback_alloc_fail;
+	uint64_t kms_callback_taskq_fail;
+	uint64_t kms_endscan_slab_dead;
+	uint64_t kms_endscan_slab_destroyed;
+	uint64_t kms_endscan_nomem;
+	uint64_t kms_endscan_refcnt_changed;
+	uint64_t kms_endscan_nomove_changed;
+	uint64_t kms_endscan_freelist;
+	uint64_t kms_avl_update;
+	uint64_t kms_avl_noupdate;
+	uint64_t kms_no_longer_reclaimable;
+	uint64_t kms_notify_no_longer_reclaimable;
+	uint64_t kms_notify_slab_dead;
+	uint64_t kms_notify_slab_destroyed;
+	uint64_t kms_alloc_fail;
+	uint64_t kms_constructor_fail;
+	uint64_t kms_dead_slabs_freed;
+	uint64_t kms_defrags;
+	uint64_t kms_scans;
+	uint64_t kms_scan_depot_ws_reaps;
+	uint64_t kms_debug_reaps;
+	uint64_t kms_debug_scans;
+} kmem_move_stats;
+#endif	/* KMEM_STATS */
+
 /* consolidator knobs */
 static boolean_t kmem_move_noreap;
 static boolean_t kmem_move_blocked;
@@ -1109,7 +1142,6 @@
 kmem_log_header_t	*kmem_content_log;
 kmem_log_header_t	*kmem_failure_log;
 kmem_log_header_t	*kmem_slab_log;
-kmem_log_header_t	*kmem_zerosized_log;
 
 static int		kmem_lite_count; /* # of PCs in kmem_buftag_lite_t */
 
@@ -1890,7 +1922,15 @@
 		cp->cache_complete_slab_count--;
 		avl_add(&cp->cache_partial_slabs, sp);
 	} else {
+#ifdef	DEBUG
+		if (avl_update_gt(&cp->cache_partial_slabs, sp)) {
+			KMEM_STAT_ADD(kmem_move_stats.kms_avl_update);
+		} else {
+			KMEM_STAT_ADD(kmem_move_stats.kms_avl_noupdate);
+		}
+#else
 		(void) avl_update_gt(&cp->cache_partial_slabs, sp);
+#endif
 	}
 
 	ASSERT((cp->cache_slab_create - cp->cache_slab_destroy) ==
@@ -2924,33 +2964,8 @@
 		/* fall through to kmem_cache_alloc() */
 
 	} else {
-		if (size == 0) {
-			if (kmflag != KM_SLEEP && !(kmflag & KM_PANIC))
-				return (NULL);
-
-			/*
-			 * If this is a sleeping allocation or one that has
-			 * been specified to panic on allocation failure, we
-			 * consider it to be deprecated behavior to allocate
-			 * 0 bytes.  If we have been configured to panic under
-			 * this condition, we panic; if to warn, we warn -- and
-			 * regardless, we log to the kmem_zerosized_log that
-			 * that this condition has occurred (which gives us
-			 * enough information to be able to debug it).
-			 */
-			if (kmem_panic && kmem_panic_zerosized)
-				panic("attempted to kmem_alloc() size of 0");
-
-			if (kmem_warn_zerosized) {
-				cmn_err(CE_WARN, "kmem_alloc(): sleeping "
-				    "allocation with size of 0; "
-				    "see kmem_zerosized_log for details");
-			}
-
-			kmem_log_event(kmem_zerosized_log, NULL, NULL, NULL);
-
+		if (size == 0)
 			return (NULL);
-		}
 
 		buf = vmem_alloc(kmem_oversize_arena, size,
 		    kmflag & KM_VMFLAGS);
@@ -3564,7 +3579,7 @@
 		kmcp->kmc_move_later.value.ui64		= kd->kmd_later;
 		kmcp->kmc_move_dont_need.value.ui64	= kd->kmd_dont_need;
 		kmcp->kmc_move_dont_know.value.ui64	= kd->kmd_dont_know;
-		kmcp->kmc_move_hunt_found.value.ui64	= 0;
+		kmcp->kmc_move_hunt_found.value.ui64	= kd->kmd_hunt_found;
 		kmcp->kmc_move_slabs_freed.value.ui64	= kd->kmd_slabs_freed;
 		kmcp->kmc_defrag.value.ui64		= kd->kmd_defrags;
 		kmcp->kmc_scan.value.ui64		= kd->kmd_scans;
@@ -4474,8 +4489,8 @@
 	}
 
 	kmem_failure_log = kmem_log_init(kmem_failure_log_size);
+
 	kmem_slab_log = kmem_log_init(kmem_slab_log_size);
-	kmem_zerosized_log = kmem_log_init(kmem_zerosized_log_size);
 
 	/*
 	 * Initialize STREAMS message caches so allocb() is available.
@@ -4663,7 +4678,95 @@
 	    (sp->slab_chunks * cp->cache_defrag->kmd_reclaim_numer));
 }
 
+static void *
+kmem_hunt_mag(kmem_cache_t *cp, kmem_magazine_t *m, int n, void *buf,
+    void *tbuf)
+{
+	int i;		/* magazine round index */
+
+	for (i = 0; i < n; i++) {
+		if (buf == m->mag_round[i]) {
+			if (cp->cache_flags & KMF_BUFTAG) {
+				(void) kmem_cache_free_debug(cp, tbuf,
+				    caller());
+			}
+			m->mag_round[i] = tbuf;
+			return (buf);
+		}
+	}
+
+	return (NULL);
+}
+
 /*
+ * Hunt the magazine layer for the given buffer. If found, the buffer is
+ * removed from the magazine layer and returned, otherwise NULL is returned.
+ * The state of the returned buffer is freed and constructed.
+ */
+static void *
+kmem_hunt_mags(kmem_cache_t *cp, void *buf)
+{
+	kmem_cpu_cache_t *ccp;
+	kmem_magazine_t	*m;
+	int cpu_seqid;
+	int n;		/* magazine rounds */
+	void *tbuf;	/* temporary swap buffer */
+
+	ASSERT(MUTEX_NOT_HELD(&cp->cache_lock));
+
+	/*
+	 * Allocated a buffer to swap with the one we hope to pull out of a
+	 * magazine when found.
+	 */
+	tbuf = kmem_cache_alloc(cp, KM_NOSLEEP);
+	if (tbuf == NULL) {
+		KMEM_STAT_ADD(kmem_move_stats.kms_hunt_alloc_fail);
+		return (NULL);
+	}
+	if (tbuf == buf) {
+		KMEM_STAT_ADD(kmem_move_stats.kms_hunt_lucky);
+		if (cp->cache_flags & KMF_BUFTAG) {
+			(void) kmem_cache_free_debug(cp, buf, caller());
+		}
+		return (buf);
+	}
+
+	/* Hunt the depot. */
+	mutex_enter(&cp->cache_depot_lock);
+	n = cp->cache_magtype->mt_magsize;
+	for (m = cp->cache_full.ml_list; m != NULL; m = m->mag_next) {
+		if (kmem_hunt_mag(cp, m, n, buf, tbuf) != NULL) {
+			mutex_exit(&cp->cache_depot_lock);
+			return (buf);
+		}
+	}
+	mutex_exit(&cp->cache_depot_lock);
+
+	/* Hunt the per-CPU magazines. */
+	for (cpu_seqid = 0; cpu_seqid < max_ncpus; cpu_seqid++) {
+		ccp = &cp->cache_cpu[cpu_seqid];
+
+		mutex_enter(&ccp->cc_lock);
+		m = ccp->cc_loaded;
+		n = ccp->cc_rounds;
+		if (kmem_hunt_mag(cp, m, n, buf, tbuf) != NULL) {
+			mutex_exit(&ccp->cc_lock);
+			return (buf);
+		}
+		m = ccp->cc_ploaded;
+		n = ccp->cc_prounds;
+		if (kmem_hunt_mag(cp, m, n, buf, tbuf) != NULL) {
+			mutex_exit(&ccp->cc_lock);
+			return (buf);
+		}
+		mutex_exit(&ccp->cc_lock);
+	}
+
+	kmem_cache_free(cp, tbuf);
+	return (NULL);
+}
+
+/*
  * May be called from the kmem_move_taskq, from kmem_cache_move_notify_task(),
  * or when the buffer is freed.
  */
@@ -4726,7 +4829,7 @@
  * NO		kmem frees the new buffer, marks the slab of the old buffer
  *              non-reclaimable to avoid bothering the client again
  * LATER	kmem frees the new buffer, increments slab_later_count
- * DONT_KNOW	kmem frees the new buffer
+ * DONT_KNOW	kmem frees the new buffer, searches mags for the old buffer
  * DONT_NEED	kmem frees both the old buffer and the new buffer
  *
  * The pending callback argument now being processed contains both of the
@@ -4760,6 +4863,9 @@
 	 * another buffer on the same slab.
 	 */
 	if (!kmem_slab_is_reclaimable(cp, sp, callback->kmm_flags)) {
+		KMEM_STAT_ADD(kmem_move_stats.kms_no_longer_reclaimable);
+		KMEM_STAT_COND_ADD((callback->kmm_flags & KMM_NOTIFY),
+		    kmem_move_stats.kms_notify_no_longer_reclaimable);
 		kmem_slab_free(cp, callback->kmm_to_buf);
 		kmem_move_end(cp, callback);
 		return;
@@ -4766,8 +4872,10 @@
 	}
 
 	/*
-	 * Checking the slab layer is easy, so we might as well do that here
-	 * in case we can avoid bothering the client.
+	 * Hunting magazines is expensive, so we'll wait to do that until the
+	 * client responds KMEM_CBRC_DONT_KNOW. However, checking the slab layer
+	 * is cheap, so we might as well do that here in case we can avoid
+	 * bothering the client.
 	 */
 	mutex_enter(&cp->cache_lock);
 	free_on_slab = (kmem_slab_allocated(cp, sp,
@@ -4775,6 +4883,7 @@
 	mutex_exit(&cp->cache_lock);
 
 	if (free_on_slab) {
+		KMEM_STAT_ADD(kmem_move_stats.kms_hunt_found_slab);
 		kmem_slab_free(cp, callback->kmm_to_buf);
 		kmem_move_end(cp, callback);
 		return;
@@ -4786,6 +4895,7 @@
 		 */
 		if (kmem_cache_alloc_debug(cp, callback->kmm_to_buf,
 		    KM_NOSLEEP, 1, caller()) != 0) {
+			KMEM_STAT_ADD(kmem_move_stats.kms_alloc_fail);
 			kmem_move_end(cp, callback);
 			return;
 		}
@@ -4793,11 +4903,15 @@
 	    cp->cache_constructor(callback->kmm_to_buf, cp->cache_private,
 	    KM_NOSLEEP) != 0) {
 		atomic_inc_64(&cp->cache_alloc_fail);
+		KMEM_STAT_ADD(kmem_move_stats.kms_constructor_fail);
 		kmem_slab_free(cp, callback->kmm_to_buf);
 		kmem_move_end(cp, callback);
 		return;
 	}
 
+	KMEM_STAT_ADD(kmem_move_stats.kms_callbacks);
+	KMEM_STAT_COND_ADD((callback->kmm_flags & KMM_NOTIFY),
+	    kmem_move_stats.kms_notify_callbacks);
 	cp->cache_defrag->kmd_callbacks++;
 	cp->cache_defrag->kmd_thread = curthread;
 	cp->cache_defrag->kmd_from_buf = callback->kmm_from_buf;
@@ -4815,6 +4929,7 @@
 	cp->cache_defrag->kmd_to_buf = NULL;
 
 	if (response == KMEM_CBRC_YES) {
+		KMEM_STAT_ADD(kmem_move_stats.kms_yes);
 		cp->cache_defrag->kmd_yes++;
 		kmem_slab_free_constructed(cp, callback->kmm_from_buf, B_FALSE);
 		/* slab safe to access until kmem_move_end() */
@@ -4829,6 +4944,7 @@
 
 	switch (response) {
 	case KMEM_CBRC_NO:
+		KMEM_STAT_ADD(kmem_move_stats.kms_no);
 		cp->cache_defrag->kmd_no++;
 		mutex_enter(&cp->cache_lock);
 		kmem_slab_move_no(cp, sp, callback->kmm_from_buf);
@@ -4835,6 +4951,7 @@
 		mutex_exit(&cp->cache_lock);
 		break;
 	case KMEM_CBRC_LATER:
+		KMEM_STAT_ADD(kmem_move_stats.kms_later);
 		cp->cache_defrag->kmd_later++;
 		mutex_enter(&cp->cache_lock);
 		if (!KMEM_SLAB_IS_PARTIAL(sp)) {
@@ -4843,6 +4960,7 @@
 		}
 
 		if (++sp->slab_later_count >= KMEM_DISBELIEF) {
+			KMEM_STAT_ADD(kmem_move_stats.kms_disbelief);
 			kmem_slab_move_no(cp, sp, callback->kmm_from_buf);
 		} else if (!(sp->slab_flags & KMEM_SLAB_NOMOVE)) {
 			sp->slab_stuck_offset = KMEM_SLAB_OFFSET(sp,
@@ -4851,6 +4969,7 @@
 		mutex_exit(&cp->cache_lock);
 		break;
 	case KMEM_CBRC_DONT_NEED:
+		KMEM_STAT_ADD(kmem_move_stats.kms_dont_need);
 		cp->cache_defrag->kmd_dont_need++;
 		kmem_slab_free_constructed(cp, callback->kmm_from_buf, B_FALSE);
 		if (sp->slab_refcnt == 0)
@@ -4860,21 +4979,19 @@
 		mutex_exit(&cp->cache_lock);
 		break;
 	case KMEM_CBRC_DONT_KNOW:
-		/*
-		 * If we don't know if we can move this buffer or not, we'll
-		 * just assume that we can't:  if the buffer is in fact free,
-		 * then it is sitting in one of the per-CPU magazines or in
-		 * a full magazine in the depot layer.  Either way, because
-		 * defrag is induced in the same logic that reaps a cache,
-		 * it's likely that full magazines will be returned to the
-		 * system soon (thereby accomplishing what we're trying to
-		 * accomplish here: return those magazines to their slabs).
-		 * Given this, any work that we might do now to locate a buffer
-		 * in a magazine is wasted (and expensive!) work; we bump
-		 * a counter in this case and otherwise assume that we can't
-		 * move it.
-		 */
+		KMEM_STAT_ADD(kmem_move_stats.kms_dont_know);
 		cp->cache_defrag->kmd_dont_know++;
+		if (kmem_hunt_mags(cp, callback->kmm_from_buf) != NULL) {
+			KMEM_STAT_ADD(kmem_move_stats.kms_hunt_found_mag);
+			cp->cache_defrag->kmd_hunt_found++;
+			kmem_slab_free_constructed(cp, callback->kmm_from_buf,
+			    B_TRUE);
+			if (sp->slab_refcnt == 0)
+				cp->cache_defrag->kmd_slabs_freed++;
+			mutex_enter(&cp->cache_lock);
+			kmem_slab_move_yes(cp, sp, callback->kmm_from_buf);
+			mutex_exit(&cp->cache_lock);
+		}
 		break;
 	default:
 		panic("'%s' (%p) unexpected move callback response %d\n",
@@ -4899,9 +5016,10 @@
 	ASSERT(sp->slab_flags & KMEM_SLAB_MOVE_PENDING);
 
 	callback = kmem_cache_alloc(kmem_move_cache, KM_NOSLEEP);
-
-	if (callback == NULL)
+	if (callback == NULL) {
+		KMEM_STAT_ADD(kmem_move_stats.kms_callback_alloc_fail);
 		return (B_FALSE);
+	}
 
 	callback->kmm_from_slab = sp;
 	callback->kmm_from_buf = buf;
@@ -4926,6 +5044,7 @@
 			pending->kmm_flags |= KMM_DESPERATE;
 		}
 		mutex_exit(&cp->cache_lock);
+		KMEM_STAT_ADD(kmem_move_stats.kms_already_pending);
 		kmem_cache_free(kmem_move_cache, callback);
 		return (B_TRUE);
 	}
@@ -4939,6 +5058,7 @@
 
 	if (!taskq_dispatch(kmem_move_taskq, (task_func_t *)kmem_move_buffer,
 	    callback, TQ_NOSLEEP)) {
+		KMEM_STAT_ADD(kmem_move_stats.kms_callback_taskq_fail);
 		mutex_enter(&cp->cache_lock);
 		avl_remove(&cp->cache_defrag->kmd_moves_pending, callback);
 		mutex_exit(&cp->cache_lock);
@@ -4984,6 +5104,7 @@
 			cp->cache_slab_destroy++;
 			mutex_exit(&cp->cache_lock);
 			kmem_slab_destroy(cp, sp);
+			KMEM_STAT_ADD(kmem_move_stats.kms_dead_slabs_freed);
 			mutex_enter(&cp->cache_lock);
 		}
 	}
@@ -5128,6 +5249,8 @@
 					 * pending move completes.
 					 */
 					list_insert_head(deadlist, sp);
+					KMEM_STAT_ADD(kmem_move_stats.
+					    kms_endscan_slab_dead);
 					return (-1);
 				}
 
@@ -5142,6 +5265,10 @@
 				cp->cache_slab_destroy++;
 				mutex_exit(&cp->cache_lock);
 				kmem_slab_destroy(cp, sp);
+				KMEM_STAT_ADD(kmem_move_stats.
+				    kms_dead_slabs_freed);
+				KMEM_STAT_ADD(kmem_move_stats.
+				    kms_endscan_slab_destroyed);
 				mutex_enter(&cp->cache_lock);
 				/*
 				 * Since we can't pick up the scan where we left
@@ -5157,6 +5284,8 @@
 				 * for the request and say nothing about the
 				 * number of reclaimable slabs.
 				 */
+				KMEM_STAT_COND_ADD(s < max_slabs,
+				    kmem_move_stats.kms_endscan_nomem);
 				return (-1);
 			}
 
@@ -5172,10 +5301,16 @@
 				 * destination buffer on the same slab. In that
 				 * case, we're not interested in counting it.
 				 */
+				KMEM_STAT_COND_ADD(!(flags & KMM_DEBUG) &&
+				    (s < max_slabs),
+				    kmem_move_stats.kms_endscan_refcnt_changed);
 				return (-1);
 			}
-			if ((sp->slab_flags & KMEM_SLAB_NOMOVE) != nomove)
+			if ((sp->slab_flags & KMEM_SLAB_NOMOVE) != nomove) {
+				KMEM_STAT_COND_ADD(s < max_slabs,
+				    kmem_move_stats.kms_endscan_nomove_changed);
 				return (-1);
+			}
 
 			/*
 			 * Generating a move request allocates a destination
@@ -5202,6 +5337,11 @@
 	}
 end_scan:
 
+	KMEM_STAT_COND_ADD(!(flags & KMM_DEBUG) &&
+	    (s < max_slabs) &&
+	    (sp == avl_first(&cp->cache_partial_slabs)),
+	    kmem_move_stats.kms_endscan_freelist);
+
 	return (s);
 }
 
@@ -5261,6 +5401,8 @@
 			    &cp->cache_defrag->kmd_moves_pending)) {
 				list_insert_head(deadlist, sp);
 				mutex_exit(&cp->cache_lock);
+				KMEM_STAT_ADD(kmem_move_stats.
+				    kms_notify_slab_dead);
 				return;
 			}
 
@@ -5268,6 +5410,9 @@
 			cp->cache_slab_destroy++;
 			mutex_exit(&cp->cache_lock);
 			kmem_slab_destroy(cp, sp);
+			KMEM_STAT_ADD(kmem_move_stats.kms_dead_slabs_freed);
+			KMEM_STAT_ADD(kmem_move_stats.
+			    kms_notify_slab_destroyed);
 			return;
 		}
 	} else {
@@ -5281,6 +5426,7 @@
 {
 	kmem_move_notify_args_t *args;
 
+	KMEM_STAT_ADD(kmem_move_stats.kms_notify);
 	args = kmem_alloc(sizeof (kmem_move_notify_args_t), KM_NOSLEEP);
 	if (args != NULL) {
 		args->kmna_cache = cp;
@@ -5303,6 +5449,7 @@
 	n = avl_numnodes(&cp->cache_partial_slabs);
 	if (n > 1) {
 		/* kmem_move_buffers() drops and reacquires cache_lock */
+		KMEM_STAT_ADD(kmem_move_stats.kms_defrags);
 		cp->cache_defrag->kmd_defrags++;
 		(void) kmem_move_buffers(cp, n, 0, KMM_DESPERATE);
 	}
@@ -5401,6 +5548,7 @@
 		 *
 		 * kmem_move_buffers() drops and reacquires cache_lock.
 		 */
+		KMEM_STAT_ADD(kmem_move_stats.kms_scans);
 		kmd->kmd_scans++;
 		slabs_found = kmem_move_buffers(cp, kmem_reclaim_scan_range,
 		    kmem_reclaim_max_slabs, 0);
@@ -5441,9 +5589,12 @@
 			if (!kmem_move_noreap &&
 			    ((debug_rand % kmem_mtb_reap) == 0)) {
 				mutex_exit(&cp->cache_lock);
+				KMEM_STAT_ADD(kmem_move_stats.kms_debug_reaps);
 				kmem_cache_reap(cp);
 				return;
 			} else if ((debug_rand % kmem_mtb_move) == 0) {
+				KMEM_STAT_ADD(kmem_move_stats.kms_scans);
+				KMEM_STAT_ADD(kmem_move_stats.kms_debug_scans);
 				kmd->kmd_scans++;
 				(void) kmem_move_buffers(cp,
 				    kmem_reclaim_scan_range, 1, KMM_DEBUG);
@@ -5454,6 +5605,8 @@
 
 	mutex_exit(&cp->cache_lock);
 
-	if (reap)
+	if (reap) {
+		KMEM_STAT_ADD(kmem_move_stats.kms_scan_depot_ws_reaps);
 		kmem_depot_ws_reap(cp);
+	}
 }
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/uts/common/os/policy.c	Wed Oct  5 00:33:52 2016
+++ new/usr/src/uts/common/os/policy.c	Wed Oct  5 00:33:52 2016
@@ -2095,13 +2095,6 @@
 }
 
 int
-secpolicy_fs_import(const cred_t *cr)
-{
-	return (PRIV_POLICY(cr, PRIV_SYS_FS_IMPORT, B_FALSE, EPERM, NULL));
-}
-
-
-int
 secpolicy_pfexec_register(const cred_t *cr)
 {
 	return (PRIV_POLICY(cr, PRIV_SYS_ADMIN, B_TRUE, EPERM, NULL));
@@ -2604,12 +2597,4 @@
 	if (PRIV_POLICY_ONLY(cr, PRIV_SYS_NET_CONFIG, B_FALSE))
 		return (secpolicy_net_config(cr, B_FALSE));
 	return (PRIV_POLICY(cr, PRIV_SYS_PPP_CONFIG, B_FALSE, EPERM, NULL));
-}
-
-int
-secpolicy_hyprlofs_control(const cred_t *cr)
-{
-	if (PRIV_POLICY(cr, PRIV_HYPRLOFS_CONTROL, B_FALSE, EPERM, NULL))
-		return (EPERM);
-	return (0);
 }
No differences encountered
--- old/usr/src/uts/common/os/sig.c	Wed Oct  5 00:33:52 2016
+++ new/usr/src/uts/common/os/sig.c	Wed Oct  5 00:33:52 2016
@@ -60,8 +60,8 @@
 #include <sys/cyclic.h>
 #include <sys/dtrace.h>
 #include <sys/sdt.h>
-#include <sys/brand.h>
 #include <sys/signalfd.h>
+#include <sys/brand.h>
 
 const k_sigset_t nullsmask = {0, 0, 0};
 
No differences encountered
No differences encountered
--- old/usr/src/uts/common/os/zone.c	Wed Oct  5 00:33:52 2016
+++ new/usr/src/uts/common/os/zone.c	Wed Oct  5 00:33:52 2016
@@ -375,8 +375,6 @@
 rctl_hndl_t rc_zone_phys_mem;
 rctl_hndl_t rc_zone_max_lofi;
 rctl_hndl_t rc_zone_cpu_cap;
-rctl_hndl_t rc_zone_cpu_baseline;
-rctl_hndl_t rc_zone_cpu_burst_time;
 rctl_hndl_t rc_zone_zfs_io_pri;
 rctl_hndl_t rc_zone_nlwps;
 rctl_hndl_t rc_zone_nprocs;
@@ -423,9 +421,8 @@
  * Version 5 alters the zone_boot system call, and converts its old
  *     bootargs parameter to be set by the zone_setattr API instead.
  * Version 6 adds the flag argument to zone_create.
- * Version 7 adds the requested zoneid to zone_create.
  */
-static const int ZONE_SYSCALL_API_VERSION = 7;
+static const int ZONE_SYSCALL_API_VERSION = 6;
 
 /*
  * Certain filesystems (such as NFS and autofs) need to know which zone
@@ -1382,77 +1379,7 @@
 	rcop_no_test
 };
 
-/*ARGSUSED*/
-static rctl_qty_t
-zone_cpu_base_get(rctl_t *rctl, struct proc *p)
-{
-	ASSERT(MUTEX_HELD(&p->p_lock));
-	return (cpucaps_zone_get_base(p->p_zone));
-}
-
 /*
- * The zone cpu base is used to set the baseline CPU for the zone
- * so we can track when the zone is bursting.
- */
-/*ARGSUSED*/
-static int
-zone_cpu_base_set(rctl_t *rctl, struct proc *p, rctl_entity_p_t *e,
-    rctl_qty_t nv)
-{
-	zone_t *zone = e->rcep_p.zone;
-
-	ASSERT(MUTEX_HELD(&p->p_lock));
-	ASSERT(e->rcep_t == RCENTITY_ZONE);
-
-	if (zone == NULL)
-		return (0);
-
-	return (cpucaps_zone_set_base(zone, nv));
-}
-
-static rctl_ops_t zone_cpu_base_ops = {
-	rcop_no_action,
-	zone_cpu_base_get,
-	zone_cpu_base_set,
-	rcop_no_test
-};
-
-/*ARGSUSED*/
-static rctl_qty_t
-zone_cpu_burst_time_get(rctl_t *rctl, struct proc *p)
-{
-	ASSERT(MUTEX_HELD(&p->p_lock));
-	return (cpucaps_zone_get_burst_time(p->p_zone));
-}
-
-/*
- * The zone cpu burst time is used to set the amount of time CPU(s) can be
- * bursting for the zone.
- */
-/*ARGSUSED*/
-static int
-zone_cpu_burst_time_set(rctl_t *rctl, struct proc *p, rctl_entity_p_t *e,
-    rctl_qty_t nv)
-{
-	zone_t *zone = e->rcep_p.zone;
-
-	ASSERT(MUTEX_HELD(&p->p_lock));
-	ASSERT(e->rcep_t == RCENTITY_ZONE);
-
-	if (zone == NULL)
-		return (0);
-
-	return (cpucaps_zone_set_burst_time(zone, nv));
-}
-
-static rctl_ops_t zone_cpu_burst_time_ops = {
-	rcop_no_action,
-	zone_cpu_burst_time_get,
-	zone_cpu_burst_time_set,
-	rcop_no_test
-};
-
-/*
  * zone.zfs-io-pri resource control support (IO priority).
  */
 /*ARGSUSED*/
@@ -1986,7 +1913,7 @@
 }
 
 static kstat_t *
-zone_rctl_kstat_create_common(zone_t *zone, char *name,
+zone_kstat_create_common(zone_t *zone, char *name,
     int (*updatefunc) (kstat_t *, int))
 {
 	kstat_t *ksp;
@@ -2215,6 +2142,7 @@
 	/* The kstat "name" field is not large enough for a full zonename */
 	kstat_named_init(&zmp->zm_zonename, "zonename", KSTAT_DATA_STRING);
 	kstat_named_setstr(&zmp->zm_zonename, zone->zone_name);
+	kstat_named_setstr(&zmp->zm_zonename, zone->zone_name);
 	kstat_named_init(&zmp->zm_rss, "rss", KSTAT_DATA_UINT64);
 	kstat_named_init(&zmp->zm_phys_cap, "physcap", KSTAT_DATA_UINT64);
 	kstat_named_init(&zmp->zm_swap, "swap", KSTAT_DATA_UINT64);
@@ -2268,8 +2196,6 @@
 	zmp->zm_ffnomem.value.ui32 = zone->zone_ffnomem;
 	zmp->zm_ffmisc.value.ui32 = zone->zone_ffmisc;
 
-	zmp->zm_mfseglim.value.ui32 = zone->zone_mfseglim;
-
 	zmp->zm_nested_intp.value.ui32 = zone->zone_nested_intp;
 
 	zmp->zm_init_pid.value.ui32 = zone->zone_proc_initpid;
@@ -2313,8 +2239,6 @@
 	    KSTAT_DATA_UINT32);
 	kstat_named_init(&zmp->zm_ffnomem, "forkfail_nomem", KSTAT_DATA_UINT32);
 	kstat_named_init(&zmp->zm_ffmisc, "forkfail_misc", KSTAT_DATA_UINT32);
-	kstat_named_init(&zmp->zm_mfseglim, "mapfail_seglim",
-	    KSTAT_DATA_UINT32);
 	kstat_named_init(&zmp->zm_nested_intp, "nested_interp",
 	    KSTAT_DATA_UINT32);
 	kstat_named_init(&zmp->zm_init_pid, "init_pid", KSTAT_DATA_UINT32);
@@ -2330,13 +2254,13 @@
 static void
 zone_kstat_create(zone_t *zone)
 {
-	zone->zone_lockedmem_kstat = zone_rctl_kstat_create_common(zone,
+	zone->zone_lockedmem_kstat = zone_kstat_create_common(zone,
 	    "lockedmem", zone_lockedmem_kstat_update);
-	zone->zone_swapresv_kstat = zone_rctl_kstat_create_common(zone,
+	zone->zone_swapresv_kstat = zone_kstat_create_common(zone,
 	    "swapresv", zone_swapresv_kstat_update);
-	zone->zone_physmem_kstat = zone_rctl_kstat_create_common(zone,
+	zone->zone_physmem_kstat = zone_kstat_create_common(zone,
 	    "physicalmem", zone_physmem_kstat_update);
-	zone->zone_nprocs_kstat = zone_rctl_kstat_create_common(zone,
+	zone->zone_nprocs_kstat = zone_kstat_create_common(zone,
 	    "nprocs", zone_nprocs_kstat_update);
 
 	if ((zone->zone_vfs_ksp = zone_vfs_kstat_create(zone)) == NULL) {
@@ -2344,11 +2268,6 @@
 		    sizeof (zone_vfs_kstat_t), KM_SLEEP);
 	}
 
-	if ((zone->zone_zfs_ksp = zone_zfs_kstat_create(zone)) == NULL) {
-		zone->zone_zfs_stats = kmem_zalloc(
-		    sizeof (zone_zfs_kstat_t), KM_SLEEP);
-	}
-
 	if ((zone->zone_mcap_ksp = zone_mcap_kstat_create(zone)) == NULL) {
 		zone->zone_mcap_stats = kmem_zalloc(
 		    sizeof (zone_mcap_kstat_t), KM_SLEEP);
@@ -2358,6 +2277,7 @@
 		zone->zone_misc_stats = kmem_zalloc(
 		    sizeof (zone_misc_kstat_t), KM_SLEEP);
 	}
+
 }
 
 static void
@@ -2387,12 +2307,11 @@
 
 	zone_kstat_delete_common(&zone->zone_vfs_ksp,
 	    sizeof (zone_vfs_kstat_t));
-	zone_kstat_delete_common(&zone->zone_zfs_ksp,
-	    sizeof (zone_zfs_kstat_t));
 	zone_kstat_delete_common(&zone->zone_mcap_ksp,
 	    sizeof (zone_mcap_kstat_t));
 	zone_kstat_delete_common(&zone->zone_misc_ksp,
 	    sizeof (zone_misc_kstat_t));
+
 }
 
 /*
@@ -2454,6 +2373,7 @@
 	zone0.zone_physmem_kstat = NULL;
 	zone0.zone_nprocs_kstat = NULL;
 	zone0.zone_zfs_io_pri = 1;
+
 	zone0.zone_stime = 0;
 	zone0.zone_utime = 0;
 	zone0.zone_wtime = 0;
@@ -2564,16 +2484,6 @@
 	    RCTL_GLOBAL_INFINITE,
 	    MAXCAP, MAXCAP, &zone_cpu_cap_ops);
 
-	rc_zone_cpu_baseline = rctl_register("zone.cpu-baseline",
-	    RCENTITY_ZONE, RCTL_GLOBAL_SIGNAL_NEVER | RCTL_GLOBAL_DENY_NEVER |
-	    RCTL_GLOBAL_NOBASIC | RCTL_GLOBAL_COUNT | RCTL_GLOBAL_SYSLOG_NEVER,
-	    MAXCAP, MAXCAP, &zone_cpu_base_ops);
-
-	rc_zone_cpu_burst_time = rctl_register("zone.cpu-burst-time",
-	    RCENTITY_ZONE, RCTL_GLOBAL_SIGNAL_NEVER | RCTL_GLOBAL_DENY_NEVER |
-	    RCTL_GLOBAL_NOBASIC | RCTL_GLOBAL_COUNT | RCTL_GLOBAL_SYSLOG_NEVER,
-	    INT_MAX, INT_MAX, &zone_cpu_burst_time_ops);
-
 	rc_zone_zfs_io_pri = rctl_register("zone.zfs-io-priority",
 	    RCENTITY_ZONE, RCTL_GLOBAL_SIGNAL_NEVER | RCTL_GLOBAL_DENY_NEVER |
 	    RCTL_GLOBAL_NOBASIC | RCTL_GLOBAL_COUNT | RCTL_GLOBAL_SYSLOG_NEVER,
@@ -2620,20 +2530,6 @@
 	rde = rctl_dict_lookup("zone.cpu-shares");
 	(void) rctl_val_list_insert(&rde->rcd_default_value, dval);
 
-	/*
-	 * Create a rctl_val with PRIVILEGED, NOACTION, value = 1.  Then attach
-	 * this at the head of the rctl_dict_entry for ``zone.zfs-io-priority'.
-	 */
-	dval = kmem_cache_alloc(rctl_val_cache, KM_SLEEP);
-	bzero(dval, sizeof (rctl_val_t));
-	dval->rcv_value = 1;
-	dval->rcv_privilege = RCPRIV_PRIVILEGED;
-	dval->rcv_flagaction = RCTL_LOCAL_NOACTION;
-	dval->rcv_action_recip_pid = -1;
-
-	rde = rctl_dict_lookup("zone.zfs-io-priority");
-	(void) rctl_val_list_insert(&rde->rcd_default_value, dval);
-
 	rc_zone_locked_mem = rctl_register("zone.max-locked-memory",
 	    RCENTITY_ZONE, RCTL_GLOBAL_NOBASIC | RCTL_GLOBAL_BYTES |
 	    RCTL_GLOBAL_DENY_ALWAYS, UINT64_MAX, UINT64_MAX,
@@ -2838,8 +2734,6 @@
 static void
 zone_status_set(zone_t *zone, zone_status_t status)
 {
-	timestruc_t now;
-	uint64_t t;
 
 	nvlist_t *nvl = NULL;
 	ASSERT(MUTEX_HELD(&zone_status_lock));
@@ -2846,10 +2740,6 @@
 	ASSERT(status > ZONE_MIN_STATE && status <= ZONE_MAX_STATE &&
 	    status >= zone_status_get(zone));
 
-	/* Current time since Jan 1 1970 but consumers expect NS */
-	gethrestime(&now);
-	t = (now.tv_sec * NANOSEC) + now.tv_nsec;
-
 	if (nvlist_alloc(&nvl, NV_UNIQUE_NAME, KM_SLEEP) ||
 	    nvlist_add_string(nvl, ZONE_CB_NAME, zone->zone_name) ||
 	    nvlist_add_string(nvl, ZONE_CB_NEWSTATE,
@@ -2857,7 +2747,7 @@
 	    nvlist_add_string(nvl, ZONE_CB_OLDSTATE,
 	    zone_status_table[zone->zone_status]) ||
 	    nvlist_add_int32(nvl, ZONE_CB_ZONEID, zone->zone_id) ||
-	    nvlist_add_uint64(nvl, ZONE_CB_TIMESTAMP, t) ||
+	    nvlist_add_uint64(nvl, ZONE_CB_TIMESTAMP, (uint64_t)gethrtime()) ||
 	    sysevent_evc_publish(zone_event_chan, ZONE_EVENT_STATUS_CLASS,
 	    ZONE_EVENT_STATUS_SUBCLASS, "sun.com", "kernel", nvl, EVCH_SLEEP)) {
 #ifdef DEBUG
@@ -3458,12 +3348,6 @@
 	return (curproc->p_zone->zone_id);
 }
 
-zoneid_t
-getzonedid(void)
-{
-	return (curproc->p_zone->zone_did);
-}
-
 /*
  * Internal versions of zone_find_by_*().  These don't zone_hold() or
  * check the validity of a zone's state.
@@ -4808,8 +4692,7 @@
 }
 
 int
-zone_create_error(int er_error, int er_ext, int *er_out)
-{
+zone_create_error(int er_error, int er_ext, int *er_out) {
 	if (er_out != NULL) {
 		if (copyout(&er_ext, er_out, sizeof (int))) {
 			return (set_errno(EFAULT));
@@ -4899,13 +4782,13 @@
     caddr_t rctlbuf, size_t rctlbufsz,
     caddr_t zfsbuf, size_t zfsbufsz, int *extended_error,
     int match, uint32_t doi, const bslabel_t *label,
-    int flags, zoneid_t zone_did)
+    int flags)
 {
 	struct zsched_arg zarg;
 	nvlist_t *rctls = NULL;
 	proc_t *pp = curproc;
 	zone_t *zone, *ztmp;
-	zoneid_t zoneid, start = GLOBAL_ZONEID;
+	zoneid_t zoneid;
 	int error;
 	int error2 = 0;
 	char *str;
@@ -4920,59 +4803,8 @@
 		return (zone_create_error(ENOTSUP, ZE_CHROOTED,
 		    extended_error));
 
-	/*
-	 * As the first step of zone creation, we want to allocate a zoneid.
-	 * This allocation is complicated by the fact that netstacks use the
-	 * zoneid to determine their stackid, but netstacks themselves are
-	 * freed asynchronously with respect to zone destruction.  This means
-	 * that a netstack reference leak (or in principle, an extraordinarily
-	 * long netstack reference hold) could result in a zoneid being
-	 * allocated that in fact corresponds to a stackid from an active
-	 * (referenced) netstack -- unleashing all sorts of havoc when that
-	 * netstack is actually (re)used.  (In the abstract, we might wish a
-	 * zoneid to not be deallocated until its last referencing netstack
-	 * has been released, but netstacks lack a backpointer into their
-	 * referencing zone -- and changing them to have such a pointer would
-	 * be substantial, to put it euphemistically.)  To avoid this, we
-	 * detect this condition on allocation: if we have allocated a zoneid
-	 * that corresponds to a netstack that's still in use, we warn about
-	 * it (as it is much more likely to be a reference leak than an actual
-	 * netstack reference), free it, and allocate another.  That these
-	 * identifers are allocated out of an ID space assures that we won't
-	 * see the identifier we just allocated.
-	 */
-	for (;;) {
-		zoneid = id_alloc(zoneid_space);
-
-		if (!netstack_inuse_by_stackid(zoneid_to_netstackid(zoneid)))
-			break;
-
-		id_free(zoneid_space, zoneid);
-
-		if (start == GLOBAL_ZONEID) {
-			start = zoneid;
-		} else if (zoneid == start) {
-			/*
-			 * We have managed to iterate over the entire available
-			 * zoneid space -- there are no identifiers available,
-			 * presumably due to some number of leaked netstack
-			 * references.  While it's in principle possible for us
-			 * to continue to try, it seems wiser to give up at
-			 * this point to warn and fail explicitly with a
-			 * distinctive error.
-			 */
-			cmn_err(CE_WARN, "zone_create() failed: all available "
-			    "zone IDs have netstacks still in use");
-			return (set_errno(ENFILE));
-		}
-
-		cmn_err(CE_WARN, "unable to reuse zone ID %d; "
-		    "netstack still in use", zoneid);
-	}
-
 	zone = kmem_zalloc(sizeof (zone_t), KM_SLEEP);
-	zone->zone_id = zoneid;
-	zone->zone_did = zone_did;
+	zoneid = zone->zone_id = id_alloc(zoneid_space);
 	zone->zone_status = ZONE_IS_UNINITIALIZED;
 	zone->zone_pool = pool_default;
 	zone->zone_pool_mod = gethrtime();
@@ -5345,7 +5177,6 @@
 static int
 zone_empty(zone_t *zone)
 {
-	int cnt = 0;
 	int waitstatus;
 
 	/*
@@ -5356,16 +5187,7 @@
 	ASSERT(MUTEX_NOT_HELD(&zonehash_lock));
 	while ((waitstatus = zone_status_timedwait_sig(zone,
 	    ddi_get_lbolt() + hz, ZONE_IS_EMPTY)) == -1) {
-		boolean_t force = B_FALSE;
-
-		/* Every 30 seconds, try harder */
-		if (cnt++ >= 30) {
-			cmn_err(CE_WARN, "attempt to force kill zone %d\n",
-			    zone->zone_id);
-			force = B_TRUE;
-			cnt = 0;
-		}
-		killall(zone->zone_id, force);
+		killall(zone->zone_id);
 	}
 	/*
 	 * return EINTR if we were signaled
@@ -6170,14 +5992,6 @@
 		}
 		kmem_free(zbuf, bufsize);
 		break;
-	case ZONE_ATTR_DID:
-		size = sizeof (zoneid_t);
-		if (bufsize > size)
-			bufsize = size;
-
-		if (buf != NULL && copyout(&zone->zone_did, buf, bufsize) != 0)
-			error = EFAULT;
-		break;
 	case ZONE_ATTR_SCHED_FIXEDHI:
 		size = sizeof (boolean_t);
 		if (bufsize > size)
@@ -7010,7 +6824,6 @@
 			zs.doi = zs32.doi;
 			zs.label = (const bslabel_t *)(uintptr_t)zs32.label;
 			zs.flags = zs32.flags;
-			zs.zoneid = zs32.zoneid;
 #else
 			panic("get_udatamodel() returned bogus result\n");
 #endif
@@ -7021,7 +6834,7 @@
 		    (caddr_t)zs.rctlbuf, zs.rctlbufsz,
 		    (caddr_t)zs.zfsbuf, zs.zfsbufsz,
 		    zs.extended_error, zs.match, zs.doi,
-		    zs.label, zs.flags, zs.zoneid));
+		    zs.label, zs.flags));
 	case ZONE_BOOT:
 		return (zone_boot((zoneid_t)(uintptr_t)arg1));
 	case ZONE_DESTROY:
@@ -7300,7 +7113,7 @@
 	 * zone_ki_call_zoneadmd() will do a more thorough job of this
 	 * later.
 	 */
-	killall(zone->zone_id, B_FALSE);
+	killall(zone->zone_id);
 	/*
 	 * Now, create the thread to contact zoneadmd and do the rest of the
 	 * work.  This thread can't be created in our zone otherwise
--- old/usr/src/uts/common/sys/Makefile	Wed Oct  5 00:33:53 2016
+++ new/usr/src/uts/common/sys/Makefile	Wed Oct  5 00:33:53 2016
@@ -23,9 +23,9 @@
 # Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
 # Copyright 2014, Joyent, Inc. All rights reserved.
 # Copyright 2013 Garrett D'Amore <garrett@damore.org>
-# Copyright 2015, Joyent, Inc. All rights reserved.
 # Copyright 2013 Saso Kiselkov. All rights reserved.
 # Copyright 2015 Igor Kozhukhov <ikozhukhov@gmail.com>
+# Copyright 2015, Joyent, Inc. All rights reserved.
 # Copyright 2016 Nexenta Systems, Inc.
 #
 
@@ -251,7 +251,6 @@
 	flock.h			\
 	flock_impl.h		\
 	fork.h			\
-	frameio.h		\
 	fss.h			\
 	fsspriocntl.h		\
 	fsid.h			\
@@ -356,7 +355,6 @@
 	lockfs.h		\
 	lockstat.h		\
 	lofi.h			\
-	lofi_impl.h		\
 	log.h			\
 	logindmux.h		\
 	logindmux_impl.h	\
@@ -429,9 +427,6 @@
 	ontrap.h		\
 	open.h			\
 	openpromio.h		\
-	overlay.h		\
-	overlay_common.h	\
-	overlay_target.h	\
 	panic.h			\
 	param.h			\
 	pathconf.h		\
@@ -654,8 +649,6 @@
 	vmem.h			\
 	vmem_impl.h		\
 	vmsystm.h		\
-	vnd.h			\
-	vnd_errno.h		\
 	vnic.h			\
 	vnic_impl.h		\
 	vnode.h			\
@@ -667,7 +660,6 @@
 	vuid_queue.h		\
 	vuid_state.h		\
 	vuid_store.h		\
-	vxlan.h			\
 	wait.h			\
 	waitq.h			\
 	wanboot_impl.h		\
@@ -868,6 +860,7 @@
 	autofs.h		\
 	decomp.h		\
 	dv_node.h		\
+	sdev_impl.h		\
 	fifonode.h		\
 	hsfs_isospec.h		\
 	hsfs_node.h		\
@@ -874,8 +867,6 @@
 	hsfs_rrip.h		\
 	hsfs_spec.h		\
 	hsfs_susp.h		\
-	hyprlofs.h		\
-	hyprlofs_info.h		\
 	lofs_info.h		\
 	lofs_node.h		\
 	mntdata.h		\
@@ -885,8 +876,6 @@
 	pc_label.h		\
 	pc_node.h		\
 	pxfs_ki.h		\
-	sdev_impl.h		\
-	sdev_plugin.h		\
 	snode.h			\
 	swapnode.h		\
 	tmp.h			\
@@ -1011,7 +1000,6 @@
 
 SYSEVENTHDRS=		\
 	ap_driver.h     \
-	datalink.h	\
 	dev.h		\
 	domain.h        \
 	dr.h            \
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/uts/common/sys/fs/tmp.h	Wed Oct  5 00:33:53 2016
+++ new/usr/src/uts/common/sys/fs/tmp.h	Wed Oct  5 00:33:53 2016
@@ -23,7 +23,7 @@
  * All rights reserved.  Use is subject to license terms.
  */
 /*
- * Copyright 2016 Joyent, Inc.
+ * Copyright 2015 Joyent, Inc.
  */
 
 #ifndef	_SYS_FS_TMP_H
@@ -43,10 +43,8 @@
 	struct vfs	*tm_vfsp;	/* filesystem's vfs struct */
 	struct tmpnode	*tm_rootnode;	/* root tmpnode */
 	char 		*tm_mntpath;	/* name of tmpfs mount point */
-	size_t		tm_anonmax;	/* file system max anon reservation */
-	size_t		tm_anonmem;	/* bytes of reserved anon memory */
-					/* and allocated kmem for the fs */
-	size_t		tm_allocmem;	/* bytes alloced from tmp_kmem_ funcs */
+	ulong_t		tm_anonmax;	/* file system max anon reservation */
+	pgcnt_t		tm_anonmem;	/* pages of reserved anon memory */
 	dev_t		tm_dev;		/* unique dev # of mounted `device' */
 	uint_t		tm_gen;		/* pseudo generation number for files */
 	kmutex_t	tm_contents;	/* lock for tmount structure */
@@ -60,7 +58,6 @@
 #define	VTOTM(vp)		((struct tmount *)(vp)->v_vfsp->vfs_data)
 #define	VTOTN(vp)		((struct tmpnode *)(vp)->v_data)
 #define	TNTOV(tp)		((tp)->tn_vnode)
-#define	TNTOTM(tp)		(VTOTM(TNTOV(tp)))
 #define	tmpnode_hold(tp)	VN_HOLD(TNTOV(tp))
 #define	tmpnode_rele(tp)	VN_RELE(TNTOV(tp))
 
@@ -72,31 +69,31 @@
 
 /*
  * tmpfs_minfree is the amount (in pages) of anonymous memory that tmpfs
- * leaves free for the rest of the system.  In antiquity, this number could be
- * relevant on a system-wide basis, as physical DRAM was routinely exhausted;
- * however, in more modern times, the relative growth of DRAM with respect to
- * application footprint means that this number is only likely to become
- * factor in a virtualized OS environment (e.g., a zone) -- and even then only
- * when DRAM and swap have both been capped low to allow for maximum tenancy.
- * TMPMINFREE -- the value from which tmpfs_minfree is derived -- should
- * therefore be configured to a value that is roughly the smallest practical
- * value for memory + swap minus the largest reasonable size for tmpfs in such
- * a configuration.  As of this writing, the smallest practical memory + swap
- * configuration is 128MB, and it seems reasonable to allow tmpfs to consume
- * no more than seven-eighths of this, yielding a TMPMINFREE of 16MB.  Care
- * should be exercised in changing this:  tuning this value too high will
- * result in spurious ENOSPC errors in tmpfs in small zones (a problem that
- * can induce cascading failure surprisingly often); tuning this value too low
- * will result in tmpfs consumption alone to alone induce application-level
- * memory allocation failure.
+ * leaves free for the rest of the system.  E.g. in a system with 32MB of
+ * configured swap space, if 16MB were reserved (leaving 16MB free),
+ * tmpfs could allocate up to 16MB - tmpfs_minfree.  The default value
+ * for tmpfs_minfree is btopr(TMPMINFREE) but it can cautiously patched
+ * to a different number of pages.
+ * NB: If tmpfs allocates too much swap space, other processes will be
+ * unable to execute.
  */
-#define	TMPMINFREE	16 * 1024 * 1024	/* 16 Megabytes */
+#define	TMPMINFREE	2 * 1024 * 1024	/* 2 Megabytes */
 
 extern size_t	tmpfs_minfree;		/* Anonymous memory in pages */
 
+/*
+ * tmpfs can allocate only a certain percentage of kernel memory,
+ * which is used for tmpnodes, directories, file names, etc.
+ * This is statically set as TMPMAXFRACKMEM of physical memory.
+ * The actual number of allocatable bytes can be patched in tmpfs_maxkmem.
+ */
+#define	TMPMAXFRACKMEM	25	/* 1/25 of physical memory */
+
+extern size_t 	tmp_kmemspace;
+extern size_t	tmpfs_maxkmem;	/* Allocatable kernel memory in bytes */
+
 extern	void	tmpnode_init(struct tmount *, struct tmpnode *,
 	struct vattr *, struct cred *);
-extern	void	tmpnode_cleanup(struct tmpnode *tp);
 extern	int	tmpnode_trunc(struct tmount *, struct tmpnode *, ulong_t);
 extern	void	tmpnode_growmap(struct tmpnode *, ulong_t);
 extern	int	tdirlookup(struct tmpnode *, char *, struct tmpnode **,
@@ -103,21 +100,20 @@
     struct cred *);
 extern	int	tdirdelete(struct tmpnode *, struct tmpnode *, char *,
 	enum dr_op, struct cred *);
-extern	int	tdirinit(struct tmpnode *, struct tmpnode *);
+extern	void	tdirinit(struct tmpnode *, struct tmpnode *);
 extern	void	tdirtrunc(struct tmpnode *);
+extern	void	*tmp_memalloc(size_t, int);
+extern	void	tmp_memfree(void *, size_t);
 extern	int	tmp_resv(struct tmount *, struct tmpnode *, size_t, int);
 extern	int	tmp_taccess(void *, int, struct cred *);
 extern	int	tmp_sticky_remove_access(struct tmpnode *, struct tmpnode *,
 	struct cred *);
-extern	int	tmp_convnum(char *, size_t *);
+extern	int	tmp_convnum(char *, pgcnt_t *);
 extern	int	tmp_convmode(char *, mode_t *);
 extern	int	tdirenter(struct tmount *, struct tmpnode *, char *,
 	enum de_op, struct tmpnode *, struct tmpnode *, struct vattr *,
 	struct tmpnode **, struct cred *, caller_context_t *);
 
-extern void	*tmp_kmem_zalloc(struct tmount *, size_t, int);
-extern void	tmp_kmem_free(struct tmount *, void *, size_t);
-
 #define	TMP_MUSTHAVE	0x01
 
 #ifdef	__cplusplus
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/uts/common/sys/proc.h	Wed Oct  5 00:33:54 2016
+++ new/usr/src/uts/common/sys/proc.h	Wed Oct  5 00:33:54 2016
@@ -21,7 +21,7 @@
 
 /*
  * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2015 Joyent, Inc.  All rights reserved.
+ * Copyright (c) 2014 Joyent, Inc.  All rights reserved.
  */
 
 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
@@ -722,10 +722,6 @@
 extern	void	thread_init(void);
 extern	void	thread_load(kthread_t *, void (*)(), caddr_t, size_t);
 
-extern	void	thread_splitstack(void (*)(void *), void *, size_t);
-extern	void	thread_splitstack_run(caddr_t, void (*)(void *), void *);
-extern	void	thread_splitstack_cleanup(void);
-
 extern	void	tsd_create(uint_t *, void (*)(void *));
 extern	void	tsd_destroy(uint_t *);
 extern	void	*tsd_getcreate(uint_t *, void (*)(void *), void *(*)(void));
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/uts/common/sys/socketvar.h	Wed Oct  5 00:33:55 2016
+++ new/usr/src/uts/common/sys/socketvar.h	Wed Oct  5 00:33:55 2016
@@ -21,7 +21,6 @@
 
 /*
  * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2015 Joyent, Inc.
  */
 
 /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
@@ -103,7 +102,6 @@
 
 typedef struct sonodeops sonodeops_t;
 typedef struct sonode sonode_t;
-typedef boolean_t (*so_krecv_f)(sonode_t *, mblk_t *, size_t, int, void *);
 
 struct sodirect_s;
 
@@ -246,10 +244,6 @@
 	struct sof_instance	*so_filter_top;		/* top of stack */
 	struct sof_instance	*so_filter_bottom;	/* bottom of stack */
 	clock_t			so_filter_defertime;	/* time when deferred */
-
-	/* Kernel direct receive callbacks */
-	so_krecv_f		so_krecv_cb;		/* recv callback */
-	void			*so_krecv_arg;		/* recv cb arg */
 };
 
 #define	SO_HAVE_DATA(so)						\
@@ -973,15 +967,6 @@
 extern int	so_copyin(const void *, void *, size_t, int);
 extern int	so_copyout(const void *, void *, size_t, int);
 
-/*
- * Functions to manipulate the use of direct receive callbacks. This should not
- * be used outside of sockfs and ksocket. These are generally considered a use
- * once interface for a socket and will cause all outstanding data on the socket
- * to be flushed.
- */
-extern int	so_krecv_set(sonode_t *, so_krecv_f, void *);
-extern void	so_krecv_unblock(sonode_t *);
-
 #endif
 
 /*
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/uts/common/sys/thread.h	Wed Oct  5 00:33:55 2016
+++ new/usr/src/uts/common/sys/thread.h	Wed Oct  5 00:33:55 2016
@@ -24,10 +24,6 @@
  * Use is subject to license terms.
  */
 
-/*
- * Copyright (c) 2015, Joyent, Inc.  All rights reserved.
- */
-
 #ifndef	_SYS_THREAD_H
 #define	_SYS_THREAD_H
 
@@ -72,8 +68,6 @@
 	void	(*free_op)(void *, int); /* function which frees the context */
 	void	*arg;		/* argument to above functions, ctx pointer */
 	struct ctxop *next;	/* next context ops */
-	hrtime_t save_ts;		/* timestamp of last save */
-	hrtime_t restore_ts;		/* timestamp of last restore */
 } ctxop_t;
 
 /*
@@ -372,7 +366,7 @@
 #define	T_WOULDBLOCK	0x0020	/* for lockfs */
 #define	T_DONTBLOCK	0x0040	/* for lockfs */
 #define	T_DONTPEND	0x0080	/* for lockfs */
-#define	T_SPLITSTK	0x0100	/* kernel stack is currently split */
+#define	T_SYS_PROF	0x0100	/* profiling on for duration of system call */
 #define	T_WAITCVSEM	0x0200	/* waiting for a lwp_cv or lwp_sema on sleepq */
 #define	T_WATCHPT	0x0400	/* thread undergoing a watchpoint emulation */
 #define	T_PANIC		0x0800	/* thread initiated a system panic */
@@ -601,7 +595,6 @@
 caddr_t	thread_stk_init(caddr_t);	/* init thread stack */
 
 extern int default_binding_mode;
-extern int default_stksize;
 
 #endif	/* _KERNEL */
 
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/uts/common/sys/vnode.h	Wed Oct  5 00:33:56 2016
+++ new/usr/src/uts/common/sys/vnode.h	Wed Oct  5 00:33:56 2016
@@ -21,7 +21,7 @@
 
 /*
  * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2016 Joyent, Inc.
+ * Copyright (c) 2014, Joyent, Inc. All rights reserved.
  */
 
 /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
@@ -221,59 +221,6 @@
  * In particular, file systems should not access other fields; they may
  * change or even be removed.  The functionality which was once provided
  * by these fields is available through vn_* functions.
- *
- * VNODE PATH THEORY:
- * In each vnode, the v_path field holds a cached version of the canonical
- * filesystem path which that node represents.  Because vnodes lack contextual
- * information about their own name or position in the VFS hierarchy, this path
- * must be calculated when the vnode is instantiated by operations such as
- * fop_create, fop_lookup, or fop_mkdir.  During said operations, both the
- * parent vnode (and its cached v_path) and future name are known, so the
- * v_path of the resulting object can easily be set.
- *
- * The caching nature of v_path is complicated in the face of directory
- * renames.  Filesystem drivers are responsible for calling vn_renamepath when
- * a fop_rename operation succeeds.  While the v_path on the renamed vnode will
- * be updated, existing children of the directory (direct, or at deeper levels)
- * will now possess v_path caches which are stale.
- *
- * It is expensive (and for non-directories, impossible) to recalculate stale
- * v_path entries during operations such as vnodetopath.  The best time during
- * which to correct such wrongs is the same as when v_path is first
- * initialized: during fop_create/fop_lookup/fop_mkdir/etc, where adequate
- * context is available to generate the current path.
- *
- * In order to quickly detect stale v_path entries (without full lookup
- * verification) to trigger a v_path update, the v_path_stamp field has been
- * added to vnode_t.  As part of successful fop_create/fop_lookup/fop_mkdir
- * operations, where the name and parent vnode are available, the following
- * rules are used to determine updates to the child:
- *
- * 1. If the parent lacks a v_path, clear any existing v_path and v_path_stamp
- *    on the child.  Until the parent v_path is refreshed to a valid state, the
- *    child v_path must be considered invalid too.
- *
- * 2. If the child lacks a v_path (implying v_path_stamp == 0), it inherits the
- *    v_path_stamp value from its parent and its v_path is updated.
- *
- * 3. If the child v_path_stamp is less than v_path_stamp in the parent, it is
- *    an indication that the child v_path is stale.  The v_path is updated and
- *    v_path_stamp in the child is set to the current hrtime().
- *
- *    It does _not_ inherit the parent v_path_stamp in order to propagate the
- *    the time of v_path invalidation through the directory structure.  This
- *    prevents concurrent invalidations (operating with a now-incorrect v_path)
- *    at deeper levels in the tree from persisting.
- *
- * 4. If the child v_path_stamp is greater or equal to the parent, no action
- *    needs to be taken.
- *
- * Note that fop_rename operations do not follow this ruleset.  They perform an
- * explicit update of v_path and v_path_stamp (setting it to the current time)
- *
- * With these constraints in place, v_path invalidations and updates should
- * proceed in a timely manner as vnodes are accessed.  While there still are
- * limited cases where vnodetopath operations will fail, the risk is minimized.
  */
 
 struct fem_head;	/* from fem.h */
@@ -300,7 +247,6 @@
 	void		*v_locality;	/* hook for locality info */
 	struct fem_head	*v_femhead;	/* fs monitoring */
 	char		*v_path;	/* cached path */
-	hrtime_t	v_path_stamp;	/* timestamp for cached path */
 	uint_t		v_rdcnt;	/* open for read count  (VREG only) */
 	uint_t		v_wrcnt;	/* open for write count (VREG only) */
 	u_longlong_t	v_mmap_read;	/* mmap read count */
@@ -792,7 +738,7 @@
 	VE_RMDIR	= 4,	/* Remove of directory vnode's name */
 	VE_CREATE	= 5,	/* Create with vnode's name which exists */
 	VE_LINK		= 6, 	/* Link with vnode's name as source */
-	VE_RENAME_DEST_DIR = 7,	/* Rename with vnode as target dir */
+	VE_RENAME_DEST_DIR	= 7, 	/* Rename with vnode as target dir */
 	VE_MOUNTEDOVER	= 8, 	/* File or Filesystem got mounted over vnode */
 	VE_TRUNCATE = 9,	/* Truncate */
 	VE_PRE_RENAME_SRC = 10,	/* Pre-rename, with vnode as source */
@@ -1347,11 +1293,6 @@
     const char *path, size_t plen);
 void vn_renamepath(vnode_t *dvp, vnode_t *vp, const char *nm, size_t len);
 
-/* Private vnode manipulation functions */
-void vn_clearpath(vnode_t *, hrtime_t);
-void vn_updatepath(vnode_t *, vnode_t *, const char *);
-
-
 /* Vnode event notification */
 void	vnevent_rename_src(vnode_t *, vnode_t *, char *, caller_context_t *);
 void	vnevent_rename_dest(vnode_t *, vnode_t *, char *, caller_context_t *);
@@ -1400,9 +1341,6 @@
 
 int	vn_vmpss_usepageio(vnode_t *);
 
-/* Empty v_path placeholder */
-extern char *vn_vpath_empty;
-
 /*
  * Needed for use of IS_VMODSORT() in kernel.
  */
No differences encountered
--- old/usr/src/uts/common/sys/zone.h	Wed Oct  5 00:33:56 2016
+++ new/usr/src/uts/common/sys/zone.h	Wed Oct  5 00:33:56 2016
@@ -20,6 +20,7 @@
  */
 /*
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2015 Joyent, Inc. All rights reserved.
  * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
  * Copyright 2014 Igor Kozhukhov <ikozhukhov@gmail.com>.
  * Copyright 2016, Joyent, Inc.
@@ -190,7 +191,6 @@
 	uint32_t doi;			/* DOI for label */
 	caddr32_t label;		/* label associated with zone */
 	int flags;
-	zoneid_t zoneid;		/* requested zoneid */
 } zone_def32;
 #endif
 typedef struct {
@@ -207,7 +207,6 @@
 	uint32_t doi;			/* DOI for label */
 	const bslabel_t *label;		/* label associated with zone */
 	int flags;
-	zoneid_t zoneid;		/* requested zoneid */
 } zone_def;
 
 /* extended error information */
@@ -383,7 +382,7 @@
 } zone_dataset_t;
 
 /*
- * structure for rctl zone kstats
+ * structure for zone kstats
  */
 typedef struct zone_kstat {
 	kstat_named_t zk_zonename;
@@ -459,7 +458,6 @@
 	kstat_named_t	zm_ffnoproc;
 	kstat_named_t	zm_ffnomem;
 	kstat_named_t	zm_ffmisc;
-	kstat_named_t	zm_mfseglim;
 	kstat_named_t	zm_nested_intp;
 	kstat_named_t	zm_init_pid;
 	kstat_named_t	zm_boot_time;
@@ -504,7 +502,6 @@
 	 */
 	list_node_t	zone_linkage;
 	zoneid_t	zone_id;	/* ID of zone */
-	zoneid_t	zone_did;	/* persistent debug ID of zone */
 	uint_t		zone_ref;	/* count of zone_hold()s on zone */
 	uint_t		zone_cred_ref;	/* count of zone_hold_cred()s on zone */
 	/*
@@ -629,6 +626,13 @@
 	sys_zio_cntr_t	zone_lwr_ops;		/* logical writes. */
 
 	/*
+	 * kstats and counters for I/O ops and bytes.
+	 */
+	kmutex_t	zone_io_lock;		/* protects I/O statistics */
+	kstat_t		*zone_io_ksp;
+	kstat_io_t	*zone_io_kiop;
+
+	/*
 	 * kstats and counters for VFS ops and bytes.
 	 */
 	kmutex_t	zone_vfs_lock;		/* protects VFS statistics */
@@ -640,7 +644,6 @@
 	 * kstats for ZFS I/O ops and bytes.
 	 */
 	kmutex_t	zone_zfs_lock;		/* protects ZFS statistics */
-	kstat_t		*zone_zfs_ksp;
 	kstat_io_t	zone_zfs_rwstats;
 	zone_zfs_kstat_t *zone_zfs_stats;
 
@@ -707,8 +710,6 @@
 	uint32_t	zone_ffnomem;		/* as_dup/memory error */
 	uint32_t	zone_ffmisc;		/* misc. other error */
 
-	uint32_t	zone_mfseglim;		/* map failure (# segs limit) */
-
 	uint32_t	zone_nested_intp;	/* nested interp. kstat */
 
 	struct loadavg_s zone_loadavg;		/* loadavg for this zone */
@@ -765,7 +766,6 @@
 extern zone_t *zone_find_by_any_path(const char *, boolean_t);
 extern zone_t *zone_find_by_path(const char *);
 extern zoneid_t getzoneid(void);
-extern zoneid_t getzonedid(void);
 extern zone_t *zone_find_by_id_nolock(zoneid_t);
 extern int zone_datalink_walk(zoneid_t, int (*)(datalink_id_t, void *), void *);
 extern int zone_check_datalink(zoneid_t *, datalink_id_t);
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/uts/common/syscall/sysconfig.c	Wed Oct  5 00:33:57 2016
+++ new/usr/src/uts/common/syscall/sysconfig.c	Wed Oct  5 00:33:57 2016
@@ -22,7 +22,7 @@
 /*
  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
- * Copyright 2012 Joyent, Inc.  All rights reserved.
+ * Copyright 2011 Joyent, Inc.  All rights reserved.
  */
 
 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
@@ -180,23 +180,26 @@
 	case _CONFIG_AVPHYS_PAGES:
 		/*
 		 * If the non-global zone has a phys. memory cap, use
-		 * the phys. memory cap - zone's rss.  We always
+		 * the phys. memory cap - zone's current rss.  We always
 		 * report the system-wide value for the global zone, even
-		 * though memory capping can be used on the global zone too.
-		 * We use the cached value for the RSS since vm_getusage()
-		 * is so expensive and we don't need this value to be exact.
+		 * though rcapd can be used on the global zone too.
 		 */
 		if (!INGLOBALZONE(curproc) &&
 		    curproc->p_zone->zone_phys_mem_ctl != UINT64_MAX) {
 			pgcnt_t cap, rss, free;
+			vmusage_t in_use;
+			size_t cnt = 1;
 
 			cap = btop(curproc->p_zone->zone_phys_mem_ctl);
 			if (cap > physinstalled)
 				return (freemem);
 
-			rss = btop(curproc->p_zone->zone_phys_mem);
+			if (vm_getusage(VMUSAGE_ZONE, 1, &in_use, &cnt,
+			    FKIOCTL) != 0)
+				in_use.vmu_rss_all = 0;
+			rss = btop(in_use.vmu_rss_all);
 			/*
-			 * Because this is a soft cap, it is possible
+			 * Because rcapd implements a soft cap, it is possible
 			 * for rss to be temporarily over the cap.
 			 */
 			if (cap > rss)
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/uts/common/vm/vm_as.c	Wed Oct  5 00:33:58 2016
+++ new/usr/src/uts/common/vm/vm_as.c	Wed Oct  5 00:33:58 2016
@@ -21,7 +21,7 @@
 /*
  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
- * Copyright 2016 Joyent, Inc.
+ * Copyright 2015, Joyent, Inc.  All rights reserved.
  * Copyright (c) 2016 by Delphix. All rights reserved.
  */
 
@@ -72,8 +72,6 @@
 
 clock_t deadlk_wait = 1; /* number of ticks to wait before retrying */
 
-ulong_t as_user_seg_limit = 0xffff; /* max segments in an (non-kas) AS */
-
 static struct kmem_cache *as_cache;
 
 static void as_setwatchprot(struct as *, caddr_t, size_t, uint_t);
@@ -891,19 +889,19 @@
 		CPU_STATS_EXIT_K();
 		if (zonep->zone_pg_flt_delay != 0) {
 			/*
-			 * The zone in which this process is running is
-			 * currently over it's physical memory cap. Throttle
-			 * page faults to help the user-land memory capper
-			 * catch up. Note that drv_usectohz() rounds up.
+			 * The zone in which this process is running
+			 * is currently over it's physical memory cap.
+			 * Throttle page faults to help the user-land
+			 * memory capper catch up. Note that
+			 * drv_usectohz() rounds up.
 			 */
 			atomic_add_64(&zonep->zone_pf_throttle, 1);
 			atomic_add_64(&zonep->zone_pf_throttle_usec,
 			    zonep->zone_pg_flt_delay);
-			if (zonep->zone_pg_flt_delay < TICK_TO_USEC(1)) {
+			if (zonep->zone_pg_flt_delay < TICK_TO_USEC(1))
 				drv_usecwait(zonep->zone_pg_flt_delay);
-			} else {
+			else
 				delay(drv_usectohz(zonep->zone_pg_flt_delay));
-			}
 		}
 		break;
 	}
@@ -1711,28 +1709,13 @@
 	as->a_updatedir = 1;	/* inform /proc */
 	gethrestime(&as->a_updatetime);
 
-	if (as != &kas) {
-		if (as->a_size + rsize > (size_t)p->p_vmem_ctl) {
-			AS_LOCK_EXIT(as);
+	if (as != &kas && as->a_size + rsize > (size_t)p->p_vmem_ctl) {
+		AS_LOCK_EXIT(as);
 
-			(void) rctl_action(rctlproc_legacy[RLIMIT_VMEM],
-			    p->p_rctls, p, RCA_UNSAFE_ALL);
-			return (ENOMEM);
-		}
+		(void) rctl_action(rctlproc_legacy[RLIMIT_VMEM], p->p_rctls, p,
+		    RCA_UNSAFE_ALL);
 
-		/*
-		 * Keep the number of segments in a userspace AS constrained to
-		 * a reasonable limit.  Linux enforces a value slightly less
-		 * than 64k in order to avoid ELF limits if/when a process
-		 * dumps core.  While SunOS avoids that specific problem with
-		 * other tricks, the limit is still valuable to keep kernel
-		 * memory consumption in check.
-		 */
-		if (avl_numnodes(&as->a_segtree) >= as_user_seg_limit) {
-			AS_LOCK_EXIT(as);
-			atomic_inc_32(&p->p_zone->zone_mfseglim);
-			return (ENOMEM);
-		}
+		return (ENOMEM);
 	}
 
 	if (AS_MAP_CHECK_VNODE_LPOOB(crfp, argsp)) {
--- old/usr/src/uts/common/vm/vm_pvn.c	Wed Oct  5 00:33:58 2016
+++ new/usr/src/uts/common/vm/vm_pvn.c	Wed Oct  5 00:33:58 2016
@@ -20,8 +20,8 @@
  */
 /*
  * Copyright (c) 1986, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, Joyent, Inc. All rights reserved.
  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
+ * Copyright (c) 2012, Joyent, Inc. All rights reserved.
  */
 
 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
--- old/usr/src/uts/common/vm/vm_usage.c	Wed Oct  5 00:33:58 2016
+++ new/usr/src/uts/common/vm/vm_usage.c	Wed Oct  5 00:33:58 2016
@@ -118,7 +118,7 @@
  *	For accurate counting of map-shared and COW-shared pages.
  *
  *    - visited private anons (refcnt > 1) for each collective.
- *	(entity->vme_anon)
+ *	(entity->vme_anon_hash)
  *	For accurate counting of COW-shared pages.
  *
  * The common accounting structure is the vmu_entity_t, which represents
@@ -156,7 +156,6 @@
 #include <sys/vm_usage.h>
 #include <sys/zone.h>
 #include <sys/sunddi.h>
-#include <sys/sysmacros.h>
 #include <sys/avl.h>
 #include <vm/anon.h>
 #include <vm/as.h>
@@ -204,14 +203,6 @@
 } vmu_object_t;
 
 /*
- * Node for tree of visited COW anons.
- */
-typedef struct vmu_anon {
-	avl_node_t vma_node;
-	uintptr_t vma_addr;
-} vmu_anon_t;
-
-/*
  * Entity by which to count results.
  *
  * The entity structure keeps the current rss/swap counts for each entity
@@ -234,7 +225,7 @@
 	struct vmu_entity *vme_next_calc;
 	mod_hash_t	*vme_vnode_hash; /* vnodes visited for entity */
 	mod_hash_t	*vme_amp_hash;	 /* shared amps visited for entity */
-	avl_tree_t	vme_anon;	 /* COW anons visited for entity */
+	mod_hash_t	*vme_anon_hash;	 /* COW anons visited for entity */
 	vmusage_t	vme_result;	 /* identifies entity and results */
 } vmu_entity_t;
 
@@ -337,23 +328,6 @@
 }
 
 /*
- * Comparison routine for our AVL tree of anon structures.
- */
-static int
-vmu_anon_cmp(const void *lhs, const void *rhs)
-{
-	const vmu_anon_t *l = lhs, *r = rhs;
-
-	if (l->vma_addr == r->vma_addr)
-		return (0);
-
-	if (l->vma_addr < r->vma_addr)
-		return (-1);
-
-	return (1);
-}
-
-/*
  * Save a bound on the free list.
  */
 static void
@@ -393,19 +367,14 @@
 vmu_free_entity(mod_hash_val_t val)
 {
 	vmu_entity_t *entity = (vmu_entity_t *)val;
-	vmu_anon_t *anon;
-	void *cookie = NULL;
 
 	if (entity->vme_vnode_hash != NULL)
 		i_mod_hash_clear_nosync(entity->vme_vnode_hash);
 	if (entity->vme_amp_hash != NULL)
 		i_mod_hash_clear_nosync(entity->vme_amp_hash);
+	if (entity->vme_anon_hash != NULL)
+		i_mod_hash_clear_nosync(entity->vme_anon_hash);
 
-	while ((anon = avl_destroy_nodes(&entity->vme_anon, &cookie)) != NULL)
-		kmem_free(anon, sizeof (vmu_anon_t));
-
-	avl_destroy(&entity->vme_anon);
-
 	entity->vme_next = vmu_data.vmu_free_entities;
 	vmu_data.vmu_free_entities = entity;
 }
@@ -520,11 +489,11 @@
 		    "vmusage amp hash", VMUSAGE_HASH_SIZE, vmu_free_object,
 		    sizeof (struct anon_map));
 
-	VERIFY(avl_first(&entity->vme_anon) == NULL);
+	if (entity->vme_anon_hash == NULL)
+		entity->vme_anon_hash = mod_hash_create_ptrhash(
+		    "vmusage anon hash", VMUSAGE_HASH_SIZE,
+		    mod_hash_null_valdtor, sizeof (struct anon));
 
-	avl_create(&entity->vme_anon, vmu_anon_cmp, sizeof (struct vmu_anon),
-	    offsetof(struct vmu_anon, vma_node));
-
 	entity->vme_next = vmu_data.vmu_entities;
 	vmu_data.vmu_entities = entity;
 	vmu_data.vmu_nentities++;
@@ -649,19 +618,21 @@
 }
 
 static int
-vmu_find_insert_anon(vmu_entity_t *entity, void *key)
+vmu_find_insert_anon(mod_hash_t *hash, caddr_t key)
 {
-	vmu_anon_t anon, *ap;
+	int ret;
+	caddr_t val;
 
-	anon.vma_addr = (uintptr_t)key;
+	ret = i_mod_hash_find_nosync(hash, (mod_hash_key_t)key,
+	    (mod_hash_val_t *)&val);
 
-	if (avl_find(&entity->vme_anon, &anon, NULL) != NULL)
+	if (ret == 0)
 		return (0);
 
-	ap = kmem_alloc(sizeof (vmu_anon_t), KM_SLEEP);
-	ap->vma_addr = (uintptr_t)key;
+	ret = i_mod_hash_insert_nosync(hash, (mod_hash_key_t)key,
+	    (mod_hash_val_t)key, (mod_hash_hndl_t)0);
 
-	avl_add(&entity->vme_anon, ap);
+	ASSERT(ret == 0);
 
 	return (1);
 }
@@ -1373,7 +1344,8 @@
 				 * Track COW anons per entity so
 				 * they are not double counted.
 				 */
-				if (vmu_find_insert_anon(entity, ap) == 0)
+				if (vmu_find_insert_anon(entity->vme_anon_hash,
+				    (caddr_t)ap) == 0)
 					continue;
 
 				result->vmu_rss_all += (pgcnt << PAGESHIFT);
@@ -1647,7 +1619,8 @@
 			mod_hash_destroy_hash(te->vme_vnode_hash);
 		if (te->vme_amp_hash != NULL)
 			mod_hash_destroy_hash(te->vme_amp_hash);
-		VERIFY(avl_first(&te->vme_anon) == NULL);
+		if (te->vme_anon_hash != NULL)
+			mod_hash_destroy_hash(te->vme_anon_hash);
 		kmem_free(te, sizeof (vmu_entity_t));
 	}
 	while (vmu_data.vmu_free_zones != NULL) {
@@ -1805,8 +1778,8 @@
 		if (rp->vmu_type == VMUSAGE_ZONE &&
 		    rp->vmu_zoneid != ALL_ZONES) {
 			if ((zp = zone_find_by_id(rp->vmu_zoneid)) != NULL) {
-				zp->zone_phys_mem = rp->vmu_rss_all;
-				zone_rele(zp);
+			        zp->zone_phys_mem = rp->vmu_rss_all;
+			        zone_rele(zp);
 			}
 		}
 	}
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/uts/i86pc/ml/syscall_asm_amd64.s	Wed Oct  5 00:33:58 2016
+++ new/usr/src/uts/i86pc/ml/syscall_asm_amd64.s	Wed Oct  5 00:33:58 2016
@@ -28,7 +28,6 @@
 #include <sys/regset.h>
 #include <sys/privregs.h>
 #include <sys/psw.h>
-#include <sys/machbrand.h>
 
 #if defined(__lint)
 
@@ -38,6 +37,7 @@
 
 #else	/* __lint */
 
+#include <sys/machbrand.h>
 #include <sys/segments.h>
 #include <sys/pcb.h>
 #include <sys/trap.h>
@@ -531,22 +531,13 @@
 	addq	$8, %rsp
 
 	/*
-	 * If the alternate handler returns non-zero, the normal system call
-	 * processing is resumed.
+	 * If the alternate handler returns 0, we skip straight to the return to
+	 * usermode.  Otherwise, we resume regular system call processing.
 	 */
 	testl	%eax, %eax
 	popq	%rax
-	jnz	_syscall_no_brand
+	jz	_syscall_after_brand
 
-	/*
-	 * For branded syscalls which were handled in-kernel, shuffle the
-	 * register state as would be done by the native handler before jumping
-	 * to the post-syscall logic.
-	 */
-	movq	REGOFF_RAX(%rsp), %r12
-	movq	REGOFF_RDX(%rsp), %r13
-	jmp	_syscall_after_brand
-
 _syscall_no_brand:
 	movw	%ax, T_SYSNUM(%r15)
 	movzbl	T_PRE_SYS(%r15), %ebx
@@ -840,21 +831,12 @@
 	call	*%rax
 
 	/*
-	 * If the alternate handler returns non-zero, the normal system call
-	 * processing is resumed.
+	 * If the alternate handler returns 0, we skip straight to the return
+	 * to usermode.  Otherwise, we resume regular system call processing.
 	 */
 	testl	%eax, %eax
-	jnz	_syscall32_no_brand
+	jz	_syscall32_after_brand
 
-	/*
-	 * For branded syscalls which were handled in-kernel, shuffle the
-	 * register state as would be done by the native handler before jumping
-	 * to the post-syscall logic.
-	 */
-	movl	REGOFF_RAX(%rsp), %r12d
-	movl	REGOFF_RDX(%rsp), %r13d
-	jmp	_syscall32_after_brand
-
 _syscall32_no_brand:
 	/*
 	 * Make some space for MAXSYSARGS (currently 8) 32-bit args placed
@@ -1255,7 +1237,6 @@
 	ENTRY_NP(brand_sys_int80)
 	SWAPGS				/* kernel gsbase */
 	XPV_TRAP_POP
-	call	smap_enable
 
 	/*
 	 * We first attempt to call the "b_int80" handler from the "struct
@@ -1294,7 +1275,6 @@
 	 * because gptrap will pop them again with its own XPV_TRAP_POP.
 	 */
 	XPV_TRAP_POP
-	call	smap_enable
 nopop_int80:
 	subq	$2, (%rsp)	/* int insn 2-bytes */
 	pushq	$_CONST(_MUL(T_INT80, GATE_DESC_SIZE) + 2)
No differences encountered
No differences encountered
--- old/usr/src/uts/i86pc/os/mp_startup.c	Wed Oct  5 00:33:59 2016
+++ new/usr/src/uts/i86pc/os/mp_startup.c	Wed Oct  5 00:33:59 2016
@@ -166,8 +166,6 @@
 void
 init_cpu_syscall(struct cpu *cp)
 {
-	uint64_t flags;
-
 	kpreempt_disable();
 
 #if defined(__amd64)
--- old/usr/src/uts/i86pc/os/timestamp.c	Wed Oct  5 00:33:59 2016
+++ new/usr/src/uts/i86pc/os/timestamp.c	Wed Oct  5 00:33:59 2016
@@ -145,6 +145,8 @@
 	volatile hrtime_t master_tsc, slave_tsc;
 } tsc_sync_t;
 static tsc_sync_t *tscp;
+static hrtime_t largest_tsc_delta = 0;
+static ulong_t shortest_write_time = ~0UL;
 
 static hrtime_t	tsc_last_jumped = 0;
 static int	tsc_jumped = 0;
@@ -445,28 +447,26 @@
 }
 
 /*
- * TSC Sync Master
+ * Called by the master in the TSC sync operation (usually the boot CPU).
+ * If the slave is discovered to have a skew, gethrtimef will be changed to
+ * point to tsc_gethrtime_delta(). Calculating skews is precise only when
+ * the master and slave TSCs are read simultaneously; however, there is no
+ * algorithm that can read both CPUs in perfect simultaneity. The proposed
+ * algorithm is an approximate method based on the behaviour of cache
+ * management. The slave CPU continuously reads TSC and then reads a global
+ * variable which the master CPU updates. The moment the master's update reaches
+ * the slave's visibility (being forced by an mfence operation) we use the TSC
+ * reading taken on the slave. A corresponding TSC read will be taken on the
+ * master as soon as possible after finishing the mfence operation. But the
+ * delay between causing the slave to notice the invalid cache line and the
+ * competion of mfence is not repeatable. This error is heuristically assumed
+ * to be 1/4th of the total write time as being measured by the two TSC reads
+ * on the master sandwiching the mfence. Furthermore, due to the nature of
+ * bus arbitration, contention on memory bus, etc., the time taken for the write
+ * to reflect globally can vary a lot. So instead of taking a single reading,
+ * a set of readings are taken and the one with least write time is chosen
+ * to calculate the final skew.
  *
- * Typically called on the boot CPU, this attempts to quantify TSC skew between
- * different CPUs.  If an appreciable difference is found, gethrtimef will be
- * changed to point to tsc_gethrtime_delta().
- *
- * Calculating skews is precise only when the master and slave TSCs are read
- * simultaneously; however, there is no algorithm that can read both CPUs in
- * perfect simultaneity.  The proposed algorithm is an approximate method based
- * on the behaviour of cache management.  The slave CPU continuously polls the
- * TSC while reading a global variable updated by the master CPU.  The latest
- * TSC reading is saved when the master's update (forced via mfence) reaches
- * visibility on the slave.  The master will also take a TSC reading
- * immediately following the mfence.
- *
- * While the delay between cache line invalidation on the slave and mfence
- * completion on the master is not repeatable, the error is heuristically
- * assumed to be 1/4th of the write time recorded by the master.  Multiple
- * samples are taken to control for the variance caused by external factors
- * such as bus contention.  Each sample set is independent per-CPU to control
- * for differing memory latency on NUMA systems.
- *
  * TSC sync is disabled in the context of virtualization because the CPUs
  * assigned to the guest are virtual CPUs which means the real CPUs on which
  * guest runs keep changing during life time of guest OS. So we would end up
@@ -478,7 +478,7 @@
 tsc_sync_master(processorid_t slave)
 {
 	ulong_t flags, source, min_write_time = ~0UL;
-	hrtime_t write_time, mtsc_after, last_delta = 0;
+	hrtime_t write_time, x, mtsc_after, tdelta;
 	tsc_sync_t *tsc = tscp;
 	int cnt;
 	int hwtype;
@@ -501,26 +501,28 @@
 			SMT_PAUSE();
 		write_time =  mtsc_after - tsc->master_tsc;
 		if (write_time <= min_write_time) {
-			hrtime_t tdelta;
-
-			tdelta = tsc->slave_tsc - mtsc_after;
-			if (tdelta < 0)
-				tdelta = -tdelta;
+			min_write_time = write_time;
 			/*
-			 * If the margin exists, subtract 1/4th of the measured
-			 * write time from the master's TSC value.  This is an
-			 * estimate of how late the mfence completion came
-			 * after the slave noticed the cache line change.
+			 * Apply heuristic adjustment only if the calculated
+			 * delta is > 1/4th of the write time.
 			 */
-			if (tdelta > (write_time/4)) {
+			x = tsc->slave_tsc - mtsc_after;
+			if (x < 0)
+				x = -x;
+			if (x > (min_write_time/4))
+				/*
+				 * Subtract 1/4th of the measured write time
+				 * from the master's TSC value, as an estimate
+				 * of how late the mfence completion came
+				 * after the slave noticed the cache line
+				 * change.
+				 */
 				tdelta = tsc->slave_tsc -
-				    (mtsc_after - (write_time/4));
-			} else {
+				    (mtsc_after - (min_write_time/4));
+			else
 				tdelta = tsc->slave_tsc - mtsc_after;
-			}
-			last_delta = tsc_sync_tick_delta[source] - tdelta;
-			tsc_sync_tick_delta[slave] = last_delta;
-			min_write_time = write_time;
+			tsc_sync_tick_delta[slave] =
+			    tsc_sync_tick_delta[source] - tdelta;
 		}
 
 		tsc->master_tsc = tsc->slave_tsc = write_time = 0;
@@ -527,13 +529,17 @@
 		membar_enter();
 		tsc_sync_go = TSC_SYNC_STOP;
 	}
-
+	if (tdelta < 0)
+		tdelta = -tdelta;
+	if (tdelta > largest_tsc_delta)
+		largest_tsc_delta = tdelta;
+	if (min_write_time < shortest_write_time)
+		shortest_write_time = min_write_time;
 	/*
-	 * Only enable the delta variants of the TSC functions if the measured
-	 * skew is greater than the fastest write time.
+	 * Enable delta variants of tsc functions if the largest of all chosen
+	 * deltas is > smallest of the write time.
 	 */
-	last_delta = (last_delta < 0) ? -last_delta : last_delta;
-	if (last_delta > min_write_time) {
+	if (largest_tsc_delta > shortest_write_time) {
 		gethrtimef = tsc_gethrtime_delta;
 		gethrtimeunscaledf = tsc_gethrtimeunscaled_delta;
 		tsc_ncpu = NCPU;
@@ -542,12 +548,11 @@
 }
 
 /*
- * TSC Sync Slave
- *
  * Called by a CPU which has just been onlined.  It is expected that the CPU
  * performing the online operation will call tsc_sync_master().
  *
- * Like tsc_sync_master, this logic is skipped on virtualized platforms.
+ * TSC sync is disabled in the context of virtualization. See comments
+ * above tsc_sync_master.
  */
 void
 tsc_sync_slave(void)
@@ -571,9 +576,11 @@
 		tsc_sync_go = TSC_SYNC_GO;
 		do {
 			/*
-			 * Do not put an SMT_PAUSE here.  If the master and
-			 * slave are the same hyper-threaded CPU, we want the
-			 * master to yield as quickly as possible to the slave.
+			 * Do not put an SMT_PAUSE here. For instance,
+			 * if the master and slave are really the same
+			 * hyper-threaded CPU, then you want the master
+			 * to yield to the slave as quickly as possible here,
+			 * but not the other way.
 			 */
 			s1 = tsc_read();
 		} while (tsc->master_tsc == 0);
@@ -704,10 +711,12 @@
 }
 
 /*
- * Adjust all the deltas by adding the passed value to the array and activate
- * the "delta" versions of the gethrtime functions.  It is possible that the
- * adjustment could be negative.  Such may occur if the SunOS instance was
- * moved by a virtual manager to a machine with a higher value of TSC.
+ * Adjust all the deltas by adding the passed value to the array.
+ * Then use the "delt" versions of the the gethrtime functions.
+ * Note that 'tdelta' _could_ be a negative number, which should
+ * reduce the values in the array (used, for example, if the Solaris
+ * instance was moved by a virtual manager to a machine with a higher
+ * value of tsc).
  */
 void
 tsc_adjust_delta(hrtime_t tdelta)
@@ -727,9 +736,13 @@
  * Functions to manage TSC and high-res time on suspend and resume.
  */
 
-/* tod_ops from "uts/i86pc/io/todpc_subr.c" */
+/*
+ * declarations needed for time adjustment
+ */
+extern void	rtcsync(void);
 extern tod_ops_t *tod_ops;
-
+/* There must be a better way than exposing nsec_scale! */
+extern uint_t	nsec_scale;
 static uint64_t tsc_saved_tsc = 0; /* 1 in 2^64 chance this'll screw up! */
 static timestruc_t tsc_saved_ts;
 static int	tsc_needs_resume = 0;	/* We only want to do this once. */
@@ -739,20 +752,23 @@
 int		tsc_resume_in_cyclic = 0;
 
 /*
- * Take snapshots of the current time and do any other pre-suspend work.
+ * Let timestamp.c know that we are suspending.  It needs to take
+ * snapshots of the current time, and do any pre-suspend work.
  */
 void
 tsc_suspend(void)
 {
-	/*
-	 * We need to collect the time at which we suspended here so we know
-	 * now much should be added during the resume.  This is called by each
-	 * CPU, so reentry must be properly handled.
-	 */
+/*
+ * What we need to do here, is to get the time we suspended, so that we
+ * know how much we should add to the resume.
+ * This routine is called by each CPU, so we need to handle reentry.
+ */
 	if (tsc_gethrtime_enable) {
 		/*
-		 * Perform the tsc_read after acquiring the lock to make it as
-		 * accurate as possible in the face of contention.
+		 * We put the tsc_read() inside the lock as it
+		 * as no locking constraints, and it puts the
+		 * aquired value closer to the time stamp (in
+		 * case we delay getting the lock).
 		 */
 		mutex_enter(&tod_lock);
 		tsc_saved_tsc = tsc_read();
@@ -774,7 +790,8 @@
 }
 
 /*
- * Restore all timestamp state based on the snapshots taken at suspend time.
+ * Restore all timestamp state based on the snapshots taken at
+ * suspend time.
  */
 void
 tsc_resume(void)
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/uts/i86pc/unix/Makefile	Wed Oct  5 00:33:59 2016
+++ new/usr/src/uts/i86pc/unix/Makefile	Wed Oct  5 00:33:59 2016
@@ -22,7 +22,6 @@
 #
 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
-# Copyright 2016 Joyent, Inc.
 #
 #	This makefile drives the production of unix (and unix.o).
 #
--- old/usr/src/uts/i86pc/vm/hat_i86.c	Wed Oct  5 00:33:59 2016
+++ new/usr/src/uts/i86pc/vm/hat_i86.c	Wed Oct  5 00:33:59 2016
@@ -27,8 +27,8 @@
  */
 /*
  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
- * Copyright 2014 Joyent, Inc.  All rights reserved.
  * Copyright (c) 2014, 2015 by Delphix. All rights reserved.
+ * Copyright 2014 Joyent, Inc.  All rights reserved.
  */
 
 /*
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/uts/intel/Makefile.files	Wed Oct  5 00:34:00 2016
+++ new/usr/src/uts/intel/Makefile.files	Wed Oct  5 00:34:00 2016
@@ -207,54 +207,38 @@
 #
 #	misc. modules
 #
-ACPICA_OBJS	+= \
-		   dmbuffer.o dmcstyle.o dmdeferred.o dmnames.o dmopcode.o \
-		   dmresrc.o dmresrcl.o dmresrcl2.o dmresrcs.o dmutils.o \
-		   dmwalk.o \
-		   \
-		   dsargs.o dscontrol.o dsdebug.o dsfield.o dsinit.o \
-		   dsmethod.o dsmthdat.o dsobject.o dsopcode.o dsutils.o \
-		   dswexec.o dswload.o dswload2.o dswscope.o dswstate.o \
-		   \
-		   evevent.o evglock.o evgpe.o evgpeblk.o evgpeinit.o \
-		   evgpeutil.o evhandler.o evmisc.o evregion.o evrgnini.o \
-		   evsci.o evxface.o evxfevnt.o evxfgpe.o evxfregn.o \
-		   \
-		   exconcat.o exconfig.o exconvrt.o excreate.o exdebug.o \
-		   exdump.o exfield.o exfldio.o exmisc.o exmutex.o exnames.o \
-		   exoparg1.o exoparg2.o exoparg3.o exoparg6.o exprep.o \
-		   exregion.o exresnte.o exresolv.o exresop.o exstore.o \
-		   exstoren.o exstorob.o exsystem.o extrace.o exutils.o \
-		   \
-		   hwacpi.o hwesleep.o hwgpe.o hwpci.o hwregs.o hwsleep.o \
-		   hwtimer.o hwvalid.o hwxface.o hwxfsleep.o \
-		   \
-		   psargs.o psloop.o psobject.o psopcode.o psopinfo.o \
-		   psparse.o psscope.o pstree.o psutils.o pswalk.o psxface.o \
-		   \
-		   nsaccess.o nsalloc.o nsarguments.o nsconvert.o nsdump.o \
-		   nsdumpdv.o nseval.o nsinit.o nsload.o nsnames.o nsobject.o \
-		   nsparse.o nspredef.o nsprepkg.o nsrepair.o nsrepair2.o \
-		   nssearch.o nsutils.o nswalk.o nsxfeval.o nsxfname.o \
-		   nsxfobj.o \
-		   \
-		   rsaddr.o rscalc.o rscreate.o rsdump.o rsdumpinfo.o \
+ACPICA_OBJS	+= dbcmds.o dbdisply.o \
+		   dbexec.o dbfileio.o dbhistry.o dbinput.o dbstats.o \
+		   dbutils.o dbxface.o evevent.o evgpe.o evgpeblk.o \
+		   evmisc.o evregion.o evrgnini.o evsci.o evxface.o \
+		   evxfevnt.o evxfregn.o hwacpi.o hwgpe.o hwregs.o \
+		   hwsleep.o hwtimer.o dsfield.o dsinit.o dsmethod.o \
+		   dsmthdat.o dsobject.o dsopcode.o dsutils.o dswexec.o \
+		   dswload.o dswscope.o dswstate.o exconfig.o exconvrt.o \
+		   excreate.o exdump.o exfield.o exfldio.o exmisc.o \
+		   exmutex.o exnames.o exoparg1.o exoparg2.o exoparg3.o \
+		   exoparg6.o exprep.o exregion.o exresnte.o exresolv.o \
+		   exresop.o exstore.o exstoren.o exstorob.o exsystem.o \
+		   exutils.o psargs.o psopcode.o psparse.o psscope.o \
+		   pstree.o psutils.o pswalk.o psxface.o nsaccess.o \
+		   nsalloc.o nsdump.o nsdumpdv.o nseval.o nsinit.o \
+		   nsload.o nsnames.o nsobject.o nsparse.o nssearch.o \
+		   nsutils.o nswalk.o nsxfeval.o nsxfname.o nsxfobj.o \
+		   rsaddr.o rscalc.o rscreate.o rsdump.o \
 		   rsinfo.o rsio.o rsirq.o rslist.o rsmemory.o rsmisc.o \
-		   rsserial.o rsutils.o rsxface.o \
-		   \
-		   tbdata.o tbfadt.o tbfind.o tbinstal.o tbprint.o tbutils.o \
-		   tbxface.o tbxfload.o tbxfroot.o \
-		   \
-		   utaddress.o utalloc.o utascii.o utbuffer.o utcache.o \
-		   utclib.o utcopy.o utdebug.o utdecode.o utdelete.o \
-		   uterror.o uteval.o utexcep.o utglobal.o uthex.o utids.o \
-		   utinit.o utlock.o utmath.o utmisc.o utmutex.o utnonansi.o \
-		   utobject.o utosi.o utownerid.o utpredef.o utprint.o \
-		   utresrc.o utstate.o utstring.o uttrack.o utuuid.o utxface.o \
-		   utxferror.o utxfinit.o utxfmutex.o \
-		   \
-		   acpi_enum.o acpica_ec.o acpica.o ahids.o master_ops.o \
-		   osl_ml.o osl.o
+		   rsutils.o rsxface.o tbfadt.o tbfind.o tbinstal.o  \
+		   tbutils.o tbxface.o tbxfroot.o \
+		   utalloc.o utclib.o utcopy.o utdebug.o utdelete.o \
+		   uteval.o utglobal.o utinit.o utmath.o utmisc.o \
+		   utobject.o utresrc.o utxface.o acpica.o acpi_enum.o \
+		   master_ops.o osl.o osl_ml.o acpica_ec.o utcache.o \
+		   utmutex.o utstate.o dmbuffer.o dmnames.o dmobject.o \
+		   dmopcode.o dmresrc.o dmresrcl.o dmresrcs.o dmutils.o \
+		   dmwalk.o psloop.o nspredef.o hwxface.o hwvalid.o \
+		   utlock.o utids.o nsrepair.o nsrepair2.o \
+		   dbmethod.o dbnames.o dsargs.o dscontrol.o dswload2.o \
+		   evglock.o evgpeinit.o evgpeutil.o evxfgpe.o exdebug.o \
+		   hwpci.o utdecode.o utosi.o utxferror.o
 
 
 AGP_OBJS += agpmaster.o
--- old/usr/src/uts/intel/Makefile.intel	Wed Oct  5 00:34:00 2016
+++ new/usr/src/uts/intel/Makefile.intel	Wed Oct  5 00:34:00 2016
@@ -242,7 +242,6 @@
 DRV_KMODS	+= dld
 DRV_KMODS	+= dlpistub
 DRV_KMODS_32	+= dnet
-DRV_KMODS	+= dr_sas
 DRV_KMODS	+= dump
 DRV_KMODS	+= ecpp
 DRV_KMODS	+= emlxs
@@ -291,7 +290,6 @@
 DRV_KMODS	+= mr_sas
 DRV_KMODS	+= mwl 
 DRV_KMODS	+= nca
-DRV_KMODS	+= nfp
 DRV_KMODS	+= nsmb
 DRV_KMODS	+= nulldriver
 DRV_KMODS	+= nv_sata
@@ -361,8 +359,6 @@
 DRV_KMODS	+= urtw
 DRV_KMODS	+= vgatext
 DRV_KMODS	+= heci
-DRV_KMODS	+= vmxnet 
-DRV_KMODS	+= vnd
 DRV_KMODS	+= vnic
 DRV_KMODS	+= vscan
 DRV_KMODS	+= wc
@@ -374,7 +370,6 @@
 DRV_KMODS	+= zfd
 DRV_KMODS	+= zyd
 DRV_KMODS	+= simnet
-DRV_KMODS	+= smrt
 DRV_KMODS	+= stmf
 DRV_KMODS	+= stmf_sbd
 DRV_KMODS	+= fct
@@ -502,15 +497,6 @@
 DRV_KMODS	+= usbecm
 
 #
-#	USBGEM modules
-#
-DRV_KMODS	+= usbgem
-DRV_KMODS	+= axf
-DRV_KMODS	+= udmf 
-DRV_KMODS	+= upf
-DRV_KMODS	+= urf 
-
-#
 #	1394 modules
 #
 MISC_KMODS	+= s1394 sbp2
@@ -550,8 +536,8 @@
 #
 #	File System Modules (/kernel/fs):
 #
-FS_KMODS	+= autofs ctfs dcfs dev devfs fdfs fifofs hsfs hyprlofs
-FS_KMODS	+= lofs lxautofs lx_proc lxprocfs mntfs namefs nfs objfs zfs zut
+FS_KMODS	+= autofs ctfs dcfs dev devfs fdfs fifofs hsfs lofs
+FS_KMODS	+= lxautofs lx_proc mntfs namefs nfs objfs zfs zut
 FS_KMODS	+= pcfs procfs sockfs specfs tmpfs udfs ufs sharefs lx_sysfs
 FS_KMODS	+= smbfs bootfs lx_cgroup lx_devfs
 
@@ -613,7 +599,6 @@
 MISC_KMODS	+= fssnap_if
 MISC_KMODS	+= gda
 MISC_KMODS	+= gld
-MISC_KMODS	+= gsqueue
 MISC_KMODS	+= hidparser
 MISC_KMODS	+= hook
 MISC_KMODS	+= hpcsvc
@@ -730,12 +715,6 @@
 MAC_KMODS	+= mac_ib
 
 #
-#	Overlay related modules (/kernel/overlay)
-#
-DRV_KMODS	+= overlay
-OVERLAY_KMODS	+= vxlan
-
-#
 # socketmod (kernel/socketmod)
 #
 SOCKET_KMODS	+= sockpfp
@@ -743,6 +722,7 @@
 SOCKET_KMODS    += socksdp
 SOCKET_KMODS	+= sockrds
 SOCKET_KMODS	+= ksslf
+SOCKET_KMODS	+= httpfilt
 SOCKET_KMODS	+= datafilt
 
 #
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/uts/intel/elfexec/Makefile	Wed Oct  5 00:34:01 2016
+++ new/usr/src/uts/intel/elfexec/Makefile	Wed Oct  5 00:34:01 2016
@@ -105,15 +105,12 @@
 
 $(OBJS_DIR)/elf32.o:	$(UTSBASE)/common/exec/elf/elf.c
 	$(COMPILE.c) -o $@ -D_ELF32_COMPAT $(UTSBASE)/common/exec/elf/elf.c
-	$(CTFCONVERT_O)
 
 $(OBJS_DIR)/elf32_notes.o: $(UTSBASE)/common/exec/elf/elf_notes.c
 	$(COMPILE.c) -o $@ -D_ELF32_COMPAT $(UTSBASE)/common/exec/elf/elf_notes.c
-	$(CTFCONVERT_O)
 
 $(OBJS_DIR)/old32_notes.o: $(UTSBASE)/common/exec/elf/old_notes.c
 	$(COMPILE.c) -o $@ -D_ELF32_COMPAT $(UTSBASE)/common/exec/elf/old_notes.c
-	$(CTFCONVERT_O)
 
 $(LINTS_DIR)/elf32.ln:	$(UTSBASE)/common/exec/elf/elf.c
 	@($(LHEAD) $(LINT.c) -Celf32 -D_ELF32_COMPAT $(UTSBASE)/common/exec/elf/elf.c $(LTAIL))
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/uts/intel/lx_brand/Makefile	Wed Oct  5 00:34:02 2016
+++ new/usr/src/uts/intel/lx_brand/Makefile	Wed Oct  5 00:34:02 2016
@@ -77,6 +77,7 @@
 #
 LINTTAGS	+= -erroff=E_ASSIGN_NARROW_CONV
 LINTTAGS	+= -erroff=E_SUSPICIOUS_COMPARISON
+LINTTAGS	+= -erroff=E_TRUE_LOGICAL_EXPR
 
 #
 #	Default build targets.
--- old/usr/src/uts/intel/lx_brand/Makefile.rules	Wed Oct  5 00:34:02 2016
+++ new/usr/src/uts/intel/lx_brand/Makefile.rules	Wed Oct  5 00:34:02 2016
@@ -93,6 +93,9 @@
 $(LINTS_DIR)/%.ln:		$(LX_CMN)/%.c
 	@($(LHEAD) $(LINT.c) $< $(LTAIL))
 
+$(LINTS_DIR)/%.ln:		$(UTSBASE)/intel/brand/lx/%.c
+	@($(LHEAD) $(LINT.c) $< $(LTAIL))
+
 $(LINTS_DIR)/%.ln:		$(UTSBASE)/intel/brand/lx/%.s
 	@($(LHEAD) $(LINT.s) $< $(LTAIL))
 
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
--- old/usr/src/uts/intel/sys/ucontext.h	Wed Oct  5 00:34:04 2016
+++ new/usr/src/uts/intel/sys/ucontext.h	Wed Oct  5 00:34:04 2016
@@ -20,9 +20,8 @@
  */
 
 /*
- * Copyright 2015 Joyent, Inc.
  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
- *
+ * Copyright 2015 Joyent, Inc.
  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
No differences encountered
No differences encountered
--- old/usr/src/uts/sparc/Makefile.sparc	Wed Oct  5 00:34:04 2016
+++ new/usr/src/uts/sparc/Makefile.sparc	Wed Oct  5 00:34:04 2016
@@ -219,7 +219,7 @@
 DRV_KMODS	+= pseudo ptc ptm pts ptsl ramdisk random rsm rts sad
 DRV_KMODS	+= simnet softmac sppp sppptun sy sysevent sysmsg 
 DRV_KMODS	+= spdsock
-DRV_KMODS	+= tcp tcp6 timerfd tl tnf ttymux udp udp6 wc winlock zcons zfd
+DRV_KMODS	+= tcp tcp6 timerfd tl tnf ttymux udp udp6 wc winlock zcons zfs
 DRV_KMODS	+= ippctl
 DRV_KMODS	+= dld
 DRV_KMODS	+= ipd
@@ -239,10 +239,9 @@
 DRV_KMODS	+= bridge trill
 DRV_KMODS	+= bpf
 DRV_KMODS	+= dca
-DRV_KMODS	+= inotify
 DRV_KMODS	+= eventfd
 DRV_KMODS	+= signalfd
-DRV_KMODS	+= timerfd
+DRV_KMODS	+= inotify
 
 #
 #       Hardware Drivers in common space
@@ -496,6 +495,7 @@
 SOCKET_KMODS	+= socksdp
 SOCKET_KMODS	+= sockrds
 SOCKET_KMODS	+= ksslf
+SOCKET_KMODS	+= httpfilt
 SOCKET_KMODS	+= datafilt
 
 #
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
No differences encountered
