PSARC 2010/013 SMF Early Manifest Import
authorTom Whitten <Thomas.Whitten@Sun.COM>
Thu, 25 Mar 2010 14:57:35 -0700
changeset 11996 91b62f7b8186
parent 11995 caff1bd711f5
child 11997 dcefb322f2a1
PSARC 2010/013 SMF Early Manifest Import 6503835 manifest-import should be done earlier in boot
exception_lists/packaging
usr/src/Targetdirs
usr/src/cmd/Makefile.cmd
usr/src/cmd/avs/dscfg/dscfgadm.sh
usr/src/cmd/cmd-inet/usr.lib/inetd/inetd-upgrade.sh
usr/src/cmd/cmd-inet/usr.sbin/inetconv/inetconv.c
usr/src/cmd/cmd-inet/usr.sbin/routeadm/Makefile
usr/src/cmd/stmsboot/stmsboot.sh
usr/src/cmd/svc/Makefile
usr/src/cmd/svc/common/manifest_find.c
usr/src/cmd/svc/common/manifest_find.h
usr/src/cmd/svc/common/manifest_hash.c
usr/src/cmd/svc/common/manifest_hash.h
usr/src/cmd/svc/configd/backend.c
usr/src/cmd/svc/mfstscan/Makefile
usr/src/cmd/svc/mfstscan/mfstscan.c
usr/src/cmd/svc/milestone/Makefile
usr/src/cmd/svc/milestone/early-manifest-import.xml
usr/src/cmd/svc/milestone/manifest-import
usr/src/cmd/svc/profile/Makefile
usr/src/cmd/svc/profile/generic_limited_net.xml
usr/src/cmd/svc/profile/generic_open.xml
usr/src/cmd/svc/prophist/Makefile
usr/src/cmd/svc/prophist/prophist.SUNWcsr
usr/src/cmd/svc/prophist/prophist.c
usr/src/cmd/svc/shell/Makefile
usr/src/cmd/svc/shell/manifest_cleanup.ksh
usr/src/cmd/svc/shell/netservices.sh
usr/src/cmd/svc/startd/Makefile
usr/src/cmd/svc/startd/fork.c
usr/src/cmd/svc/startd/graph.c
usr/src/cmd/svc/startd/startd.c
usr/src/cmd/svc/startd/startd.h
usr/src/cmd/svc/svccfg/Makefile
usr/src/cmd/svc/svccfg/svccfg.h
usr/src/cmd/svc/svccfg/svccfg.l
usr/src/cmd/svc/svccfg/svccfg.y
usr/src/cmd/svc/svccfg/svccfg_engine.c
usr/src/cmd/svc/svccfg/svccfg_help.c
usr/src/cmd/svc/svccfg/svccfg_libscf.c
usr/src/cmd/svc/svccfg/svccfg_xml.c
usr/src/cmd/svr4pkg/pkgscripts/Makefile
usr/src/lib/cfgadm_plugins/fp/Makefile.com
usr/src/lib/efcode/efdaemon/Makefile
usr/src/lib/libresolv2/Makefile
usr/src/lib/libscf/inc/libscf.h
usr/src/lib/libscf/inc/libscf_priv.h
usr/src/lib/libsecdb/Makefile
usr/src/lib/print/mod_ipp/Makefile
usr/src/pkg/manifests/SUNWcs.mf
usr/src/pkg/manifests/SUNWcsd.mf
usr/src/pkg/manifests/driver-network-srpt.mf
usr/src/pkg/manifests/driver-storage-sv.mf
usr/src/pkg/manifests/driver-usb.mf
usr/src/pkg/manifests/network-bridging.mf
usr/src/pkg/manifests/network-ipfilter.mf
usr/src/pkg/manifests/network-iscsi-initiator.mf
usr/src/pkg/manifests/network-iscsi-target.mf
usr/src/pkg/manifests/package-svr4.mf
usr/src/pkg/manifests/print-lp-ipp-ipp-listener.mf
usr/src/pkg/manifests/print-lp-print-manager-legacy.mf
usr/src/pkg/manifests/print-lp.mf
usr/src/pkg/manifests/service-file-system-nfs.mf
usr/src/pkg/manifests/service-file-system-smb.mf
usr/src/pkg/manifests/service-hal.mf
usr/src/pkg/manifests/service-key-management-sun-fire-15000.mf
usr/src/pkg/manifests/service-network-dhcp.mf
usr/src/pkg/manifests/service-network-dns-mdns.mf
usr/src/pkg/manifests/service-network-ftp.mf
usr/src/pkg/manifests/service-network-legacy.mf
usr/src/pkg/manifests/service-network-load-balancer-ilb.mf
usr/src/pkg/manifests/service-network-network-servers.mf
usr/src/pkg/manifests/service-network-nis.mf
usr/src/pkg/manifests/service-network-slp.mf
usr/src/pkg/manifests/service-network-smtp-sendmail.mf
usr/src/pkg/manifests/service-network-ssh.mf
usr/src/pkg/manifests/service-network-telnet.mf
usr/src/pkg/manifests/service-network-uucp.mf
usr/src/pkg/manifests/service-network-wpa.mf
usr/src/pkg/manifests/service-picl.mf
usr/src/pkg/manifests/service-resource-cap.mf
usr/src/pkg/manifests/service-resource-pools.mf
usr/src/pkg/manifests/service-security-gss.mf
usr/src/pkg/manifests/service-security-kerberos-5.mf
usr/src/pkg/manifests/service-storage-avs-cache-management.mf
usr/src/pkg/manifests/service-storage-fibre-channel-fc-fabric.mf
usr/src/pkg/manifests/service-storage-isns.mf
usr/src/pkg/manifests/service-storage-media-volume-manager.mf
usr/src/pkg/manifests/service-storage-ndmp.mf
usr/src/pkg/manifests/service-storage-removable-media.mf
usr/src/pkg/manifests/service-storage-virus-scan.mf
usr/src/pkg/manifests/storage-avs-point-in-time-copy.mf
usr/src/pkg/manifests/storage-avs-remote-mirror.mf
usr/src/pkg/manifests/storage-stmf.mf
usr/src/pkg/manifests/storage-svm.mf
usr/src/pkg/manifests/system-accounting-legacy.mf
usr/src/pkg/manifests/system-boot-network.mf
usr/src/pkg/manifests/system-domain-configuration-sparc-enterprise.mf
usr/src/pkg/manifests/system-domain-service-processor-protocol-sparc-enterprise.mf
usr/src/pkg/manifests/system-embedded-fcode-interpreter.mf
usr/src/pkg/manifests/system-file-system-autofs.mf
usr/src/pkg/manifests/system-file-system-nfs.mf
usr/src/pkg/manifests/system-file-system-smb.mf
usr/src/pkg/manifests/system-floating-point-scrubber.mf
usr/src/pkg/manifests/system-kernel-dynamic-reconfiguration-sun-fire-880.mf
usr/src/pkg/manifests/system-kernel-power.mf
usr/src/pkg/manifests/system-kernel.mf
usr/src/pkg/manifests/system-ldoms.mf
usr/src/pkg/manifests/system-management-intel-amt.mf
usr/src/pkg/manifests/system-management-snmp-sea-sea-config.mf
usr/src/pkg/manifests/system-network-console.mf
usr/src/pkg/manifests/system-network-nis.mf
usr/src/pkg/manifests/system-network-routing-vrrp.mf
usr/src/pkg/manifests/system-network-routing.mf
usr/src/pkg/manifests/system-security-kerberos-5.mf
usr/src/pkg/manifests/system-storage-fibre-channel-port-utility.mf
usr/src/pkg/manifests/system-storage-mms.mf
usr/src/pkg/manifests/system-trusted-global-zone.mf
usr/src/pkg/manifests/system-trusted.mf
usr/src/pkg/manifests/system-xvm-ipagent.mf
usr/src/pkg/manifests/system-zones.mf
usr/src/pkg/transforms/restart_fmri
usr/src/tools/scripts/bfu.sh
--- a/exception_lists/packaging	Thu Mar 25 13:21:39 2010 -0700
+++ b/exception_lists/packaging	Thu Mar 25 14:57:35 2010 -0700
@@ -402,18 +402,20 @@
 usr/include/librestart.h
 usr/lib/librestart.so
 usr/lib/sparcv9/librestart.so					sparc
+lib/svc/manifest/platform/sun4u					i386
+lib/svc/manifest/platform/sun4v					i386
 var/svc/manifest/platform/sun4u					i386
 var/svc/manifest/platform/sun4v					i386
-var/svc/profile/platform_sun4v.xml				i386
-var/svc/profile/platform_SUNW,SPARC-Enterprise.xml		i386
-var/svc/profile/platform_SUNW,Sun-Fire-15000.xml		i386
-var/svc/profile/platform_SUNW,Sun-Fire-880.xml			i386
-var/svc/profile/platform_SUNW,Sun-Fire-V890.xml			i386
-var/svc/profile/platform_SUNW,Sun-Fire.xml			i386
-var/svc/profile/platform_SUNW,Ultra-Enterprise-10000.xml	i386
-var/svc/profile/platform_SUNW,UltraSPARC-IIe-NetraCT-40.xml	i386
-var/svc/profile/platform_SUNW,UltraSPARC-IIe-NetraCT-60.xml	i386
-var/svc/profile/platform_SUNW,UltraSPARC-IIi-Netract.xml	i386
+etc/svc/profile/platform_sun4v.xml				i386
+etc/svc/profile/platform_SUNW,SPARC-Enterprise.xml		i386
+etc/svc/profile/platform_SUNW,Sun-Fire-15000.xml		i386
+etc/svc/profile/platform_SUNW,Sun-Fire-880.xml			i386
+etc/svc/profile/platform_SUNW,Sun-Fire-V890.xml			i386
+etc/svc/profile/platform_SUNW,Sun-Fire.xml			i386
+etc/svc/profile/platform_SUNW,Ultra-Enterprise-10000.xml	i386
+etc/svc/profile/platform_SUNW,UltraSPARC-IIe-NetraCT-40.xml	i386
+etc/svc/profile/platform_SUNW,UltraSPARC-IIe-NetraCT-60.xml	i386
+etc/svc/profile/platform_SUNW,UltraSPARC-IIi-Netract.xml	i386
 #
 # Private libuutil files
 #
--- a/usr/src/Targetdirs	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/Targetdirs	Thu Mar 25 14:57:35 2010 -0700
@@ -150,6 +150,7 @@
 	/etc/sasl	\
 	/etc/sfw \
 	/etc/svc \
+	/etc/svc/profile \
 	/etc/svc/volatile \
 	/etc/tm  \
 	/etc/usb   \
@@ -165,6 +166,32 @@
 	/lib/svc \
 	/lib/svc/bin \
 	/lib/svc/capture \
+	/lib/svc/manifest \
+	/lib/svc/manifest/milestone \
+	/lib/svc/manifest/device \
+	/lib/svc/manifest/system \
+	/lib/svc/manifest/system/device \
+	/lib/svc/manifest/system/filesystem \
+	/lib/svc/manifest/system/security \
+	/lib/svc/manifest/system/svc \
+	/lib/svc/manifest/network \
+	/lib/svc/manifest/network/dns \
+  	/lib/svc/manifest/network/ipsec \
+	/lib/svc/manifest/network/ldap \
+	/lib/svc/manifest/network/nfs \
+	/lib/svc/manifest/network/nis \
+	/lib/svc/manifest/network/rpc \
+	/lib/svc/manifest/network/security \
+	/lib/svc/manifest/network/shares \
+	/lib/svc/manifest/network/ssl \
+	/lib/svc/manifest/application \
+	/lib/svc/manifest/application/management \
+	/lib/svc/manifest/application/security \
+	/lib/svc/manifest/application/print \
+	/lib/svc/manifest/platform \
+	/lib/svc/manifest/platform/sun4u \
+	/lib/svc/manifest/platform/sun4v \
+	/lib/svc/manifest/site \
 	/lib/svc/method \
 	/lib/svc/monitor \
 	/lib/svc/seed \
@@ -372,18 +399,19 @@
 	/var/svc/manifest/system/svc \
 	/var/svc/manifest/network \
 	/var/svc/manifest/network/dns \
-	/var/svc/manifest/network/ipsec \
+  	/var/svc/manifest/network/ipsec \
 	/var/svc/manifest/network/ldap \
 	/var/svc/manifest/network/nfs \
 	/var/svc/manifest/network/nis \
 	/var/svc/manifest/network/rpc \
+	/var/svc/manifest/network/routing \
 	/var/svc/manifest/network/security \
 	/var/svc/manifest/network/shares \
 	/var/svc/manifest/network/ssl \
 	/var/svc/manifest/application \
 	/var/svc/manifest/application/management \
+	/var/svc/manifest/application/print \
 	/var/svc/manifest/application/security \
-	/var/svc/manifest/application/print \
 	/var/svc/manifest/platform \
 	/var/svc/manifest/platform/sun4u \
 	/var/svc/manifest/platform/sun4v \
--- a/usr/src/cmd/Makefile.cmd	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/Makefile.cmd	Thu Mar 25 14:57:35 2010 -0700
@@ -19,7 +19,7 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 # Definitions common to command source.
@@ -206,18 +206,19 @@
 #
 # Directories for smf(5) service manifests and profiles.
 #
-ROOTVARSVC=			$(ROOT)/var/svc
+ROOTSVC=			$(ROOT)/lib/svc
+ROOTETCSVC=			$(ROOT)/etc/svc
 
-ROOTVARSVCMANIFEST=		$(ROOTVARSVC)/manifest
-ROOTVARSVCPROFILE=		$(ROOTVARSVC)/profile
+ROOTSVCMANIFEST=		$(ROOTSVC)/manifest
+ROOTSVCPROFILE=			$(ROOTETCSVC)/profile
 
-ROOTSVCMILESTONE=		$(ROOTVARSVCMANIFEST)/milestone
-ROOTSVCDEVICE=			$(ROOTVARSVCMANIFEST)/device
-ROOTSVCSYSTEM=			$(ROOTVARSVCMANIFEST)/system
+ROOTSVCMILESTONE=		$(ROOTSVCMANIFEST)/milestone
+ROOTSVCDEVICE=			$(ROOTSVCMANIFEST)/device
+ROOTSVCSYSTEM=			$(ROOTSVCMANIFEST)/system
 ROOTSVCSYSTEMDEVICE=		$(ROOTSVCSYSTEM)/device
 ROOTSVCSYSTEMFILESYSTEM=	$(ROOTSVCSYSTEM)/filesystem
 ROOTSVCSYSTEMSECURITY=		$(ROOTSVCSYSTEM)/security
-ROOTSVCNETWORK=			$(ROOTVARSVCMANIFEST)/network
+ROOTSVCNETWORK=			$(ROOTSVCMANIFEST)/network
 ROOTSVCNETWORKDNS=		$(ROOTSVCNETWORK)/dns
 ROOTSVCNETWORKISCSI=		$(ROOTSVCNETWORK)/iscsi
 ROOTSVCNETWORKLDAP=		$(ROOTSVCNETWORK)/ldap
@@ -231,10 +232,10 @@
 ROOTSVCNETWORKIPSEC=		$(ROOTSVCNETWORK)/ipsec
 ROOTSVCNETWORKSHARES=		$(ROOTSVCNETWORK)/shares
 ROOTSVCSMB=			$(ROOTSVCNETWORK)/smb
-ROOTSVCPLATFORM=		$(ROOTVARSVCMANIFEST)/platform
+ROOTSVCPLATFORM=		$(ROOTSVCMANIFEST)/platform
 ROOTSVCPLATFORMSUN4U=		$(ROOTSVCPLATFORM)/sun4u
 ROOTSVCPLATFORMSUN4V=		$(ROOTSVCPLATFORM)/sun4v
-ROOTSVCAPPLICATION=		$(ROOTVARSVCMANIFEST)/application
+ROOTSVCAPPLICATION=		$(ROOTSVCMANIFEST)/application
 ROOTSVCAPPLICATIONMANAGEMENT=	$(ROOTSVCAPPLICATION)/management
 ROOTSVCAPPLICATIONSECURITY=	$(ROOTSVCAPPLICATION)/security
 ROOTSVCAPPLICATIONPRINT=	$(ROOTSVCAPPLICATION)/print
@@ -251,7 +252,7 @@
 # The manifest validation of the $SRC/cmd check target is also derived from a
 # valid MANIFEST setting.
 #
-ROOTMANIFESTDIR=	$(ROOTVARSVCMANIFEST)/__nonexistent_directory__
+ROOTMANIFESTDIR=	$(ROOTSVCMANIFEST)/__nonexistent_directory__
 ROOTMANIFEST=		$(MANIFEST:%=$(ROOTMANIFESTDIR)/%)
 CHKMANIFEST=		$(MANIFEST:%.xml=%.xmlchk)
 
--- a/usr/src/cmd/avs/dscfg/dscfgadm.sh	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/avs/dscfg/dscfgadm.sh	Thu Mar 25 14:57:35 2010 -0700
@@ -19,7 +19,7 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 
@@ -100,7 +100,7 @@
 DSCFG_DEPEND_NOCHK="/tmp/.dscfgadm_pid"
 
 # SMF defines
-MANIFEST_PATH=/var/svc/manifest/system
+MANIFEST_PATH=/lib/svc/manifest/system
 
 # SMF services (enable and disable)
 SMF_ENABLE="nws_scm nws_sv nws_ii nws_rdc nws_rdcsyncd"
--- a/usr/src/cmd/cmd-inet/usr.lib/inetd/inetd-upgrade.sh	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/cmd-inet/usr.lib/inetd/inetd-upgrade.sh	Thu Mar 25 14:57:35 2010 -0700
@@ -20,9 +20,7 @@
 # CDDL HEADER END
 #
 #
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 
@@ -106,7 +104,7 @@
 EOF
 
 # get list of inetconv generated manifests
-inetconv_manifests=`/usr/bin/find /var/svc/manifest -type f -name \*.xml | \
+inetconv_manifests=`/usr/bin/find /lib/svc/manifest -type f -name \*.xml | \
     /usr/bin/xargs /usr/bin/grep -l "Generated by inetconv"`
 
 # For each inetconv generated manifest determine the instances that should
--- a/usr/src/cmd/cmd-inet/usr.sbin/inetconv/inetconv.c	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/cmd-inet/usr.sbin/inetconv/inetconv.c	Thu Mar 25 14:57:35 2010 -0700
@@ -19,12 +19,10 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 /*
  * inetconv - convert inetd.conf entries into smf(5) service manifests,
  *            import them into smf(5) repository
@@ -64,7 +62,7 @@
 #define	MAIN_CONFIG		"/etc/inet/inetd.conf"
 #define	ALT_CONFIG		"/etc/inetd.conf"
 
-#define	MANIFEST_DIR		"/var/svc/manifest/network"
+#define	MANIFEST_DIR		"/lib/svc/manifest/network"
 #define	MANIFEST_RPC_DIR	MANIFEST_DIR  "/rpc"
 #define	SVCCFG_PATH		"/usr/sbin/svccfg"
 
--- a/usr/src/cmd/cmd-inet/usr.sbin/routeadm/Makefile	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/cmd-inet/usr.sbin/routeadm/Makefile	Thu Mar 25 14:57:35 2010 -0700
@@ -19,7 +19,7 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 
@@ -34,17 +34,17 @@
 
 #
 # We cannot use the usual manifest rules here since we deliver
-# manifests to two different locations, /var/svc/manifest/network/forwarding.xml
-# and /var/svc/manifest/network/routing/legacy-routing.xml
+# manifests to two different locations, /lib/svc/manifest/network/forwarding.xml
+# and /lib/svc/manifest/network/routing/legacy-routing.xml
 #
 
 ROOTSVCMANIFESTDIR=	$(ROOTSVCNETWORK) $(ROOTSVCNETWORKROUTING)
-ROOTSVCMANIFEST=	$(ROOTSVCNETWORKROUTING)/legacy-routing.xml \
+ROOTSVCMANIFESTS=	$(ROOTSVCNETWORKROUTING)/legacy-routing.xml \
 			$(ROOTSVCNETWORK)/forwarding.xml
 
 include ../../Makefile.cmd-inet
 
-$(ROOTSVCMANIFEST)	:=	FILEMODE= 444
+$(ROOTSVCMANIFESTS)	:=	FILEMODE= 444
 
 ROOTUSRSBINLINKS=	$(PROG:%=$(ROOTUSRSBIN)/%)
 
@@ -59,7 +59,7 @@
 
 all: $(PROG)
 
-install: all $(ROOTSBINPROG) $(ROOTUSRSBINLINKS) $(ROOTSVCMANIFEST) \
+install: all $(ROOTSBINPROG) $(ROOTUSRSBINLINKS) $(ROOTSVCMANIFESTS) \
 	$(ROOTSVCMETHOD)
 
 $(ROOTUSRSBINLINKS):
@@ -71,7 +71,7 @@
 
 lint: lint_PROG
 
-$(ROOTSVCMANIFEST): $(ROOTSVCMANIFESTDIR)
+$(ROOTSVCMANIFESTS): $(ROOTSVCMANIFESTDIR)
 
 $(ROOTSVCMANIFESTDIR):
 	$(INS.dir)
--- a/usr/src/cmd/stmsboot/stmsboot.sh	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/stmsboot/stmsboot.sh	Thu Mar 25 14:57:35 2010 -0700
@@ -508,8 +508,8 @@
 # now import the new service, if necessary
 $SVCPROP -q $STMSINSTANCE < /dev/null > /dev/null 2>&1
 if [ $? -ne 0 ]; then
-	if [ -f /var/svc/manifest/system/device/mpxio-upgrade.xml ]; then
-		$SVCCFG import /var/svc/manifest/system/device/mpxio-upgrade.xml
+	if [ -f /lib/svc/manifest/system/device/mpxio-upgrade.xml ]; then
+		$SVCCFG import /lib/svc/manifest/system/device/mpxio-upgrade.xml
 		if [ $? -ne 0 ]; then
 
 			fmt=`gettext "Unable to import the %s service"`
--- a/usr/src/cmd/svc/Makefile	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/svc/Makefile	Thu Mar 25 14:57:35 2010 -0700
@@ -19,13 +19,13 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 
 include ../Makefile.cmd
 
-SUBDIR_CMD=	lsvcrun mfstscan prophist servinfo svcadm svccfg svcprop svcs
+SUBDIR_CMD=	lsvcrun mfstscan servinfo svcadm svccfg svcprop svcs
 SUBDIR_DAEMON=	configd startd
 SUBDIR_REPO=	milestone profile seed
 SUBDIR_MISC=	shell
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/svc/common/manifest_find.c	Thu Mar 25 14:57:35 2010 -0700
@@ -0,0 +1,324 @@
+/*
+ * CDDL HEADER START
+ *
+ * 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 2010 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * The primary role of this file is to obtain a list of manifests that are
+ * located in a specified directory or one of its subdirectories.  The
+ * find_manifests() function provides this service, and
+ * free_manifest_array() is used to free the memory associated with the
+ * returned list.
+ *
+ * The find_manifests() function can return an array consisting of all the
+ * .xml files in the directory and its subdirectories.  Alternatively,
+ * find_manifests() can be asked to only return new manifests based on the
+ * return of mhash_test_file().  The list that is returned is an array of
+ * pointers to manifest_info structures.
+ *
+ * Implementation Notes:
+ * ====================
+ * This module makes use of the nftw(3C) function to scan the directory.
+ * nftw() calls a processing function for every file that it finds.
+ * Unfortunately, nftw does not allow us to pass in any structure pointers
+ * to the processing function, and that makes it hard to accumulate a list.
+ * Thus, we will use the thread specific data area to hold data that must
+ * be retained between calls to the processing function.  This will allow
+ * this module to be used in multi-threaded applications if the need
+ * arises.
+ */
+
+#include <assert.h>
+#include <errno.h>
+#include <ftw.h>
+#include <libscf.h>
+#include <libuutil.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <string.h>
+#include "manifest_find.h"
+#include "manifest_hash.h"
+
+#define	MAX_DEPTH	24
+
+/* Thread specific data */
+typedef struct mftsd {
+	manifest_info_t ** tsd_array;	/* Array of manifest_info structs */
+	int		tsd_count;	/* Number items in list */
+	int		tsd_max;	/* Number of pointers allocated */
+					/* at tsd_array. */
+	int		tsd_flags;	/* Check flags for hash and extension */
+	scf_handle_t	*tsd_hndl;	/* Handle for libscf. */
+} mftsd_t;
+
+static pthread_key_t tsd_key = PTHREAD_ONCE_KEY_NP;
+
+/*
+ * Add the manifest info consisting of filename (fn), hash property name
+ * (pname) and hash to the array at tsd_array.  If necessary, realloc()
+ * will be called to increase the size of the buffer at tsd_array.
+ *
+ * Returns 0 on success and -1 on failure.  If a failure occurs, errno will
+ * be set.
+ */
+static int
+add_pointer(mftsd_t *tsdp, const char *fn, const char *pname, uchar_t *hash)
+{
+	manifest_info_t *info;
+	manifest_info_t **newblock;
+	int new_max;
+
+	if (tsdp->tsd_count >= (tsdp->tsd_max - 1)) {
+		/* Need more memory. */
+		new_max = (tsdp->tsd_max == 0) ? 16 : 2 * tsdp->tsd_max;
+		newblock = realloc(tsdp->tsd_array,
+		    new_max * sizeof (*tsdp->tsd_array));
+		if (newblock == NULL)
+			return (-1);
+		tsdp->tsd_array = newblock;
+		/* NULL terminate list in case allocations fail below. */
+		*(tsdp->tsd_array + tsdp->tsd_count) = NULL;
+		tsdp->tsd_max = new_max;
+	}
+	info = uu_zalloc(sizeof (*info));
+	if (info == NULL) {
+		errno = ENOMEM;
+		return (-1);
+	}
+	info->mi_path = uu_strdup(fn);
+	if (info->mi_path == NULL) {
+		uu_free(info);
+		errno = ENOMEM;
+		return (-1);
+	}
+	info->mi_prop = pname;
+	if (hash != NULL)
+		(void) memcpy(info->mi_hash, hash, MHASH_SIZE);
+	*(tsdp->tsd_array + tsdp->tsd_count) = info;
+	tsdp->tsd_count++;
+
+	/* NULL terminate the list. */
+	*(tsdp->tsd_array + tsdp->tsd_count) = NULL;
+
+	return (0);
+}
+
+/*
+ * If necessary initialize the thread specific data key at tsd_key, and
+ * allocate a mftsd_t structure to hold our thread specific data.  Upon
+ * success, the address the thread specific data is returned.  On failure,
+ * NULL is returned and errno is set.
+ */
+static mftsd_t *
+get_thread_specific_data()
+{
+	mftsd_t *tsdp;
+
+	if (pthread_key_create_once_np(&tsd_key, NULL) != 0)
+		return (NULL);
+	tsdp = (mftsd_t *)pthread_getspecific(tsd_key);
+	if (tsdp == NULL) {
+		/*
+		 * First time for this thread.  We need to allocate memory
+		 * for our thread specific data.
+		 */
+		tsdp = uu_zalloc(sizeof (*tsdp));
+		if (tsdp == NULL) {
+			errno = ENOMEM;
+			return (NULL);
+		}
+		errno = pthread_setspecific(tsd_key, tsdp);
+		if (errno != 0) {
+			/*
+			 * EINVAL means that our key is invalid, which
+			 * would be a coding error.
+			 */
+			assert(errno != EINVAL);
+			return (NULL);
+		}
+	}
+	return (tsdp);
+}
+
+/*
+ * This function is called by nftw(3C) every time that it finds an object
+ * in a directory of interest.  If the object is a file, process() checks
+ * to see if it is a manifest file by insuring that it has a .xml
+ * extension.
+ *
+ * If the file is a manifest file, and the CHECKHASH flag is set process()
+ * calls mhash_test_file() to see if it is a new manifest.  Manfest data
+ * for selected manifests is added to tsd_array in our thread specific data.
+ *
+ * The CHECKEXT flag may be set if this was not a directory search request
+ * but a single manifest file check that was determined by the caller to
+ * be found based not on the extension of the file.
+ */
+/*ARGSUSED*/
+static int
+process(const char *fn, const struct stat *sp, int ftw_type,
+    struct FTW *ftws)
+{
+	char *suffix_match;
+	uchar_t hash[MHASH_SIZE];
+	char *pname;
+	mftsd_t *tsdp;
+
+	if (ftw_type != FTW_F)
+		return (0);
+
+	tsdp = get_thread_specific_data();
+	if (tsdp == NULL)
+		return (-1);
+
+	/*
+	 * Only check the extension on the file when
+	 * requested.
+	 */
+	if (tsdp->tsd_flags & CHECKEXT) {
+		suffix_match = strstr(fn, ".xml");
+		if (suffix_match == NULL || strcmp(suffix_match, ".xml") != 0)
+			return (0);
+	}
+
+	if (tsdp->tsd_flags & CHECKHASH) {
+		if (mhash_test_file(tsdp->tsd_hndl, fn, 0, &pname, hash) ==
+		    MHASH_NEWFILE) {
+			return (add_pointer(tsdp, fn, pname, hash));
+		}
+	} else {
+		return (add_pointer(tsdp, fn, NULL, NULL));
+	}
+
+	return (0);
+}
+
+/*
+ * This function returns a pointer to an array of manifest_info_t pointers.
+ * There is one manifest_info_t pointer for each manifest file in the
+ * directory, dir, that satifies the selection criteria.  The array is
+ * returned to arrayp.  The array will be terminated with a NULL pointer.
+ * It is the responsibility of the caller to free the memory associated
+ * with the array by calling free_manifest_array().
+ *
+ * flags :
+ * 	0x1 - CHECKHASH - do the hash check and only return manifest
+ * 	files that do not have a hash entry in the smf/manifest table
+ * 	or the hash value has changed due to the manifest file having
+ * 	been modified.  If not set then all manifest files found are
+ * 	returned, regardless of the hash status.
+ *
+ * 	0x2 - CHECKEXT - Check the extension of the file is .xml
+ *
+ * On success a count of the number of selected manifests is returned.
+ * Note, however, that *arrayp will be set to NULL if the selection is
+ * empty, and a count of 0 will be returned.  In the case of failure, -1
+ * will be returned and errno will be set.
+ */
+int
+find_manifests(const char *dir, manifest_info_t ***arrayp, int flags)
+{
+	mftsd_t *tsdp;
+	int status = -1;
+	int count;
+
+	tsdp = get_thread_specific_data();
+	if (tsdp == NULL)
+		return (NULL);
+
+	tsdp->tsd_flags = flags;
+
+	/*
+	 * Create a handle for use by mhast_test_file() if
+	 * the flag is set to request hash checking be enabled.
+	 */
+	if (tsdp->tsd_flags & CHECKHASH) {
+		tsdp->tsd_hndl = scf_handle_create(SCF_VERSION);
+		if (tsdp->tsd_hndl == NULL) {
+			if (scf_error() == SCF_ERROR_NO_MEMORY) {
+				errno = ENOMEM;
+			} else {
+				errno = EINVAL;
+			}
+			goto out;
+		}
+		if (scf_handle_bind(tsdp->tsd_hndl) != SCF_SUCCESS) {
+			if (scf_error() == SCF_ERROR_NO_RESOURCES) {
+				errno = ENOMEM;
+			} else {
+				errno = EINVAL;
+			}
+			goto out;
+		}
+	}
+
+	if (nftw(dir, process, MAX_DEPTH, FTW_MOUNT) == 0) {
+		status = 0;
+	}
+
+out:
+	if (tsdp->tsd_hndl != NULL) {
+		(void) scf_handle_unbind(tsdp->tsd_hndl);
+		(void) scf_handle_destroy(tsdp->tsd_hndl);
+	}
+	if (status == 0) {
+		*arrayp = tsdp->tsd_array;
+		count = tsdp->tsd_count;
+	} else {
+		*arrayp = NULL;
+		free_manifest_array(tsdp->tsd_array);
+		count = -1;
+	}
+
+	/* Reset thread specific data. */
+	(void) memset(tsdp, 0, sizeof (*tsdp));
+
+	return (count);
+}
+
+/*
+ * Free the memory associated with the array of manifest_info structures.
+ */
+void
+free_manifest_array(manifest_info_t **array)
+{
+	manifest_info_t **entry;
+	manifest_info_t *info;
+
+	if (array == NULL)
+		return;
+
+	for (entry = array; *entry != NULL; entry++) {
+		info = *entry;
+		uu_free((void *) info->mi_path);
+		uu_free((void *) info->mi_prop);
+		uu_free(info);
+	}
+
+	/*
+	 * Array is allocated with realloc(3C), so it must be freed with
+	 * free(3c) rather than uu_free().
+	 */
+	free(array);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/svc/common/manifest_find.h	Thu Mar 25 14:57:35 2010 -0700
@@ -0,0 +1,59 @@
+/*
+ * CDDL HEADER START
+ *
+ * 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 2010 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _MANIFEST_FIND_H
+#define	_MANIFEST_FIND_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <sys/types.h>
+#include "manifest_hash.h"
+
+#define	CHECKHASH	0x1
+#define	CHECKEXT	0x2
+
+typedef struct manifest_info {
+	const char	*mi_path;	/* Path of manifest file */
+	const char	*mi_prop;	/* Property that holds manifest hash */
+	uchar_t		mi_hash[MHASH_SIZE]; /* Manifest hash */
+} manifest_info_t;
+
+/*
+ * Declare functions that are used for finding manifest files in a
+ * directory.
+ */
+
+
+int find_manifests(const char *, manifest_info_t ***, int);
+void free_manifest_array(manifest_info_t **);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _MANIFEST_FIND_H */
--- a/usr/src/cmd/svc/common/manifest_hash.c	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/svc/common/manifest_hash.c	Thu Mar 25 14:57:35 2010 -0700
@@ -19,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -110,16 +110,21 @@
 }
 
 int
-mhash_retrieve_entry(scf_handle_t *hndl, const char *name, uchar_t *hash)
+mhash_retrieve_entry(scf_handle_t *hndl, const char *name, uchar_t *hash,
+    apply_action_t *action)
 {
 	scf_scope_t *scope;
 	scf_service_t *svc;
 	scf_propertygroup_t *pg;
 	scf_property_t *prop;
 	scf_value_t *val;
+	scf_error_t err;
 	ssize_t szret;
 	int result = 0;
 
+	if (action)
+		*action = APPLY_NONE;
+
 	/*
 	 * In this implementation the hash for name is the opaque value of
 	 * svc:/MHASH_SVC/:properties/name/MHASH_PROP
@@ -178,6 +183,38 @@
 		goto out;
 	}
 
+	/*
+	 * If caller has requested the apply_last property, read the
+	 * property if it exists.
+	 */
+	if (action != NULL) {
+		uint8_t apply_value;
+
+		if (scf_pg_get_property(pg, MHASH_APPLY_PROP, prop) !=
+		    SCF_SUCCESS) {
+			err = scf_error();
+			if ((err != SCF_ERROR_DELETED) &&
+			    (err != SCF_ERROR_NOT_FOUND)) {
+				result = -1;
+			}
+			goto out;
+		}
+		if (scf_property_get_value(prop, val) != SCF_SUCCESS) {
+			err = scf_error();
+			if ((err != SCF_ERROR_DELETED) &&
+			    (err != SCF_ERROR_NOT_FOUND)) {
+				result = -1;
+			}
+			goto out;
+		}
+		if (scf_value_get_boolean(val, &apply_value) != SCF_SUCCESS) {
+			result = -1;
+			goto out;
+		}
+		if (apply_value)
+			*action = APPLY_LATE;
+	}
+
 out:
 	(void) scf_value_destroy(val);
 	scf_property_destroy(prop);
@@ -190,17 +227,20 @@
 
 int
 mhash_store_entry(scf_handle_t *hndl, const char *name, const char *fname,
-    uchar_t *hash, char **errstr)
+    uchar_t *hash, apply_action_t apply_late, char **errstr)
 {
 	scf_scope_t *scope = NULL;
 	scf_service_t *svc = NULL;
 	scf_propertygroup_t *pg = NULL;
 	scf_property_t *prop = NULL;
+	scf_value_t *aval = NULL;
 	scf_value_t *val = NULL;
 	scf_value_t *fval = NULL;
 	scf_transaction_t *tx = NULL;
+	scf_transaction_entry_t *ae = NULL;
 	scf_transaction_entry_t *e = NULL;
 	scf_transaction_entry_t *fe = NULL;
+	scf_error_t err;
 	int ret, result = 0;
 
 	int i;
@@ -223,7 +263,6 @@
 	}
 
 	for (i = 0; i < 5; ++i) {
-		scf_error_t err;
 
 		if (scf_scope_get_service(scope, MHASH_SVC, svc) ==
 		    SCF_SUCCESS)
@@ -270,8 +309,6 @@
 	}
 
 	for (i = 0; i < 5; ++i) {
-		scf_error_t err;
-
 		if (scf_service_get_pg(svc, name, pg) == SCF_SUCCESS)
 			break;
 
@@ -316,7 +353,9 @@
 	if ((e = scf_entry_create(hndl)) == NULL ||
 	    (val = scf_value_create(hndl)) == NULL ||
 	    (fe = scf_entry_create(hndl)) == NULL ||
-	    (fval = scf_value_create(hndl)) == NULL) {
+	    (fval = scf_value_create(hndl)) == NULL ||
+	    (ae = scf_entry_create(hndl)) == NULL ||
+	    (aval = scf_value_create(hndl)) == NULL) {
 		if (errstr != NULL)
 			*errstr = gettext("Could not store file hash: "
 			    "permission denied.\n");
@@ -328,6 +367,9 @@
 	assert(ret == SCF_SUCCESS);
 	ret = scf_value_set_astring(fval, fname);
 	assert(ret == SCF_SUCCESS);
+	if (apply_late == APPLY_LATE) {
+		scf_value_set_boolean(aval, 1);
+	}
 
 	tx = scf_transaction_create(hndl);
 	if (tx == NULL) {
@@ -378,10 +420,10 @@
 		ret = scf_entry_add_value(e, val);
 		assert(ret == SCF_SUCCESS);
 
-		if (scf_transaction_property_new(tx, fe, MFILE_PROP,
+		if (scf_transaction_property_new(tx, fe, MHASH_FILE_PROP,
 		    SCF_TYPE_ASTRING) != SCF_SUCCESS &&
-		    scf_transaction_property_change_type(tx, fe, MFILE_PROP,
-		    SCF_TYPE_ASTRING) != SCF_SUCCESS) {
+		    scf_transaction_property_change_type(tx, fe,
+		    MHASH_FILE_PROP, SCF_TYPE_ASTRING) != SCF_SUCCESS) {
 			if (errstr != NULL)
 				*errstr = gettext("Could not modify file "
 				    "entry");
@@ -392,6 +434,45 @@
 		ret = scf_entry_add_value(fe, fval);
 		assert(ret == SCF_SUCCESS);
 
+		switch (apply_late) {
+		case APPLY_NONE:
+			if (scf_transaction_property_delete(tx, ae,
+			    MHASH_APPLY_PROP) != 0) {
+				err = scf_error();
+				if ((err != SCF_ERROR_DELETED) &&
+				    (err != SCF_ERROR_NOT_FOUND)) {
+					if (errstr != NULL) {
+						*errstr = gettext("Could not "
+						    "delete apply_late "
+						    "property");
+					}
+					result = -1;
+					goto out;
+				}
+			}
+			break;
+		case APPLY_LATE:
+			if ((scf_transaction_property_new(tx, ae,
+			    MHASH_APPLY_PROP,
+			    SCF_TYPE_BOOLEAN) != SCF_SUCCESS) &&
+			    (scf_transaction_property_change_type(tx, ae,
+			    MHASH_APPLY_PROP, SCF_TYPE_BOOLEAN) !=
+			    SCF_SUCCESS)) {
+				if (errstr != NULL) {
+					*errstr = gettext("Could not modify "
+					    "apply_late property");
+				}
+				result = -1;
+				goto out;
+			}
+
+			ret = scf_entry_add_value(ae, aval);
+			assert(ret == SCF_SUCCESS);
+			break;
+		default:
+			abort();
+		};
+
 		ret = scf_transaction_commit(tx);
 
 		if (ret == 0)
@@ -415,10 +496,12 @@
 	scf_transaction_destroy(tx);
 	(void) scf_entry_destroy(e);
 	(void) scf_entry_destroy(fe);
+	(void) scf_entry_destroy(ae);
 
 out:
 	(void) scf_value_destroy(val);
 	(void) scf_value_destroy(fval);
+	(void) scf_value_destroy(aval);
 	scf_property_destroy(prop);
 	scf_pg_destroy(pg);
 	scf_service_destroy(svc);
@@ -495,6 +578,7 @@
 mhash_test_file(scf_handle_t *hndl, const char *file, uint_t is_profile,
     char **pnamep, uchar_t *hashbuf)
 {
+	apply_action_t action;
 	boolean_t do_hash;
 	struct stat64 st;
 	char *cp;
@@ -506,6 +590,9 @@
 	int hashash;
 	int metahashok = 0;
 
+	if (pnamep)
+		*pnamep = NULL;
+
 	/*
 	 * In the case where we are doing automated imports, we reduce the UID,
 	 * the GID, the size, and the mtime into a string (to eliminate
@@ -542,8 +629,6 @@
 	cp = getenv("SVCCFG_CHECKHASH");
 	do_hash = (cp != NULL && *cp != '\0');
 	if (!do_hash) {
-		if (pnamep != NULL)
-			*pnamep = NULL;
 		return (MHASH_NEWFILE);
 	}
 
@@ -551,12 +636,25 @@
 	if (pname == NULL)
 		return (MHASH_FAILURE);
 
-	hashash = mhash_retrieve_entry(hndl, pname, stored_hash) == 0;
+	hashash = mhash_retrieve_entry(hndl, pname, stored_hash, &action) == 0;
+	if (is_profile == 0) {
+		/* Actions other than APPLY_NONE are restricted to profiles. */
+		assert(action == APPLY_NONE);
+	}
 
-	/* Never reread a profile. */
+	/*
+	 * As a general rule, we do not reread a profile.  The exception to
+	 * this rule is when we are running as part of the manifest import
+	 * service and the apply_late property is set to true.
+	 */
 	if (hashash && is_profile) {
-		uu_free(pname);
-		return (MHASH_RECONCILED);
+		cp = getenv("SMF_FMRI");
+		if ((cp == NULL) ||
+		    (strcmp(cp, SCF_INSTANCE_MI) != 0) ||
+		    (action != APPLY_LATE)) {
+			uu_free(pname);
+			return (MHASH_RECONCILED);
+		}
 	}
 
 	/*
@@ -604,8 +702,15 @@
 		 */
 		for (i = 0; i < MD5_DIGEST_LENGTH; i++) {
 			if (stored_hash[MD5_DIGEST_LENGTH+i] != 0) {
-				uu_free(pname);
-				return (MHASH_RECONCILED);
+				if (action == APPLY_LATE) {
+					if (pnamep != NULL)
+						*pnamep = pname;
+					ret = MHASH_NEWFILE;
+				} else {
+					uu_free(pname);
+					ret = MHASH_RECONCILED;
+				}
+				return (ret);
 			}
 		}
 	}
@@ -631,9 +736,17 @@
 			 * we then update the database with the complete
 			 * new hash so we can be a bit quicker next time.
 			 */
-			(void) mhash_store_entry(hndl, pname, file, hash, NULL);
-			uu_free(pname);
-			return (MHASH_RECONCILED);
+			(void) mhash_store_entry(hndl, pname, file, hash,
+			    APPLY_NONE, NULL);
+			if (action == APPLY_LATE) {
+				if (pnamep != NULL)
+					*pnamep = pname;
+				ret = MHASH_NEWFILE;
+			} else {
+				uu_free(pname);
+				ret = MHASH_RECONCILED;
+			}
+			return (ret);
 		}
 
 		/*
@@ -655,7 +768,8 @@
 			 * Update the new entry so we don't have to go through
 			 * all this trouble next time.
 			 */
-			(void) mhash_store_entry(hndl, pname, file, hash, NULL);
+			(void) mhash_store_entry(hndl, pname, file, hash,
+			    APPLY_NONE, NULL);
 			uu_free(pname);
 			return (MHASH_RECONCILED);
 		}
--- a/usr/src/cmd/svc/common/manifest_hash.h	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/svc/common/manifest_hash.h	Thu Mar 25 14:57:35 2010 -0700
@@ -19,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -41,7 +41,8 @@
 #define	MHASH_PG_TYPE	"framework"
 #define	MHASH_PG_FLAGS	0
 #define	MHASH_PROP	"md5sum"
-#define	MFILE_PROP	"manifestfile"
+#define	MHASH_FILE_PROP	"manifestfile"
+#define	MHASH_APPLY_PROP	"apply_late"
 
 #define	MHASH_FORMAT_V1	"%llx%x%llx%lx"
 #define	MHASH_FORMAT_V2	"%x%x%llx%lx"
@@ -50,10 +51,16 @@
 #define	MHASH_RECONCILED	(1)
 #define	MHASH_FAILURE		(-1)
 
+typedef enum apply_action {
+	APPLY_NONE,		/* No special apply action. */
+	APPLY_LATE		/* Apply profile in late manifest import. */
+} apply_action_t;
+
 char *mhash_filename_to_propname(const char *, boolean_t);
-int mhash_retrieve_entry(scf_handle_t *, const char *, uchar_t *);
+int mhash_retrieve_entry(scf_handle_t *, const char *, uchar_t *,
+    apply_action_t *);
 int mhash_store_entry(scf_handle_t *, const char *, const char *, uchar_t *,
-    char **);
+    apply_action_t, char **);
 int mhash_test_file(scf_handle_t *, const char *, uint_t, char **, uchar_t *);
 
 #ifdef	__cplusplus
--- a/usr/src/cmd/svc/configd/backend.c	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/svc/configd/backend.c	Thu Mar 25 14:57:35 2010 -0700
@@ -20,12 +20,10 @@
  */
 
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 /*
  * sqlite is not compatible with _FILE_OFFSET_BITS=64, but we need to
  * be able to statvfs(2) possibly large systems.  This define gives us
@@ -35,6 +33,7 @@
 #define	_LARGEFILE64_SOURCE
 
 #include <assert.h>
+#include <atomic.h>
 #include <door.h>
 #include <dirent.h>
 #include <errno.h>
@@ -45,8 +44,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 #include <sys/stat.h>
 #include <sys/statvfs.h>
+#include <time.h>
 #include <unistd.h>
 #include <zone.h>
 #include <libscf_priv.h>
@@ -67,6 +68,15 @@
  *    synchronizes MT access to the database.
  */
 
+#define	IS_VOLATILE(be)		((be)->be_ppath != NULL)
+#define	MAX_FLIGHT_RECORDER_EVENTS	100
+
+typedef enum backend_switch_results {
+	BACKEND_SWITCH_FATAL =	-1,
+	BACKEND_SWITCH_OK =	0,
+	BACKEND_SWITCH_RO
+} backend_switch_results_t;
+
 typedef struct backend_spent {
 	uint64_t bs_count;
 	hrtime_t bs_time;
@@ -78,11 +88,23 @@
 	backend_spent_t	bt_exec;	/* time spent executing SQL */
 } backend_totals_t;
 
+/*
+ * There are times when svcadm asks configd to move the BACKEND_TYPE_NORMAL
+ * repository to volatile storage.  See backend_switch().  When the
+ * repository is on volatile storage, we save the location of the permanent
+ * repository in be_ppath.  We use the saved path when the time comes to
+ * move the repository back.  When the repository is on permanent storage,
+ * be_ppath is set to NULL.  Also see the definition of IS_VOLATILE() above
+ * for testing if the repository is on volatile storage.
+ */
 typedef struct sqlite_backend {
 	pthread_mutex_t	be_lock;
 	pthread_t	be_thread;	/* thread holding lock */
 	struct sqlite	*be_db;
 	const char	*be_path;	/* path to db */
+	const char	*be_ppath;	/* saved path to persistent db when */
+					/* backend is volatile */
+	const char	*be_checkpoint;	/* path to repository checkpoint */
 	int		be_readonly;	/* readonly at start, and still is */
 	int		be_writing;	/* held for writing */
 	backend_type_t	be_type;	/* type of db */
@@ -123,6 +145,52 @@
 	const char *bxi_cols;
 };
 
+/* Definitions for the flight recorder: */
+
+typedef enum be_flight_type {
+	BE_FLIGHT_EV_NOEVENT = 0,	/* No event yet recorded. */
+	BE_FLIGHT_EV_BACKUP,		/* Information about repo. backup */
+	BE_FLIGHT_EV_BACKUP_ENTER,	/* Enter */
+					/* backend_create_backup_locked() */
+	BE_FLIGHT_EV_CHECKPOINT,	/* Request to checkpoint repository */
+					/* for boot time backup */
+	BE_FLIGHT_EV_CHECKPOINT_EXISTS,	/* Existing checkpoint detected on */
+					/* restart */
+	BE_FLIGHT_EV_LINGERING_FAST,	/* Use lingering fast repository */
+	BE_FLIGHT_EV_NO_BACKUP,		/* Requested backup not made */
+	BE_FLIGHT_EV_REPO_CREATE,	/* Main repository created */
+	BE_FLIGHT_EV_RESTART,		/* This is a restart of configd */
+	BE_FLIGHT_EV_SWITCH,		/* Switch repositories */
+	BE_FLIGHT_EV_TRANS_RW		/* Root transitioned to read/write */
+} be_flight_type_t;
+
+typedef enum be_flight_status {
+	BE_FLIGHT_ST_INFO = 0,		/* No status.  Event is informative */
+	BE_FLIGHT_ST_BOOT_BACKUP,	/* Boot time backup */
+	BE_FLIGHT_ST_CHECKPOINT_BACKUP,	/* Backup from checkpoint */
+	BE_FLIGHT_ST_CLIENT,		/* Request form client as opposed to */
+					/* internal call */
+	BE_FLIGHT_ST_DUPLICATE,		/* Backup duplicates existing one */
+	BE_FLIGHT_ST_FAIL,		/* Operation failed. */
+	BE_FLIGHT_ST_FAST,		/* Fast repository (tmpfs) */
+	BE_FLIGHT_ST_MI_BACKUP,		/* Manifest-import backup */
+	BE_FLIGHT_ST_NO_SWITCH,		/* Don't switch repositories */
+	BE_FLIGHT_ST_OTHER_BACKUP,	/* Other type of backup */
+	BE_FLIGHT_ST_PERMANENT,		/* Repository on permanet storage */
+	BE_FLIGHT_ST_REPO_BACKUP,	/* Backup from repository */
+	BE_FLIGHT_ST_RO,		/* Main repository is read-only */
+	BE_FLIGHT_ST_RW,		/* Main repository is read/write */
+	BE_FLIGHT_ST_SUCCESS,		/* Operation was successful */
+	BE_FLIGHT_ST_SWITCH		/* Switch repository */
+} be_flight_status_t;
+
+typedef struct be_flight_event {
+	be_flight_type_t	bfe_type;	/* Type of event. */
+	be_flight_status_t	bfe_status;	/* Result of the event. */
+	time_t			bfe_time;	/* Time of the event. */
+	uint_t			bfe_sequence;	/* Sequence number. */
+} be_flight_event_t;
+
 static pthread_mutex_t backend_panic_lock = PTHREAD_MUTEX_INITIALIZER;
 static pthread_cond_t backend_panic_cv = PTHREAD_COND_INITIALIZER;
 pthread_t backend_panic_thread = 0;
@@ -131,6 +199,14 @@
 int backend_print_trace = 0;		/* tracing callback prints SQL */
 int backend_panic_abort = 0;		/* abort when panicking */
 
+/* Data for the flight_recorder. */
+
+static pthread_mutex_t backend_flight_recorder_lock = PTHREAD_MUTEX_INITIALIZER;
+static be_flight_event_t flight_recorder[MAX_FLIGHT_RECORDER_EVENTS];
+static uint_t flight_recorder_next = 0;
+static uint_t flight_recorder_missed = 0;
+static uint_t flight_recorder_sequence = 0;
+
 /* interval between read-only checks while starting up */
 #define	BACKEND_READONLY_CHECK_INTERVAL	(2 * (hrtime_t)NANOSEC)
 
@@ -313,6 +389,51 @@
 	int		rs_result;
 };
 
+static rep_protocol_responseid_t backend_copy_repository(const char *,
+    const char *, int);
+static rep_protocol_responseid_t backend_do_copy(const char *, int,
+    const char *, int, size_t *);
+
+/*
+ * The flight recorder keeps track of events that happen primarily while
+ * the system is booting.  Once the system is up an running, one can take a
+ * gcore(1) of configd and examine the events with mdb.  Since we're most
+ * interested in early boot events, we stop recording events when the
+ * recorder is full.
+ */
+static void
+flight_recorder_event(be_flight_type_t type, be_flight_status_t res)
+{
+	be_flight_event_t *data;
+	uint_t item;
+	uint_t sequence;
+
+	if (pthread_mutex_lock(&backend_flight_recorder_lock) != 0) {
+		atomic_inc_uint(&flight_recorder_missed);
+		return;
+	}
+	if (flight_recorder_next >= MAX_FLIGHT_RECORDER_EVENTS) {
+		/* Hit end of the array.  No more event recording. */
+		item = flight_recorder_next;
+	} else {
+		item = flight_recorder_next++;
+		sequence = flight_recorder_sequence++;
+	}
+	(void) pthread_mutex_unlock(&backend_flight_recorder_lock);
+
+	if (item >= MAX_FLIGHT_RECORDER_EVENTS) {
+		/* Array is filled.  Stop recording events */
+		atomic_inc_uint(&flight_recorder_missed);
+		return;
+	}
+	data = &flight_recorder[item];
+	(void) memset(data, 0, sizeof (*data));
+	data->bfe_type = type;
+	data->bfe_status = res;
+	data->bfe_sequence = sequence;
+	data->bfe_time = time(NULL);
+}
+
 /*ARGSUSED*/
 static int
 run_single_int_callback(void *arg, int columns, char **vals, char **names)
@@ -680,7 +801,8 @@
 	 * for paths of the form /path/to/foo.db, we truncate at the final
 	 * '.'.
 	 */
-	(void) strlcpy(out, be->be_path, out_len);
+	(void) strlcpy(out, IS_VOLATILE(be) ? be->be_ppath : be->be_path,
+	    out_len);
 
 	p = strrchr(out, '/');
 	q = strrchr(out, '.');
@@ -713,6 +835,34 @@
 }
 
 /*
+ * Make a checkpoint of the repository, so that we can use it for a backup
+ * when the root file system becomes read/write.  We'll first copy the
+ * repository into a temporary file and then rename it to
+ * REPOSITORY_CHECKPOINT.  This is protection against configd crashing in
+ * the middle of the copy and leaving a partial copy at
+ * REPOSITORY_CHECKPOINT.  Renames are atomic.
+ */
+static rep_protocol_responseid_t
+backend_checkpoint_repository(sqlite_backend_t *be)
+{
+	rep_protocol_responseid_t r;
+
+	assert(be->be_readonly);	/* Only need a checkpoint if / is ro */
+	assert(be->be_type == BACKEND_TYPE_NORMAL);
+	assert(be->be_checkpoint == NULL); /* Only 1 checkpoint */
+
+	r = backend_copy_repository(be->be_path, REPOSITORY_CHECKPOINT, 0);
+	if (r == REP_PROTOCOL_SUCCESS)
+		be->be_checkpoint = REPOSITORY_CHECKPOINT;
+
+	flight_recorder_event(BE_FLIGHT_EV_CHECKPOINT,
+	    r == REP_PROTOCOL_SUCCESS ? BE_FLIGHT_ST_SUCCESS :
+	    BE_FLIGHT_ST_FAIL);
+
+	return (r);
+}
+
+/*
  * See if a backup is needed.  We do a backup unless both files are
  * byte-for-byte identical.
  */
@@ -857,7 +1007,19 @@
 	size_t len;
 	time_t now;
 	struct tm now_tm;
+	be_flight_status_t backup_type;
 	rep_protocol_responseid_t result;
+	const char *src;
+	int use_checkpoint;
+
+	if (strcmp(name, REPOSITORY_BOOT_BACKUP) == 0) {
+		backup_type = BE_FLIGHT_ST_BOOT_BACKUP;
+	} else if (strcmp(name, "manifest_import") ==  0) {
+		backup_type = BE_FLIGHT_ST_MI_BACKUP;
+	} else {
+		backup_type = BE_FLIGHT_ST_OTHER_BACKUP;
+	}
+	flight_recorder_event(BE_FLIGHT_EV_BACKUP_ENTER, backup_type);
 
 	if ((finalpath = malloc(PATH_MAX)) == NULL)
 		return (REP_PROTOCOL_FAIL_NO_RESOURCES);
@@ -868,6 +1030,7 @@
 	}
 
 	if (be->be_readonly) {
+		flight_recorder_event(BE_FLIGHT_EV_NO_BACKUP, BE_FLIGHT_ST_RO);
 		result = REP_PROTOCOL_FAIL_BACKEND_READONLY;
 		goto out;
 	}
@@ -876,7 +1039,29 @@
 	if (result != REP_PROTOCOL_SUCCESS)
 		goto out;
 
-	if (!backend_check_backup_needed(be->be_path, finalpath)) {
+	/*
+	 * If this is a boot backup and if we made a checkpoint before the
+	 * root file system became read/write, then we should use the
+	 * checkpoint as the source.  Otherwise, we'll use the actual
+	 * repository as the source.
+	 */
+	if (be->be_checkpoint && name &&
+	    strcmp(REPOSITORY_BOOT_BACKUP, name) == 0) {
+		backup_type = BE_FLIGHT_ST_CHECKPOINT_BACKUP;
+		use_checkpoint = 1;
+		src = be->be_checkpoint;
+	} else {
+		backup_type = BE_FLIGHT_ST_REPO_BACKUP;
+		use_checkpoint = 0;
+		src = be->be_path;
+	}
+	flight_recorder_event(BE_FLIGHT_EV_BACKUP, backup_type);
+	if (!backend_check_backup_needed(src, finalpath)) {
+		/*
+		 * No changes, so there is no need for a backup.
+		 */
+		flight_recorder_event(BE_FLIGHT_EV_NO_BACKUP,
+		    BE_FLIGHT_ST_DUPLICATE);
 		result = REP_PROTOCOL_SUCCESS;
 		goto out;
 	}
@@ -901,7 +1086,7 @@
 	if (localtime_r(&now, &now_tm) == NULL) {
 		configd_critical(
 		    "\"%s\" backup failed: localtime(3C) failed: %s\n", name,
-		    be->be_path, strerror(errno));
+		    strerror(errno));
 		result = REP_PROTOCOL_FAIL_UNKNOWN;
 		goto out;
 	}
@@ -912,10 +1097,10 @@
 		goto out;
 	}
 
-	infd = open(be->be_path, O_RDONLY);
+	infd = open(src, O_RDONLY);
 	if (infd < 0) {
 		configd_critical("\"%s\" backup failed: opening %s: %s\n", name,
-		    be->be_path, strerror(errno));
+		    src, strerror(errno));
 		result = REP_PROTOCOL_FAIL_UNKNOWN;
 		goto out;
 	}
@@ -929,8 +1114,8 @@
 		goto out;
 	}
 
-	if ((result = backend_do_copy((const char *)be->be_path, infd,
-	    (const char *)tmppath, outfd, NULL)) != REP_PROTOCOL_SUCCESS)
+	if ((result = backend_do_copy(src, infd, (const char *)tmppath,
+	    outfd, NULL)) != REP_PROTOCOL_SUCCESS)
 		goto fail;
 
 	/*
@@ -973,14 +1158,22 @@
 	}
 
 	result = REP_PROTOCOL_SUCCESS;
+	flight_recorder_event(BE_FLIGHT_EV_BACKUP, BE_FLIGHT_ST_SUCCESS);
 
 fail:
 	(void) close(infd);
 	(void) close(outfd);
-	if (result != REP_PROTOCOL_SUCCESS)
+	if (result != REP_PROTOCOL_SUCCESS) {
+		flight_recorder_event(BE_FLIGHT_EV_BACKUP, BE_FLIGHT_ST_FAIL);
 		(void) unlink(tmppath);
+	}
 
 out:
+	/* Get rid of the checkpoint file now that we've used it. */
+	if (use_checkpoint && (result == REP_PROTOCOL_SUCCESS)) {
+		(void) unlink(be->be_checkpoint);
+		be->be_checkpoint = NULL;
+	}
 	free(finalpath);
 	free(tmppath);
 
@@ -1059,6 +1252,7 @@
 static int
 backend_check_readonly(sqlite_backend_t *be, int writing, hrtime_t t)
 {
+	const char *check_path;
 	char *errp;
 	struct sqlite *new;
 	int r;
@@ -1077,27 +1271,62 @@
 		be->be_lastcheck = t;
 	}
 
-	new = sqlite_open(be->be_path, 0600, &errp);
+	/*
+	 * It could be that the repository has been moved to non-persistent
+	 * storage for performance reasons.  In this case we need to check
+	 * the persistent path to see if it is writable.  The
+	 * non-persistent path will always be writable.
+	 */
+	check_path = IS_VOLATILE(be) ? be->be_ppath : be->be_path;
+
+	new = sqlite_open(check_path, 0600, &errp);
 	if (new == NULL) {
-		backend_panic("reopening %s: %s\n", be->be_path, errp);
+		backend_panic("reopening %s: %s\n", check_path, errp);
 		/*NOTREACHED*/
 	}
-	r = backend_is_readonly(new, be->be_path);
+	r = backend_is_readonly(new, check_path);
 
 	if (r != SQLITE_OK) {
+		/*
+		 * The underlying storage for the permanent repository is
+		 * still read-only, so we don't want to change the state or
+		 * move the checkpointed backup if it exists.  On the other
+		 * hand if the repository has been copied to volatile
+		 * storage, we'll let our caller go ahead and write to the
+		 * database.
+		 */
 		sqlite_close(new);
-		if (writing)
+		if (writing && (IS_VOLATILE(be) == 0))
 			return (REP_PROTOCOL_FAIL_BACKEND_READONLY);
 		return (REP_PROTOCOL_SUCCESS);
 	}
 
 	/*
-	 * We can write!  Swap the db handles, mark ourself writable,
-	 * upgrade if necessary,  and make a backup.
+	 * We can write!  If the repository is not on volatile storage,
+	 * swap the db handles.  Mark ourself as writable, upgrade the
+	 * repository if necessary and make a backup.
 	 */
-	sqlite_close(be->be_db);
-	be->be_db = new;
 	be->be_readonly = 0;
+	flight_recorder_event(BE_FLIGHT_EV_TRANS_RW, BE_FLIGHT_ST_RW);
+	if (IS_VOLATILE(be)) {
+		/*
+		 * If the repository is on volatile storage, don't switch
+		 * the handles.  We'll continue to use the repository that
+		 * is on tmpfs until we're told to move it back by one of
+		 * our clients.  Clients, specifically manifest_import,
+		 * move the repository to tmpfs for performance reasons,
+		 * and that is the reason to not switch it back until we're
+		 * told to do so.
+		 */
+		flight_recorder_event(BE_FLIGHT_EV_TRANS_RW,
+		    BE_FLIGHT_ST_NO_SWITCH);
+		sqlite_close(new);
+	} else {
+		flight_recorder_event(BE_FLIGHT_EV_TRANS_RW,
+		    BE_FLIGHT_ST_SWITCH);
+		sqlite_close(be->be_db);
+		be->be_db = new;
+	}
 
 	if (be->be_type == BACKEND_TYPE_NORMAL)
 		backend_check_upgrade(be, B_TRUE);
@@ -1234,6 +1463,7 @@
 	rep_protocol_responseid_t result;
 	sqlite_backend_t *be;
 
+	flight_recorder_event(BE_FLIGHT_EV_BACKUP, BE_FLIGHT_ST_CLIENT);
 	result = backend_lock(BACKEND_TYPE_NORMAL, 0, &be);
 	assert(result == REP_PROTOCOL_SUCCESS);
 
@@ -1244,11 +1474,11 @@
 }
 
 /*
- * Copy the repository.  If the sw_back flag is not set, we are
- * copying the repository from the default location under /etc/svc to
- * the tmpfs /etc/svc/volatile location.  If the flag is set, we are
- * copying back to the /etc/svc location from the volatile location
- * after manifest-import is completed.
+ * This function makes a copy of the repository at src, placing the copy at
+ * dst.  It is used to copy a repository on permanent storage to volatile
+ * storage or vice versa.  If the source file is on volatile storage, it is
+ * often times desirable to delete it after the copy has been made and
+ * verified.  To remove the source repository, set remove_src to 1.
  *
  * Can return:
  *
@@ -1257,7 +1487,7 @@
  *	REP_PROTOCOL_FAIL_NO_RESOURCES	out of memory
  */
 static rep_protocol_responseid_t
-backend_switch_copy(const char *src, const char *dst, int sw_back)
+backend_copy_repository(const char *src, const char *dst, int remove_src)
 {
 	int srcfd, dstfd;
 	char *tmppath = malloc(PATH_MAX);
@@ -1337,7 +1567,7 @@
 
 out:
 	free(tmppath);
-	if (sw_back) {
+	if (remove_src) {
 		if (unlink(src) < 0)
 			configd_critical(
 			    "Backend copy failed: remove %s: %s\n",
@@ -1374,10 +1604,15 @@
 }
 
 /*
- * Backend switch entry point.  It is called to perform the backend copy and
- * switch from src to dst.  First, it blocks all other clients from accessing
- * the repository by calling backend_lock to lock the repository.  Upon
- * successful lock, copying and switching of the repository are performed.
+ * backend_switch() implements the REP_PROTOCOL_SWITCH request from
+ * clients.  First, it blocks all other clients from accessing the
+ * repository by calling backend_lock to lock the repository.  It either
+ * copies the repository from it's permanent storage location
+ * (REPOSITORY_DB) to its fast volatile location (FAST_REPOSITORY_DB), or
+ * vice versa.  dir determines the direction of the copy.
+ *
+ *	dir = 0	Copy from permanent location to volatile location.
+ *	dir = 1	Copy from volatile location to permanent location.
  *
  * Can return:
  *	REP_PROTOCOL_SUCCESS			successful switch
@@ -1387,7 +1622,7 @@
  *	REP_PROTOCOL_FAIL_NO_RESOURCES		out of memory
  */
 rep_protocol_responseid_t
-backend_switch(int sw_back)
+backend_switch(int dir)
 {
 	rep_protocol_responseid_t result;
 	sqlite_backend_t *be;
@@ -1395,20 +1630,38 @@
 	char *errp;
 	const char *dst;
 
-	result = backend_lock(BACKEND_TYPE_NORMAL, 1, &be);
+	flight_recorder_event(BE_FLIGHT_EV_SWITCH, BE_FLIGHT_ST_CLIENT);
+
+	/*
+	 * If switching back to the main repository, lock for writing.
+	 * Otherwise, lock for reading.
+	 */
+	result = backend_lock(BACKEND_TYPE_NORMAL, dir ? 1 : 0,
+	    &be);
 	if (result != REP_PROTOCOL_SUCCESS)
 		return (result);
 
-	if (sw_back) {
+	if (dir) {
+		flight_recorder_event(BE_FLIGHT_EV_SWITCH,
+		    BE_FLIGHT_ST_PERMANENT);
 		dst = REPOSITORY_DB;
 	} else {
+		flight_recorder_event(BE_FLIGHT_EV_SWITCH,
+		    BE_FLIGHT_ST_FAST);
 		dst = FAST_REPOSITORY_DB;
 	}
 
 	/*
 	 * Do the actual copy and rename
 	 */
-	result = backend_switch_copy(be->be_path, dst, sw_back);
+	if (strcmp(be->be_path, dst) == 0) {
+		flight_recorder_event(BE_FLIGHT_EV_SWITCH,
+		    BE_FLIGHT_ST_DUPLICATE);
+		result = REP_PROTOCOL_SUCCESS;
+		goto errout;
+	}
+
+	result = backend_copy_repository(be->be_path, dst, dir);
 	if (result != REP_PROTOCOL_SUCCESS) {
 		goto errout;
 	}
@@ -1433,6 +1686,17 @@
 			} else {
 				sqlite_close(be->be_db);
 				be->be_db = new;
+				if (dir) {
+					/* We're back on permanent storage. */
+					be->be_ppath = NULL;
+				} else {
+					/*
+					 * Repository is now on volatile
+					 * storage.  Save the location of
+					 * the persistent repository.
+					 */
+					be->be_ppath = REPOSITORY_DB;
+				}
 			}
 		} else {
 			configd_critical(
@@ -1447,6 +1711,12 @@
 	}
 
 errout:
+	if (result == REP_PROTOCOL_SUCCESS) {
+		flight_recorder_event(BE_FLIGHT_EV_SWITCH,
+		    BE_FLIGHT_ST_SUCCESS);
+	} else {
+		flight_recorder_event(BE_FLIGHT_EV_SWITCH, BE_FLIGHT_ST_FAIL);
+	}
 	backend_unlock(be);
 	return (result);
 }
@@ -1459,23 +1729,41 @@
  * referenced here are indicators of successful switch
  * operations.
  */
-static void
+static backend_switch_results_t
 backend_switch_recovery(void)
 {
 	const char *fast_db = FAST_REPOSITORY_DB;
-	char *errp;
+	char *errp = NULL;
 	struct stat s_buf;
 	struct sqlite *be_db;
-
+	int r;
+	backend_switch_results_t res = BACKEND_SWITCH_OK;
 
 	/*
 	 * A good transient db containing most recent data can
-	 * exist if system or svc.configd crashes during the
+	 * exist if svc.configd crashes during the
 	 * switch operation.  If that is the case, check its
 	 * integrity and use it.
 	 */
 	if (stat(fast_db, &s_buf) < 0) {
-		return;
+		return (BACKEND_SWITCH_OK);
+	}
+
+	/* Determine if persistent repository is read-only */
+	be_db = sqlite_open(REPOSITORY_DB, 0600, &errp);
+	if (be_db == NULL) {
+		configd_critical("Unable to open \"%s\".  %s\n",
+		    REPOSITORY_DB, errp == NULL ? "" : errp);
+		free(errp);
+		return (BACKEND_SWITCH_FATAL);
+	}
+	r = backend_is_readonly(be_db, REPOSITORY_DB);
+	sqlite_close(be_db);
+	if (r != SQLITE_OK) {
+		if (r == SQLITE_READONLY) {
+			return (BACKEND_SWITCH_RO);
+		}
+		return (BACKEND_SWITCH_FATAL);
 	}
 
 	/*
@@ -1484,11 +1772,23 @@
 	be_db = sqlite_open(fast_db, 0600, &errp);
 
 	if (be_db != NULL) {
-		if (backend_switch_check(be_db, &errp) == 0)
-			(void) backend_switch_copy(fast_db, REPOSITORY_DB, 1);
+		if (backend_switch_check(be_db, &errp) == 0) {
+			if (backend_copy_repository(fast_db,
+			    REPOSITORY_DB, 1) != REP_PROTOCOL_SUCCESS) {
+				res = BACKEND_SWITCH_FATAL;
+			}
+		}
+		sqlite_close(be_db);
 	}
-
+	free(errp);
+
+	/*
+	 * If we get to this point, the fast_db has either been copied or
+	 * it is useless.  Either way, get rid of it.
+	 */
 	(void) unlink(fast_db);
+
+	return (res);
 }
 
 /*ARGSUSED*/
@@ -2289,7 +2589,10 @@
 backend_init(const char *db_file, const char *npdb_file, int have_np)
 {
 	sqlite_backend_t *be;
+	char *errp;
+	struct sqlite *fast_db;
 	int r;
+	backend_switch_results_t switch_result = BACKEND_SWITCH_OK;
 	int writable_persist = 1;
 
 	/* set up our temporary directory */
@@ -2301,19 +2604,37 @@
 		return (CONFIGD_EXIT_DATABASE_INIT_FAILED);
 	}
 
-	/*
-	 * If the system crashed during a backend switch, there might
-	 * be a leftover transient database which contains useful
-	 * information which can be used for recovery.
-	 */
-	backend_switch_recovery();
-
 	if (db_file == NULL)
 		db_file = REPOSITORY_DB;
 	if (strcmp(db_file, REPOSITORY_DB) != 0) {
 		is_main_repository = 0;
 	}
 
+	/*
+	 * If the svc.configd crashed, there might be a leftover transient
+	 * database at FAST_REPOSITORY_DB,which contains useful
+	 * information.  Both early manifest import and late manifest
+	 * import use svcadm to copy the repository to FAST_REPOSITORY_DB.
+	 * One reason for doing this is that it improves the performance of
+	 * manifest import.  The other reason is that the repository may be
+	 * on read-only root in the case of early manifest import.
+	 *
+	 * If FAST_REPOSITORY_DB exists, it is an indication that
+	 * svc.configd has been restarted for some reason.  Since we have
+	 * no way of knowing where we are in the boot process, the safe
+	 * thing to do is to move the repository back to it's non-transient
+	 * location, REPOSITORY_DB.  This may slow manifest import
+	 * performance, but it avoids the problem of missing the command to
+	 * move the repository to permanent storage.
+	 *
+	 * There is a caveat, though.  If root is read-only, we'll need to
+	 * leave the repository at FAST_REPOSITORY_DB.  If root is
+	 * read-only, late manifest import has not yet run, so it will move
+	 * the repository back to permanent storage when it runs.
+	 */
+	if (is_main_repository)
+		switch_result = backend_switch_recovery();
+
 	r = backend_create(BACKEND_TYPE_NORMAL, db_file, &be);
 	switch (r) {
 	case BACKEND_CREATE_FAIL:
@@ -2336,6 +2657,40 @@
 		/*NOTREACHED*/
 	}
 	backend_create_finish(BACKEND_TYPE_NORMAL, be);
+	flight_recorder_event(BE_FLIGHT_EV_REPO_CREATE,
+	    writable_persist == 1 ? BE_FLIGHT_ST_RW : BE_FLIGHT_ST_RO);
+	/*
+	 * If there was a transient repository that could not be copied
+	 * back because the root file system was read-only, switch over to
+	 * using the transient repository.
+	 */
+	if (switch_result == BACKEND_SWITCH_RO) {
+		char *db_name_copy = NULL;
+
+		fast_db = sqlite_open(FAST_REPOSITORY_DB, 0600, &errp);
+		if (fast_db == NULL) {
+			/* Can't open fast repository.  Stick with permanent. */
+			configd_critical("Cannot open \"%s\".  %s\n",
+			    FAST_REPOSITORY_DB, errp == NULL ? "" : errp);
+			free(errp);
+		} else {
+			db_name_copy = strdup(FAST_REPOSITORY_DB);
+			if (db_name_copy == NULL) {
+				configd_critical("backend_init: out of "
+				    "memory.\n");
+				sqlite_close(fast_db);
+				return (CONFIGD_EXIT_INIT_FAILED);
+			} else {
+				flight_recorder_event(
+				    BE_FLIGHT_EV_LINGERING_FAST,
+				    BE_FLIGHT_ST_RO);
+				sqlite_close(be->be_db);
+				be->be_db = fast_db;
+				be->be_ppath = be->be_path;
+				be->be_path = db_name_copy;
+			}
+		}
+	}
 
 	if (have_np) {
 		if (npdb_file == NULL)
@@ -2365,10 +2720,19 @@
 		}
 		backend_create_finish(BACKEND_TYPE_NONPERSIST, be);
 
+		if (r != BACKEND_CREATE_NEED_INIT) {
+			flight_recorder_event(BE_FLIGHT_EV_RESTART,
+			    BE_FLIGHT_ST_INFO);
+		}
+
 		/*
 		 * If we started up with a writable filesystem, but the
-		 * non-persistent database needed initialization, we
-		 * are booting a non-global zone, so do a backup.
+		 * non-persistent database needed initialization, we are
+		 * booting a non-global zone or a system with a writable
+		 * root (ZFS), so do a backup.  Checking to see if the
+		 * non-persistent database needed initialization also keeps
+		 * us from making additional backups if configd gets
+		 * restarted.
 		 */
 		if (r == BACKEND_CREATE_NEED_INIT && writable_persist &&
 		    backend_lock(BACKEND_TYPE_NORMAL, 0, &be) ==
@@ -2382,6 +2746,65 @@
 			}
 			backend_unlock(be);
 		}
+
+		/*
+		 * On the other hand if we started with a read-only file
+		 * system and the non-persistent database needed
+		 * initialization, then we need to take a checkpoint of the
+		 * repository.  We grab the checkpoint now before Early
+		 * Manifest Import starts modifying the repository.  Then
+		 * when the file system becomes writable, the checkpoint
+		 * can be used to create the boot time backup of the
+		 * repository.  Checking that the non-persistent database
+		 * needed initialization, keeps us from making additional
+		 * checkpoints if configd gets restarted.
+		 */
+		if (r == BACKEND_CREATE_NEED_INIT && writable_persist == 0 &&
+		    backend_lock(BACKEND_TYPE_NORMAL, 0, &be) ==
+		    REP_PROTOCOL_SUCCESS) {
+			r = backend_checkpoint_repository(be);
+			if (r != REP_PROTOCOL_SUCCESS) {
+				configd_critical("unable to create checkpoint "
+				    "of \"%s\"\n", be->be_path);
+			}
+			backend_unlock(be);
+		}
+
+		/*
+		 * If the non-persistent database did not need
+		 * initialization, svc.configd has been restarted.  See if
+		 * the boot time checkpoint exists.  If it does, use it to
+		 * make a backup if root is writable.
+		 */
+		if (r != BACKEND_CREATE_NEED_INIT &&
+		    backend_lock(BACKEND_TYPE_NORMAL, 0, &be) ==
+		    REP_PROTOCOL_SUCCESS) {
+			struct stat sb;
+
+			if ((stat(REPOSITORY_CHECKPOINT, &sb) == 0) &&
+			    (sb.st_size > 0) && (sb.st_mode & S_IFREG)) {
+				be->be_checkpoint = REPOSITORY_CHECKPOINT;
+				flight_recorder_event(
+				    BE_FLIGHT_EV_CHECKPOINT_EXISTS,
+				    BE_FLIGHT_ST_INFO);
+			}
+
+			/*
+			 * If we have a checkpoint and root is writable,
+			 * make the backup now.
+			 */
+			if (be->be_checkpoint && writable_persist) {
+				if (backend_create_backup_locked(be,
+				    REPOSITORY_BOOT_BACKUP) !=
+				    REP_PROTOCOL_SUCCESS) {
+					configd_critical(
+					    "unable to create \"%s\" backup of "
+					    "\"%s\"\n", REPOSITORY_BOOT_BACKUP,
+					    be->be_path);
+				}
+			}
+			backend_unlock(be);
+		}
 	}
 
 	/*
--- a/usr/src/cmd/svc/mfstscan/Makefile	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/svc/mfstscan/Makefile	Thu Mar 25 14:57:35 2010 -0700
@@ -19,17 +19,18 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#ident	"%Z%%M%	%I%	%E% SMI"
 
 PROG =		mfstscan
 
 OBJS =		mfstscan.o \
+		manifest_find.o \
 		manifest_hash.o
 
 SRCS =		mfstscan.c \
+		../common/manifest_find.c \
 		../common/manifest_hash.c
 
 POFILES = 	$(SRCS:.c=.po)
--- a/usr/src/cmd/svc/mfstscan/mfstscan.c	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/svc/mfstscan/mfstscan.c	Thu Mar 25 14:57:35 2010 -0700
@@ -19,30 +19,29 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
 
 #include <sys/types.h>
 
-#include <ftw.h>
+#include <errno.h>
+#include <fcntl.h>
 #include <libintl.h>
-#include <libscf.h>
 #include <libuutil.h>
 #include <locale.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/stat.h>
 #include <unistd.h>
 
+#include "manifest_find.h"
 #include "manifest_hash.h"
 
 #define	MAX_DEPTH	24
 
-static scf_handle_t *hndl;
-static int tflag;
-
 /*
  * mfstscan - service manifest change detection utility
  *
@@ -59,32 +58,16 @@
 	exit(UU_EXIT_USAGE);
 }
 
-/*ARGSUSED*/
-static int
-process(const char *fn, const struct stat *sp, int ftw_type,
-    struct FTW *ftws)
-{
-	char *suffix_match;
-
-	if (ftw_type != FTW_F)
-		return (0);
-
-	suffix_match = strstr(fn, ".xml");
-	if (suffix_match == NULL || strcmp(suffix_match, ".xml") != 0)
-		return (0);
-
-	if (mhash_test_file(hndl, fn, 0, NULL, NULL) == MHASH_NEWFILE)
-		(void) printf("%s\n", fn);
-
-	return (0);
-}
-
 int
 main(int argc, char *argv[])
 {
+	manifest_info_t **entry;
+	manifest_info_t **manifests;
 	int i;
 	int paths_walked = 0;
 	struct stat sb;
+	int status;
+	int tflag = 0;
 
 	(void) uu_setpname(argv[0]);
 
@@ -104,12 +87,6 @@
 	if (optind >= argc)
 		usage();
 
-	hndl = scf_handle_create(SCF_VERSION);
-
-	if (scf_handle_bind(hndl) != SCF_SUCCESS)
-		uu_die(gettext("cannot bind to repository: %s\n"),
-		    scf_strerror(scf_error()));
-
 	for (i = optind; i < argc; i++) {
 		if (tflag) {
 			char *pname = mhash_filename_to_propname(argv[i],
@@ -129,15 +106,25 @@
 			continue;
 		}
 
-		if (nftw(argv[i], process, MAX_DEPTH, FTW_MOUNT) == -1)
+		status = find_manifests(argv[i], &manifests,
+		    CHECKHASH|CHECKEXT);
+		if (status < 0) {
 			uu_warn(gettext("file tree walk of %s encountered "
-			    "error"), argv[i]);
-		else
+			    "error.  %s\n"), argv[i], strerror(errno));
+		} else {
 			paths_walked++;
-	}
+			if (manifests != NULL) {
+				for (entry = manifests;
+				    *entry != NULL;
+				    entry++) {
+					(void) printf("%s\n",
+					    (*entry)->mi_path);
+				}
+				free_manifest_array(manifests);
+			}
+		}
 
-	(void) scf_handle_unbind(hndl);
-	(void) scf_handle_destroy(hndl);
+	}
 
 	if (!paths_walked)
 		uu_die(gettext("no paths walked\n"));
--- a/usr/src/cmd/svc/milestone/Makefile	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/svc/milestone/Makefile	Thu Mar 25 14:57:35 2010 -0700
@@ -72,6 +72,7 @@
 SYSTEMSVCS= \
 	boot-archive.xml \
 	console-login.xml \
+	early-manifest-import.xml \
 	identity.xml \
 	manifest-import.xml \
 	rmtmpfiles.xml	\
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/svc/milestone/early-manifest-import.xml	Thu Mar 25 14:57:35 2010 -0700
@@ -0,0 +1,103 @@
+<?xml version="1.0"?>
+<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
+<!--
+ Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
+ Use is subject to license terms.
+
+ CDDL HEADER START
+
+ 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
+
+	NOTE:  This service manifest is not editable; its contents will
+	be overwritten by package or patch operations, including
+	operating system upgrade.  Make customizations in a different
+	file.
+-->
+
+<service_bundle type='manifest' name='SUNWcsr:early-import'>
+
+<service
+	name='system/early-manifest-import'
+	type='service'
+	version='1'>
+
+	<create_default_instance enabled='true' />
+
+	<single_instance/>
+
+	<!--
+	    EMI is actually run by svc.startd before any services are
+	    started.  Thus, there is nothing for these methods to do.
+	-->
+	<exec_method
+		type='method'
+		name='start'
+		exec=':true'
+		timeout_seconds='0' />
+
+	<exec_method
+		type='method'
+		name='stop'
+		exec=':true'
+		timeout_seconds='0' />
+
+	<exec_method
+		type='method'
+		name='refresh'
+		exec=':true'
+		timeout_seconds='0' />
+
+	<!--
+	    Make service transient, so that startd doesn't try to restart
+	    the service when there are no processes associated with it. 
+	-->
+	<property_group name='startd' type='framework'>
+		<propval name='duration' type='astring'
+			value='transient' />
+	</property_group>
+
+	<stability value='Unstable' />
+
+	<template>
+		<common_name>
+			<loctext xml:lang='C'>
+early manifest import
+			</loctext>
+		</common_name>
+		<description>
+			<loctext xml:lang='C'>
+				This service imports manifests early
+				in the boot process before services
+				start.
+			</loctext>
+		</description>
+		<documentation>
+			<manpage title='svc.startd' section='1M'
+			    manpath='/usr/share/man' />
+			<manpage title='smf_method' section='5'
+			    manpath='/usr/share/man' />
+			<manpage title='smf' section='5'
+			    manpath='/usr/share/man' />
+			<manpage title='smf_bootstrap' section='5'
+			    manpath='/usr/share/man' />
+		</documentation>
+
+	</template>
+</service>
+
+</service_bundle>
--- a/usr/src/cmd/svc/milestone/manifest-import	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/svc/milestone/manifest-import	Thu Mar 25 14:57:35 2010 -0700
@@ -20,7 +20,7 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 
@@ -29,12 +29,15 @@
 [ -f /lib/svc/share/smf_include.sh ] || exit 1
 
 . /lib/svc/share/smf_include.sh
-. /lib/svc/share/manifest_cleanup.ksh
 
 activity=false
 
+EMI_SERVICE="svc:/system/early-manifest-import:default"
+
 X=
-while getopts n opt; do
+early=false
+[ "$SMF_FMRI" == "$EMI_SERVICE" ] && early=true
+while getopts "n" opt; do
 	case $opt in
 		n)	X=echo;;
 		?)	echo "Usage: /lib/svc/method/manifest-import [-n]\n"
@@ -49,243 +52,66 @@
 	fi
 }
 
-function svccfg_import {
-	$X /usr/sbin/svccfg import $1 2>>/tmp/manifest_import.$$
-	if [ $? -ne 0 ]; then
-		echo > /dev/msglog
-		echo "WARNING: svccfg import $1 failed" | tee /dev/msglog
-	fi
-}
-
-function prophist_upgrade {
-	#
-	# A property has changed in the manifest that we wish to propagate into
-	# the repository during manifest import.  We don't want to pollute
-	# manifests with overrides, so handle explicitly here.
-	#
-	fmri=$1
-	pgrp=$2
-	prop=$3
-	nval=$4
-	shift 4
-
-	/lib/svc/bin/prophist upgrade -e $fmri -g $pgrp -p $prop -n "$nval" \
-	    "$@"
-	[ $? = 0 ] && instance_refresh $fmri
-}
-
-function prophist_override {
-	#
-	# A property has changed in the manifest that we wish to propagate
-	# into the repository during manifest import.
-	#
-	fmri=$1
-	pgrp=$2
-	prop=$3
-	nval=$4
-
-	/lib/svc/bin/prophist overwrite -e $fmri -g $pgrp -p $prop -n "$nval"
-	[ $? = 0 ] && instance_refresh $fmri
-}
-
-function prophist_delete_svc_pg {
-	#
-	# Certain property groups have migrated from the service level to the
-	# instance level.  We don't care if they are at both, as the instance
-	# level will trump.  But having neither could be bad.  So check and if
-	# the given pg exists at both levels, delete the service-level one only.
-	#
-	service=$1
-	instance=$2
-	property_group=$3
-
-	/usr/bin/svcprop -q -p $property_group $service
-	res1=$?
-	/usr/bin/svcprop -q -c -p $property_group $service:$instance
-	res2=$?
-	if [ $res1 -eq 0 -a $res2 -eq 0 ]; then
-		/lib/svc/bin/prophist delete -e $service -g $property_group
-		instance_refresh $service:$instance
-	fi
-}
-
-function prophist_delete_dependency {
-	#
-	# Some services have stale dependencies that need to be removed.
-	# This is done by removing the dependency property group.
-	#
-	fmri=$1
-	property_group=$2
-
-	/usr/bin/svcprop -q -c -p $property_group $fmri
-	if [ $? -eq 0 ]; then
-		/lib/svc/bin/prophist delete -e $fmri -g $property_group
+#
+# If the smf/manifest table has file entries that are missing
+# then there is work to be done by the cleanup process.
+#
+function cleanup_needwork {
+	if [ "$early" == true ]; then
+		smfmfiles=`/usr/bin/svcprop smf/manifest | \
+		    awk '(/^lib_) && (/\/manifestfile /) {print $3}'`
 	else
-		[ -n "$_MFST_DEBUG" ] && \
-		    echo "Dependency $property_group not defined on $fmri"
-	fi
-}
-
-function prophist_delete_pg {
-	# Delete obsolete property groups from old manifests.  Instances
-	# should be refreshed for changes to take effect.
-	fmri=$1
-	pg=$2
-
-	/usr/bin/svcprop -Cqp $pg $fmri &&
-	    /lib/svc/bin/prophist delete -e $fmri -g $pg
-}
-
-function prophist_addprop {
-	#
-	# If a property doesn't exist, create it.  Instances should be
-	# refreshed for changes to take effect.
-	#
-	if [ $# -lt 6 ]; then
-		echo "prophist_addprop(): Insufficient arguments ($*)."
-		exit 1
+		smfmfiles=`/usr/bin/svcprop smf/manifest | \
+		    awk '/\/manifestfile / {print $3}'`
 	fi
 
-	fmri=$1
-	/usr/bin/svcprop -q $fmri || return
-
-	pg=$2
-	pgtype=$3
-	prop=$4
+	nw=`/lib/svc/bin/mfstscan $smfmfiles 2>&1 1>/dev/null`
+	[ "$nw" ] && return 1
 
-	/usr/bin/svcprop -Cqp $pg/$prop $fmri && return
-
-	shift 4
-
-	/usr/bin/svcprop -Cqp $pg $fmri || \
-	    /usr/sbin/svccfg -s $fmri addpg $pg $pgtype
-	/usr/sbin/svccfg -s $fmri setprop $pg/$prop = $*
+	return 0
 }
 
-function prophist_addmeth {
-	#
-	# If a method doesn't exist, create it.  Instances should be refreshed
-	# for changes to take effect.
-	#
-	if [ $# -ne 4 ]; then
-		echo "prophist_addmeth(): Insufficient arguments ($*)"
-		exit 1
-	fi
-
-	fmri=$1
-	/usr/bin/svcprop -q $fmri || return
-
-	name=$2
-	/usr/bin/svcprop -Cqp $name $fmri && return
-
-	exec=$3
-	to=$4
-
-	/usr/sbin/svccfg -s $fmri <<END
-	    addpg $name method
-	    setprop $name/type = astring: method
-	    setprop $name/exec = astring: "$exec"
-	    setprop $name/timeout_seconds = count: $to
-END
-}
-
-function prophist_adddep {
-	#
-	# If a dependency doesn't exist, create it.  Instances should be
-	# refreshed for changes to take effect.
-	#
-	if [ $# -lt 6 ]; then
-		echo "prophist_adddep(): Insufficient arguments ($*)"
-		exit 1
-	fi
-
-	fmri=$1
-	/usr/bin/svcprop -q $fmri || return
-
-	name=$2
-	/usr/bin/svcprop -Cqp $name $fmri && return
-
-	type=$3
-	group=$4
-	ro=$5
-	shift 5
+#
+# Upon upgrading to early manifest import code, preserve hashes of system
+# profiles which lived under /var/svc/profile so that svccfg apply would
+# not re-apply the profiles and overwrite user customizations. Simply 
+# migrate manifestfile and hash values to new property groups named after
+# profiles under /etc/svc/profile. If the profiles don't really exist,
+# svccfg cleanup will remove the property groups in a later step.
+# 
+# Existing generic.xml, inetd_services.xml, and name_service.xml symlinks
+# need to be preserved.
+#
+# Don't process site.xml profile since it is still supported under
+# /var/svc/profile directory.
+#
+function preserve_system_profiles {
 
-	/usr/sbin/svccfg -s $fmri <<END
-	    addpg $name dependency
-	    setprop $name/type = astring: $type
-	    setprop $name/grouping = astring: $group
-	    setprop $name/restart_on = astring: $ro
-	    setprop $name/entities = fmri: $*
-END
-}
-
-function prophist_adddpt {
 	#
-	# If a dependent doesn't exist, create it.  Instances should be
-	# refresh for changes to take effect.
-	#
-	if [ $# -ne 5 ]; then
-		echo "prophist_adddpt(): Incorrect arguments ($*).\n"
-		exit 1
-	fi
-
-	fmri=$1
-	/usr/bin/svcprop -q $fmri || return
-
-	name=$2
-	/usr/bin/svcprop -Cqp dependents/$name $fmri && return
-
-	group=$3
-	ro=$4
-	target=$5
+	# If /var is a separate fs, return and let Late Import
+	# preserves the hashes.
+	#	
+	[ -d "/var/svc/profile" ] || return 1
 
-	prophist_addprop $fmri dependents framework $name fmri: $target
-	prophist_adddep $target $name service $group $ro $fmri
-}
-
-function instance_refresh {
-	echo $1 >> /etc/svc/volatile/refreshes
-}
-
-function refresh_instances {
-	[ -r /etc/svc/volatile/refreshes ] && {
-		sort -u /etc/svc/volatile/refreshes | xargs -l svcadm refresh
-	}
-}
-
-function instance_clear {
-	echo $1 >> /etc/svc/volatile/clears
-}
-
-function clear_conditionally {
-	[ "`/usr/bin/svcprop -p restarter/state $1`" = "maintenance" ] && \
-	    /usr/sbin/svcadm clear $1
-}
-
-function clear_instances {
-	[ -r /etc/svc/volatile/clears ] && {
-		for inst in `/usr/bin/sort -u /etc/svc/volatile/clears`; do
-			clear_conditionally $inst
-		done
-	}
-}
-
-function prepare_last_import {
-	# Preserve the five hashes for the profiles: generic (two
-	# cases), platform (uname -i, uname -m outputs), and site.
-
+	#
+	# Preserve hashes for the following profiles: generic (two
+	# cases) and platform (uname -i, uname -m outputs).
+	#
 	gn="var_svc_profile_generic_open_xml"
 	gh=`/usr/bin/svcprop -p ${gn}/md5sum smf/manifest 2>/dev/null`
 	[ $? = 0 ] || gh=""
+	gn="etc_svc_profile_generic_open_xml"
 
 	gln="var_svc_profile_generic_limited_net_xml"
 	glh=`/usr/bin/svcprop -p ${gln}/md5sum smf/manifest 2>/dev/null`
 	[ $? = 0 ] || glh=""
+	gln="etc_svc_profile_generic_limited_net_xml"
 
 	LC_ALL=C pl=`/usr/bin/uname -i | /usr/bin/tr , _`
 	pln="var_svc_profile_platform_${pl}_xml"
 	plh=`/usr/bin/svcprop -p ${pln}/md5sum smf/manifest 2>/dev/null`
 	[ $? = 0 ] || plh=""
+	pln="etc_svc_profile_platform_${pl}_xml"
 
 	LC_ALL=C plm=`/usr/bin/uname -m | /usr/bin/tr , _`
 	if [ $plm != $pl ]; then
@@ -293,177 +119,80 @@
 		plmh=`/usr/bin/svcprop -p ${plmn}/md5sum smf/manifest \
 		    2>/dev/null`
 		[ $? = 0 ] || plmh=""
+		plmn="etc_svc_profile_platform_${plm}_xml"
 	else
 		plmh=""
 	fi
 
-	sn="var_svc_profile_site_xml"
-	sh=`/usr/bin/svcprop -p $sn/md5sum smf/manifest 2>/dev/null`
-	[ $? = 0 ] || sh=""
-
-	# Remove all manifest hashes.
-	/usr/sbin/svccfg delete smf/manifest
-
-	# Restore smf/manifest and hash values.
-	/usr/sbin/svccfg add smf/manifest
 	[ -n "$gh" ] && {
 		echo "Preserving generic hash ($gh)."
 		/usr/sbin/svccfg -s smf/manifest addpg ${gn} framework
 		/usr/sbin/svccfg -s smf/manifest setprop ${gn}/md5sum = \
 		    opaque: $gh
+		/usr/sbin/svccfg -s smf/manifest setprop ${gn}/manifestfile = \
+		    astring: "/etc/svc/profile/generic.xml"
 	}
 	[ -n "$glh" ] && {
 		echo "Preserving generic_limited hash ($glh)."
 		/usr/sbin/svccfg -s smf/manifest addpg ${gln} framework
 		/usr/sbin/svccfg -s smf/manifest setprop ${gln}/md5sum = \
 		    opaque: $glh
+		/usr/sbin/svccfg -s smf/manifest setprop ${gln}/manifestfile = \
+		    astring: "/etc/svc/profile/generic.xml"
 	}
 	[ -n "$plh" ] && {
 		echo "Preserving platform hash ($plh)."
 		/usr/sbin/svccfg -s smf/manifest addpg $pln framework
 		/usr/sbin/svccfg -s smf/manifest setprop $pln/md5sum = \
 		    opaque: $plh
+		/usr/sbin/svccfg -s smf/manifest setprop ${pln}/manifestfile = \
+		    astring: "/etc/svc/profile/platform_${pl}_xml"
 	}
 	[ -n "$plmh" ] && {
 		echo "Preserving platform hash ($plmh)."
 		/usr/sbin/svccfg -s smf/manifest addpg $plmn framework
 		/usr/sbin/svccfg -s smf/manifest setprop $plmn/md5sum = \
 		    opaque: $plmh
-	}
-	[ -n "$sh" ] && {
-		echo "Preserving site hash ($sh)."
-		/usr/sbin/svccfg -s smf/manifest addpg $sn framework
-		/usr/sbin/svccfg -s smf/manifest setprop $sn/md5sum = \
-		    opaque: $sh
+		/usr/sbin/svccfg -s smf/manifest setprop \
+		    ${plmn}/manifestfile = \
+		    astring: "/etc/svc/profile/platform_${plm}_xml"
 	}
-}
-
-#
-# 0b Cleanup deathrow
-#
-deathrow=/etc/svc/deathrow
-if [ -s $deathrow ];then
-	#
-	# svc.startd has unconfigured the services found in deathrow,
-	# clean them now.
-	#
-	while read fmri mfst pkgname; do
-		# Delete services and instances from the deathrow file.
-		/usr/sbin/svccfg delete -f $fmri >/dev/null 2>&1
-		# Remove deathrow manifest hash.
-		/usr/sbin/svccfg delhash -d $mfst >/dev/null 2>&1
-	done < $deathrow
-	/usr/bin/mv $deathrow $deathrow.old
-fi
-SVCCFG_CHECKHASH=1 export SVCCFG_CHECKHASH
-
-#
-# 0c Clean up repository
-#
-if [ -z "$X" ] && /usr/bin/svcprop smf/manifest 2>/dev/null |
-    /usr/bin/grep '^ar_svc_[^/]*/md5sum opaque ' >/dev/null
-then
-	set -- `
-		/usr/bin/svcprop smf/manifest 2>/dev/null |
-		    /usr/bin/grep '^ar_svc[^/]*/md5sum opaque ' |
-		    /usr/bin/tr '/' ' ' |
-		    while read pg prop type value; do
-			echo "$pg/$value"
-		done
-	`
-	backup=`echo "$#/$#" | sed 's/.//g'`
-	fwidth=`echo "$#\c" | wc -c`
-
-	echo "Converting obsolete repository entries: \c" > /dev/msglog
-	i=1; n=$#
-	while [ $# -gt 0 ]; do
-		printf "%${fwidth}s/%${fwidth}s" $i $n > /dev/msglog
-		echo $1 | sed 's:/: :' | (
-			read pg value
-
-			(echo "select /smf/manifest"; echo "delpg v$pg") |
-			    /usr/sbin/svccfg 2>/dev/null >/dev/null
-			(echo "select /smf/manifest"; echo "delpg $pg") |
-			    /usr/sbin/svccfg 2>/dev/null >/dev/null
-			(echo "select /smf/manifest";
-			    echo "addpg v$pg framework") |
-			    /usr/sbin/svccfg 2>/dev/null >/dev/null
-			(echo "select /smf/manifest";
-			    echo "setprop v$pg/md5sum = opaque: $value") |
-			    /usr/sbin/svccfg 2>/dev/null >/dev/null
-		)
-		i=`expr $i + 1`
-		shift
-		echo "$backup\c" > /dev/msglog
-	done
-	echo > /dev/msglog
-	echo "Converted $n obsolete repository entries"
-	activity=true
-fi
-
-#
-# If no last-import snapshots are present on critical services, then we are
-# creating the last-import snapshots for the first time post upgrade.
-#
-create_last_import=1
-for svc in single-user multi-user multi-user-server; do
-	if /usr/bin/svcprop -s last-import svc:/milestone/$svc:default \
-	    >/dev/null 2>&1
-	then
-		create_last_import=
-		break
-	fi
-done
-
-if [ $create_last_import ]; then
-	echo "Last import snapshots absent; preparing for re-import"
-	prepare_last_import
 
 	#
-	# Apply property history files.
+	# Move symlinks from /var/svc/profile to /etc/svc/profile
 	#
-	echo "Upgrade detected; applying property history"
-	for phist in /var/svc/profile/prophist.*; do
-		/lib/svc/bin/prophist hash $phist
-		if [ $? = 3 ]; then
-			echo "Sourcing $phist"
-			. $phist
-		fi
-	done
+	generic_prof="/var/svc/profile/generic.xml"
+	ns_prof="/var/svc/profile/name_service.xml"
+	inetd_prof="/var/svc/profile/inetd_services.xml"
+	[ -L "$generic_prof" ] && mv $generic_prof /etc/svc/profile/
+	[ -L "$ns_prof" ] && mv $ns_prof /etc/svc/profile/
+	[ -L "$inetd_prof" ] && mv $inetd_prof /etc/svc/profile/
 
-	/usr/bin/rm -f /var/svc/profile/.upgrade_prophist
-fi
+	return 0
+}
 
 #
 # 2.  Manifest import.  Application directories first, then
 # site-specific manifests.
 #
-nonsite_dirs=`/usr/bin/find /var/svc/manifest/* -name site -prune -o -type d \
-	-print -prune`
-
-nonsite_manifests=`/lib/svc/bin/mfstscan $nonsite_dirs`
-site_manifests=`/lib/svc/bin/mfstscan /var/svc/manifest/site`
+function import_manifests {
+	typeset basedir=$1
+	typeset logf="/etc/svc/volatile/manifest_import.$$"
 
-manifests="$nonsite_manifests $site_manifests"
+	rm -f $logf
 
-[ -n "$_MFST_DEBUG" ] && {
-	echo "Changed manifests to import:"
-	for m in $manifests; do echo "  $m"; done
-}
+	nonsite_dirs=`/usr/bin/find $basedir/svc/manifest/* -name site \
+	    -prune -o -type d -print -prune`
 
-#
-# 2b.  Import the manifests while giving a running display of imports on
-# console, and a final count in the logfile.
-#
-if [ -n "$nonsite_manifests" -o -n "$site_manifests" ]; then
-	rm -f /tmp/manifest_import.$$
+	if [ -n "$_MFST_DEBUG" ]; then
+		nonsite_manifests=`/lib/svc/bin/mfstscan $nonsite_dirs`
+		site_manifests=`/lib/svc/bin/mfstscan $basedir/svc/manifest/site`
 
-	set -- $manifests
-	cleanup=""
-	backup=`echo "$#/$#" | sed 's/.//g'`
-	fwidth=`echo "$#\c" | wc -c`
+		manifests="$nonsite_manifests $site_manifests"
 
-	echo "Loading smf(5) service descriptions: \c" > /dev/msglog
+		echo "Changed manifests to import:"
+		for m in $manifests; do echo "  $m"; done
+	fi
 
 	#
 	# Attempt of moving the repository to tmpfs.  If that doesn't
@@ -472,120 +201,262 @@
 	/usr/sbin/svcadm _smf_repository_switch fast
 	doswitch=$?
 
-	i=1; n=$#
-	svcprop smf/manifest > /etc/svc/volatile/smf_manifest_svcprop 2>&1
-	while [ $# -gt 0 ]; do
-		printf "%${fwidth}s/%${fwidth}s" $i $n > /dev/msglog
-		grep $1 /etc/svc/volatile/smf_manifest_svcprop > /dev/null 2>&1
-		if [ $? -eq 0 ]; then
-			cleanup="$cleanup $1"
-		fi	
-		svccfg_import $1
-		i=`expr $i + 1`
-		shift
-		echo "$backup\c" > /dev/msglog
-	done
-	rm -f /etc/svc/volatile/smf_manifest_svcprop
+	#
+	# Import the manifests while giving a running display of imports on
+	# console, and a final count in the logfile.
+	#
+	dirs="$nonsite_dirs $basedir/svc/manifest/site"
+	$X /usr/sbin/svccfg import -p /dev/msglog $dirs > $logf 2>&1
 
-	#
-	# If switch back fails, exit with the fatal error code.
-	# Normally the failure indicates that there is a serious
-	# problem on the root file system such as file operation
-	# failure or repository access failure.
-	#
-	if [ $doswitch -eq 0 ]; then
-		/usr/sbin/svcadm _smf_repository_switch perm || { \
-		    echo "Repository switch back operation failed, \c"
-		    echo "please check the system log for the"
-		    echo "possible fatal error messages."
-		    exit $SMF_EXIT_ERR_FATAL
-                    }
+	grep "Loaded .*. smf(5) service descriptions" $logf > /dev/null 2>&1
+	if [ $? -eq 0 ]; then
+		activity=true
 	fi
 
-	echo > /dev/msglog
-	echo "Loaded $n smf(5) service descriptions"
-	activity=true
+	if [ -s $logf ]; then
+		grep "smf(5) service descriptions failed to load" $logf > /dev/null 2>&1
+		failures=$?
+		if [ $failures -eq 0 ]; then
+			echo "svccfg warnings:"
+		fi
+		cat $logf
 
-	if [ -s /tmp/manifest_import.$$ ]; then
-		echo "svccfg warnings:"
-		cat /tmp/manifest_import.$$
-
-		msg="svccfg import warnings.  See"
-		msg="$msg /var/svc/log/system-manifest-import:default.log ."
-		echo $msg > /dev/msglog
+		if [ $failures -eq 0 ]; then
+			msg="svccfg import warnings.  See"
+			msg="$msg /var/svc/log/system-manifest-import:default.log ."
+			echo $msg > /dev/msglog
+		fi
 	fi
-	rm -f /tmp/manifest_import.$$
-fi
+	rm -f $logf
+}
 
 #
 # 3.  Profile application.  We must create the platform profile upon
 # first boot, as we may be a diskless client of a platform or
 # architecture distinct from our NFS server.
 #
-svccfg_apply /var/svc/profile/generic.xml
+# Generic and platform profiles are only supported in /etc.
+#
+function apply_profile {
+	#
+	# If smf/manifest doesn't have any profile under /etc/var/profile,
+	# this is very likely an import after upgrade so call
+	# preserve_system_profiles in that case.
+	#
+	LC_ALL=C pl=`/usr/bin/uname -i | /usr/bin/tr , _`
+	pln="etc_svc_profile_platform_${pl}_xml"
 
-if [ ! -f /var/svc/profile/platform.xml ]; then
-	this_karch=`uname -m`
-	this_plat=`uname -i`
+	LC_ALL=C plm=`/usr/bin/uname -m | /usr/bin/tr , _`
+	[ $plm != $pl ] && plmn="etc_svc_profile_platform_${plm}_xml"
 
-	if [ -f /var/svc/profile/platform_$this_plat.xml ]; then
-		platform_profile=platform_$this_plat.xml
-	elif [ -f /var/svc/profile/platform_$this_karch.xml ]; then
-		platform_profile=platform_$this_karch.xml
-	else
-		platform_profile=platform_none.xml
+	preserve_profiles=1
+	for prof in $pln $plmn etc_svc_profile_platform_none_xml \
+	    etc_svc_profile_generic_limited_net_xml \
+	    etc_svc_profile_generic_open_xml; do
+		if /usr/bin/svcprop -p $prof smf/manifest >/dev/null 2>&1
+		then
+			preserve_profiles=0
+			break
+		fi
+	done
+
+	if [ $preserve_profiles -eq 1 ]; then
+		echo "/etc/svc system profiles not found: upgrade system profiles"
+		preserve_system_profiles || return
 	fi
 
-	ln -s $platform_profile /var/svc/profile/platform.xml
-fi
+	typeset prefix="/etc/svc/profile"
+	svccfg_apply $prefix/generic.xml
+	if [ ! -f $prefix/platform.xml ]; then
+		this_karch=`uname -m`
+		this_plat=`uname -i`
 
-svccfg_apply /var/svc/profile/platform.xml
+		if [ -f $prefix/platform_$this_plat.xml ]; then
+			platform_profile=platform_$this_plat.xml
+		elif [ -f $prefix/platform_$this_karch.xml ]; then
+			platform_profile=platform_$this_karch.xml
+		else
+			platform_profile=platform_none.xml
+		fi
+
+		ln -s $platform_profile $prefix/platform.xml
+	fi
+
+	svccfg_apply $prefix/platform.xml
+}
 
 #
 # 4.  Upgrade handling.  The upgrade file generally consists of a series
 # of svcadm(1M) and svccfg(1M) commands.
 #
-(
-	unset SVCCFG_CHECKHASH
+function handle_upgrade {
+
+	[ -f /var/svc/profile/upgrade ] && activity=true
+
+	(
+		unset SVCCFG_CHECKHASH
 
-	if [ -f /var/svc/profile/upgrade ]; then
-		. /var/svc/profile/upgrade
+		if [ -f /var/svc/profile/upgrade ]; then
+			. /var/svc/profile/upgrade
 
-		/usr/bin/mv /var/svc/profile/upgrade \
-		    /var/svc/profile/upgrade.app.`date +\%Y\%m\%d\%H\%M\%S`
-		activity=true
-	fi
+			/usr/bin/mv /var/svc/profile/upgrade \
+			    /var/svc/profile/upgrade.app.`date +\%Y\%m\%d\%H\%M\%S`
+		fi
 
-	#
-	# Rename the datalink upgrade script file. This script is used in the
-	# network/physical service to upgrade datalink configuration, but
-	# the file cannot be renamed until now (when the file system becomes
-	# read-write).
-	#
-	datalink_script=/var/svc/profile/upgrade_datalink
-	if [ -f "${datalink_script}" ]; then
-		/usr/bin/mv "${datalink_script}" \
-		    "${datalink_script}".app.`date +\%Y\%m\%d\%H\%M\%S`
-	fi
-)
+		#
+		# Rename the datalink upgrade script file. This script is used in the
+		# network/physical service to upgrade datalink configuration, but
+		# the file cannot be renamed until now (when the file system becomes
+		# read-write).
+		#
+		datalink_script=/var/svc/profile/upgrade_datalink
+		if [ -f "${datalink_script}" ]; then
+			/usr/bin/mv "${datalink_script}" \
+			    "${datalink_script}".app.`date +\%Y\%m\%d\%H\%M\%S`
+		fi
+	)
+}
 
 #
 # 5.  Site profile is applied last to give administrator the final say.
 #
-if [ -f /var/svc/profile/site.xml ]; then
-	svccfg_apply /var/svc/profile/site.xml
+function apply_site_profile {
+        typeset prefix="$1/svc/profile"
+	[ -f $prefix/site.xml ] && svccfg_apply $prefix/site.xml
+}
+
+#
+# 0b Cleanup deathrow
+#
+if [ "$early" = "false" ];then
+	deathrow=/etc/svc/deathrow
+	if [ -s $deathrow ];then
+		#
+		# svc.startd has unconfigured the services found in deathrow,
+		# clean them now.
+		#
+		while read fmri mfst pkgname; do
+			# Delete services and instances from the deathrow file.
+			/usr/sbin/svccfg delete -f $fmri >/dev/null 2>&1
+			# Remove deathrow manifest hash.
+			/usr/sbin/svccfg delhash -d $mfst >/dev/null 2>&1
+		done < $deathrow
+		/usr/bin/mv $deathrow $deathrow.old
+	fi
 fi
 
+SVCCFG_CHECKHASH=1 export SVCCFG_CHECKHASH
+
+#
+# 0c Clean up repository
+#
+if [ "$early" = "false" ]; then
+	if [ -z "$X" ] && /usr/bin/svcprop smf/manifest 2>/dev/null |
+	    /usr/bin/grep '^ar_svc_[^/]*/md5sum opaque ' >/dev/null
+	then
+		set -- `
+			/usr/bin/svcprop smf/manifest 2>/dev/null |
+			    /usr/bin/grep '^ar_svc[^/]*/md5sum opaque ' |
+			    /usr/bin/tr '/' ' ' |
+			    while read pg prop type value; do
+				echo "$pg/$value"
+			done
+		`
+		backup=`echo "$#/$#" | sed 's/.//g'`
+		fwidth=`echo "$#\c" | wc -c`
+
+		echo "Converting obsolete repository entries: \c" > /dev/msglog
+		i=1; n=$#
+		while [ $# -gt 0 ]; do
+			printf "%${fwidth}s/%${fwidth}s" $i $n > /dev/msglog
+			echo $1 | sed 's:/: :' | (
+				read pg value
+
+				(echo "select /smf/manifest"; echo "delpg v$pg") |
+				    /usr/sbin/svccfg 2>/dev/null >/dev/null
+				(echo "select /smf/manifest"; echo "delpg $pg") |
+				    /usr/sbin/svccfg 2>/dev/null >/dev/null
+				(echo "select /smf/manifest";
+				    echo "addpg v$pg framework") |
+				    /usr/sbin/svccfg 2>/dev/null >/dev/null
+				(echo "select /smf/manifest";
+				    echo "setprop v$pg/md5sum = opaque: $value") |
+				    /usr/sbin/svccfg 2>/dev/null >/dev/null
+			)
+			i=`expr $i + 1`
+			shift
+			echo "$backup\c" > /dev/msglog
+		done
+		echo > /dev/msglog
+		echo "Converted $n obsolete repository entries"
+		activity=true
+	fi
+
+fi
+
+#
+# Call import and apply profiles here
+#
+if [ "$early" = "true" ]; then
+	import_manifests "/lib"
+	apply_profile
+	apply_site_profile "/etc"
+else
+	#
+	# Process both /lib/svc and /var/svc
+	# during late manifest-import
+	#
+	# First import the manifests
+	#
+	import_manifests "/lib"
+	import_manifests "/var"
+
+	#
+	# Apply profiles
+	#
+	apply_profile
+	apply_site_profile "/etc"
+
+	#
+	# Run the upgrade script
+	#
+	handle_upgrade
+	apply_site_profile "/var"
+fi
+
+
 #
 # 6.  Final actions.
 #
-refresh_instances
-clear_instances
 
 if $activity; then
-	svcadm _smf_backup "manifest_import" || true
+	/usr/sbin/svcadm _smf_backup "manifest_import" || true
 fi
 
-manifest_cleanup $activity $cleanup
+#
+# If the filesystem is NOT read only then move the repo back to perm
+# There is no care wether the switch was made or not, but just want
+# to move it.  If it is already perm this does not affect anything
+# at least on the surface.  REALLY want to improve on this...
+#
+touch /etc/svc/smf_rwtest.$$ > /dev/null 2>&1
+if [ $? -eq 0 ]; then
+	rm -f /etc/svc/smf_rwtest.$$
+	/usr/sbin/svcadm _smf_repository_switch perm || { \
+	    echo "Repository switch back operation failed, \c"
+	    echo "please check the system log for the"
+	    echo "possible fatal error messages."
+	    exit $SMF_EXIT_ERR_FATAL
+	    }
+fi
+
+if $activity; then
+	/usr/sbin/svccfg cleanup | /usr/bin/tee /dev/msglog
+else
+	cleanup_needwork
+	if [ $? -ne 0 ]; then
+		/usr/sbin/svccfg cleanup -a | /usr/bin/tee /dev/msglog
+	fi
+fi
 
 exit 0
--- a/usr/src/cmd/svc/profile/Makefile	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/svc/profile/Makefile	Thu Mar 25 14:57:35 2010 -0700
@@ -20,7 +20,7 @@
 #
 
 #
-# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 
@@ -28,7 +28,7 @@
 
 FILEMODE = 0444
 
-ROOTPROFILE = $(ROOT)/var/svc/profile
+ROOTPROFILE = $(ROOT)/etc/svc/profile
 
 PROFILESRCS = \
 	generic_open.xml \
--- a/usr/src/cmd/svc/profile/generic_limited_net.xml	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/svc/profile/generic_limited_net.xml	Thu Mar 25 14:57:35 2010 -0700
@@ -32,16 +32,16 @@
     NOTE:  Service profiles delivered by this package are not editable,
     and their contents will be overwritten by package or patch
     operations, including operating system upgrade.  Make customizations
-    in a distinct file.  The path, /var/svc/profile/site.xml, is a
-    distinguished location for a site-specific service profile, treated
-    otherwise equivalently to this file.
+    in a distinct file.  The paths, /etc/svc/profile/site.xml and
+    /var/svc/profile/site.xml, are distinguished locations for site-specific
+    service profile, treated otherwise equivalently to this file.
 -->
 <service_bundle type='profile' name='generic_limited_net'
 	 xmlns:xi='http://www.w3.org/2003/XInclude' >
   <!--
       Include name service profile, as set by system id tools.
   -->
-  <xi:include href='file:/var/svc/profile/name_service.xml' />
+  <xi:include href='file:/etc/svc/profile/name_service.xml' />
 
   <!--
       svc.startd(1M) services
--- a/usr/src/cmd/svc/profile/generic_open.xml	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/svc/profile/generic_open.xml	Thu Mar 25 14:57:35 2010 -0700
@@ -29,16 +29,16 @@
     NOTE:  Service profiles delivered by this package are not editable,
     and their contents will be overwritten by package or patch
     operations, including operating system upgrade.  Make customizations
-    in a different file.  The path, /var/svc/profile/site.xml, is a
-    distinguished location for a site-specific service profile, treated
-    otherwise equivalently to this file.
+    in a different file.  The paths, /etc/svc/profile/site.xml and
+    /var/svc/profile/site.xml, are distinguished location for site-specific
+    service profiles, treated otherwise equivalently to this file.
 -->
 <service_bundle type='profile' name='generic_open'
 	 xmlns:xi='http://www.w3.org/2003/XInclude' >
   <!--
       Include name service profile, as set by system id tools.
   -->
-  <xi:include href='file:/var/svc/profile/name_service.xml' />
+  <xi:include href='file:/etc/svc/profile/name_service.xml' />
 
   <!--
       svc.startd(1M) services
@@ -188,6 +188,5 @@
   <!--
       Include inetd(1M) services profile.
   -->
-  <xi:include href='file:/var/svc/profile/inetd_services.xml' />
-
+  <xi:include href='file:/etc/svc/profile/inetd_services.xml' />
 </service_bundle>
--- a/usr/src/cmd/svc/prophist/Makefile	Thu Mar 25 13:21:39 2010 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-#
-# CDDL HEADER START
-#
-# 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 2009 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-
-PROG =		prophist
-OBJS =		prophist.o \
-		manifest_hash.o
-LNTS =		$(OBJS:%.o=%.ln)
-POFILES =	$(OBJS:%.o=%.po)
-
-SRCS =		prophist.c \
-		../common/manifest_hash.c
-
-POFILES = 	$(OBJS:.o=.po)
-
-include ../../Makefile.cmd
-include ../../Makefile.ctf
-
-ROOTCMDDIR=     $(ROOT)/lib/svc/bin
-
-ROOTPROPHIST=	$(ROOT)/var/svc/profile/prophist.SUNWcsr
-
-$(ROOTPROPHIST) := FILEMODE = 0444
-
-CPPFLAGS +=	-I../common
-LDLIBS +=	-lscf -luutil -lmd5
-CLOBBERFILES += $(POFILES)
-
-lint := LINTFLAGS = -mux
-
-.KEEP_STATE:
-
-all: $(PROG)
-
-$(PROG): $(OBJS)
-	$(LINK.c) -o $@ $(OBJS) $(LDLIBS)
-	$(POST_PROCESS)
-
-install: all $(ROOTCMD) $(ROOTPROPHIST)
-
-clean:
-	$(RM) $(OBJS) $(POFILES) $(LNTS)
-
-lint: $(LNTS)
-	$(LINT.c) $(LINTFLAGS) $(LNTS) $(LDLIBS)
-
-%.o: ../common/%.c
-	$(COMPILE.c) $(OUTPUT_OPTION) $<
-	$(POST_PROCESS_O)
-
-%.ln: ../common/%.c
-	$(LINT.c) $(OUTPUT_OPTION) -c $<
-
-$(ROOT)/var/svc/profile/%: %
-	$(INS.file)
-
-include ../../Makefile.targ
--- a/usr/src/cmd/svc/prophist/prophist.SUNWcsr	Thu Mar 25 13:21:39 2010 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,688 +0,0 @@
-#!/bin/sh
-#
-# CDDL HEADER START
-#
-# 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 2009 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# prophist.SUNWcsr - historical property corrections for ON
-#
-# For builds prior to S10 final product release, certain manifests were
-# delivered with incorrect property values or dependencies.  This file
-# contains corrected values and, optionally for each property, a series
-# of previous default values which should be corrected.
-#
-# With the arrival of manifest merging support, this file's contents
-# should be treated as fixed.
-#
-# NB:  prophist_upgrade calls that have a hyphen-prefixed prior value
-# must use -- at the head of the prior value sequence.  Value arguments
-# with spaces require doubly-nested quoting.
-
-# milestone/
-
-prophist_upgrade milestone/single-user start timeout_seconds 1800 30
-prophist_delete_dependency milestone/single-user physical-network
-prophist_adddep svc:/milestone/single-user network service optional_all none \
-    svc:/milestone/network
-prophist_addprop svc:/milestone/single-user startd framework timeout_retry \
-    boolean: false
-prophist_delete_dependency milestone/single-user sysidtool
-prophist_adddep svc:/milestone/single-user milestone-devices \
-    service require_all none svc:/milestone/devices
-instance_refresh milestone/single-user:default
-instance_clear milestone/single-user:default
-instance_clear system/sysidtool:net
-instance_clear system/sysidtool:system
-
-prophist_upgrade milestone/multi-user start timeout_seconds 1800 3
-prophist_adddep svc:/milestone/multi-user kdmconfig service optional_all none \
-    svc:/platform/i86pc/kdmconfig:default
-prophist_addprop svc:/milestone/multi-user startd framework timeout_retry \
-    boolean: false
-/usr/sbin/svccfg -s milestone/multi-user addpropvalue milestones/entities \
-    svc:/milestone/sysconfig
-instance_refresh milestone/multi-user:default
-
-prophist_upgrade milestone/multi-user-server start timeout_seconds 1800 3
-prophist_upgrade milestone/multi-user-server multi-user restart_on none refresh
-prophist_addprop svc:/milestone/multi-user-server startd framework \
-    timeout_retry boolean: false
-instance_refresh milestone/multi-user-server
-
-prophist_delete_dependency milestone/name-services nis_server
-instance_refresh milestone/name-services
-
-# system/
-
-prophist_upgrade system/consadm start timeout_seconds 60 2
-
-prophist_upgrade system/console-login start timeout_seconds 3 0
-if /usr/bin/svcprop -Cqp ttymon svc:/system/console-login; then :; else
-	/usr/sbin/svccfg -s svc:/system/console-login <<\END
-	    addpg ttymon application
-	    setprop ttymon/device = astring: /dev/console
-	    setprop ttymon/label = astring: console
-	    setprop ttymon/timeout = count: 0
-	    setprop ttymon/nohangup = boolean: true
-	    setprop ttymon/modules = astring: ldterm,ttcompat
-	    setprop ttymon/prompt = astring: "`uname -n` console login:"
-END
-
-	if [ "`/usr/bin/uname -p`" = "i386" ]; then
-		/usr/sbin/svccfg -s svc:/system/console-login \
-		    setprop ttymon/terminal_type = astring: sun-color
-	else
-		/usr/sbin/svccfg -s svc:/system/console-login \
-		    setprop ttymon/terminal_type = astring: sun
-	fi
-fi
-prophist_delete_dependency system/console-login sysidtool
-prophist_adddep svc:/system/console-login sysconfig service require_all none \
-    svc:/milestone/sysconfig
-instance_refresh system/console-login
-
-prophist_upgrade system/coreadm start timeout_seconds 60 3
-prophist_upgrade system/coreadm stop timeout_seconds 60 0
-
-prophist_upgrade system/cron start timeout_seconds 60 6
-prophist_upgrade system/cron stop timeout_seconds 60 3
-prophist_adddpt svc:/system/cron cron_multi-user optional_all none \
-    svc:/milestone/multi-user
-prophist_addprop svc:/system/cron general framework action_authorization \
-    astring: solaris.smf.manage.cron
-instance_refresh svc:/milestone/multi-user:default
-instance_refresh svc:/system/cron:default
-
-prophist_upgrade system/cryptosvc start exec "/usr/sbin/cryptoadm %m" \
-    /lib/svc/method/crypto
-prophist_upgrade system/cryptosvc stop exec "/usr/sbin/cryptoadm %m" :kill
-prophist_addmeth svc:/system/cryptosvc refresh "/usr/sbin/cryptoadm %m" 60
-prophist_adddpt svc:/system/cryptosvc cryptosvc_single optional_all none \
-    svc:/milestone/single-user
-instance_refresh svc:/milestone/single-user:default
-instance_refresh system/cryptosvc:default
-
-prophist_upgrade system/device/local start timeout_seconds 6000 600
-
-prophist_upgrade system/filesystem/autofs start timeout_seconds 60 6
-prophist_upgrade system/filesystem/autofs stop timeout_seconds 60 15
-prophist_adddpt svc:/system/filesystem/autofs autofs_multi-user \
-    optional_all none svc:/milestone/multi-user
-prophist_addprop svc:/system/filesystem/autofs application framework \
-    stability astring: Evolving
-prophist_addprop svc:/system/filesystem/autofs application framework \
-    auto_enable boolean: true
-prophist_addprop svc:/system/filesystem/autofs general framework \
-    action_authorization astring: solaris.smf.manage.autofs
-prophist_upgrade system/filesystem/autofs stop exec \
-    "/lib/svc/method/svc-autofs %m %{restarter/contract}" \
-    "/lib/svc/method/svc-autofs %m"
-instance_refresh svc:/system/filesystem/autofs:default
-instance_refresh svc:/milestone/multi-user:default
-
-prophist_upgrade system/filesystem/minimal start timeout_seconds 0 30 3
-prophist_upgrade system/filesystem/local start timeout_seconds 0 30
-prophist_upgrade system/filesystem/usr start timeout_seconds 0 3
-prophist_upgrade system/filesystem/root start timeout_seconds 300 30
-
-prophist_delete_dependency system/fmd SUNfmd
-prophist_adddep svc:/system/fmd SUNWfmd path require_all none \
-    file://localhost/usr/lib/fm/fmd/fmd
-prophist_delete_dependency system/fmd startup
-prophist_adddep svc:/system/fmd startup_req service require_all none \
-    '("svc:/system/sysevent" "svc:/system/filesystem/minimal"' \
-    '"svc:/system/dumpadm")'
-prophist_adddep svc:/system/fmd startup_opt service optional_all none \
-    svc:/network/rpc/bind
-instance_refresh system/fmd:default
-
-prophist_delete_svc_pg system/identity domain   tm_common_name
-prophist_delete_svc_pg system/identity domain   tm_man_defaultdomain
-prophist_delete_svc_pg system/identity domain   tm_man_domainname
-prophist_delete_svc_pg system/identity node     tm_man_nodename
-
-prophist_upgrade system/mdmonitor start timeout_seconds 60 2
-prophist_upgrade system/mdmonitor stop timeout_seconds 60 2
-instance_refresh svc:/system/mdmonitor:default
-
-prophist_delete_dependency svc:/system/metainit usr
-prophist_adddpt svc:/system/metainit metainit-root optional_all none \
-    svc:/system/filesystem/root
-prophist_adddep svc:/system/metainit identity service require_all none \
-    svc:/system/identity:node
-prophist_upgrade system/metainit start timeout_seconds 180 10
-instance_refresh svc:/system/metainit:default
-
-prophist_addmeth svc:/system/manifest-import stop :true 3
-prophist_upgrade system/manifest-import start timeout_seconds 1800 3
-prophist_upgrade system/manifest-import stop timeout_seconds 3 -- -1
-instance_refresh svc:/system/manifest-import:default
-
-prophist_adddep svc:/system/name-service-cache filesystem \
-    service require_all none svc:/system/filesystem/minimal
-prophist_adddpt svc:/system/name-service-cache name-service-cache_multi-user \
-    optional_all none svc:/milestone/multi-user
-prophist_addprop svc:/system/name-service-cache general framework \
-    action_authorization astring: solaris.smf.manage.name-service-cache
-instance_refresh svc:/system/name-service-cache:default
-instance_refresh svc:/milestone/multi-user:default
-
-prophist_upgrade system/picl start timeout_seconds 60 30
-prophist_upgrade system/picl stop timeout_seconds 60 30
-
-prophist_upgrade system/power start timeout_seconds 60 6
-prophist_upgrade system/power stop timeout_seconds 60 6
-prophist_adddpt svc:/system/power power_multi-user optional_all none \
-    svc:/milestone/multi-user
-prophist_addprop svc:/system/power general framework action_authorization \
-    astring: solaris.smf.manage.power
-instance_refresh svc:/system/power:default
-instance_refresh svc:/milestone/multi-user:default
-
-prophist_upgrade system/rcap start timeout_seconds 60 3
-prophist_upgrade system/rcap refresh timeout_seconds 60 3
-prophist_upgrade system/rcap stop timeout_seconds 60 3
-prophist_adddpt svc:/system/rcap rcap_multi-user optional_all none \
-    svc:/milestone/multi-user
-instance_refresh svc:/system/rcap:default
-instance_refresh svc:/milestone/multi-user:default
-
-prophist_upgrade system/rmtmpfiles start timeout_seconds 30 3
-
-prophist_delete_dependency system/sac single-user
-prophist_adddep svc:/system/sac sysconfig service require_all none \
-    svc:/milestone/sysconfig
-instance_refresh svc:/system/sac:default
-
-prophist_upgrade system/sysevent start timeout_seconds 60 2
-prophist_upgrade system/sysevent stop timeout_seconds 60 2
-prophist_upgrade system/sysevent stop exec \
-    "/lib/svc/method/svc-syseventd %m %{restarter/contract}" \
-    "/lib/svc/method/svc-syseventd %m"
-instance_refresh svc:/system/sysevent:default
-instance_clear svc:/system/sysevent:default
-
-prophist_addmeth svc:/system/system-log refresh ":kill -HUP" 60
-prophist_adddep svc:/system/system-log filesystem service require_all none \
-    svc:/system/filesystem/local
-prophist_upgrade system/system-log start timeout_seconds 600 3
-prophist_upgrade system/system-log stop timeout_seconds 60 3
-prophist_upgrade system/system-log refresh timeout_seconds 60 3
-prophist_addprop svc:/system/system-log general framework action_authorization \
-    astring: solaris.smf.manage.system-log
-prophist_upgrade system/system-log milestone entities \
-    svc:/milestone/sysconfig svc:/milestone/single-user
-prophist_adddep svc:/system/system-log autofs service optional_all none \
-    svc:/system/filesystem/autofs
-prophist_adddep svc:/system/system-log name-services service require_all none \
-    svc:/milestone/name-services
-instance_refresh svc:/system/system-log:default
-
-prophist_upgrade system/utmp milestone entities \
-    svc:/milestone/sysconfig svc:/milestone/single-user
-instance_refresh system/utmp
-
-# network/
-
-prophist_adddep svc:/network/initial devices service require_all none \
-    svc:/milestone/devices
-prophist_adddep svc:/network/initial filesystem service require_all none \
-    svc:/system/filesystem/usr
-prophist_upgrade network/initial start timeout_seconds 600 3
-prophist_delete_dependency network/initial loopback
-prophist_delete_dependency network/initial physical
-prophist_adddep svc:/network/initial network service optional_all none \
-    svc:/milestone/network
-instance_refresh network/initial:default
-
-prophist_upgrade network/loopback:default start timeout_seconds 60 3
-prophist_upgrade network/physical:default start timeout_seconds 600 3
-prophist_upgrade network/service start timeout_seconds 600 3
-
-prophist_adddep svc:/network/inetd filesystem service require_all error \
-    svc:/system/filesystem/local
-prophist_adddep svc:/network/inetd upgrade service optional_all none \
-    svc:/network/inetd-upgrade
-prophist_adddpt svc:/network/inetd inetd_multi-user optional_all none \
-    svc:/milestone/multi-user
-prophist_delete_dependency network/inetd physical
-prophist_adddep svc:/network/inetd network service optional_all error \
-    svc:/milestone/network
-/usr/sbin/svccfg -s network/inetd delpropvalue milestones/entities \
-    svc:/milestone/single-user
-/usr/sbin/svccfg -s network/inetd addpropvalue milestones/entities \
-    svc:/milestone/sysconfig
-instance_refresh network/inetd:default
-instance_refresh svc:/milestone/multi-user:default
-
-prophist_delete_dependency svc:/network/inetd-upgrade network
-prophist_adddep svc:/network/inetd-upgrade filesystem \
-    service require_all error svc:/system/filesystem/local
-instance_refresh svc:/network/inetd-upgrade:default
-instance_clear svc:/network/inetd:default
-
-prophist_adddep svc:/network/ipfilter filesystem service require_all none \
-    svc:/system/filesystem/usr
-instance_refresh svc:/network/ipfilter:default
-
-prophist_delete_dependency network/dhcp-server milestone
-prophist_delete_dependency network/dhcp-server:default milestone
-prophist_adddep svc:/network/dhcp-server multi-user service require_all \
-    refresh svc:/milestone/multi-user
-prophist_adddpt svc:/network/dhcp-server dhcp_multi-user-server \
-    optional_all none svc:/milestone/multi-user-server
-instance_refresh network/dhcp-server:default
-instance_refresh svc:/milestone/multi-user-server:default
-instance_clear network/dhcp-server:default
-instance_clear milestone/multi-user:default
-instance_clear milestone/multi-user-server:default
-
-prophist_delete_dependency network/dns/client physical
-prophist_adddep svc:/network/dns/client network service optional_all error \
-    svc:/milestone/network
-instance_refresh network/dns/client:default
-
-prophist_upgrade network/ldap/client start timeout_seconds 120 60 30
-prophist_upgrade network/ldap/client stop timeout_seconds 60 10
-
-prophist_adddep svc:/network/nfs/cbd filesystem-minimal \
-    service require_all error svc:/system/filesystem/minimal
-prophist_addprop svc:/network/nfs/cbd application framework stability \
-    astring: Evolving
-prophist_addprop svc:/network/nfs/cbd application framework auto_enable \
-    boolean: true
-prophist_override network/nfs/cbd network entities "svc:/milestone/network"
-instance_refresh svc:/network/nfs/cbd
-
-prophist_adddep svc:/network/nfs/client nlockmgr service require_all error \
-    svc:/network/nfs/nlockmgr
-prophist_adddep svc:/network/nfs/client cbd service optional_all error \
-    svc:/network/nfs/cbd
-prophist_adddep svc:/network/nfs/client mapid service optional_all error \
-    svc:/network/nfs/mapid
-prophist_upgrade network/nfs/client start timeout_seconds 3600 60
-prophist_adddpt svc:/network/nfs/client nfs-client_multi-user \
-    optional_all none svc:/milestone/multi-user
-prophist_override network/nfs/client network entities "svc:/milestone/network"
-prophist_upgrade network/nfs/client stop timeout_seconds 60 600
-instance_refresh svc:/network/nfs/client:default
-instance_refresh svc:/milestone/multi-user:default
-
-prophist_adddep svc:/network/nfs/mapid filesystem-minimal \
-    service require_all error svc:/system/filesystem/minimal
-prophist_addprop svc:/network/nfs/mapid application framework stability \
-    astring: Evolving
-prophist_addprop svc:/network/nfs/mapid application framework auto_enable \
-    boolean: true
-prophist_override network/nfs/mapid network entities "svc:/milestone/network"
-instance_refresh svc:/network/nfs/mapid:default
-
-prophist_adddep svc:/network/nfs/nlockmgr filesystem-minimal \
-    service require_all error svc:/system/filesystem/minimal
-prophist_addprop svc:/network/nfs/nlockmgr application framework stability \
-    astring: Evolving
-prophist_addprop svc:/network/nfs/nlockmgr application framework auto_enable \
-    boolean: true
-prophist_override network/nfs/nlockmgr network entities "svc:/milestone/network"
-instance_refresh svc:/network/nfs/nlockmgr:default
-
-prophist_addprop svc:/network/nfs/rquota inetd framework proto \
-    astring: datagram_v
-prophist_addprop svc:/network/nfs/rquota application framework stability \
-    astring: Evolving
-prophist_addprop svc:/network/nfs/rquota application framework auto_enable \
-    boolean: true
-instance_refresh svc:/network/nfs/rquota:default
-
-prophist_adddep svc:/network/nfs/server nlockmgr service require_all error \
-    svc:/network/nfs/nlockmgr
-prophist_adddep svc:/network/nfs/server mapid service optional_all error \
-    svc:/network/nfs/mapid
-prophist_upgrade network/nfs/server start timeout_seconds 3600 60
-prophist_upgrade network/nfs/server stop timeout_seconds 3600 60
-prophist_adddpt svc:/network/nfs/server nfs-server_multi-user-server \
-    optional_all none svc:/milestone/multi-user-server
-prophist_addprop svc:/network/nfs/server application framework stability \
-    astring: Evolving
-prophist_addprop svc:/network/nfs/server application framework auto_enable \
-    boolean: true
-prophist_override network/nfs/server network entities "svc:/milestone/network"
-prophist_upgrade network/nfs/server stop exec \
-    "/lib/svc/method/nfs-server %m %{restarter/contract}" \
-    "/lib/svc/method/nfs-server %m"
-instance_refresh svc:/network/nfs/server:default
-instance_refresh svc:/milestone/multi-user-server:default
-
-prophist_adddep svc:/network/nfs/status filesystem-local service require_all \
-    error svc:/system/filesystem/local
-prophist_addprop svc:/network/nfs/status application framework stability \
-    astring: Evolving
-prophist_addprop svc:/network/nfs/status application framework auto_enable \
-    boolean: true
-prophist_override network/nfs/status network entities "svc:/milestone/network"
-instance_refresh svc:/network/nfs/status:default
-
-prophist_upgrade network/nis/client start timeout_seconds 300 30 3
-prophist_upgrade network/nis/client stop timeout_seconds 60 30 3
-prophist_upgrade network/nis/client start exec \
-    /lib/svc/method/yp "/usr/lib/netsvc/yp/ypstart client"
-prophist_upgrade network/nis/client yp_server grouping \
-    optional_all exclude_all
-instance_refresh svc:/network/nis/client:default
-instance_clear svc:/network/nis/client:default
-
-prophist_upgrade svc:/network/nis/server start exec /lib/svc/method/yp \
-    "/usr/lib/netsvc/yp/ypstart server"
-prophist_upgrade network/nis/server start timeout_seconds 300 30 3
-prophist_upgrade network/nis/server stop timeout_seconds 60 30 3
-instance_refresh svc:/network/nis/server:default
-
-prophist_upgrade network/ntp start timeout_seconds 1800 6
-prophist_upgrade network/ntp stop timeout_seconds 60 3
-prophist_upgrade network/ntp start exec "/lib/svc/method/xntp" \
-    "/lib/svc/method/xntp start"
-prophist_upgrade network/ntp stop exec ":kill" \
-    "/lib/svc/method/xntp stop"
-/usr/sbin/svccfg -s network/ntp delpropvalue paths/entities \
-    "file://localhost/etc/inet/ntp.conf"
-prophist_adddpt svc:/network/ntp ntp_multi-user optional_all none \
-    svc:/milestone/multi-user
-instance_refresh svc:/network/ntp:default
-instance_refresh svc:/milestone/multi-user:default
-
-prophist_upgrade network/rarp start timeout_seconds 60 3
-prophist_upgrade network/rarp stop timeout_seconds 60 3
-prophist_adddpt svc:/network/rarp rarp_multi-user-server optional_all none \
-    svc:/milestone/multi-user-server
-prophist_delete_dependency network/rarp physical
-prophist_adddep svc:/network/rarp network service optional_all error \
-    svc:/milestone/network
-instance_refresh network/rarp:default
-instance_refresh svc:/milestone/multi-user-server:default
-
-prophist_delete_dependency svc:/network/rpc/bind refresh
-prophist_upgrade network/rpc/bind stop exec \
-    "/lib/svc/method/rpc-bind %m %{restarter/contract}" \
-    "/lib/svc/method/rpc-bind %m"
-instance_refresh network/rpc/bind:default
-
-prophist_upgrade network/rpc/bootparams start timeout_seconds 60 3
-prophist_upgrade network/rpc/bootparams stop timeout_seconds 60 3
-prophist_upgrade network/rpc/bootparams rpcbind restart_on restart error
-prophist_delete_dependency network/rpc/bootparams physical
-prophist_adddpt svc:/network/rpc/bootparams rpc-bootparams_multi-user-server \
-    optional_all none svc:/milestone/multi-user-server
-prophist_adddep svc:/network/rpc/bootparams network service require_all none \
-    svc:/milestone/network
-instance_refresh network/rpc/bootparams:default
-instance_refresh svc:/milestone/multi-user-server:default
-
-/usr/sbin/svcadm disable network/rpc/gss:ticotsord
-/usr/sbin/svccfg delete network/rpc/gss:ticotsord
-prophist_override network/rpc/gss inetd_start privileges \
-    "basic,!file_link_any,!proc_info,!proc_session,net_privaddr,file_chown,file_dac_read,file_dac_write"
-instance_refresh svc:/network/rpc/gss:default
-
-/usr/sbin/svcadm disable network/rpc/mdcomm:tcp6
-/usr/sbin/svcadm disable network/rpc/mdcomm:tcp
-/usr/sbin/svccfg delete network/rpc/mdcomm:tcp6
-/usr/sbin/svccfg delete network/rpc/mdcomm:tcp
-prophist_addprop svc:/network/rpc/mdcomm inetd framework proto astring: tcp
-prophist_override network/rpc/mdcomm inetd proto tcp
-instance_refresh svc:/network/rpc/mdcomm:default
-
-/usr/sbin/svcadm disable network/rpc/meta:tcp6
-/usr/sbin/svcadm disable network/rpc/meta:tcp
-/usr/sbin/svccfg delete network/rpc/meta:tcp6
-/usr/sbin/svccfg delete network/rpc/meta:tcp
-prophist_addprop svc:/network/rpc/meta inetd framework proto astring: tcp
-prophist_override network/rpc/meta inetd proto tcp
-instance_refresh svc:/network/rpc/meta:default
-
-/usr/sbin/svcadm disable network/rpc/metamed:tcp6
-/usr/sbin/svcadm disable network/rpc/metamed:tcp
-/usr/sbin/svccfg delete network/rpc/metamed:tcp6
-/usr/sbin/svccfg delete network/rpc/metamed:tcp
-prophist_addprop svc:/network/rpc/metamed inetd framework proto astring: tcp
-prophist_override network/rpc/metamed inetd proto tcp
-instance_refresh svc:/network/rpc/metamed:default
-
-/usr/sbin/svcadm disable network/rpc/metamh:tcp6
-/usr/sbin/svcadm disable network/rpc/metamh:tcp
-/usr/sbin/svccfg delete network/rpc/metamh:tcp6
-/usr/sbin/svccfg delete network/rpc/metamh:tcp
-prophist_addprop svc:/network/rpc/metamh inetd framework proto astring: tcp
-prophist_override network/rpc/metamh inetd proto tcp
-instance_refresh svc:/network/rpc/metamh:default
-
-prophist_upgrade network/security/kadmin start timeout_seconds 60 30
-prophist_upgrade network/security/kadmin stop timeout_seconds 60 30
-if /usr/bin/svcprop -Cqp start/use_profile svc:/network/security/kadmin; then
-	prophist_override network/security/kadmin start privileges \
-	    "basic,!file_link_any,!proc_info,!proc_session,net_privaddr,proc_audit,file_dac_write"
-else
-	/usr/sbin/svccfg -s svc:/network/security/kadmin <<END
-	    setprop start/working_directory = astring: :default
-	    setprop start/project = astring: :default
-	    setprop start/resource_pool = astring: :default
-	    setprop start/use_profile = boolean: false
-	    setprop start/user = astring: root
-	    setprop start/group = astring: root
-	    setprop start/supp_groups = astring: :default
-	    setprop start/privileges = astring: \
-	        basic,!file_link_any,!proc_info,!proc_session,net_privaddr,proc_audit,file_dac_write
-	    setprop start/limit_privileges = astring: :default
-END
-fi
-instance_refresh svc:/network/security/kadmin:default
-
-prophist_upgrade network/security/krb5kdc start timeout_seconds 60 30
-prophist_upgrade network/security/krb5kdc stop timeout_seconds 60 30
-if /usr/bin/svcprop -Cqp start/use_profile svc:/network/security/krb5kdc; then
-	prophist_override network/security/krb5kdc start privileges \
-	 "basic,!file_link_any,!proc_info,!proc_session,net_privaddr,proc_audit"
-else
-	/usr/sbin/svccfg -s svc:/network/security/krb5kdc <<END
-	    setprop start/working_directory = astring: :default
-	    setprop start/project = astring: :default
-	    setprop start/resource_pool = astring: :default
-	    setprop start/use_profile = boolean: false
-	    setprop start/user = astring: root
-	    setprop start/group = astring: root
-	    setprop start/supp_groups = astring: :default
-	    setprop start/privileges = astring: \
-	   basic,!file_link_any,!proc_info,!proc_session,net_privaddr,proc_audit
-	    setprop start/limit_privileges = astring: :default
-END
-fi
-instance_refresh svc:/network/security/krb5kdc:default
-
-if svcprop -q svc:/network/security/krb5_prop:tcp; then
-	/usr/sbin/svcadm disable svc:/network/security/krb5_prop:tcp
-	sleep 1
-	/usr/sbin/svccfg delete -f svc:/network/security/krb5_prop:tcp
-fi
-prophist_override network/security/krb5_prop inetd_start privileges \
-    "basic,!file_link_any,!proc_info,!proc_session"
-prophist_addprop svc:/network/security/krb5_prop inetd framework proto \
-    astring: tcp
-instance_refresh svc:/network/security/krb5_prop:default
-
-if svcprop -q svc:/network/security/ktkt_warn:ticotsord; then
-	/usr/sbin/svcadm disable svc:/network/security/ktkt_warn:ticotsord
-	sleep 1
-	/usr/sbin/svccfg delete -f svc:/network/security/ktkt_warn:ticotsord
-fi
-prophist_override network/security/ktkt_warn inetd_start privileges \
-    "basic,!file_link_any,!proc_info,!proc_session,proc_setid"
-prophist_addprop svc:/network/security/ktkt_warn inetd framework proto \
-    astring: ticotsord
-instance_refresh svc:/network/security/ktkt_warn:default
-
-prophist_addprop svc:/network/shell inetd framework proto \
-    astring: '("tcp" "tcp6only")'
-prophist_delete_dependency network/shell physical
-prophist_adddep svc:/network/shell network service optional_all error \
-    svc:/milestone/network
-instance_refresh network/shell:default
-instance_refresh network/shell:kshell
-
-prophist_upgrade network/slp start timeout_seconds 60 6
-prophist_upgrade network/slp stop timeout_seconds 60 3
-prophist_upgrade network/slp stop exec \
-    "/lib/svc/method/slp stop %{restarter/contract}" \
-    "/lib/svc/method/slp stop"
-prophist_delete_dependency network/slp physical
-prophist_adddep svc:/network/slp network service optional_all error \
-    svc:/milestone/network
-prophist_upgrade network/slp milestone entities \
-    svc:/milestone/sysconfig svc:/milestone/single-user
-instance_refresh network/slp:default
-
-prophist_upgrade network/smtp:sendmail start timeout_seconds 120 60 30
-prophist_upgrade network/smtp:sendmail stop timeout_seconds 60 30
-prophist_upgrade network/smtp:sendmail stop exec \
-   "/lib/svc/method/smtp-sendmail stop %{restarter/contract}" \
-   "/lib/svc/method/smtp-sendmail stop"
-prophist_upgrade network/smtp:sendmail refresh timeout_seconds 60 10
-prophist_upgrade network/smtp identity grouping optional_all require_all
-prophist_delete_pg svc:/network/smtp config-file
-prophist_adddep svc:/network/smtp:sendmail config-file \
-    path require_all refresh file://localhost/etc/mail/sendmail.cf
-prophist_delete_pg svc:/network/smtp nsswitch
-prophist_adddep svc:/network/smtp:sendmail nsswitch \
-    path require_all refresh file://localhost/etc/nsswitch.conf
-prophist_delete_pg svc:/network/smtp autofs
-prophist_adddep svc:/network/smtp:sendmail autofs service optional_all none \
-    svc:/system/filesystem/autofs
-prophist_delete_pg svc:/network/smtp start
-prophist_addmeth svc:/network/smtp:sendmail start \
-    "/lib/svc/method/smtp-sendmail start" 120
-prophist_delete_pg svc:/network/smtp stop
-prophist_addmeth svc:/network/smtp:sendmail stop \
-    "/lib/svc/method/smtp-sendmail stop" 60
-prophist_delete_pg svc:/network/smtp refresh
-prophist_addmeth svc:/network/smtp:sendmail refresh \
-    "/lib/svc/method/smtp-sendmail refresh" 60
-prophist_delete_svc_pg network/smtp    sendmail tm_common_name
-prophist_delete_svc_pg network/smtp    sendmail tm_man_sendmail
-prophist_adddpt svc:/network/smtp:sendmail smtp-sendmail_multi-user \
-    optional_all none svc:/milestone/multi-user
-prophist_addprop svc:/network/smtp:sendmail startd framework ignore_error \
-    astring: core,signal
-prophist_addprop svc:/network/smtp:sendmail general framework \
-    action_authorization astring: solaris.smf.manage.sendmail
-instance_refresh network/smtp:sendmail
-instance_refresh svc:/milestone/multi-user:default
-
-prophist_upgrade network/ssh start timeout_seconds 60 30
-prophist_upgrade network/ssh stop timeout_seconds 60 30
-prophist_upgrade network/ssh refresh timeout_seconds 60 30
-prophist_adddpt svc:/network/ssh ssh_multi-user-server optional_all none \
-    svc:/milestone/multi-user-server
-prophist_adddep svc:/network/ssh fs-local service require_all none \
-    svc:/system/filesystem/local
-prophist_adddep svc:/network/ssh fs-autofs service optional_all none \
-    svc:/system/filesystem/autofs
-prophist_adddep svc:/network/ssh net-loopback service require_all none \
-    svc:/network/loopback
-prophist_adddep svc:/network/ssh net-physical service require_all none \
-    svc:/network/physical
-prophist_adddep svc:/network/ssh utmp service require_all none \
-    svc:/system/utmp
-prophist_addprop svc:/network/ssh general framework action_authorization \
-    astring: solaris.smf.manage.ssh
-instance_refresh svc:/network/ssh:default
-instance_refresh svc:/milestone/multi-user-server:default
-
-# Add inetd_offline methods for some services
-for svc in chargen comsat daytime discard echo nfs/rquota rpc/gss rpc/rex \
-    rpc/ocfserv rpc/rstat rpc/rusers rpc/smserver rpc/spray rpc/wall \
-    security/ktkt_warn talk time; do
-	prophist_addmeth svc:/network/$svc inetd_offline :kill_process 0
-	instance_refresh svc:/network/$svc:default
-done
-
-# application/
-
-prophist_adddep svc:/application/print/cleanup filesystem \
-    service require_all none svc:/system/filesystem/minimal
-prophist_upgrade application/print/cleanup start timeout_seconds 60 10
-prophist_upgrade application/print/cleanup stop timeout_seconds 0 5 -- -1
-instance_refresh svc:/application/print/cleanup:default
-
-prophist_adddep svc:/application/print/server filesystem \
-    service require_all none svc:/system/filesystem/usr
-if /usr/bin/svcprop -Cqp lpsched svc:/application/print/server; then :; else
-	/usr/sbin/svccfg -s svc:/application/print/server <<END
-	    addpg lpsched framework
-	    setprop lpsched/num_notifiers = count: 0
-	    setprop lpsched/num_filters = count: 0
-	    setprop lpsched/fd_limit = count: 0
-	    setprop lpsched/reserved_fds = count: 0
-END
-fi
-prophist_upgrade application/print/server start timeout_seconds 60 10
-prophist_upgrade application/print/server stop timeout_seconds 60 5
-prophist_adddpt svc:/application/print/server print-server_multi-user \
-    optional_all none svc:/milestone/multi-user
-prophist_addprop svc:/application/print/server general framework \
-    single_instance boolean: true
-prophist_adddep svc:/application/print/server fs-local service require_all \
-    none svc:/system/filesystem/local
-prophist_adddep svc:/application/print/server identity service require_all \
-    refresh svc:/system/identity:domain
-prophist_adddep svc:/application/print/server system-log service optional_all \
-    none svc:/system/system-log
-instance_refresh svc:/application/print/server:default
-
-# platform/
-
-if [ "`/usr/bin/uname -p`" = "i386" ]; then
-	# /i86pc/
-	prophist_upgrade platform/i86pc/eeprom start timeout_seconds 60 6
-
-	prophist_delete_dependency platform/i86pc/kdmconfig kdmconfig_console
-	prophist_delete_dependency system/console-login kdmconfig_console
-	instance_refresh platform/i86pc/kdmconfig
-else
-	# ! /i86pc/
-	prophist_upgrade system/cvc start timeout_seconds 60 5
-	prophist_upgrade system/cvc stop timeout_seconds 60 0
-
-	prophist_addprop svc:/platform/sun4u/dcs inetd framework proto \
-	    astring: '("tcp" "tcp6only")'
-	prophist_addmeth svc:/platform/sun4u/dcs inetd_offline :kill_process 0
-	instance_refresh svc:/platform/sun4u/dcs:default
-
-	prophist_adddep svc:/platform/sun4u/mpxio-upgrade metainit \
-	    service optional_all none svc:/system/metainit
-	instance_refresh svc:/platform/sun4u/mpxio-upgrade:default
-
-	prophist_upgrade platform/sun4u/sf880drd start timeout_seconds \
-	    60 3
-	prophist_upgrade platform/sun4u/sf880drd stop timeout_seconds \
-	    60 3
-	prophist_upgrade platform/sun4u/sf880drd milestone entities \
-	    svc:/milestone/sysconfig svc:/milestone/single-user
-	instance_refresh platform/sun4u/sf880drd
-fi
--- a/usr/src/cmd/svc/prophist/prophist.c	Thu Mar 25 13:21:39 2010 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,536 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * 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 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * prophist - property history utility
- *
- * 1.  Description
- *
- * During the development of smf(5), a set of service manifests were delivered
- * that required subsequent changes.  The bulk of these changes are in ON,
- * although additional consolidations may possess one or two manifests that are
- * affected.  These incorrect values need to be smoothed into a correct
- * configuration surface for subsequent automatic merge technology to be
- * introduced safely.  The mechanism is the combination of this utility with a
- * set of "property history" files.
- *
- * /var/svc/profile/prophist.SUNWcsr is delivered as an immutable file by the
- * SUNWcsr packages.  prophist.SUNWcsr covers the entire ON consolidation, for
- * the purposes of collecting in one place what is essentially a temporary
- * construct.  Other consolidations should deliver /var/svc/profile/prophist.*
- * files.
- *
- * The processing of the property history files occurs in
- * svc:/system/manifest-import:default.  Each prophist.* file is checked against
- * its hashed value in smf/manifest using the "hash" subcommand.  If a change is
- * detected, the prophist.* file is sourced.  These operations are carried out
- * prior to any manifest being imported.
- *
- * 2.  Interface
- *
- * prophist presents a subcommand style interface, with various suboptions to
- * each subcommand:
- *
- * prophist delete -e FMRI -g pg [-p prop]
- * prophist upgrade -e FMRI -g pg -p prop -n newval oldval ...
- * prophist overwrite -e FMRI -g pg -p prop -n newval
- * prophist hash file
- *
- * The hash subcommand signals that a file requires processing using an exit
- * status of 3.  Otherwise, exit statuses of 0, 1, and 2 have their conventional
- * meaning.
- *
- * 3.  Limitations
- *
- * The present implementation has no support for multiply-valued properties.
- * Manipulation of such properties should be done using a svccfg(1M) invocation
- * in the appropriate prophist.* file.
- */
-
-#include <sys/types.h>
-
-#include <assert.h>
-#include <libintl.h>
-#include <libscf.h>
-#include <libscf_priv.h>
-#include <libuutil.h>
-#include <locale.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <strings.h>
-#include <unistd.h>
-
-#include <manifest_hash.h>
-
-#define	OPTIONS_STR	"e:g:n:p:"
-
-static int o_delete;
-static int o_hash;
-static int o_overwrite;
-
-static char *entity;
-static char *pgrp_name;
-static char *prop_name;
-static char *new_value;
-
-static scf_handle_t *hndl;
-static scf_service_t *svc;
-static scf_instance_t *inst;
-static scf_snapshot_t *snap;
-static scf_snaplevel_t *level;
-static scf_propertygroup_t *pg;
-static scf_property_t *prop;
-static scf_value_t *value;
-static scf_iter_t *iter;
-static scf_transaction_t *tx;
-static scf_transaction_entry_t *entry;
-
-static scf_type_t ptype;
-
-static char *valbuf;
-static ssize_t valbuf_sz;
-
-#define	LG_BUFSIZ	1024		/* larger than a property name */
-static char namebuf[LG_BUFSIZ];
-
-static void
-usage()
-{
-	(void) fprintf(stderr, gettext(
-	    "Usage:"
-	    "\tprophist hash file\n"
-	    "\tprophist delete -e FMRI -g pg [-p prop]\n"
-	    "\tprophist overwrite -e FMRI -g pg -p prop -n newval\n"
-	    "\tprophist upgrade -e FMRI -g pg -p prop -n newval oldval "
-	    "...\n"));
-	exit(UU_EXIT_USAGE);
-}
-
-static void
-ready_scf_objects()
-{
-	if ((hndl = scf_handle_create(SCF_VERSION)) == NULL)
-		uu_die(gettext("handle creation failed: %s\n"),
-		    scf_strerror(scf_error()));
-
-	if (scf_handle_bind(hndl) != 0)
-		uu_die(gettext("handle bind failed: %s\n"),
-		    scf_strerror(scf_error()));
-
-	svc = scf_service_create(hndl);
-	inst = scf_instance_create(hndl);
-	snap = scf_snapshot_create(hndl);
-	level = scf_snaplevel_create(hndl);
-	pg = scf_pg_create(hndl);
-	prop = scf_property_create(hndl);
-	value = scf_value_create(hndl);
-	iter = scf_iter_create(hndl);
-	tx = scf_transaction_create(hndl);
-	entry = scf_entry_create(hndl);
-
-	if (svc == NULL ||
-	    inst == NULL ||
-	    snap == NULL ||
-	    level == NULL ||
-	    pg == NULL ||
-	    prop == NULL ||
-	    value == NULL ||
-	    iter == NULL ||
-	    tx == NULL ||
-	    entry == NULL)
-		uu_die(gettext("object creation failed: %s\n"),
-		    scf_strerror(scf_error()));
-
-	valbuf_sz = 4096;
-	valbuf = malloc(valbuf_sz);
-	if (valbuf == NULL)
-		uu_die(gettext("value buffer allocation failed"));
-}
-
-static int
-hash(char *arg)
-{
-	char *pname;
-	char *errstr;
-	int ret;
-	uchar_t hash[MHASH_SIZE];
-
-	ready_scf_objects();
-
-	switch (ret = mhash_test_file(hndl, arg, 0, &pname, hash)) {
-	case MHASH_RECONCILED:
-		/* Equivalent hash already stored. */
-		return (0);
-	case MHASH_NEWFILE:
-		/* Hash differs. */
-		break;
-	case MHASH_FAILURE:
-		uu_die(gettext("mhash_test_file() failed"));
-	default:
-		uu_die(gettext("unknown return value (%d) from "
-		    "mhash_test_file()"), ret);
-	}
-
-	if (mhash_store_entry(hndl, pname, arg, hash, &errstr)) {
-		if (errstr)
-			uu_die(errstr);
-		else
-			uu_die(gettext("Unknown error from "
-			    "mhash_store_entry()\n"));
-	}
-
-	return (3);
-}
-
-static int
-delete_prop(scf_propertygroup_t *pg, char *prop_name)
-{
-	if (scf_transaction_start(tx, pg) != 0)
-		uu_die(gettext("transaction start failed: %s\n"),
-		    scf_strerror(scf_error()));
-	if (scf_transaction_property_delete(tx, entry, prop_name) != 0)
-		uu_die(gettext("transaction property delete failed: %s\n"),
-		    scf_strerror(scf_error()));
-	if (scf_transaction_commit(tx) != 1)
-		return (1);
-
-	return (0);
-}
-
-/*
- * Returns 1 if target property group or property not found.
- */
-static int
-delete_pg_or_prop(scf_iter_t *pg_iter, char *pgrp_name, char *prop_name)
-{
-	while (scf_iter_next_pg(pg_iter, pg) > 0) {
-		if (scf_pg_get_name(pg, namebuf, LG_BUFSIZ) == -1)
-			continue;
-
-		if (strcmp(namebuf, pgrp_name) != 0)
-			continue;
-
-		if (prop_name != NULL)
-			return (delete_prop(pg, prop_name));
-
-		if (scf_pg_delete(pg) != 0)
-			uu_die(gettext("property group delete failed: %s\n"),
-			    scf_strerror(scf_error()));
-
-		return (0);
-	}
-
-	return (1);
-}
-
-/*
- * Remove property group or property from both service and instance.
- */
-static int
-delete(char *entity, char *pgrp_name, char *prop_name)
-{
-	ready_scf_objects();
-
-	if (scf_handle_decode_fmri(hndl, entity, NULL, svc, inst, NULL, NULL,
-	    SCF_DECODE_FMRI_EXACT) == 0) {
-		(void) scf_iter_instance_pgs(iter, inst);
-		return (delete_pg_or_prop(iter, pgrp_name, prop_name));
-	}
-
-	if (scf_handle_decode_fmri(hndl, entity, NULL, svc, NULL, NULL,
-	    NULL, SCF_DECODE_FMRI_EXACT) == 0) {
-		(void) scf_iter_service_pgs(iter, svc);
-		return (delete_pg_or_prop(iter, pgrp_name, prop_name));
-	}
-
-	uu_die(gettext("%s not decoded: %s\n"), entity,
-	    scf_strerror(scf_error()));
-
-	/*NOTREACHED*/
-}
-
-static void
-replace_value(scf_propertygroup_t *pg, char *prop_name, char *new_value)
-{
-	int result;
-	int ret;
-
-	do {
-		if (scf_pg_update(pg) == -1)
-			uu_die(gettext("property group update failed: %s\n"),
-			    scf_strerror(scf_error()));
-		if (scf_transaction_start(tx, pg) != SCF_SUCCESS) {
-			if (scf_error() == SCF_ERROR_PERMISSION_DENIED)
-				uu_die(gettext("permission denied\n"));
-
-			uu_die(gettext("transaction start failed: %s\n"),
-			    scf_strerror(scf_error()));
-		}
-
-		ret = scf_pg_get_property(pg, prop_name, prop);
-		if (ret == SCF_SUCCESS) {
-			if (scf_property_type(prop, &ptype) != SCF_SUCCESS)
-				uu_die(gettext("couldn't get property type\n"));
-			if (scf_transaction_property_change_type(tx, entry,
-			    prop_name, ptype) == -1)
-				uu_die(gettext("couldn't change entry\n"));
-		} else if (scf_error() == SCF_ERROR_INVALID_ARGUMENT) {
-			uu_die(gettext("illegal property name\n"));
-		} else {
-			uu_die(gettext("property fetch failed\n"));
-		}
-
-		if (scf_value_set_from_string(value, ptype,
-		    (const char *)new_value) != 0) {
-			assert(scf_error() == SCF_ERROR_INVALID_ARGUMENT);
-			uu_die(gettext("Invalid \"%s\" value \"%s\".\n"),
-			    scf_type_to_string(ptype), new_value);
-		}
-
-		ret = scf_entry_add_value(entry, value);
-		if (ret != SCF_SUCCESS)
-			uu_die(gettext("scf_entry_add_value failed: %s\n"),
-			    scf_strerror(scf_error()));
-
-		assert(ret == SCF_SUCCESS);
-
-		result = scf_transaction_commit(tx);
-
-		scf_transaction_reset(tx);
-		scf_entry_destroy_children(entry);
-	} while (result == 0);
-
-	if (result < 0) {
-		if (scf_error() != SCF_ERROR_PERMISSION_DENIED)
-			uu_die(gettext("transaction commit failed: %s\n"),
-			    scf_strerror(scf_error()));
-
-		uu_die(gettext("permission denied\n"));
-	}
-}
-
-static scf_propertygroup_t *
-get_pg(char *entity, char *pgrp_name, char *prop_name)
-{
-	scf_propertygroup_t *targetpg;
-
-	ready_scf_objects();
-
-	if (scf_handle_decode_fmri(hndl, entity, NULL, svc, inst, NULL, NULL,
-	    SCF_DECODE_FMRI_EXACT) == 0) {
-		/*
-		 * 1.  Working at the instance level.  The instance level
-		 * contains one special case:  general/enabled is active in the
-		 * current version, and its value in snapshots is not relevant.
-		 * Otherwise, pull from running snapshot.
-		 */
-		if (strcmp(pgrp_name, "general") == 0 &&
-		    strcmp(prop_name, "enabled") == 0) {
-			if (scf_instance_get_pg(inst, pgrp_name, pg) == 0)
-				return (pg);
-
-			uu_die(gettext("property group %s not available: %s\n"),
-			    pgrp_name, scf_strerror(scf_error()));
-		}
-
-		if (scf_instance_get_snapshot(inst, "running", snap) == -1) {
-			if (scf_instance_get_pg(inst, pgrp_name, pg) == 0)
-				return (pg);
-
-			uu_die(gettext("property group %s not available: %s\n"),
-			    pgrp_name, scf_strerror(scf_error()));
-		}
-
-		if (scf_snapshot_get_base_snaplevel(snap, level) != 0)
-			uu_die(gettext("base snaplevel not available: %s\n"),
-			    scf_strerror(scf_error()));
-
-		if (scf_snaplevel_get_pg(level, pgrp_name, pg) == -1)
-			uu_die(gettext("property group %s not available: %s\n"),
-			    pgrp_name, scf_strerror(scf_error()));
-
-		targetpg = scf_pg_create(hndl);
-		if (scf_instance_get_pg(inst, pgrp_name, targetpg) == -1)
-			uu_die(gettext("property group %s not available: %s\n"),
-			    pgrp_name, scf_strerror(scf_error()));
-
-		return (targetpg);
-	}
-
-	if (scf_handle_decode_fmri(hndl, entity, NULL, svc, NULL, NULL,
-	    NULL, SCF_DECODE_FMRI_EXACT) == 0) {
-		/*
-		 * 2.  Working at the service level.
-		 */
-		if (scf_service_get_pg(svc, pgrp_name, pg) == 0)
-			return (pg);
-
-		uu_die(gettext("property group %s not available: %s\n"),
-		    pgrp_name, scf_strerror(scf_error()));
-	}
-
-	/*
-	 * 3.  Cannot decode either instance or service exactly.
-	 */
-	uu_die(gettext("%s not decoded: %s\n"), entity,
-	    scf_strerror(scf_error()));
-
-	/*NOTREACHED*/
-}
-
-static int
-upgrade(char *entity, char *pgrp_name, char *prop_name, char *new_value,
-    int argc, char *argv[], int optind)
-{
-	int replace = 0;
-	int vals = 0;
-	scf_propertygroup_t *targetpg;
-
-	targetpg = get_pg(entity, pgrp_name, prop_name);
-
-	if (scf_pg_get_property(targetpg, prop_name, prop) != 0)
-		uu_die(gettext("property %s/%s not available: %s\n"), pgrp_name,
-		    prop_name, scf_strerror(scf_error()));
-
-	if (scf_iter_property_values(iter, prop) != 0)
-		uu_die(gettext("could not establish value iterator: %s\n"),
-		    scf_strerror(scf_error()));
-
-	while (scf_iter_next_value(iter, value) == 1) {
-		if (scf_value_get_as_string(value, valbuf, valbuf_sz) < 0)
-			uu_die(gettext("string value get failed: %s\n"),
-			    scf_strerror(scf_error()));
-
-		for (; optind < argc; optind++)
-			if (strcmp(valbuf, argv[optind]) == 0) {
-				replace = 1;
-				break;
-			}
-
-		vals++;
-		if (vals > 1)
-			uu_die(gettext("too many values to upgrade\n"));
-	}
-
-	if (replace)
-		replace_value(targetpg, prop_name, new_value);
-
-	return (0);
-}
-
-static int
-overwrite(char *entity, char *pgrp_name, char *prop_name, char *new_value)
-{
-	scf_propertygroup_t *targetpg;
-
-	targetpg = get_pg(entity, pgrp_name, prop_name);
-
-	if (scf_pg_get_property(targetpg, prop_name, prop) != 0)
-		uu_die(gettext("property %s/%s not available: %s\n"), pgrp_name,
-		    prop_name, scf_strerror(scf_error()));
-
-	replace_value(targetpg, prop_name, new_value);
-
-	return (0);
-}
-
-int
-main(int argc, char *argv[])
-{
-	int c;
-
-	if (argc < 2)
-		usage();
-
-	if (strcmp(argv[1], "hash") == 0)
-		o_hash = 1;
-	else if (strcmp(argv[1], "delete") == 0)
-		o_delete = 1;
-	else if (strcmp(argv[1], "overwrite") == 0)
-		o_overwrite = 1;
-	else if (strcmp(argv[1], "upgrade") != 0)
-		usage();
-
-	(void) uu_setpname(argv[0]);
-
-	argv++;
-	argc--;
-
-	while ((c = getopt(argc, argv, OPTIONS_STR)) != EOF) {
-		switch (c) {
-		case 'e':
-			entity = optarg;
-			break;
-		case 'g':
-			pgrp_name = optarg;
-			break;
-		case 'n':
-			new_value = optarg;
-			break;
-		case 'p':
-			prop_name = optarg;
-			break;
-		case '?':
-		default:
-			usage();
-			break;
-		}
-	}
-
-	if (o_hash) {
-		if (entity != NULL ||
-		    pgrp_name != NULL ||
-		    prop_name != NULL ||
-		    new_value != NULL)
-			usage();
-
-		return (hash(argv[optind]));
-	}
-
-	if (entity == NULL)
-		usage();
-
-	if (o_delete) {
-		if (pgrp_name == NULL ||
-		    new_value != NULL ||
-		    optind < argc)
-			usage();
-
-		return (delete(entity, pgrp_name, prop_name));
-	}
-
-	if (pgrp_name == NULL || prop_name == NULL || new_value == NULL)
-		usage();
-
-	if (o_overwrite)
-		return (overwrite(entity, pgrp_name, prop_name, new_value));
-
-	if (optind >= argc)
-		usage();
-
-	return (upgrade(entity, pgrp_name, prop_name, new_value, argc, argv,
-	    optind));
-}
--- a/usr/src/cmd/svc/shell/Makefile	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/svc/shell/Makefile	Thu Mar 25 14:57:35 2010 -0700
@@ -18,7 +18,7 @@
 #
 # CDDL HEADER END
 #
-# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 
 include ../../Makefile.cmd
@@ -32,8 +32,7 @@
 	routing_include.sh \
 	sendmail_include.sh \
 	smf_include.sh \
-	mfsthistory \
-	manifest_cleanup.ksh
+	mfsthistory
 
 SCRIPTS = $(SRCS:%=$(ROOT)/lib/svc/share/%)
 
--- a/usr/src/cmd/svc/shell/manifest_cleanup.ksh	Thu Mar 25 13:21:39 2010 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,501 +0,0 @@
-#!/bin/ksh
-#
-# CDDL HEADER START
-#
-# 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 2009 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-
-[ -f /lib/svc/share/smf_include.sh ] || exit 1
-
-. /lib/svc/share/smf_include.sh
-
-SVCADM=/usr/sbin/svcadm
-SVCCFG=/usr/sbin/svccfg
-SVCPROP=/bin/svcprop
-SVCS=/usr/bin/svcs
-MFSTPG=manifestfiles
-MFSTSCAN=/lib/svc/bin/mfstscan
-MCLEANUPFILE=/etc/svc/volatile/mcleanup.$$
-IGNORELIST="system/install-discovery smf/manifest"
-MFSTHISTORY=/lib/svc/share/mfsthistory
-UPLIST=0
-
-#
-# Create a list of service to manifest pairs for the upgrade
-# process to determine what files are associated with a service
-#
-function create_list {
-	for cl_mfile in `find /var/svc/manifest -name "*.xml"`
-	do
-		for cl_invent in `svccfg inventory $cl_mfile`
-		do
-			cl_invent=${cl_invent#svc:/*}
-
-			cl_instance=${cl_invent#*:}
-			cl_instance=${cl_instance##*/*}
-			[ $cl_instance ] && continue
-
-			cl_invent=${cl_invent%:*}
-			cl_invent=`echo $cl_invent | sed -e 's/[-\/\,]/_/g'`
-
-
-			eval $cl_invent=\"\$$cl_invent $cl_mfile\"
-		done
-	done
-	UPLIST=1
-}
-
-#
-# Inventory the instances listed with a manifest file
-#
-function get_instances {
-	gi_mfile=$1
-
-	lst=""
-	for gi_invent in `svccfg inventory $gi_mfile`
-	do
-		gi_tmp=${gi_invent#svc:/*}
-		gi_tmp=${gi_tmp#*:}
-		gi_tmp=${gi_tmp##*/*}
-
-		[ $gi_tmp ] && lst="$lst $gi_invent"
-	done
-
-	echo $lst
-}
-
-function pid_timeout {
-	pt_pid=$1
-
-	pt_cnt=0
-	while [ `ps -p $pt_pid -o pid | grep -v PID` -a $pt_cnt -lt 30 ]
-	do
-		sleep 1
-		cnt=`expr $pt_cnt + 1`
-	done
-	if [ $pt_cnt -eq 30 -a "`ps -p $pt_pid -o pid | grep -v PID`" ]; then
-		return 1
-	else
-		return 0
-	fi
-}
-
-#
-# Process a service to ensure that it's manifests exist
-# and are in sync with the service.
-#
-function process_service {
-	ps_service=$1
-
-	#
-	# Throw away unsupported services, if there is a false listing
-	# for manifestfiles support
-	#
-	$SVCPROP -p $MFSTPG/support $ps_service 2>/dev/null | grep false > /dev/null
-	[ $? -eq 0 ] && return
-
-	#
-	# Create the list of instances for this service.
-	#
-	$SVCPROP -p $MFSTPG $ps_service > $MCLEANUPFILE
-	set -A ps_mfiles `grep astring $MCLEANUPFILE | awk '{print $3}'`
-
-	#
-	# Check to see if the manifest files associated with the service are
-	# missing, or if the manifest file has changed, either caught here
-	# or by the caller.
-	#
-	ps_x=`$MFSTSCAN ${ps_mfiles[@]} 2>&1`
-	if [ $? -eq 0 ]; then
-		if [ "$force" != "true" -a ! "$ps_x" ]; then
-			ps_ret=0
-			for ps_f in ${ps_mfiles[@]}
-			do
-				echo "$force" | grep -v $ps_f > /dev/null 2>&1
-				ps_ret=`expr $ps_ret + $?`
-			done
-			[ $ps_ret -eq 0 ] && return
-		fi
-	fi
-
-	ps_refresh=0
-	ps_mfiles_tmp=""
-	ps_mfiles_cnt=${#ps_mfiles[@]}
-	ps_instances=`$SVCS -H -oFMRI $ps_service 2>/dev/null`
-
-	#
-	# For each manifest file that is listed by the service
-	# check for its existance.  If it exists, then check that
-	# the instances of the service are supported by at least
-	# one of the manifest files listed.
-	#
-	for mf in ${ps_mfiles[@]}
-	do
-		#
-		# This is an unsupported service just return
-		# skipping the service.
-		#
-		[ ${mf%/var/svc/manifest*} ] && return
-
-		if [ ! -f $mf ]; then
-			ps_mfiles_tmp="$ps_mfiles_tmp $mf"
-			continue
-		fi
-
-		inst=`get_instances $mf`
-
-		set -A ps_inst_list
-		for i in $inst
-		do
-			ps_inst_tmp=""
-			for j in $ps_instances
-			do
-				if [ "$i" == "$j" ]; then
-					set -A ps_inst_list ${ps_inst_list[*]} $j
-					continue
-				else
-					ps_inst_tmp="$ps_inst_tmp $j"
-				fi
-			done
-			#
-			# If there are any instances not accounted for add
-			# them to the list to be cleaned up.
-			#
-			ps_instances=$ps_inst_tmp
-		done
-	done
-	#
-	# If there are any manifest files set them to the list
-	# to be cleaned up.
-	#
-	set -A ps_mfiles $ps_mfiles_tmp
-
-	#
-	# For each manifest file that was not found remove it from
-	# the service's list of manifest files.
-	#
-	for mf in ${ps_mfiles[@]}
-	do
-		#
-		# Need to remove the file from the smf/manifest
-		# list.
-		#
-		ps_refresh=1
-		mf_nw=`echo "$needwork" | grep -v $mf`
-		needwork="$mf_nw"
-		mf_srch=`echo $mf | sed -e 's/\./\\\./g'`
-		mf_pg=`grep "$mf_srch" $MCLEANUPFILE | awk '{print $1}'`
-		[ $ps_mfiles_cnt -ne ${#ps_mfiles[@]} ] && \
-		    $SVCCFG -s $ps_service delprop $mf_pg > /dev/null 2>&1
-		mf_pg=`echo $mf_pg | awk -F'/' '{print $2}'`
-		$SVCCFG -s smf/manifest delpg $mf_pg > /dev/null 2>&1
-	done
-
-	#
-	# If all the manifest files that were listed in the service have now
-	# been removed, delete the service.
-	#
-	if [ $ps_mfiles_cnt -eq ${#ps_mfiles[@]} ]; then
-		#
-		# Disable each of the instances for the service
-		# then delete the service.
-		#
-		# If the restarter is not startd then the service
-		# will not be online at this point and we need
-		# to not wait on the disable.
-		#
-		# Set the delete opt to -f if the disable is not
-		# synchronous.
-		#
-		$SVCPROP -q -p general/restarter $ps_service
-		if [ $? -ne 0 ]; then
-			DISOPT="-s"
-			DELOP=""
-		else
-			DISOPT=""
-			DELOP="-f"
-		fi
-
-		for i in `$SVCS -H -oFMRI $ps_service`
-		do
-			$SVCADM disable $DISOPT $i &
-			CPID=$!
-
-			pid_timeout $CPID
-			if [ $? -ne 0 ]; then
-				DELOPT="-f"
-				kill $CPID
-			fi
-		done
-
-		echo "$SVCCFG delete $ps_service"
-		$SVCCFG delete $DELOPT $ps_service
-		return
-	fi
-
-	#
-	# Need to only cleanup instances that are no longer supported
-	# by the manifest files associated with the service.
-	#
-	for i in $ps_instances
-	do
-		#
-		# Ignore any instances that are hand created
-		#
-		ps_refresh=1
-		$SVCCFG -s $i selectsnap last-import > /dev/null 2>&1
-		[ $? -ne 0 ] && continue
-
-		#
-		# If the restarter is not startd then the service
-		# will not be online at this point and we need
-		# to not wait on the disable.
-		#
-		$SVCPROP -q -p general/restarter $ps_service
-		if [ $? -ne 0 ]; then
-			DELOP=""
-			$SVCADM disable -s $i &
-			CPID=$!
-
-			pid_timeout $CPID
-			if [ $? -ne 0 ]; then
-				DELOPT="-f"
-				kill $CPID
-			fi
-		else
-			DELOP="-f"
-			$SVCADM disable $i
-		fi
-
-		echo "$SVCCFG delete $i"
-		$SVCCFG delete $DELOP $i
-	done
-
-	#
-	# If instances of the services were removed, refresh the
-	# additional instances, or cleanup any leftover services.
-	#
-	if [ $ps_refresh -ne 0 ]; then
-		if [ ${#ps_inst_list[@]} -gt 0 ]; then
-			for i in ${ps_inst_list[@]}
-			do
-				$SVCCFG -s $i refresh
-			done
-		else
-			ps_support=0
-			for ps_mfile in `awk '{print $3}' $MCLEANUPFILE`
-			do
-				$SVCCFG inventory $ps_mfile | grep $ps_service > /dev/null 2>&1
-				[ $? -eq 0 ] && ps_supprt=1
-			done
-			[ $ps_support -eq 0 ] && $SVCCFG delete $ps_service
-		fi
-	fi
-}
-
-#
-# Upgrade a service to have the manifest files associated with
-# listed in the manifestfiles property group.
-#
-# If the first argument is FALSE, then check to see if the service
-# has any previous import indications.  If so then delete the
-# service, otherwise set the service as a non-supported service
-# for the automated manifest deletion process.
-#
-function add_manifest {
-	am_service=$1
-	shift
-
-	$SVCCFG -s $am_service addpg $MFSTPG framework
-
-	if [ "$1" == "FALSE" ]; then
-		am_lisnap=1
-		am_inst=`svcs -H -oFMRI $am_service 2>/dev/null`
-
-		#
-		# Check for a last-import snapshot, if there is not
-		# one then the service was hand crafted and the support
-		# should be set to false.
-		#
-		if [ $? -eq 0 ]; then
-			for i in $am_inst
-			do
-				$SVCCFG -s $i selectsnap last-import > /dev/null 2>&1
-				[ $? -eq 0 ] && am_lisnap=0
-			done
-		fi
-
-		if [ $am_lisnap -ne 0 ]; then
-			$SVCCFG -s $am_service setprop $MFSTPG/support = boolean: 0
-
-			return
-		fi
-
-		#
-		# If the service was not hand crafted then check to see if
-		# the service has ever been installed in the /var/svc/manifest
-		# directory and therefore a known removed service.
-		#
-		grep "$am_service " $MFSTHISTORY | grep -v "^#" > /dev/null 2>&1
-		if [ $? -eq 0 ]; then
-			echo "$SVCCFG delete $am_service"
-			$SVCCFG delete -f $am_service
-		else
-			#
-			# Do not know where the service came from so set
-			# it to false.
-			#
-			$SVCCFG -s $am_service setprop $MFSTPG/support = boolean: 0
-		fi
-	else
-		for am_mfile in $@
-		do
-			CF=${am_mfile#/*}
-			CF=`echo $CF | sed -e 's/[\/\,\.]/_/g'`
-			$SVCCFG -s $am_service setprop $MFSTPG/$CF = astring: $am_mfile
-		done
-	fi
-}
-
-#
-# upgrade the entries in the smf/manifest table to have
-# a pointer to the actual manifest file.
-#
-function upgrade_smfmanifest {
-	us_unfnd=""
-
-	for us_E in `$SVCPROP smf/manifest | grep md5sum | grep var_svc_manifest | awk '{print $1}' | awk -F'/' '{print $1}'`
-	do
-		$SVCPROP -q -p $us_E/manifestfile smf/manifest
-		[ $? -eq 0 ] && continue
-
-		us_S=`echo $us_E | sed -e 's/_xml/.xml/'`
-		us_S=`echo $us_S | sed -e 's/var_svc_manifest_/var\/svc\/manifest\//'`
-
-		us_R=""
-		while [ ! -f $us_S -a ! "$us_R" ]
-		do
-			us_S=`echo $us_S | sed -e 's/_/\//'`
-			us_R=${us_S##*_*}
-		done
-
-		us_S="/$us_S"
-		if [ -f $us_S ]; then
-			us_R=`$MFSTSCAN $us_S`
-			[ ! "$R" ] && \
-				$SVCCFG -s smf/manifest setprop ${us_E}/manifestfile = astring: $us_S
-		else
-			us_unfnd="$us_unfnd $us_E"
-		fi
-	done
-
-	echo "$us_unfnd"
-}
-
-function manifest_cleanup {
-	#
-	# If manifest-import had activity then need to make checks to override
-	# a mfstscan that returns no modifications.  This is because the hash
-	# table will already have been updated by the manifest-import run, 
-	# therefor manifest-cleanup will not see those changes in the mfstscan
-	# call.
-	#
-	# activity indicates changes and overrides the needwork check.
-	# force can be a list of files that will only be processed
-	# 	or force can be set to true, so that all files are checked
-	# 	regardless.
-	#
-	arg1=$1
-	activity=${arg1:-true}
-	[ "$1" ] && shift
-	argrest=$@
-	force=${argrest:-false}
-
-	#
-	# Check the smf/manifest table to see if it needs upgrading
-	#
-	md5c=`$SVCPROP smf/manifest | grep var_svc_manifest | grep -c md5sum`
-	mfc=`$SVCPROP smf/manifest | grep var_svc_manifest | grep -cw manifestfile`
-	if [ $md5c -ne $mfc ]; then
-		unfnd_upgrade=`upgrade_smfmanifest`
-		if [ "$force" == false ]; then
-			activity="true"
-			force="true"
-		fi
-	fi
-
-	smfmfiles=`svcprop smf/manifest | grep manifestfile | grep astring | awk '{print $3}'`
-	needwork=`/lib/svc/bin/mfstscan $smfmfiles 2>&1 1>/dev/null`
-	if [ ! "$needwork" ]; then
-		[ "$activity" == false ] && return
-	
-		[ "$activity" == true -a "$force" == false ] && return
-	fi
-
-	#
-	# Walk the list of services...
-	#
-	export SVCCFG_CHECKHASH=1
-	for service in `$SVCCFG list`
-	do
-		svcprop -q -p $MFSTPG $service
-		if [ $? -ne 0 ]; then
-			mc_igchk=`eval expr \"$IGNORELIST \" : "'.*\($service \)'"`
-			if [[ -n $mc_igchk ]]; then
-				echo "add_manifest $service FALSE"
-				add_manifest $service FALSE
-				continue
-			fi
-			
-			[ $UPLIST -eq 0 ] && create_list
-
-			CS=`echo $service | sed -e 's/[-\/\,]/_/g'`
-
-			eval manifestlist=\$$CS
-			if [ -n "$manifestlist" ]; then
-				echo "add_manifest $service $manifestlist"
-				add_manifest $service $manifestlist
-			else
-				echo "add_manifest $service FALSE"
-				add_manifest $service FALSE
-			fi
-		else
-			process_service $service
-		fi
-	done
-
-	rm -f $MCLEANUPFILE
-	unset SVCCFG_CHECKHASH
-
-	#
-	# Check to make sure all work was processed and 
-	# that all the files were removed correctly from
-	# the smf/manifest table.
-	#
-	leftover=`echo "$needwork" | grep "cannot stat" | awk '{print $4}'`
-	for f in $leftover $unfnd_upgrade
-	do
-		f_srch=`echo $f | sed -e 's/\./\\\./g; s/:$//'`
-		f_entry=`$SVCPROP smf/manifest | grep "$f_srch" | awk -F'/' '{print $1}'`
-		[ "$f_entry" ] && $SVCCFG -s smf/manifest delpg $f_entry
-	done
-}
--- a/usr/src/cmd/svc/shell/netservices.sh	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/svc/shell/netservices.sh	Thu Mar 25 14:57:35 2010 -0700
@@ -19,7 +19,7 @@
 #
 # CDDL HEADER END
 #
-# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 
@@ -261,8 +261,8 @@
 		;;
 esac
 
-if [ ! -f /var/svc/profile/$profile ]; then
-	echo "/var/svc/profile/$profile nonexistent. Exiting."
+if [ ! -f /etc/svc/profile/$profile ]; then
+	echo "/etc/svc/profile/$profile nonexistent. Exiting."
 	exit 1
 fi
 
@@ -283,18 +283,19 @@
 #
 # put the new profile into place, and apply it
 #
-ln -sf ./$profile /var/svc/profile/generic.xml
-svccfg apply /var/svc/profile/generic.xml
-
-#
 # Create a hash entry so that manifest_import is aware of the
 # profile being applied and does not reapply the profile on reboot.
 #
-SVCCFG_CHECKHASH="TRUE" /lib/svc/bin/prophist hash /var/svc/profile/generic.xml
+ln -sf ./$profile /etc/svc/profile/generic.xml
+svccfg delhash /etc/svc/profile/generic.xml > /dev/null 2>&1
+SVCCFG_CHECKHASH="TRUE" svccfg apply /etc/svc/profile/generic.xml
+
+#
+# generic_open may not start inetd services on upgraded systems
+#
 if [ $profile = "generic_open.xml" ]
 then
-	# generic_open may not start inetd services on upgraded systems
-	svccfg apply /var/svc/profile/inetd_generic.xml
+	svccfg apply /etc/svc/profile/inetd_generic.xml
 fi
 
 #
--- a/usr/src/cmd/svc/startd/Makefile	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/svc/startd/Makefile	Thu Mar 25 14:57:35 2010 -0700
@@ -19,7 +19,7 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 
@@ -45,11 +45,17 @@
 	wait.o \
 	utmpx.o
 
-ALLOBJS = $(OBJS) proc.o
+ALLOBJS = $(OBJS) \
+	proc.o \
+	manifest_hash.o
 
-SRCS = $(OBJS:%.o=%.c)
+SRCS = $(OBJS:%.o=%.c) \
+	proc.c \
+	../common/manifest_hash.c
 
-POFILES = $(ALLOBJS:%.o=%.po)
+POFILES = $(OBJS:%.o=%.po) \
+	proc.po \
+	../common/manifest_hash.po
 
 include ../../Makefile.cmd
 include ../../Makefile.ctf
@@ -57,17 +63,23 @@
 ROOTCMDDIR=	$(ROOT)/lib/svc/bin
 
 CFLAGS += -v
+CPPFLAGS += -I. -I../common
 
-$(OBJS) := CPPFLAGS += \
-	-I. -I../common -D_REENTRANT -D_FILE_OFFSET_BITS=64
+$(OBJS) := CPPFLAGS += -D_FILE_OFFSET_BITS=64 -D_REENTRANT
+
+proc.o := CPPFLAGS += -D_REENTRANT
 
-$(POFILE) := CPPFLAGS += -I. -I../common
+%.o:	../common/%.c
+	$(COMPILE.c) $(OUTPUT_OPTION) $<
+	$(POST_PROCESS_O)
 
-proc.o := CPPFLAGS += -I. -I../common -D_REENTRANT
+%.ln:	../common/%.c
+	$(LINT.c) $(OUTPUT_OPTION) -c $<
 
 LDLIBS += \
 	-lcontract \
 	-lkstat \
+	-lmd5 \
 	-lnvpair \
 	-lrestart \
 	-lscf \
--- a/usr/src/cmd/svc/startd/fork.c	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/svc/startd/fork.c	Thu Mar 25 14:57:35 2010 -0700
@@ -19,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -55,6 +55,7 @@
 #include <utmpx.h>
 #include <spawn.h>
 
+#include "manifest_hash.h"
 #include "configd_exit.h"
 #include "protocol.h"
 #include "startd.h"
@@ -125,8 +126,8 @@
 
 /*
  * pid_t fork_common(...)
- *   Common routine used by fork_sulogin and fork_configd to fork a
- *   process in a contract with the provided terms.  Invokes
+ *   Common routine used by fork_sulogin, fork_emi, and fork_configd to
+ *   fork a process in a contract with the provided terms.  Invokes
  *   fork_sulogin (with its no-fork argument set) on errors.
  */
 static pid_t
@@ -682,6 +683,393 @@
 	exit(0);
 }
 
+#define	SVCCFG_PATH	"/usr/sbin/svccfg"
+#define	EMI_MFST	"/lib/svc/manifest/system/early-manifest-import.xml"
+#define	EMI_PATH	"/lib/svc/method/manifest-import"
+
+/*
+ * Set Early Manifest Import service's state and log file.
+ */
+static int
+emi_set_state(restarter_instance_state_t state, boolean_t setlog)
+{
+	int r, ret = 1;
+	instance_data_t idata;
+	scf_handle_t *hndl = NULL;
+	scf_instance_t *inst = NULL;
+
+retry:
+	if (hndl == NULL)
+		hndl = libscf_handle_create_bound(SCF_VERSION);
+
+	if (hndl == NULL) {
+		/*
+		 * In the case that we can't bind to the repository
+		 * (which should have been started), we need to allow
+		 * the user into maintenance mode to determine what's
+		 * failed.
+		 */
+		fork_sulogin(B_FALSE, "Unable to bind a new repository"
+		    " handle: %s\n", scf_strerror(scf_error()));
+		goto retry;
+	}
+
+	if (inst == NULL)
+		inst = safe_scf_instance_create(hndl);
+
+	if (scf_handle_decode_fmri(hndl, SCF_INSTANCE_EMI, NULL, NULL,
+	    inst, NULL, NULL, SCF_DECODE_FMRI_EXACT) == -1) {
+		switch (scf_error()) {
+		case SCF_ERROR_NOT_FOUND:
+			goto out;
+
+		case SCF_ERROR_CONNECTION_BROKEN:
+		case SCF_ERROR_NOT_BOUND:
+			libscf_handle_rebind(hndl);
+			goto retry;
+
+		default:
+			fork_sulogin(B_FALSE, "Couldn't fetch %s service: "
+			    "%s\n", SCF_INSTANCE_EMI,
+			    scf_strerror(scf_error()));
+			goto retry;
+		}
+	}
+
+	if (setlog) {
+		(void) libscf_note_method_log(inst, st->st_log_prefix, EMI_LOG);
+		log_framework(LOG_DEBUG,
+		    "Set logfile property for %s\n", SCF_INSTANCE_EMI);
+	}
+
+	idata.i_fmri = SCF_INSTANCE_EMI;
+	idata.i_state =  RESTARTER_STATE_NONE;
+	idata.i_next_state = RESTARTER_STATE_NONE;
+	switch (r = _restarter_commit_states(hndl, &idata, state,
+	    RESTARTER_STATE_NONE, NULL)) {
+	case 0:
+		break;
+
+	case ECONNABORTED:
+		libscf_handle_rebind(hndl);
+		goto retry;
+
+	case ENOMEM:
+	case ENOENT:
+	case EPERM:
+	case EACCES:
+	case EROFS:
+		fork_sulogin(B_FALSE, "Could not set state of "
+		    "%s: %s\n", SCF_INSTANCE_EMI, strerror(r));
+		goto retry;
+		break;
+
+	case EINVAL:
+	default:
+		bad_error("_restarter_commit_states", r);
+	}
+	ret = 0;
+
+out:
+	scf_instance_destroy(inst);
+	scf_handle_destroy(hndl);
+	return (ret);
+}
+
+/*
+ * It is possible that the early-manifest-import service is disabled.  This
+ * would not be the normal case for Solaris, but it may happen on dedicated
+ * systems.  So this function checks the state of the general/enabled
+ * property for Early Manifest Import.
+ *
+ * It is also possible that the early-manifest-import service does not yet
+ * have a repository representation when this function runs.  This happens
+ * if non-Early Manifest Import system is upgraded to an Early Manifest
+ * Import based system.  Thus, the non-existence of general/enabled is not
+ * an error.
+ *
+ * Returns 1 if Early Manifest Import is disabled and 0 otherwise.
+ */
+static int
+emi_is_disabled()
+{
+	int disabled = 0;
+	int disconnected = 1;
+	int enabled;
+	scf_handle_t *hndl = NULL;
+	scf_instance_t *inst = NULL;
+	uchar_t stored_hash[MHASH_SIZE];
+	char *pname;
+	int hashash, r;
+
+	while (hndl == NULL) {
+		hndl = libscf_handle_create_bound(SCF_VERSION);
+
+		if (hndl == NULL) {
+			/*
+			 * In the case that we can't bind to the repository
+			 * (which should have been started), we need to
+			 * allow the user into maintenance mode to
+			 * determine what's failed.
+			 */
+			fork_sulogin(B_FALSE, "Unable to bind a new repository "
+			    "handle: %s\n", scf_strerror(scf_error()));
+		}
+	}
+
+	while (disconnected) {
+		r = libscf_fmri_get_instance(hndl, SCF_INSTANCE_EMI, &inst);
+		if (r != 0) {
+			switch (r) {
+			case ECONNABORTED:
+				libscf_handle_rebind(hndl);
+				continue;
+
+			case ENOENT:
+				/*
+				 * Early Manifest Import service is not in
+				 * the repository. Check the manifest file
+				 * and service's hash in smf/manifest to
+				 * figure out whether Early Manifest Import
+				 * service was deleted. If Early Manifest Import
+				 * service was deleted, treat that as a disable
+				 * and don't run early import.
+				 */
+
+				if (access(EMI_MFST, F_OK)) {
+					/*
+					 * Manifest isn't found, so service is
+					 * properly removed.
+					 */
+					disabled = 1;
+				} else {
+					/*
+					 * If manifest exists and we have the
+					 * hash, the service was improperly
+					 * deleted, generate a warning and treat
+					 * this as a disable.
+					 */
+
+					if ((pname = mhash_filename_to_propname(
+					    EMI_MFST, B_TRUE)) == NULL) {
+						/*
+						 * Treat failure to get propname
+						 * as a disable.
+						 */
+						disabled = 1;
+						uu_warn("Failed to get propname"
+						    " for %s.\n",
+						    SCF_INSTANCE_EMI);
+					} else {
+						hashash = mhash_retrieve_entry(
+						    hndl, pname,
+						    stored_hash,
+						    NULL) == 0;
+						uu_free(pname);
+
+						if (hashash) {
+							disabled = 1;
+							uu_warn("%s service is "
+							    "deleted \n",
+							    SCF_INSTANCE_EMI);
+						}
+					}
+
+				}
+
+				disconnected = 0;
+				continue;
+
+			default:
+				bad_error("libscf_fmri_get_instance",
+				    scf_error());
+			}
+		}
+		r = libscf_get_basic_instance_data(hndl, inst, SCF_INSTANCE_EMI,
+		    &enabled, NULL, NULL);
+		if (r == 0) {
+			/*
+			 * enabled can be returned as -1, which indicates
+			 * that the enabled property was not found.  To us
+			 * that means that the service was not disabled.
+			 */
+			if (enabled == 0)
+				disabled = 1;
+		} else {
+			switch (r) {
+			case ECONNABORTED:
+				libscf_handle_rebind(hndl);
+				continue;
+
+			case ECANCELED:
+			case ENOENT:
+				break;
+			default:
+				bad_error("libscf_get_basic_instance_data", r);
+			}
+		}
+		disconnected = 0;
+	}
+
+out:
+	if (inst != NULL)
+		scf_instance_destroy(inst);
+	scf_handle_destroy(hndl);
+	return (disabled);
+}
+
+void
+fork_emi()
+{
+	pid_t pid;
+	ctid_t ctid = -1;
+	char **envp, **np;
+	char *emipath;
+	char corepath[PATH_MAX];
+	char *svc_state;
+	int setemilog;
+	int sz;
+
+	if (emi_is_disabled()) {
+		log_framework(LOG_NOTICE, "%s is  disabled and will "
+		    "not be run.\n", SCF_INSTANCE_EMI);
+		return;
+	}
+
+	/*
+	 * Early Manifest Import should run only once, at boot. If svc.startd
+	 * is some how restarted, Early Manifest Import  should not run again.
+	 * Use the Early Manifest Import service's state to figure out whether
+	 * Early Manifest Import has successfully completed earlier and bail
+	 * out if it did.
+	 */
+	if (svc_state = smf_get_state(SCF_INSTANCE_EMI)) {
+		if (strcmp(svc_state, SCF_STATE_STRING_ONLINE) == 0) {
+			free(svc_state);
+			return;
+		}
+		free(svc_state);
+	}
+
+	/*
+	 * Attempt to set Early Manifest Import service's state and log file.
+	 * If emi_set_state fails, set log file again in the next call to
+	 * emi_set_state.
+	 */
+	setemilog = emi_set_state(RESTARTER_STATE_OFFLINE, B_TRUE);
+
+	/* Don't go further if /usr isn't available */
+	if (access(SVCCFG_PATH, F_OK)) {
+		log_framework(LOG_NOTICE, "Early Manifest Import is not "
+		    "supported on systems with a separate /usr filesystem.\n");
+		return;
+	}
+
+fork_retry:
+	log_framework(LOG_DEBUG, "Starting Early Manifest Import\n");
+
+	/*
+	 * If we're retrying, we will have an old contract lying around
+	 * from the failure.  Since we're going to be creating a new
+	 * contract shortly, we abandon the old one now.
+	 */
+	if (ctid != -1)
+		contract_abandon(ctid);
+	ctid = -1;
+
+	pid = fork_common(SCF_INSTANCE_EMI, SCF_INSTANCE_EMI,
+	    MAX_EMI_RETRIES, &ctid, 0, 0, 0, 0, EMI_COOKIE);
+
+	if (pid != 0) {
+		int exitstatus;
+
+		if (waitpid(pid, &exitstatus, 0) == -1) {
+			fork_sulogin(B_FALSE, "waitpid on %s failed: "
+			    "%s\n", SCF_INSTANCE_EMI, strerror(errno));
+		} else if (WIFEXITED(exitstatus)) {
+			if (WEXITSTATUS(exitstatus)) {
+				fork_sulogin(B_FALSE, "%s exited with status "
+				    "%d \n", SCF_INSTANCE_EMI,
+				    WEXITSTATUS(exitstatus));
+				goto fork_retry;
+			}
+		} else if (WIFSIGNALED(exitstatus)) {
+			char signame[SIG2STR_MAX];
+
+			if (sig2str(WTERMSIG(exitstatus), signame))
+				(void) snprintf(signame, SIG2STR_MAX,
+				    "signum %d", WTERMSIG(exitstatus));
+
+			fork_sulogin(B_FALSE, "%s signalled: %s\n",
+			    SCF_INSTANCE_EMI, signame);
+			goto fork_retry;
+		} else {
+			fork_sulogin(B_FALSE, "%s non-exit condition: 0x%x\n",
+			    SCF_INSTANCE_EMI, exitstatus);
+			goto fork_retry;
+		}
+
+		log_framework(LOG_DEBUG, "%s completed successfully\n",
+		    SCF_INSTANCE_EMI);
+
+		/*
+		 * Once Early Manifest Import completed, the Early Manifest
+		 * Import service must have been imported so set log file and
+		 * state properties. Since this information is required for
+		 * late manifest import and common admin operations, failing to
+		 * set these properties should result in su login so admin can
+		 * correct the problem.
+		 */
+		(void) emi_set_state(RESTARTER_STATE_ONLINE,
+		    setemilog ? B_TRUE : B_FALSE);
+
+		return;
+	}
+
+	/* child */
+
+	/*
+	 * Set our per-process core file path to leave core files in
+	 * /etc/svc/volatile directory, named after the PID to aid in debugging.
+	 */
+	(void) snprintf(corepath, sizeof (corepath),
+	    "/etc/svc/volatile/core.emi.%%p");
+	(void) core_set_process_path(corepath, strlen(corepath) + 1, getpid());
+
+	/*
+	 * Similar to running legacy services, we need to manually set
+	 * log files here and environment variables.
+	 */
+	setlog(EMI_LOG);
+
+	envp = startd_zalloc(sizeof (char *) * 3);
+	np = envp;
+
+	sz = sizeof ("SMF_FMRI=") + strlen(SCF_INSTANCE_EMI);
+	*np = startd_zalloc(sz);
+	(void) strlcpy(*np, "SMF_FMRI=", sz);
+	(void) strncat(*np, SCF_INSTANCE_EMI, sz);
+	np++;
+
+	emipath = getenv("PATH");
+	if (emipath == NULL)
+		emipath = strdup("/usr/sbin:/usr/bin");
+
+	sz = sizeof ("PATH=") + strlen(emipath);
+	*np = startd_zalloc(sz);
+	(void) strlcpy(*np, "PATH=", sz);
+	(void) strncat(*np, emipath, sz);
+
+	log_framework(LOG_DEBUG, "executing Early Manifest Import\n");
+	(void) execle(EMI_PATH, EMI_PATH, NULL, envp);
+
+	/*
+	 * Status code is used above to identify Early Manifest Import
+	 * exec failure.
+	 */
+	exit(1);
+}
+
 extern char **environ;
 
 /*
--- a/usr/src/cmd/svc/startd/graph.c	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/svc/startd/graph.c	Thu Mar 25 14:57:35 2010 -0700
@@ -237,8 +237,7 @@
 static graph_vertex_t *up_svcs_p[] = { NULL, NULL, NULL, NULL };
 
 /* These are for seed repository magic.  See can_come_up(). */
-static const char * const manifest_import =
-	"svc:/system/manifest-import:default";
+static const char * const manifest_import = SCF_INSTANCE_MI;
 static graph_vertex_t *manifest_import_p = NULL;
 
 
--- a/usr/src/cmd/svc/startd/startd.c	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/svc/startd/startd.c	Thu Mar 25 14:57:35 2010 -0700
@@ -20,12 +20,10 @@
  */
 
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 /*
  * startd.c - the master restarter
  *
@@ -781,6 +779,15 @@
 	timeout_init();
 	restarter_protocol_init();
 	restarter_init();
+
+	/*
+	 * svc.configd is started by fork_configd_thread so repository access is
+	 * available, run early manifest import before continuing with starting
+	 * graph engine and the rest of startd.
+	 */
+	log_framework(LOG_DEBUG, "Calling fork_emi...\n");
+	fork_emi();
+
 	graph_protocol_init();
 	graph_init();
 
--- a/usr/src/cmd/svc/startd/startd.h	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/svc/startd/startd.h	Thu Mar 25 14:57:35 2010 -0700
@@ -101,6 +101,7 @@
 #define	FAULT_THRESHOLD		3
 
 #define	MAX_CONFIGD_RETRIES	5
+#define	MAX_EMI_RETRIES		5
 #define	MAX_MOUNT_RETRIES	5
 #define	MAX_SULOGIN_RETRIES	5
 
@@ -127,6 +128,7 @@
 #define	METHOD_START_COOKIE	0x20
 #define	METHOD_OTHER_COOKIE	0x21
 #define	MONITOR_COOKIE		0x30
+#define	EMI_COOKIE		0x31
 
 
 #define	ALLOC_RETRY		3
@@ -198,6 +200,7 @@
 #define	LOG_SUFFIX		".log"
 
 #define	STARTD_DEFAULT_LOG	"svc.startd.log"
+#define	EMI_LOG ((const char *) "system-early-manifest-import:default.log")
 
 extern const char *log_directory;	/* Current log directory path */
 
@@ -595,6 +598,7 @@
 
 pid_t startd_fork1(int *);
 void fork_with_timeout(const char *, uint_t, uint_t);
+void fork_emi();
 
 /* graph.c */
 void graph_init(void);
--- a/usr/src/cmd/svc/svccfg/Makefile	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/svc/svccfg/Makefile	Thu Mar 25 14:57:35 2010 -0700
@@ -20,7 +20,7 @@
 #
 
 #
-# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 
@@ -36,17 +36,20 @@
 		svccfg_help.c
 
 LNTS =		$(SRCS:%.c=%.ln) \
+		manifest_find.ln \
 		manifest_hash.ln
 
 MYOBJS =	$(SRCS:%.c=%.o) \
 		svccfg_grammar.o \
 		svccfg_lex.o \
-		manifest_hash.o
+		manifest_find.o \
+		manifest_hash.o 
 OBJS =		$(MYOBJS)
 
 POFILES = 	$(SRCS:%.c=%.po) \
 		svccfg_grammar.po \
 		svccfg_lex.po \
+		../common/manifest_find.po \
 		../common/manifest_hash.po
 
 include ../../Makefile.cmd
--- a/usr/src/cmd/svc/svccfg/svccfg.h	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/svc/svccfg/svccfg.h	Thu Mar 25 14:57:35 2010 -0700
@@ -20,7 +20,7 @@
  */
 
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -33,6 +33,7 @@
 #include <libxml/tree.h>
 
 #include <libscf.h>
+#include <libscf_priv.h>
 #include <libtecla.h>
 #include <libuutil.h>
 
@@ -57,6 +58,14 @@
 #define	SCI_NOSNAP	0x80		/* Don't take last-import snapshot */
 #define	SCI_DELAYENABLE	0x100		/* Delay the general/enable property */
 
+#define	HASH_SVC		"smf/manifest"
+
+/*
+ * If the filesystem/minimal service is not online, do not consider
+ * manifests in the /var file system.
+ */
+#define	IGNORE_VAR	(!est->sc_fs_minimal)
+
 /* Flags for lscf_service_export() */
 #define	SCE_ALL_VALUES	0x01		/* Include all property values */
 
@@ -282,6 +291,8 @@
 	size_t		sc_cmd_bufsz;
 	off_t		sc_cmd_bufoff;
 	GetLine		*sc_gl;
+	boolean_t	sc_fs_minimal;	/* SCF_INSTANCE_FS_MINIMAL is online. */
+	boolean_t	sc_in_emi;	/* During early import */
 
 	pid_t		sc_repo_pid;
 	const char	*sc_repo_filename;
@@ -405,6 +416,8 @@
 char *filename_to_propname(const char *);
 int lscf_retrieve_hash(const char *, unsigned char *);
 int lscf_store_hash(const char *, unsigned char *);
+int lscf_service_cleanup(void *, scf_walkinfo_t *);
+int lscf_hash_cleanup();
 CPL_MATCH_FN(complete_select);
 CPL_MATCH_FN(complete_command);
 
@@ -418,6 +431,7 @@
 int engine_interp(void);
 int engine_source(const char *, boolean_t);
 int engine_import(uu_list_t *);
+int engine_cleanup(int);
 void help(int);
 
 int engine_cmd_getc(engine_state_t *);
--- a/usr/src/cmd/svc/svccfg/svccfg.l	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/svc/svccfg/svccfg.l	Thu Mar 25 14:57:35 2010 -0700
@@ -21,7 +21,7 @@
  */
 
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -77,6 +77,7 @@
 
 <INITIAL>validate	{ BEGIN WORD; return (SCC_VALIDATE); }
 <INITIAL>import		{ BEGIN WORD; return (SCC_IMPORT); }
+<INITIAL>cleanup	{ BEGIN WORD; return (SCC_CLEANUP); }
 <INITIAL>export		{ BEGIN WORD; return (SCC_EXPORT); }
 <INITIAL>archive	{ BEGIN WORD; return (SCC_ARCHIVE); }
 <INITIAL>restore	{ BEGIN WORD; return (SCC_RESTORE); }
--- a/usr/src/cmd/svc/svccfg/svccfg.y	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/svc/svccfg/svccfg.y	Thu Mar 25 14:57:35 2010 -0700
@@ -21,7 +21,7 @@
  */
 
 /*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -43,6 +43,7 @@
 %start commands
 
 %token SCC_VALIDATE SCC_IMPORT SCC_EXPORT SCC_ARCHIVE SCC_APPLY SCC_EXTRACT
+%token SCC_CLEANUP
 %token SCC_REPOSITORY SCC_INVENTORY SCC_SET SCC_END SCC_HELP SCC_RESTORE
 %token SCC_LIST SCC_ADD SCC_DELETE SCC_SELECT SCC_UNSELECT
 %token SCC_LISTPG SCC_ADDPG SCC_DELPG SCC_DELHASH
@@ -74,6 +75,7 @@
 command : terminator
 	| validate_cmd
 	| import_cmd
+	| cleanup_cmd
 	| export_cmd
 	| archive_cmd
 	| restore_cmd
@@ -157,6 +159,24 @@
 	}
 	| SCC_IMPORT error terminator	{ synerr(SCC_IMPORT); return(0); }
 
+cleanup_cmd : SCC_CLEANUP terminator	
+	{ 
+		engine_cleanup(0);
+	}
+	| SCC_CLEANUP SCV_WORD terminator
+	{
+		if (strcmp($2, "-a") == 0) {
+			engine_cleanup(1);
+			free($2);
+		} else {
+			synerr(SCC_CLEANUP);
+			free($2);
+			return (0);
+		}
+	}
+	| SCC_CLEANUP error terminator { synerr(SCC_CLEANUP); return(0); }
+
+
 export_cmd : SCC_EXPORT SCV_WORD terminator
 	{
 		lscf_service_export($2, NULL, 0);
@@ -566,6 +586,7 @@
 
 command_token : SCC_VALIDATE	{ $$ = SCC_VALIDATE; }
 	| SCC_IMPORT		{ $$ = SCC_IMPORT; }
+	| SCC_CLEANUP		{ $$ = SCC_CLEANUP; }
 	| SCC_EXPORT		{ $$ = SCC_EXPORT; }
 	| SCC_APPLY		{ $$ = SCC_APPLY; }
 	| SCC_EXTRACT		{ $$ = SCC_EXTRACT; }
--- a/usr/src/cmd/svc/svccfg/svccfg_engine.c	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/svc/svccfg/svccfg_engine.c	Thu Mar 25 14:57:35 2010 -0700
@@ -20,7 +20,7 @@
  */
 
 /*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -34,6 +34,7 @@
 #include <sys/types.h>
 #include <assert.h>
 #include <errno.h>
+#include <fcntl.h>
 #include <libintl.h>
 #include <libtecla.h>
 #include <md5.h>
@@ -41,6 +42,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 
+#include "manifest_find.h"
 #include "manifest_hash.h"
 #include "svccfg.h"
 
@@ -196,6 +198,7 @@
 } cmds[] = {
 	{ "validate", CS_GLOBAL, complete_single_xml_file_arg },
 	{ "import", CS_GLOBAL, complete_single_xml_file_arg },
+	{ "cleanup", CS_GLOBAL, NULL},
 	{ "export", CS_GLOBAL, NULL },
 	{ "archive", CS_GLOBAL, NULL },
 	{ "apply", CS_GLOBAL, complete_single_xml_file_arg },
@@ -501,21 +504,125 @@
 
 	cp = getenv("SVCCFG_CONFIGD_PATH");
 	est->sc_repo_server = cp ? cp : "/lib/svc/bin/svc.configd";
+
+	est->sc_in_emi = 0;
+	cp = getenv("SMF_FMRI");
+	if ((cp != NULL) && (strcmp(cp, SCF_INSTANCE_EMI) == 0))
+		est->sc_in_emi = 1;
+
+	cp = smf_get_state(SCF_INSTANCE_FS_MINIMAL);
+	if (cp && (strcmp(cp, SCF_STATE_STRING_ONLINE) == 0))
+		est->sc_fs_minimal = B_TRUE;
+	free((void *) cp);
 }
 
+static int
+import_manifest_file(manifest_info_t *info, boolean_t validate, FILE *pout,
+    uint_t flags)
+{
+	bundle_t *b;
+	tmpl_errors_t *errs;
+	const char *file;
+	tmpl_validate_status_t vr;
+
+	file = info->mi_path;
+
+	/* Load the manifest */
+	b = internal_bundle_new();
+
+	if (lxml_get_bundle_file(b, file, SVCCFG_OP_IMPORT) != 0) {
+		internal_bundle_free(b);
+		return (-1);
+	}
+
+	/* Validate */
+	if ((vr = tmpl_validate_bundle(b, &errs)) != TVS_SUCCESS) {
+		char *prefix;
+
+		if ((validate == 0) || (vr == TVS_WARN)) {
+			prefix = gettext("Warning: ");
+		} else {
+			prefix = "";
+		}
+		tmpl_errors_print(stderr, errs, prefix);
+		if (validate && (vr != TVS_WARN)) {
+			tmpl_errors_destroy(errs);
+			semerr(gettext("Import of %s failed.\n"),
+			    info->mi_path);
+			if (pout != NULL) {
+				(void) fprintf(pout, gettext("WARNING: svccfg "
+				    "import of %s failed.\n"), info->mi_path);
+			}
+
+			return (-1);
+		}
+	}
+	tmpl_errors_destroy(errs);
+
+	/* Import */
+	if (lscf_bundle_import(b, file, flags) != 0) {
+		internal_bundle_free(b);
+		semerr(gettext("Import of %s failed.\n"), info->mi_path);
+		if (pout != NULL) {
+			(void) fprintf(pout, gettext("WARNING: svccfg import "
+			    "of %s failed.\n"), info->mi_path);
+		}
+		return (-1);
+	}
+
+	internal_bundle_free(b);
+
+	if (info->mi_prop) {
+		char *errstr;
+
+		if (mhash_store_entry(g_hndl, info->mi_prop, file,
+		    info->mi_hash, APPLY_NONE, &errstr)) {
+			if (errstr)
+				semerr(gettext("Could not store hash for %s. "
+				    "%s\n"), info->mi_path, errstr);
+			else
+				semerr(gettext("Unknown error from "
+				    "mhash_store_entry() for %s\n"),
+				    info->mi_path);
+		}
+
+	}
+
+	return (0);
+}
+
+/*
+ * Return values:
+ *	1	No manifests need to be imported.
+ *	0	Success
+ *	-1	Error
+ *	-2	Syntax error
+ */
 int
 engine_import(uu_list_t *args)
 {
-	int ret, argc, i, o;
-	bundle_t *b;
-	char *file, *pname;
-	uchar_t hash[MHASH_SIZE];
-	char **argv;
+	int argc, i, o;
+	int dont_exit;
+	int failed_manifests;
+	int total_manifests;
+	char *file;
+	char **argv = NULL;
 	string_list_t *slp;
 	boolean_t validate = B_FALSE;
-	tmpl_validate_status_t vr;
 	uint_t flags = SCI_GENERALLAST;
-	tmpl_errors_t *errs;
+	int dirarg = 0;
+	int isdir;
+	int rc = -1;
+	struct stat sb;
+	char **paths;
+	manifest_info_t ***manifest_sets = NULL;
+	manifest_info_t **manifests;
+	char *progress_file = NULL;
+	FILE *progress_out = NULL;
+	int progress_count;
+	int back_count;
+	int count;
+	int fm_flags;
 
 	argc = uu_list_numnodes(args);
 	if (argc < 1)
@@ -535,7 +642,7 @@
 	opterr = 0;
 	optind = 0;				/* Remember, no argv[0]. */
 	for (;;) {
-		o = getopt(argc, argv, "nV");
+		o = getopt(argc, argv, "np:V");
 		if (o == -1)
 			break;
 
@@ -544,6 +651,10 @@
 			flags |= SCI_NOREFRESH;
 			break;
 
+		case 'p':
+			progress_file = optarg;
+			break;
+
 		case 'V':
 			validate = B_TRUE;
 			break;
@@ -558,13 +669,29 @@
 	}
 
 	argc -= optind;
-	if (argc != 1) {
+	if (argc < 1) {
 		free(argv);
 		return (-2);
 	}
 
-	file = argv[optind];
-	free(argv);
+	/* Open device for progress messages */
+	if (progress_file != NULL) {
+		if (strcmp(progress_file, "-") == 0) {
+			progress_out = stdout;
+		} else {
+			progress_out = fopen(progress_file, "w");
+			if (progress_out == NULL) {
+				semerr(gettext("Unable to open %s for "
+				    "progress reporting.  %s\n"),
+				    progress_file, strerror(errno));
+				goto out;
+			}
+			setbuf(progress_out, NULL);
+		}
+	}
+
+	paths = argv+optind;
+	manifest_sets = safe_malloc(argc * sizeof (*manifest_sets));
 
 	/* If we're in interactive mode, force strict validation. */
 	if (est->sc_cmd_flags & SC_CMD_IACTIVE)
@@ -572,68 +699,157 @@
 
 	lscf_prep_hndl();
 
-	ret = mhash_test_file(g_hndl, file, 0, &pname, hash);
-	if (ret != MHASH_NEWFILE) {
-		if (ret == MHASH_FAILURE)
-			semerr(gettext("Could not hash file %s\n"), file);
-		else if (g_verbose && ret == MHASH_RECONCILED)
-			warn(gettext("No changes were necessary.\n"));
-		return (ret);
+	/* Determine which manifests must be imported. */
+
+	total_manifests = 0;
+	for (i = 0; i < argc; i++) {
+		file = *(paths + i);
+		fm_flags = CHECKHASH;
+
+		/* Determine if argument is a directory or file. */
+		if (stat(file, &sb) == -1) {
+			semerr(gettext("Unable to stat file %s.  %s\n"), file,
+			    strerror(errno));
+			goto out;
+		}
+		if (sb.st_mode & S_IFDIR) {
+			fm_flags |= CHECKEXT;
+			dirarg = 1;
+			isdir = 1;
+		} else if (sb.st_mode & S_IFREG) {
+			isdir = 0;
+		} else {
+			semerr(gettext("%s is not a directory or regular "
+			    "file\n"), file);
+			goto out;
+		}
+
+		/* Get list of manifests that we should import for this path. */
+		if ((count = find_manifests(file, &manifests, fm_flags)) < 0) {
+			if (isdir) {
+				semerr(gettext("Could not hash directory %s\n"),
+				    file);
+			} else {
+				semerr(gettext("Could not hash file %s\n"),
+				    file);
+			}
+			free_manifest_array(manifests);
+			goto out;
+		}
+		total_manifests += count;
+		manifest_sets[i] = manifests;
 	}
 
-	/* Load */
-	b = internal_bundle_new();
-
-	if (lxml_get_bundle_file(b, file, SVCCFG_OP_IMPORT) != 0) {
-		internal_bundle_free(b);
-		return (-1);
+	if (total_manifests == 0) {
+		/* No manifests to process. */
+		if (g_verbose) {
+			warn(gettext("No changes were necessary\n"));
+		}
+		rc = 1;
+		goto out;
 	}
 
-	/* Validate */
-	if ((vr = tmpl_validate_bundle(b, &errs)) != TVS_SUCCESS) {
-		char *prefix;
+	/*
+	 * If we're processing more than one file, we don't want to exit if
+	 * we encounter an error.  We should go ahead and process all of
+	 * the manifests.
+	 */
+	dont_exit = est->sc_cmd_flags & SC_CMD_DONT_EXIT;
+	if (total_manifests > 1)
+		est->sc_cmd_flags |= SC_CMD_DONT_EXIT;
+
+	if (progress_out != NULL)
+		(void) fprintf(progress_out,
+		    "Loading smf(5) service descriptions: ");
 
-		if ((validate == 0) || (vr == TVS_WARN)) {
-			prefix = gettext("Warning: ");
-		} else {
-			prefix = "";
-		}
-		tmpl_errors_print(stderr, errs, prefix);
-		if (validate && (vr != TVS_WARN)) {
-			tmpl_errors_destroy(errs);
-			semerr(gettext("Import failed.\n"));
-			return (-1);
+	failed_manifests = 0;
+	progress_count = 0;
+	for (i = 0; i < argc; i++) {
+		manifests = manifest_sets[i];
+		if (manifests == NULL)
+			continue;
+		for (; *manifests != NULL; manifests++) {
+			progress_count++;
+			if (progress_out != NULL) {
+				back_count = fprintf(progress_out, "%d/%d",
+				    progress_count, total_manifests);
+				while (back_count-- > 0) {
+					(void) fputc('\b', progress_out);
+				}
+			}
+			if (import_manifest_file(*manifests, validate,
+			    progress_out, flags) != 0) {
+				failed_manifests++;
+			}
 		}
 	}
-	tmpl_errors_destroy(errs);
+	if (progress_out != NULL)
+		(void) fputc('\n', progress_out);
+
+	if ((total_manifests > 1) && (dont_exit == 0))
+		est->sc_cmd_flags &= ~SC_CMD_DONT_EXIT;
 
-	/* Import */
-	if (lscf_bundle_import(b, file, flags) != 0) {
-		internal_bundle_free(b);
-		semerr(gettext("Import failed.\n"));
-		return (-1);
+	if (dirarg && total_manifests > 0) {
+		char *msg;
+
+		msg = "Loaded %d smf(5) service descriptions\n";
+		warn(gettext(msg), progress_count);
+
+		if (failed_manifests) {
+			msg = "%d smf(5) service descriptions failed to load\n";
+			warn(gettext(msg), failed_manifests);
+		}
 	}
 
-	internal_bundle_free(b);
+	if (failed_manifests > 0)
+		goto out;
 
 	if (g_verbose)
 		warn(gettext("Successful import.\n"));
+	rc = 0;
 
-	if (pname) {
-		char *errstr;
+out:
+	if ((progress_out != NULL) && (progress_out != stdout))
+		(void) fclose(progress_out);
+	free(argv);
+	if (manifest_sets != NULL) {
+		for (i = 0; i < argc; i++) {
+			free_manifest_array(manifest_sets[i]);
+		}
+		free(manifest_sets);
+	}
+	return (rc);
+}
 
-		if (mhash_store_entry(g_hndl, pname, file, hash, &errstr)) {
-			if (errstr)
-				semerr(errstr);
-			else
-				semerr(gettext("Unknown error from "
-				    "mhash_store_entry()\n"));
-		}
+/*
+ * Walk each service and get its manifest file.
+ *
+ * If the file exists check instance support, and cleanup any
+ * stale instances.
+ *
+ * If the file doesn't exist tear down the service and/or instances
+ * that are no longer supported by files.
+ */
+int
+engine_cleanup(int flags)
+{
+	boolean_t		activity = B_TRUE;
+	int			r = -1;
 
-		free(pname);
+	lscf_prep_hndl();
+
+	if (flags == 1) {
+		activity = B_FALSE;
 	}
 
-	return (0);
+	if (scf_walk_fmri(g_hndl, 0, NULL, SCF_WALK_SERVICE|SCF_WALK_NOINSTANCE,
+	    lscf_service_cleanup, (void *)activity, NULL,
+	    uu_warn) == SCF_SUCCESS)
+		r = 0;
+
+	(void) lscf_hash_cleanup();
+
+	return (r);
 }
 
 int
@@ -670,9 +886,14 @@
 	internal_bundle_free(b);
 
 	if (pname) {
+		apply_action_t apply;
 		char *errstr;
-		if (mhash_store_entry(g_hndl, pname, file, hash, &errstr))
+
+		apply = (est->sc_in_emi == 1) ? APPLY_LATE : APPLY_NONE;
+		if (mhash_store_entry(g_hndl, pname, file, hash, apply,
+		    &errstr)) {
 			semerr(errstr);
+		}
 
 		free(pname);
 	}
--- a/usr/src/cmd/svc/svccfg/svccfg_help.c	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/svc/svccfg/svccfg_help.c	Thu Mar 25 14:57:35 2010 -0700
@@ -20,7 +20,7 @@
  */
 
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -33,9 +33,12 @@
 "Validate a manifest file without changing the repository.\n"
 "Validate an instance FMRI against the template specifications."
 	},
-	{ SCC_IMPORT, "import [-V] file\n\n"
-"Import a manifest into the repository.  With -V force strict adherence\n"
-"to the template specifications."
+	{ SCC_IMPORT, "import [-p outfile] [-V] paths...\n\n"
+"Import manifests into the repository.  paths can be one or more\n"
+"manifest files or directories.  If directories are specified, they\n"
+"will be searched for files with a .xml extension.  If -p is specified,\n"
+"a progress message will be written to outfile as each manifest is\n"
+"imported.  With -V force strict adherence to the template specifications."
 	},
 	{ SCC_EXPORT, "export [-a] {service | pattern} [> file]\n\n"
 "Print a manifest for service to file, or standard output if not specified."
@@ -87,6 +90,10 @@
 "Delete the named manifest hash entry (from smf/manifest).\n"
 "With -d, manifest file doesn't need to exist."
 	},
+	{ SCC_CLEANUP, "cleanup\n\n"
+"Cleanup any service or instances that no longer have manifest files that\n"
+"support the services or instances in /lib/svc/manifest or /var/svc/manifest."
+	},
 	{ SCC_LISTPROP, "listprop [glob_pattern]\n\n"
 "List property groups and properties of the currently selected entity."
 	},
--- a/usr/src/cmd/svc/svccfg/svccfg_libscf.c	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/svc/svccfg/svccfg_libscf.c	Thu Mar 25 14:57:35 2010 -0700
@@ -20,7 +20,7 @@
  */
 
 /*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -45,13 +45,18 @@
 #include <strings.h>
 #include <unistd.h>
 #include <wait.h>
+#include <poll.h>
 
 #include <libxml/tree.h>
 
 #include <sys/param.h>
 
+#include <sys/stat.h>
+#include <sys/mman.h>
+
 #include "svccfg.h"
 #include "manifest_hash.h"
+#include "manifest_find.h"
 
 /* The colon namespaces in each entity (each followed by a newline). */
 #define	COLON_NAMESPACES	":properties\n"
@@ -62,7 +67,6 @@
 #define	CHARS_TO_QUOTE		" \t\n\\>=\"()"
 
 #define	HASH_SIZE		16
-#define	HASH_SVC		"smf/manifest"
 #define	HASH_PG_TYPE		"framework"
 #define	HASH_PG_FLAGS		0
 #define	HASH_PROP		"md5sum"
@@ -76,6 +80,21 @@
 #define	TMPL_CHOICE_INDENT	"      "
 
 /*
+ * Directory locations for manifests
+ */
+#define	VARSVC_DIR		"/var/svc/manifest"
+#define	LIBSVC_DIR		"/lib/svc/manifest"
+#define	VARSVC_PR		"var_svc_manifest"
+#define	LIBSVC_PR		"lib_svc_manifest"
+#define	MFSTFILEPR		"manifestfile"
+
+#define	SUPPORTPROP		"support"
+
+#define	MFSTHISTFILE		"/lib/svc/share/mfsthistory"
+
+#define	MFSTFILE_MAX		16
+
+/*
  * These are the classes of elements which may appear as children of service
  * or instance elements in XML manifests.
  */
@@ -129,6 +148,31 @@
 	int 		flags;
 };
 
+/*
+ * The service_manifest structure is used by the upgrade process
+ * to create a list of service to manifest linkages from the manifests
+ * in a set of given directories.
+ */
+typedef struct service_manifest {
+	const char 	*servicename;
+	uu_list_t	*mfstlist;
+	size_t	mfstlist_sz;
+
+	uu_avl_node_t	svcmfst_node;
+} service_manifest_t;
+
+/*
+ * Structure to track the manifest file property group
+ * and the manifest file associated with that property
+ * group.  Also, a flag to keep the access once it has
+ * been checked.
+ */
+struct mpg_mfile {
+	char	*mpg;
+	char	*mfile;
+	int	access;
+};
+
 const char * const scf_pg_general = SCF_PG_GENERAL;
 const char * const scf_group_framework = SCF_GROUP_FRAMEWORK;
 const char * const scf_property_enabled = SCF_PROPERTY_ENABLED;
@@ -182,7 +226,7 @@
 static const char *emsg_dpt_dangling;
 static const char *emsg_dpt_no_dep;
 
-static int li_only;
+static int li_only = 0;
 static int no_refresh = 0;
 
 /* import globals, to minimize allocations */
@@ -230,6 +274,10 @@
 static char *exp_str;
 static size_t exp_str_sz;
 
+/* cleanup globals */
+static uu_avl_pool_t *service_manifest_pool = NULL;
+static uu_avl_t *service_manifest_tree = NULL;
+
 static void scfdie_lineno(int lineno) __NORETURN;
 
 static char *start_method_names[] = {
@@ -637,7 +685,6 @@
 	}
 }
 
-
 /*
  * To be registered with atexit().
  */
@@ -648,7 +695,7 @@
 
 	if (tempfile != NULL) {
 		if (fclose(tempfile) == EOF)
-			warn(gettext("Could not close temporary file"));
+			(void) warn(gettext("Could not close temporary file"));
 		tempfile = NULL;
 	}
 
@@ -1494,8 +1541,14 @@
 	int r;
 
 	if (!isservice) {
+		/*
+		 * Let restarter handles refreshing and making new running
+		 * snapshot only if operating on a live repository and not
+		 * running in early import.
+		 */
 		if (est->sc_repo_filename == NULL &&
-		    est->sc_repo_doorname == NULL) {
+		    est->sc_repo_doorname == NULL &&
+		    est->sc_in_emi == 0) {
 			if (_smf_refresh_instance_i(entity) == 0) {
 				if (g_verbose)
 					warn(gettext("Refreshed %s.\n"), fmri);
@@ -1571,8 +1624,13 @@
 			}
 		}
 
+		/*
+		 * Similarly, just take a new running snapshot if operating on
+		 * a non-live repository or running during early import.
+		 */
 		if (est->sc_repo_filename != NULL ||
-		    est->sc_repo_doorname != NULL) {
+		    est->sc_repo_doorname != NULL ||
+		    est->sc_in_emi == 1) {
 			r = refresh_running_snapshot(inst);
 			switch (r) {
 			case 0:
@@ -3291,7 +3349,7 @@
 
 /*
  * Used to add the manifests to the list of currently supported manifests.
- * We could modify the existing manifest list removing entries if the files
+ * We can modify the existing manifest list removing entries if the files
  * don't exist.
  *
  * Get the old list and the new file name
@@ -3315,7 +3373,7 @@
 	property_t *mfst_prop;
 	property_t *old_prop;
 	char *pname = malloc(MAXPATHLEN);
-	char *fval;
+	char *fval = NULL;
 	char *old_pname;
 	char *old_fval;
 	int no_upgrade_pg;
@@ -3404,7 +3462,8 @@
 		 * property list to get proccessed into the repo.
 		 */
 		if (mfst_seen == 0) {
-			fval = malloc(MAXPATHLEN);
+			if (fval == NULL)
+				fval = malloc(MAXPATHLEN);
 
 			/*
 			 * If we cannot get the value then there is no
@@ -3416,11 +3475,19 @@
 			    scf_value_get_astring(fname_value, fval,
 			    MAXPATHLEN) != -1)  {
 				/*
-				 * First check to see if the manifest is there
-				 * if not then there is no need to add it.
+				 * If the filesystem/minimal service is
+				 * online check to see if the manifest is
+				 * there.  If not then there is no need to
+				 * add it.
+				 *
+				 * If filesystem/minimal service is not
+				 * online, we go ahead and record the
+				 * manifest file name.  We don't check for
+				 * its existence because it may be on a
+				 * file system that is not yet mounted.
 				 */
-				if (access(fval, F_OK) == -1) {
-					free(fval);
+				if ((est->sc_fs_minimal) &&
+				    (access(fval, F_OK) == -1)) {
 					continue;
 				}
 
@@ -3438,6 +3505,7 @@
 			}
 		}
 	}
+	free(fval);
 
 	cbdata.sc_handle = g_hndl;
 	cbdata.sc_parent = ent;
@@ -6231,7 +6299,7 @@
 	int r;
 	int fresh = 0;
 	scf_snaplevel_t *running;
-	int have_ge;
+	int have_ge = 0;
 
 	const char * const ts_deleted = gettext("Temporary service svc:/%s "
 	    "was deleted unexpectedly.\n");
@@ -6244,6 +6312,7 @@
 	const char * const badsnap = gettext("\"%s\" snapshot of svc:/%s:%s "
 	    "is corrupt (missing service snaplevel).\n");
 
+	li_only = 0;
 	/* Validate the service name */
 	if (scf_scope_get_service(scope, s->sc_name, imp_svc) != 0) {
 		switch (scf_error()) {
@@ -6709,9 +6778,6 @@
 		}
 	}
 
-	have_ge = 0;
-	li_only = 0;
-
 	for (;;) {
 		r = scf_iter_next_instance(imp_iter, imp_inst);
 		if (r == -1) {
@@ -7340,6 +7406,7 @@
 		/* Success.  Refresh everything. */
 
 		if (flags & SCI_NOREFRESH || no_refresh) {
+			no_refresh = 0;
 			result = 0;
 			goto out;
 		}
@@ -7618,6 +7685,7 @@
 	scf_scope_t *rscope;
 	scf_service_t *rsvc;
 	scf_instance_t *rinst;
+	scf_snapshot_t *rsnap;
 	scf_iter_t *iter;
 	int annotation_set = 0;
 	int r;
@@ -7627,8 +7695,10 @@
 	if ((rscope = scf_scope_create(g_hndl)) == NULL ||
 	    (rsvc = scf_service_create(g_hndl)) == NULL ||
 	    (rinst = scf_instance_create(g_hndl)) == NULL ||
+	    (rsnap = scf_snapshot_create(g_hndl)) == NULL ||
 	    (iter = scf_iter_create(g_hndl)) == NULL ||
 	    (imp_pg = scf_pg_create(g_hndl)) == NULL ||
+	    (imp_prop = scf_property_create(g_hndl)) == NULL ||
 	    (imp_tx = scf_transaction_create(g_hndl)) == NULL)
 		scfdie();
 
@@ -7726,6 +7796,30 @@
 				}
 			}
 
+			/*
+			 * If the instance does not have a general/enabled
+			 * property and no last-import snapshot then the
+			 * instance is not a fully installed instance and
+			 * should not have a profile applied to it.
+			 *
+			 * This could happen if a service/instance declares
+			 * a dependent on behalf of another service/instance.
+			 */
+			if (scf_instance_get_snapshot(rinst, snap_lastimport,
+			    rsnap) != 0) {
+				if (scf_instance_get_pg(rinst, SCF_PG_GENERAL,
+				    imp_pg) != 0 || scf_pg_get_property(imp_pg,
+				    SCF_PROPERTY_ENABLED, imp_prop) != 0) {
+					if (g_verbose)
+						warn(gettext("Ignoreing "
+						    "partial instance "
+						    "%s:%s.\n"),
+						    inst->sc_parent->sc_name,
+						    inst->sc_name);
+					continue;
+				}
+			}
+
 			r = lscf_import_instance_pgs(rinst, inst->sc_fmri, inst,
 			    SCI_FORCE | SCI_KEEP);
 			switch (_lscf_import_err(r, inst->sc_fmri)) {
@@ -7765,7 +7859,10 @@
 	imp_tx = NULL;
 	scf_pg_destroy(imp_pg);
 	imp_pg = NULL;
-
+	scf_property_destroy(imp_prop);
+	imp_prop = NULL;
+
+	scf_snapshot_destroy(rsnap);
 	scf_iter_destroy(iter);
 	scf_instance_destroy(rinst);
 	scf_service_destroy(rsvc);
@@ -12413,7 +12510,7 @@
 	}
 
 	/* select smf/manifest */
-	lscf_select("smf/manifest");
+	lscf_select(HASH_SVC);
 	/*
 	 * Translate the manifest file name to property name. In the deathrow
 	 * case, the manifest file does not need to exist.
@@ -13074,6 +13171,39 @@
 		    uu_strerror(uu_error()));
 }
 
+static int
+remove_string(uu_list_t *strlist, const char *str)
+{
+	uu_list_walk_t	*elems;
+	string_list_t	*sp;
+
+	/*
+	 * Find the element that needs to be removed.
+	 */
+	elems = uu_list_walk_start(strlist, UU_DEFAULT);
+	while ((sp = uu_list_walk_next(elems)) != NULL) {
+		if (strcmp(sp->str, str) == 0)
+			break;
+	}
+	uu_list_walk_end(elems);
+
+	/*
+	 * Returning 1 here as the value was not found, this
+	 * might not be an error.  Leave it to the caller to
+	 * decide.
+	 */
+	if (sp == NULL) {
+		return (1);
+	}
+
+	uu_list_remove(strlist, sp);
+
+	free(sp->str);
+	free(sp);
+
+	return (0);
+}
+
 /*
  * Get all property values that don't match the given glob pattern,
  * if a pattern is specified.
@@ -14293,6 +14423,1272 @@
 	goto out;
 }
 
+/*
+ * Creates a list of instance name strings associated with a service. If
+ * wohandcrafted flag is set, get only instances that have a last-import
+ * snapshot, instances that were imported via svccfg.
+ */
+static uu_list_t *
+create_instance_list(scf_service_t *svc, int wohandcrafted)
+{
+	scf_snapshot_t  *snap = NULL;
+	scf_instance_t  *inst;
+	scf_iter_t	*inst_iter;
+	uu_list_t	*instances;
+	char		*instname;
+	int		r;
+
+	inst_iter = scf_iter_create(g_hndl);
+	inst = scf_instance_create(g_hndl);
+	if (inst_iter == NULL || inst == NULL) {
+		uu_warn(gettext("Could not create instance or iterator\n"));
+		scfdie();
+	}
+
+	if ((instances = uu_list_create(string_pool, NULL, 0)) == NULL)
+		return (instances);
+
+	if (scf_iter_service_instances(inst_iter, svc) != 0) {
+		switch (scf_error()) {
+		case SCF_ERROR_CONNECTION_BROKEN:
+		case SCF_ERROR_DELETED:
+			uu_list_destroy(instances);
+			instances = NULL;
+			goto out;
+
+		case SCF_ERROR_HANDLE_MISMATCH:
+		case SCF_ERROR_NOT_BOUND:
+		case SCF_ERROR_NOT_SET:
+		default:
+			bad_error("scf_iter_service_instances", scf_error());
+		}
+	}
+
+	instname = safe_malloc(max_scf_name_len + 1);
+	while ((r = scf_iter_next_instance(inst_iter, inst)) != 0) {
+		if (r == -1) {
+			(void) uu_warn(gettext("Unable to iterate through "
+			    "instances to create instance list : %s\n"),
+			    scf_strerror(scf_error()));
+
+			uu_list_destroy(instances);
+			instances = NULL;
+			goto out;
+		}
+
+		/*
+		 * If the instance does not have a last-import snapshot
+		 * then do not add it to the list as it is a hand-crafted
+		 * instance that should not be managed.
+		 */
+		if (wohandcrafted) {
+			if (snap == NULL &&
+			    (snap = scf_snapshot_create(g_hndl)) == NULL) {
+				uu_warn(gettext("Unable to create snapshot "
+				    "entity\n"));
+				scfdie();
+			}
+
+			if (scf_instance_get_snapshot(inst,
+			    snap_lastimport, snap) != 0) {
+				switch (scf_error()) {
+				case SCF_ERROR_NOT_FOUND :
+				case SCF_ERROR_DELETED:
+					continue;
+
+				case SCF_ERROR_CONNECTION_BROKEN:
+					uu_list_destroy(instances);
+					instances = NULL;
+					goto out;
+
+				case SCF_ERROR_HANDLE_MISMATCH:
+				case SCF_ERROR_NOT_BOUND:
+				case SCF_ERROR_NOT_SET:
+				default:
+					bad_error("scf_iter_service_instances",
+					    scf_error());
+				}
+			}
+		}
+
+		if (scf_instance_get_name(inst, instname,
+		    max_scf_name_len + 1) < 0) {
+			switch (scf_error()) {
+			case SCF_ERROR_NOT_FOUND :
+				continue;
+
+			case SCF_ERROR_CONNECTION_BROKEN:
+			case SCF_ERROR_DELETED:
+				uu_list_destroy(instances);
+				instances = NULL;
+				goto out;
+
+			case SCF_ERROR_HANDLE_MISMATCH:
+			case SCF_ERROR_NOT_BOUND:
+			case SCF_ERROR_NOT_SET:
+			default:
+				bad_error("scf_iter_service_instances",
+				    scf_error());
+			}
+		}
+
+		add_string(instances, instname);
+	}
+
+out:
+	if (snap)
+		scf_snapshot_destroy(snap);
+
+	scf_instance_destroy(inst);
+	scf_iter_destroy(inst_iter);
+	free(instname);
+	return (instances);
+}
+
+/*
+ * disable an instance but wait for the instance to
+ * move out of the running state.
+ *
+ * Returns 0 : if the instance did not disable
+ * Returns non-zero : if the instance disabled.
+ *
+ */
+static int
+disable_instance(scf_instance_t *instance)
+{
+	char	*fmribuf;
+	int	enabled = 10000;
+
+	if (inst_is_running(instance)) {
+		fmribuf = safe_malloc(max_scf_name_len + 1);
+		if (scf_instance_to_fmri(instance, fmribuf,
+		    max_scf_name_len + 1) < 0) {
+			free(fmribuf);
+			return (0);
+		}
+
+		/*
+		 * If the instance cannot be disabled then return
+		 * failure to disable and let the caller decide
+		 * if that is of importance.
+		 */
+		if (smf_disable_instance(fmribuf, 0) != 0) {
+			free(fmribuf);
+			return (0);
+		}
+
+		while (enabled) {
+			if (!inst_is_running(instance))
+				break;
+
+			(void) poll(NULL, 0, 5);
+			enabled = enabled - 5;
+		}
+
+		free(fmribuf);
+	}
+
+	return (enabled);
+}
+
+/*
+ * Function to compare two service_manifest structures.
+ */
+/* ARGSUSED2 */
+static int
+service_manifest_compare(const void *left, const void *right, void *unused)
+{
+	service_manifest_t *l = (service_manifest_t *)left;
+	service_manifest_t *r = (service_manifest_t *)right;
+	int rc;
+
+	rc = strcmp(l->servicename, r->servicename);
+
+	return (rc);
+}
+
+/*
+ * Look for the provided service in the service to manifest
+ * tree.  If the service exists, and a manifest was provided
+ * then add the manifest to that service.  If the service
+ * does not exist, then add the service and manifest to the
+ * list.
+ *
+ * If the manifest is NULL, return the element if found.  If
+ * the service is not found return NULL.
+ */
+service_manifest_t *
+find_add_svc_mfst(const char *svnbuf, const char *mfst)
+{
+	service_manifest_t	elem;
+	service_manifest_t	*fnelem;
+	uu_avl_index_t		marker;
+
+	elem.servicename = svnbuf;
+	fnelem = uu_avl_find(service_manifest_tree, &elem, NULL, &marker);
+
+	if (mfst) {
+		if (fnelem) {
+			add_string(fnelem->mfstlist, strdup(mfst));
+		} else {
+			fnelem = safe_malloc(sizeof (*fnelem));
+			fnelem->servicename = safe_strdup(svnbuf);
+			if ((fnelem->mfstlist =
+			    uu_list_create(string_pool, NULL, 0)) == NULL)
+				uu_die(gettext("Could not create property "
+				    "list: %s\n"), uu_strerror(uu_error()));
+
+			add_string(fnelem->mfstlist, safe_strdup(mfst));
+
+			uu_avl_insert(service_manifest_tree, fnelem, marker);
+		}
+	}
+
+	return (fnelem);
+}
+
+/*
+ * Create the service to manifest avl tree.
+ *
+ * Walk each of the manifests currently installed in the supported
+ * directories, /lib/svc/manifests and /var/svc/manifests.  For
+ * each of the manifests, inventory the services and add them to
+ * the tree.
+ *
+ * Code that calls this function should make sure fileystem/minimal is online,
+ * /var is available, since this function walks the /var/svc/manifest directory.
+ */
+static void
+create_manifest_tree(void)
+{
+	manifest_info_t **entry;
+	manifest_info_t **manifests;
+	uu_list_walk_t	*svcs;
+	bundle_t	*b;
+	entity_t	*mfsvc;
+	char		*dirs[] = {LIBSVC_DIR, VARSVC_DIR, NULL};
+	int		c, status;
+
+	if (service_manifest_pool)
+		return;
+
+	/*
+	 * Create the list pool for the service manifest list
+	 */
+	service_manifest_pool = uu_avl_pool_create("service_manifest",
+	    sizeof (service_manifest_t),
+	    offsetof(service_manifest_t, svcmfst_node),
+	    service_manifest_compare, UU_DEFAULT);
+	if (service_manifest_pool == NULL)
+		uu_die(gettext("service_manifest pool creation failed: %s\n"),
+		    uu_strerror(uu_error()));
+
+	/*
+	 * Create the list
+	 */
+	service_manifest_tree = uu_avl_create(service_manifest_pool, NULL,
+	    UU_DEFAULT);
+	if (service_manifest_tree == NULL)
+		uu_die(gettext("service_manifest tree creation failed: %s\n"),
+		    uu_strerror(uu_error()));
+
+	/*
+	 * Walk the manifests adding the service(s) from each manifest.
+	 *
+	 * If a service already exists add the manifest to the manifest
+	 * list for that service.  This covers the case of a service that
+	 * is supported by multiple manifest files.
+	 */
+	for (c = 0; dirs[c]; c++) {
+		status = find_manifests(dirs[c], &manifests, CHECKEXT);
+		if (status < 0) {
+			uu_warn(gettext("file tree walk of %s encountered "
+			    "error %s\n"), dirs[c], strerror(errno));
+
+			uu_avl_destroy(service_manifest_tree);
+			service_manifest_tree = NULL;
+			return;
+		}
+
+		/*
+		 * If a manifest that was in the list is not found
+		 * then skip and go to the next manifest file.
+		 */
+		if (manifests != NULL) {
+			for (entry = manifests; *entry != NULL; entry++) {
+				b = internal_bundle_new();
+				if (lxml_get_bundle_file(b, (*entry)->mi_path,
+				    SVCCFG_OP_IMPORT) != 0) {
+					internal_bundle_free(b);
+					continue;
+				}
+
+				svcs = uu_list_walk_start(b->sc_bundle_services,
+				    0);
+				if (svcs == NULL) {
+					internal_bundle_free(b);
+					continue;
+				}
+
+				while ((mfsvc = uu_list_walk_next(svcs)) !=
+				    NULL) {
+					/* Add manifest to service */
+					(void) find_add_svc_mfst(mfsvc->sc_name,
+					    (*entry)->mi_path);
+				}
+
+				uu_list_walk_end(svcs);
+				internal_bundle_free(b);
+			}
+
+			free_manifest_array(manifests);
+		}
+	}
+}
+
+/*
+ * Check the manifest history file to see
+ * if the service was ever installed from
+ * one of the supported directories.
+ *
+ * Return Values :
+ * 	-1 - if there's error reading manifest history file
+ *	 1 - if the service is not found
+ *	 0 - if the service is found
+ */
+static int
+check_mfst_history(const char *svcname)
+{
+	struct stat	st;
+	caddr_t		mfsthist_start;
+	char		*svnbuf;
+	int		fd;
+	int		r = 1;
+
+	fd = open(MFSTHISTFILE, O_RDONLY);
+	if (fd == -1) {
+		uu_warn(gettext("Unable to open the history file\n"));
+		return (-1);
+	}
+
+	if (fstat(fd, &st) == -1) {
+		uu_warn(gettext("Unable to stat the history file\n"));
+		return (-1);
+	}
+
+	mfsthist_start = mmap(0, st.st_size, PROT_READ,
+	    MAP_PRIVATE, fd, 0);
+
+	(void) close(fd);
+	if (mfsthist_start == MAP_FAILED ||
+	    *(mfsthist_start + st.st_size) != '\0') {
+		(void) munmap(mfsthist_start, st.st_size);
+		return (-1);
+	}
+
+	/*
+	 * The manifest history file is a space delimited list
+	 * of service and instance to manifest linkage.  Adding
+	 * a space to the end of the service name so to get only
+	 * the service that is being searched for.
+	 */
+	svnbuf = uu_msprintf("%s ", svcname);
+	if (svnbuf == NULL)
+		uu_die(gettext("Out of memory"));
+
+	if (strstr(mfsthist_start, svnbuf) != NULL)
+		r = 0;
+
+	(void) munmap(mfsthist_start, st.st_size);
+	uu_free(svnbuf);
+	return (r);
+}
+
+/*
+ * Take down each of the instances in the service
+ * and remove them, then delete the service.
+ */
+static void
+teardown_service(scf_service_t *svc, const char *svnbuf)
+{
+	scf_instance_t	*instance;
+	scf_iter_t	*iter;
+	int		r;
+
+	safe_printf(gettext("Delete service %s as there are no "
+	    "supporting manifests\n"), svnbuf);
+
+	instance = scf_instance_create(g_hndl);
+	iter = scf_iter_create(g_hndl);
+	if (iter == NULL || instance == NULL) {
+		uu_warn(gettext("Unable to create supporting entities to "
+		    "teardown the service\n"));
+		uu_warn(gettext("scf error is : %s\n"),
+		    scf_strerror(scf_error()));
+		scfdie();
+	}
+
+	if (scf_iter_service_instances(iter, svc) != 0) {
+		switch (scf_error()) {
+		case SCF_ERROR_CONNECTION_BROKEN:
+		case SCF_ERROR_DELETED:
+			goto out;
+
+		case SCF_ERROR_HANDLE_MISMATCH:
+		case SCF_ERROR_NOT_BOUND:
+		case SCF_ERROR_NOT_SET:
+		default:
+			bad_error("scf_iter_service_instances",
+			    scf_error());
+		}
+	}
+
+	while ((r = scf_iter_next_instance(iter, instance)) != 0) {
+		if (r == -1) {
+			uu_warn(gettext("Error - %s\n"),
+			    scf_strerror(scf_error()));
+			goto out;
+		}
+
+		(void) disable_instance(instance);
+	}
+
+	/*
+	 * Delete the service... forcing the deletion in case
+	 * any of the instances did not disable.
+	 */
+	(void) lscf_service_delete(svc, 1);
+out:
+	scf_instance_destroy(instance);
+	scf_iter_destroy(iter);
+}
+
+/*
+ * Get the list of instances supported by the manifest
+ * file.
+ *
+ * Return 0 if there are no instances.
+ *
+ * Return -1 if there are errors attempting to collect instances.
+ *
+ * Return the count of instances found if there are no errors.
+ *
+ */
+static int
+check_instance_support(char *mfstfile, const char *svcname,
+    uu_list_t *instances)
+{
+	uu_list_walk_t	*svcs, *insts;
+	uu_list_t	*ilist;
+	bundle_t	*b;
+	entity_t	*mfsvc, *mfinst;
+	const char	*svcn;
+	int		rminstcnt = 0;
+
+
+	b = internal_bundle_new();
+
+	if (lxml_get_bundle_file(b, mfstfile, SVCCFG_OP_IMPORT) != 0) {
+		/*
+		 * Unable to process the manifest file for
+		 * instance support, so just return as
+		 * don't want to remove instances that could
+		 * not be accounted for that might exist here.
+		 */
+		internal_bundle_free(b);
+		return (0);
+	}
+
+	svcs = uu_list_walk_start(b->sc_bundle_services, 0);
+	if (svcs == NULL) {
+		internal_bundle_free(b);
+		return (0);
+	}
+
+	svcn = svcname + (sizeof (SCF_FMRI_SVC_PREFIX) - 1) +
+	    (sizeof (SCF_FMRI_SERVICE_PREFIX) - 1);
+
+	while ((mfsvc = uu_list_walk_next(svcs)) != NULL) {
+		if (strcmp(mfsvc->sc_name, svcn) == 0)
+			break;
+	}
+	uu_list_walk_end(svcs);
+
+	if (mfsvc == NULL) {
+		internal_bundle_free(b);
+		return (-1);
+	}
+
+	ilist = mfsvc->sc_u.sc_service.sc_service_instances;
+	if ((insts = uu_list_walk_start(ilist, 0)) == NULL) {
+		internal_bundle_free(b);
+		return (0);
+	}
+
+	while ((mfinst = uu_list_walk_next(insts)) != NULL) {
+		/*
+		 * Remove the instance from the instances list.
+		 * The unaccounted for instances will be removed
+		 * from the service once all manifests are
+		 * processed.
+		 */
+		(void) remove_string(instances,
+		    mfinst->sc_name);
+		rminstcnt++;
+	}
+
+	uu_list_walk_end(insts);
+	internal_bundle_free(b);
+
+	return (rminstcnt);
+}
+
+/*
+ * For the given service, set its SCF_PG_MANIFESTFILES/SUPPORT property to
+ * 'false' to indicate there's no manifest file(s) found for the service.
+ */
+static void
+svc_add_no_support(scf_service_t *svc)
+{
+	char	*pname;
+
+	/* Add no support */
+	cur_svc = svc;
+	if (addpg(SCF_PG_MANIFESTFILES, SCF_GROUP_FRAMEWORK))
+		return;
+
+	pname = uu_msprintf("%s/%s", SCF_PG_MANIFESTFILES, SUPPORTPROP);
+	if (pname == NULL)
+		uu_die(gettext("Out of memory.\n"));
+
+	(void) lscf_addpropvalue(pname, "boolean:", "0");
+
+	uu_free(pname);
+	cur_svc = NULL;
+}
+
+/*
+ * This function handles all upgrade scenarios for a service that doesn't have
+ * SCF_PG_MANIFESTFILES pg. The function creates and populates
+ * SCF_PG_MANIFESTFILES pg for the given service to keep track of service to
+ * manifest(s) mapping. Manifests under supported directories are inventoried
+ * and a property is added for each file that delivers configuration to the
+ * service.  A service that has no corresponding manifest files (deleted) are
+ * removed from repository.
+ *
+ * Unsupported services:
+ *
+ * A service is considered unsupported if there is no corresponding manifest
+ * in the supported directories for that service and the service isn't in the
+ * history file list.  The history file, MFSTHISTFILE, contains a list of all
+ * services and instances that were delivered by Solaris before the introduction
+ * of the SCF_PG_MANIFESTFILES property group.  The history file also contains
+ * the path to the manifest file that defined the service or instance.
+ *
+ * Another type of unsupported services is 'handcrafted' services,
+ * programmatically created services or services created by dependent entries
+ * in other manifests. A handcrafted service is identified by its lack of any
+ * instance containing last-import snapshot which is created during svccfg
+ * import.
+ *
+ * This function sets a flag for unsupported services by setting services'
+ * SCF_PG_MANIFESTFILES/support property to false.
+ */
+static void
+upgrade_svc_mfst_connection(scf_service_t *svc, const char *svcname)
+{
+	service_manifest_t	*elem;
+	uu_list_walk_t		*mfwalk;
+	string_list_t		*mfile;
+	uu_list_t		*instances;
+	const char		*sname;
+	char			*pname;
+	int			r;
+
+	/*
+	 * Since there's no guarantee manifests under /var are available during
+	 * early import, don't perform any upgrade during early import.
+	 */
+	if (IGNORE_VAR)
+		return;
+
+	if (service_manifest_tree == NULL) {
+		create_manifest_tree();
+	}
+
+	/*
+	 * Find service's supporting manifest(s) after
+	 * stripping off the svc:/ prefix that is part
+	 * of the fmri that is not used in the service
+	 * manifest bundle list.
+	 */
+	sname = svcname + strlen(SCF_FMRI_SVC_PREFIX) +
+	    strlen(SCF_FMRI_SERVICE_PREFIX);
+	elem = find_add_svc_mfst(sname, NULL);
+	if (elem == NULL) {
+
+		/*
+		 * A handcrafted service, one that has no instance containing
+		 * last-import snapshot, should get unsupported flag.
+		 */
+		instances = create_instance_list(svc, 1);
+		if (instances == NULL) {
+			uu_warn(gettext("Unable to create instance list %s\n"),
+			    svcname);
+			return;
+		}
+
+		if (uu_list_numnodes(instances) == 0) {
+			svc_add_no_support(svc);
+			return;
+		}
+
+		/*
+		 * If the service is in the history file, and its supporting
+		 * manifests are not found, we can safely delete the service
+		 * because its manifests are removed from the system.
+		 *
+		 * Services not found in the history file are not delivered by
+		 * Solaris and/or delivered outside supported directories, set
+		 * unsupported flag for these services.
+		 */
+		r = check_mfst_history(svcname);
+		if (r == -1)
+			return;
+
+		if (r) {
+			/* Set unsupported flag for service  */
+			svc_add_no_support(svc);
+		} else {
+			/* Delete the service */
+			teardown_service(svc, svcname);
+		}
+
+		return;
+	}
+
+	/*
+	 * Walk through the list of manifests and add them
+	 * to the service.
+	 *
+	 * Create a manifestfiles pg and add the property.
+	 */
+	mfwalk = uu_list_walk_start(elem->mfstlist, 0);
+	if (mfwalk == NULL)
+		return;
+
+	cur_svc = svc;
+	r = addpg(SCF_PG_MANIFESTFILES, SCF_GROUP_FRAMEWORK);
+	if (r != 0) {
+		cur_svc = NULL;
+		return;
+	}
+
+	while ((mfile = uu_list_walk_next(mfwalk)) != NULL) {
+		pname = uu_msprintf("%s/%s", SCF_PG_MANIFESTFILES,
+		    mhash_filename_to_propname(mfile->str, 0));
+		if (pname == NULL)
+			uu_die(gettext("Out of memory.\n"));
+
+		(void) lscf_addpropvalue(pname, "astring:", mfile->str);
+		uu_free(pname);
+	}
+	uu_list_walk_end(mfwalk);
+
+	cur_svc = NULL;
+}
+
+/*
+ * Take a service and process the manifest file entires to see if
+ * there is continued support for the service and instances.  If
+ * not cleanup as appropriate.
+ *
+ * If a service does not have a manifest files entry flag it for
+ * upgrade and return.
+ *
+ * For each manifestfiles property check if the manifest file is
+ * under the supported /lib/svc/manifest or /var/svc/manifest path
+ * and if not then return immediately as this service is not supported
+ * by the cleanup mechanism and should be ignored.
+ *
+ * For each manifest file that is supported, check to see if the
+ * file exists.  If not then remove the manifest file property
+ * from the service and the smf/manifest hash table.  If the manifest
+ * file exists then verify that it supports the instances that are
+ * part of the service.
+ *
+ * Once all manifest files have been accounted for remove any instances
+ * that are no longer supported in the service.
+ *
+ * Return values :
+ * 0 - Successfully processed the service
+ * non-zero - failed to process the service
+ *
+ * On most errors, will just return to wait and get the next service,
+ * unless in case of unable to create the needed structures which is
+ * most likely a fatal error that is not going to be recoverable.
+ */
+int
+lscf_service_cleanup(void *act, scf_walkinfo_t *wip)
+{
+	struct mpg_mfile	*mpntov;
+	struct mpg_mfile	**mpvarry = NULL;
+	scf_service_t		*svc;
+	scf_propertygroup_t	*mpg;
+	scf_property_t		*mp;
+	scf_value_t		*mv;
+	scf_iter_t		*mi;
+	scf_instance_t		*instance;
+	uu_list_walk_t		*insts;
+	uu_list_t		*instances = NULL;
+	boolean_t		activity = (boolean_t)act;
+	char			*mpnbuf;
+	char			*mpvbuf;
+	char			*pgpropbuf;
+	int			mfstcnt, rminstct, instct, mfstmax;
+	int			index;
+	int			r = 0;
+
+	assert(g_hndl != NULL);
+	assert(wip->svc != NULL);
+	assert(wip->fmri != NULL);
+
+	svc = wip->svc;
+
+	mpg = scf_pg_create(g_hndl);
+	mp = scf_property_create(g_hndl);
+	mi = scf_iter_create(g_hndl);
+	mv = scf_value_create(g_hndl);
+	instance = scf_instance_create(g_hndl);
+
+	if (mpg == NULL || mp == NULL || mi == NULL || mv == NULL ||
+	    instance == NULL) {
+		uu_warn(gettext("Unable to create the supporting entities\n"));
+		uu_warn(gettext("scf error is : %s\n"),
+		    scf_strerror(scf_error()));
+		scfdie();
+	}
+
+	/*
+	 * Get the manifestfiles property group to be parsed for
+	 * files existence.
+	 */
+	if (scf_service_get_pg(svc, SCF_PG_MANIFESTFILES, mpg) != SCF_SUCCESS) {
+		switch (scf_error()) {
+		case SCF_ERROR_NOT_FOUND:
+			upgrade_svc_mfst_connection(svc, wip->fmri);
+			break;
+		case SCF_ERROR_DELETED:
+		case SCF_ERROR_CONNECTION_BROKEN:
+			goto out;
+
+		case SCF_ERROR_HANDLE_MISMATCH:
+		case SCF_ERROR_NOT_BOUND:
+		case SCF_ERROR_NOT_SET:
+		default:
+			bad_error("scf_iter_pg_properties",
+			    scf_error());
+		}
+
+		goto out;
+	}
+
+	/*
+	 * Iterate through each of the manifestfiles properties
+	 * to determine what manifestfiles are available.
+	 *
+	 * If a manifest file is supported then increment the
+	 * count and therefore the service is safe.
+	 */
+	if (scf_iter_pg_properties(mi, mpg) != 0) {
+		switch (scf_error()) {
+		case SCF_ERROR_DELETED:
+		case SCF_ERROR_CONNECTION_BROKEN:
+			goto out;
+
+		case SCF_ERROR_HANDLE_MISMATCH:
+		case SCF_ERROR_NOT_BOUND:
+		case SCF_ERROR_NOT_SET:
+		default:
+			bad_error("scf_iter_pg_properties",
+			    scf_error());
+		}
+	}
+
+	mfstcnt = 0;
+	mfstmax = MFSTFILE_MAX;
+	mpvarry = safe_malloc(sizeof (struct mpg_file *) * MFSTFILE_MAX);
+	while ((r = scf_iter_next_property(mi, mp)) != 0) {
+		if (r == -1)
+			bad_error(gettext("Unable to iterate through "
+			    "manifestfiles properties : %s"),
+			    scf_error());
+
+		mpntov = safe_malloc(sizeof (struct mpg_mfile));
+		mpnbuf = safe_malloc(max_scf_name_len + 1);
+		mpvbuf = safe_malloc(max_scf_value_len + 1);
+		mpntov->mpg = mpnbuf;
+		mpntov->mfile = mpvbuf;
+		mpntov->access = 1;
+		if (scf_property_get_name(mp, mpnbuf,
+		    max_scf_name_len + 1) < 0) {
+			uu_warn(gettext("Unable to get manifest file "
+			    "property : %s\n"),
+			    scf_strerror(scf_error()));
+
+			switch (scf_error()) {
+			case SCF_ERROR_DELETED:
+			case SCF_ERROR_CONNECTION_BROKEN:
+				r = scferror2errno(scf_error());
+				goto out_free;
+
+			case SCF_ERROR_HANDLE_MISMATCH:
+			case SCF_ERROR_NOT_BOUND:
+			case SCF_ERROR_NOT_SET:
+			default:
+				bad_error("scf_iter_pg_properties",
+				    scf_error());
+			}
+		}
+
+		/*
+		 * The support property is a boolean value that indicates
+		 * if the service is supported for manifest file deletion.
+		 * Currently at this time there is no code that sets this
+		 * value to true.  So while we could just let this be caught
+		 * by the support check below, in the future this by be set
+		 * to true and require processing.  So for that, go ahead
+		 * and check here, and just return if false.  Otherwise,
+		 * fall through expecting that other support checks will
+		 * handle the entries.
+		 */
+		if (strcmp(mpnbuf, SUPPORTPROP) == 0) {
+			uint8_t	support;
+
+			if (scf_property_get_value(mp, mv) != 0 ||
+			    scf_value_get_boolean(mv, &support) != 0) {
+				uu_warn(gettext("Unable to get the manifest "
+				    "support value: %s\n"),
+				    scf_strerror(scf_error()));
+
+				switch (scf_error()) {
+				case SCF_ERROR_DELETED:
+				case SCF_ERROR_CONNECTION_BROKEN:
+					r = scferror2errno(scf_error());
+					goto out_free;
+
+				case SCF_ERROR_HANDLE_MISMATCH:
+				case SCF_ERROR_NOT_BOUND:
+				case SCF_ERROR_NOT_SET:
+				default:
+					bad_error("scf_iter_pg_properties",
+					    scf_error());
+				}
+			}
+
+			if (support == B_FALSE)
+				goto out_free;
+		}
+
+		/*
+		 * Anything with a manifest outside of the supported
+		 * directories, immediately bail out because that makes
+		 * this service non-supported.  We don't even want
+		 * to do instance processing in this case because the
+		 * instances could be part of the non-supported manifest.
+		 */
+		if (strncmp(mpnbuf, LIBSVC_PR, strlen(LIBSVC_PR)) != 0) {
+			/*
+			 * Manifest is not in /lib/svc, so we need to
+			 * consider the /var/svc case.
+			 */
+			if (strncmp(mpnbuf, VARSVC_PR,
+			    strlen(VARSVC_PR)) != 0 || IGNORE_VAR) {
+				/*
+				 * Either the manifest is not in /var/svc or
+				 * /var is not yet mounted.  We ignore the
+				 * manifest either because it is not in a
+				 * standard location or because we cannot
+				 * currently access the manifest.
+				 */
+				goto out_free;
+			}
+		}
+
+		/*
+		 * Get the value to of the manifest file for this entry
+		 * for access verification and instance support
+		 * verification if it still exists.
+		 *
+		 * During Early Manifest Import if the manifest is in
+		 * /var/svc then it may not yet be available for checking
+		 * so we must determine if /var/svc is available.  If not
+		 * then defer until Late Manifest Import to cleanup.
+		 */
+		if (scf_property_get_value(mp, mv) != 0) {
+			uu_warn(gettext("Unable to get the manifest file "
+			    "value: %s\n"),
+			    scf_strerror(scf_error()));
+
+			switch (scf_error()) {
+			case SCF_ERROR_DELETED:
+			case SCF_ERROR_CONNECTION_BROKEN:
+				r = scferror2errno(scf_error());
+				goto out_free;
+
+			case SCF_ERROR_HANDLE_MISMATCH:
+			case SCF_ERROR_NOT_BOUND:
+			case SCF_ERROR_NOT_SET:
+			default:
+				bad_error("scf_property_get_value",
+				    scf_error());
+			}
+		}
+
+		if (scf_value_get_astring(mv, mpvbuf,
+		    max_scf_value_len + 1) < 0) {
+			uu_warn(gettext("Unable to get the manifest "
+			    "file : %s\n"),
+			    scf_strerror(scf_error()));
+
+			switch (scf_error()) {
+			case SCF_ERROR_DELETED:
+			case SCF_ERROR_CONNECTION_BROKEN:
+				r = scferror2errno(scf_error());
+				goto out_free;
+
+			case SCF_ERROR_HANDLE_MISMATCH:
+			case SCF_ERROR_NOT_BOUND:
+			case SCF_ERROR_NOT_SET:
+			default:
+				bad_error("scf_value_get_astring",
+				    scf_error());
+			}
+		}
+
+		mpvarry[mfstcnt] = mpntov;
+		mfstcnt++;
+
+		/*
+		 * Check for the need to reallocate array
+		 */
+		if (mfstcnt >= (mfstmax - 1)) {
+			struct mpg_mfile **newmpvarry;
+
+			mfstmax = mfstmax * 2;
+			newmpvarry = realloc(mpvarry,
+			    sizeof (struct mpg_mfile *) * mfstmax);
+
+			if (newmpvarry == NULL)
+				goto out_free;
+
+			mpvarry = newmpvarry;
+		}
+
+		mpvarry[mfstcnt] = NULL;
+	}
+
+	for (index = 0; mpvarry[index]; index++) {
+		mpntov = mpvarry[index];
+
+		/*
+		 * Check to see if the manifestfile is accessable, if so hand
+		 * this service and manifestfile off to be processed for
+		 * instance support.
+		 */
+		mpnbuf = mpntov->mpg;
+		mpvbuf = mpntov->mfile;
+		if (access(mpvbuf, F_OK) != 0) {
+			mpntov->access = 0;
+			activity++;
+			mfstcnt--;
+			/* Remove the entry from the service */
+			cur_svc = svc;
+			pgpropbuf = uu_msprintf("%s/%s", SCF_PG_MANIFESTFILES,
+			    mpnbuf);
+			if (pgpropbuf == NULL)
+				uu_die(gettext("Out of memory.\n"));
+
+			lscf_delprop(pgpropbuf);
+			cur_svc = NULL;
+
+			uu_free(pgpropbuf);
+		}
+	}
+
+	/*
+	 * If mfstcnt is 0, none of the manifests that supported the service
+	 * existed so remove the service.
+	 */
+	if (mfstcnt == 0) {
+		teardown_service(svc, wip->fmri);
+
+		goto out_free;
+	}
+
+	if (activity) {
+		int	nosvcsupport = 0;
+
+		/*
+		 * If the list of service instances is NULL then
+		 * create the list.
+		 */
+		instances = create_instance_list(svc, 1);
+		if (instances == NULL) {
+			uu_warn(gettext("Unable to create instance list %s\n"),
+			    wip->fmri);
+			goto out_free;
+		}
+
+		rminstct = uu_list_numnodes(instances);
+		instct = rminstct;
+
+		for (index = 0; mpvarry[index]; index++) {
+			mpntov = mpvarry[index];
+			if (mpntov->access == 0)
+				continue;
+
+			mpnbuf = mpntov->mpg;
+			mpvbuf = mpntov->mfile;
+			r = check_instance_support(mpvbuf, wip->fmri,
+			    instances);
+			if (r == -1) {
+				nosvcsupport++;
+			} else {
+				rminstct -= r;
+			}
+		}
+
+		if (instct && instct == rminstct && nosvcsupport == mfstcnt) {
+			teardown_service(svc, wip->fmri);
+
+			goto out_free;
+		}
+	}
+
+	/*
+	 * If there are instances left on the instance list, then
+	 * we must remove them.
+	 */
+	if (instances != NULL && uu_list_numnodes(instances)) {
+		string_list_t *sp;
+
+		insts = uu_list_walk_start(instances, 0);
+		while ((sp = uu_list_walk_next(insts)) != NULL) {
+			/*
+			 * Remove the instance from the instances list.
+			 */
+			safe_printf(gettext("Delete instance %s from "
+			    "service %s\n"), sp->str, wip->fmri);
+			if (scf_service_get_instance(svc, sp->str,
+			    instance) != SCF_SUCCESS) {
+				(void) uu_warn("scf_error - %s\n",
+				    scf_strerror(scf_error()));
+
+				continue;
+			}
+
+			(void) disable_instance(instance);
+
+			(void) lscf_instance_delete(instance, 1);
+		}
+		scf_instance_destroy(instance);
+		uu_list_walk_end(insts);
+	}
+
+out_free:
+	if (mpvarry) {
+		struct mpg_mfile *fmpntov;
+
+		for (index = 0; mpvarry[index]; index++) {
+			fmpntov  = mpvarry[index];
+			if (fmpntov->mpg == mpnbuf)
+				mpnbuf = NULL;
+			free(fmpntov->mpg);
+
+			if (fmpntov->mfile == mpvbuf)
+				mpvbuf = NULL;
+			free(fmpntov->mfile);
+
+			if (fmpntov == mpntov)
+				mpntov = NULL;
+			free(fmpntov);
+		}
+		if (mpnbuf)
+			free(mpnbuf);
+		if (mpvbuf)
+			free(mpvbuf);
+		if (mpntov)
+			free(mpntov);
+
+		free(mpvarry);
+	}
+out:
+	scf_pg_destroy(mpg);
+	scf_property_destroy(mp);
+	scf_iter_destroy(mi);
+	scf_value_destroy(mv);
+
+	return (0);
+}
+
+/*
+ * Take the service and search for the manifestfiles property
+ * in each of the property groups.  If the manifest file
+ * associated with the property does not exist then remove
+ * the property group.
+ */
+int
+lscf_hash_cleanup()
+{
+	scf_service_t		*svc;
+	scf_scope_t		*scope;
+	scf_propertygroup_t	*pg;
+	scf_property_t		*prop;
+	scf_value_t		*val;
+	scf_iter_t		*iter;
+	char			*pgname;
+	char			*mfile;
+	int			r;
+
+	svc = scf_service_create(g_hndl);
+	scope = scf_scope_create(g_hndl);
+	pg = scf_pg_create(g_hndl);
+	prop = scf_property_create(g_hndl);
+	val = scf_value_create(g_hndl);
+	iter = scf_iter_create(g_hndl);
+	if (pg == NULL || prop == NULL || val == NULL || iter == NULL ||
+	    svc == NULL || scope == NULL) {
+		uu_warn(gettext("Unable to create a property group, or "
+		    "property\n"));
+		uu_warn("%s\n", pg == NULL ? "pg is NULL" :
+		    "pg is not NULL");
+		uu_warn("%s\n", prop == NULL ? "prop is NULL" :
+		    "prop is not NULL");
+		uu_warn("%s\n", val == NULL ? "val is NULL" :
+		    "val is not NULL");
+		uu_warn("%s\n", iter == NULL ? "iter is NULL" :
+		    "iter is not NULL");
+		uu_warn("%s\n", svc == NULL ? "svc is NULL" :
+		    "svc is not NULL");
+		uu_warn("%s\n", scope == NULL ? "scope is NULL" :
+		    "scope is not NULL");
+		uu_warn(gettext("scf error is : %s\n"),
+		    scf_strerror(scf_error()));
+		scfdie();
+	}
+
+	if (scf_handle_get_scope(g_hndl, SCF_SCOPE_LOCAL, scope) != 0) {
+		switch (scf_error()) {
+		case SCF_ERROR_CONNECTION_BROKEN:
+		case SCF_ERROR_NOT_FOUND:
+			goto out;
+
+		case SCF_ERROR_HANDLE_MISMATCH:
+		case SCF_ERROR_NOT_BOUND:
+		case SCF_ERROR_INVALID_ARGUMENT:
+		default:
+			bad_error("scf_handle_get_scope", scf_error());
+		}
+	}
+
+	if (scf_scope_get_service(scope, HASH_SVC, svc) != 0) {
+		uu_warn(gettext("Unable to process the hash service, %s\n"),
+		    HASH_SVC);
+		goto out;
+	}
+
+	pgname = safe_malloc(max_scf_name_len + 1);
+	mfile = safe_malloc(max_scf_value_len + 1);
+
+	if (scf_iter_service_pgs(iter, svc) != SCF_SUCCESS) {
+		uu_warn(gettext("Unable to cleanup smf hash table : %s\n"),
+		    scf_strerror(scf_error()));
+		goto out;
+	}
+
+	while ((r = scf_iter_next_pg(iter, pg)) != 0) {
+		if (r == -1)
+			goto out;
+
+		if (scf_pg_get_name(pg, pgname, max_scf_name_len + 1) < 0) {
+			switch (scf_error()) {
+			case SCF_ERROR_DELETED:
+				return (ENODEV);
+
+			case SCF_ERROR_CONNECTION_BROKEN:
+				return (ECONNABORTED);
+
+			case SCF_ERROR_NOT_SET:
+			case SCF_ERROR_NOT_BOUND:
+			default:
+				bad_error("scf_pg_get_name", scf_error());
+			}
+		}
+		if (IGNORE_VAR) {
+			if (strncmp(pgname, VARSVC_PR, strlen(VARSVC_PR)) == 0)
+				continue;
+		}
+
+		/*
+		 * If unable to get the property continue as this is an
+		 * entry that has no location to check against.
+		 */
+		if (scf_pg_get_property(pg, MFSTFILEPR, prop) != SCF_SUCCESS) {
+			continue;
+		}
+
+		if (scf_property_get_value(prop, val) != SCF_SUCCESS) {
+			uu_warn(gettext("Unable to get value from %s\n"),
+			    pgname);
+			goto error_handle;
+		}
+
+		if (scf_value_get_astring(val, mfile, max_scf_value_len + 1) ==
+		    -1) {
+			uu_warn(gettext("Unable to get astring from %s : %s\n"),
+			    pgname, scf_strerror(scf_error()));
+			goto error_handle;
+		}
+
+		if (access(mfile, F_OK) == 0)
+			continue;
+
+		(void) scf_pg_delete(pg);
+
+error_handle:
+		switch (scf_error()) {
+		case SCF_ERROR_DELETED:
+		case SCF_ERROR_CONSTRAINT_VIOLATED:
+		case SCF_ERROR_NOT_FOUND:
+		case SCF_ERROR_NOT_SET:
+			continue;
+
+		case SCF_ERROR_CONNECTION_BROKEN:
+			r = scferror2errno(scf_error());
+			goto out;
+
+		case SCF_ERROR_HANDLE_MISMATCH:
+		case SCF_ERROR_NOT_BOUND:
+		default:
+			bad_error("scf_value_get_astring",
+			    scf_error());
+		}
+	}
+
+out:
+	scf_scope_destroy(scope);
+	scf_service_destroy(svc);
+	scf_pg_destroy(pg);
+	scf_property_destroy(prop);
+	scf_value_destroy(val);
+	scf_iter_destroy(iter);
+	free(pgname);
+	free(mfile);
+
+	return (0);
+}
+
 #ifndef NATIVE_BUILD
 /* ARGSUSED */
 CPL_MATCH_FN(complete_select)
--- a/usr/src/cmd/svc/svccfg/svccfg_xml.c	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/svc/svccfg/svccfg_xml.c	Thu Mar 25 14:57:35 2010 -0700
@@ -19,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -2945,6 +2945,64 @@
 }
 
 /*
+ * Check to see if the service should allow the upgrade
+ * process to handle adding of the manifestfiles linkage.
+ *
+ * If the service exists and does not have a manifestfiles
+ * property group then the upgrade process should handle
+ * the service.
+ *
+ * If the service doesn't exist or the service exists
+ * and has a manifestfiles property group then the import
+ * process can handle the manifestfiles property group
+ * work.
+ *
+ * This prevents potential cleanup of unaccounted for instances
+ * in early manifest import due to upgrade process needing
+ * information that has not yet been supplied by manifests
+ * that are still located in the /var/svc manifests directory.
+ */
+static int
+lxml_check_upgrade(const char *service) {
+	scf_handle_t	*h = NULL;
+	scf_scope_t	*sc = NULL;
+	scf_service_t	*svc = NULL;
+	scf_propertygroup_t	*pg = NULL;
+	int rc = SCF_FAILED;
+
+	if ((h = scf_handle_create(SCF_VERSION)) == NULL ||
+	    (sc = scf_scope_create(h)) == NULL ||
+	    (svc = scf_service_create(h)) == NULL ||
+	    (pg = scf_pg_create(h)) == NULL)
+		goto out;
+
+	if (scf_handle_bind(h) != 0)
+		goto out;
+
+	if (scf_handle_get_scope(h, SCF_FMRI_LOCAL_SCOPE, sc) == -1)
+		goto out;
+
+	if (scf_scope_get_service(sc, service, svc) != SCF_SUCCESS) {
+		if (scf_error() == SCF_ERROR_NOT_FOUND)
+			rc = SCF_SUCCESS;
+
+		goto out;
+	}
+
+	if (scf_service_get_pg(svc, SCF_PG_MANIFESTFILES, pg) != SCF_SUCCESS)
+		goto out;
+
+	rc = SCF_SUCCESS;
+out:
+	scf_pg_destroy(pg);
+	scf_service_destroy(svc);
+	scf_scope_destroy(sc);
+	scf_handle_destroy(h);
+
+	return (rc);
+}
+
+/*
  * Translate a service element into an internal instance/property tree, added
  * to bundle.  If op is SVCCFG_OP_APPLY, allow only instance subelements.
  */
@@ -2977,7 +3035,8 @@
 	 * Now that the service is created create the manifest
 	 * property group and add the property value of the service.
 	 */
-	if (svc->doc->name != NULL &&
+	if (lxml_check_upgrade(s->sc_name) == SCF_SUCCESS &&
+	    svc->doc->name != NULL &&
 	    bundle->sc_bundle_type == SVCCFG_MANIFEST) {
 		char *buf, *base, *fname;
 
--- a/usr/src/cmd/svr4pkg/pkgscripts/Makefile	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/cmd/svr4pkg/pkgscripts/Makefile	Thu Mar 25 14:57:35 2010 -0700
@@ -20,7 +20,7 @@
 #
 
 #
-# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 
@@ -39,7 +39,7 @@
 			r.sed
 ADMINFILE =		default
 
-ROOTPKGMNFSTDIR=$(ROOT)/var/svc/manifest/system
+ROOTPKGMNFSTDIR=$(ROOT)/lib/svc/manifest/system
 ROOTPKGMNFST=   $(ROOTPKGMNFSTDIR)/pkgserv.xml
 
 $(ROOTPKGMNFST) := FILEMODE = 0444
--- a/usr/src/lib/cfgadm_plugins/fp/Makefile.com	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/lib/cfgadm_plugins/fp/Makefile.com	Thu Mar 25 14:57:35 2010 -0700
@@ -19,7 +19,7 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 #
@@ -58,7 +58,7 @@
 LDLIBS +=	-lHBAAPI -lgen
 
 MANIFEST=	devices-fc-fabric.xml
-ROOTMANIFESTDIR=	$(ROOT)/var/svc/manifest/system/device
+ROOTMANIFESTDIR=	$(ROOT)/lib/svc/manifest/system/device
 ROOTMANIFEST=	$(MANIFEST:%=$(ROOTMANIFESTDIR)/%)
 $(ROOTMANIFEST)	:= FILEMODE= 444
 
--- a/usr/src/lib/efcode/efdaemon/Makefile	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/lib/efcode/efdaemon/Makefile	Thu Mar 25 14:57:35 2010 -0700
@@ -19,11 +19,9 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#ident	"%Z%%M%	%I%	%E% SMI"
-#
 # lib/efcode/efdaemon/Makefile
 
 include $(SRC)/cmd/Makefile.cmd
@@ -39,8 +37,8 @@
 EFTARGETS += $(EFCODEDIR64)/$(PROG)
 EFTARGETS += $(EFCODEDIR)/efcode.sh
 
-MFSTDIR = $(ROOT)/var/svc/manifest/platform/sun4u
-MFSTDIR_SUN4V = $(ROOT)/var/svc/manifest/platform/sun4v
+MFSTDIR = $(ROOT)/lib/svc/manifest/platform/sun4u
+MFSTDIR_SUN4V = $(ROOT)/lib/svc/manifest/platform/sun4v
 MANIFEST = efdaemon.xml
 MANIFEST_SUN4V = efdaemon_sun4v.xml
 EFTARGETS += $(MFSTDIR)/$(MANIFEST)
--- a/usr/src/lib/libresolv2/Makefile	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/lib/libresolv2/Makefile	Thu Mar 25 14:57:35 2010 -0700
@@ -19,7 +19,7 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 #
@@ -29,7 +29,7 @@
 include		../Makefile.lib
 
 MANIFEST=	client.xml
-MANIFESTDIR=	$(ROOT)/var/svc/manifest/network/dns
+MANIFESTDIR=	$(ROOT)/lib/svc/manifest/network/dns
 ROOTMANIFEST=	$(MANIFEST:%=$(MANIFESTDIR)/%)
 
 $(ROOTMANIFEST) :=	FILEMODE = 444
--- a/usr/src/lib/libscf/inc/libscf.h	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/lib/libscf/inc/libscf.h	Thu Mar 25 14:57:35 2010 -0700
@@ -20,7 +20,7 @@
  */
 
 /*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -211,6 +211,12 @@
 				    "svc:/system/svc/global")
 #define	SCF_SERVICE_STARTD	((const char *) \
 				    "svc:/system/svc/restarter:default")
+#define	SCF_INSTANCE_EMI	((const char *) \
+				    "svc:/system/early-manifest-import:default")
+#define	SCF_INSTANCE_FS_MINIMAL	((const char *) \
+				    "svc:/system/filesystem/minimal:default")
+#define	SCF_INSTANCE_MI		((const char *) \
+				    "svc:/system/manifest-import:default")
 
 /*
  * Major milestones
--- a/usr/src/lib/libscf/inc/libscf_priv.h	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/lib/libscf/inc/libscf_priv.h	Thu Mar 25 14:57:35 2010 -0700
@@ -19,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -292,6 +292,7 @@
 #define	REPOSITORY_DB		"/etc/svc/repository.db"
 #define	NONPERSIST_DB		"/etc/svc/volatile/svc_nonpersist.db"
 #define	FAST_REPOSITORY_DB	"/etc/svc/volatile/fast_repository.db"
+#define	REPOSITORY_CHECKPOINT	"/etc/svc/volatile/checkpoint_repository.db"
 
 
 typedef struct scf_walkinfo {
--- a/usr/src/lib/libsecdb/Makefile	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/lib/libsecdb/Makefile	Thu Mar 25 14:57:35 2010 -0700
@@ -55,7 +55,7 @@
 
 
 MFSTFILES =	rbac.xml
-MANIFESTDIR =	$(ROOT)/var/svc/manifest/system
+MANIFESTDIR =	$(ROOT)/lib/svc/manifest/system
 MANIFEST =	$(MFSTFILES:%=$(MANIFESTDIR)/%)
 $(MANIFEST) :=	FILEMODE = 0444
 
--- a/usr/src/lib/print/mod_ipp/Makefile	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/lib/print/mod_ipp/Makefile	Thu Mar 25 14:57:35 2010 -0700
@@ -19,7 +19,7 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 
@@ -58,7 +58,7 @@
 
 #	SMF manifest
 MANIFEST=       ipp-listener.xml
-ROOTMANIFESTDIR=        $(ROOT)/var/svc/manifest/application/print
+ROOTMANIFESTDIR=        $(ROOT)/lib/svc/manifest/application/print
 ROOTMANIFEST=		$(MANIFEST:%=$(ROOTMANIFESTDIR)/%)
 $(ROOTMANIFEST)         := FILEMODE= 444
 
--- a/usr/src/pkg/manifests/SUNWcs.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/SUNWcs.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -77,6 +77,7 @@
 dir path=etc/security/spool group=sys
 dir path=etc/skel group=sys
 dir path=etc/svc group=sys
+dir path=etc/svc/profile group=sys
 dir path=etc/svc/volatile group=sys
 dir path=etc/sysevent group=sys
 dir path=etc/sysevent/config group=sys
@@ -92,6 +93,28 @@
 dir path=lib/svc/monitor
 dir path=lib/svc/seed
 dir path=lib/svc/share
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/application group=sys
+dir path=lib/svc/manifest/application/management group=sys
+dir path=lib/svc/manifest/application/security group=sys
+dir path=lib/svc/manifest/device group=sys
+dir path=lib/svc/manifest/milestone group=sys
+dir path=lib/svc/manifest/network group=sys
+dir path=lib/svc/manifest/network/dns group=sys
+dir path=lib/svc/manifest/network/ipsec group=sys
+dir path=lib/svc/manifest/network/ldap group=sys
+dir path=lib/svc/manifest/network/routing group=sys
+dir path=lib/svc/manifest/network/rpc group=sys
+dir path=lib/svc/manifest/network/shares group=sys
+dir path=lib/svc/manifest/network/ssl group=sys
+dir path=lib/svc/manifest/platform group=sys
+$(sparc_ONLY)dir path=lib/svc/manifest/platform/sun4u group=sys
+dir path=lib/svc/manifest/site group=sys
+dir path=lib/svc/manifest/system group=sys
+dir path=lib/svc/manifest/system/device group=sys
+dir path=lib/svc/manifest/system/filesystem group=sys
+dir path=lib/svc/manifest/system/security group=sys
+dir path=lib/svc/manifest/system/svc group=sys
 dir path=mnt group=sys
 dir path=opt group=sys
 dir path=proc group=root mode=0555
@@ -289,6 +312,7 @@
 dir path=var/svc/manifest group=sys
 dir path=var/svc/manifest/application group=sys
 dir path=var/svc/manifest/application/management group=sys
+dir path=var/svc/manifest/application/print group=sys
 dir path=var/svc/manifest/application/security group=sys
 dir path=var/svc/manifest/device group=sys
 dir path=var/svc/manifest/milestone group=sys
@@ -296,18 +320,22 @@
 dir path=var/svc/manifest/network/dns group=sys
 dir path=var/svc/manifest/network/ipsec group=sys
 dir path=var/svc/manifest/network/ldap group=sys
+dir path=var/svc/manifest/network/nfs group=sys
+dir path=var/svc/manifest/network/nis group=sys
+dir path=var/svc/manifest/network/rpc group=sys
 dir path=var/svc/manifest/network/routing group=sys
-dir path=var/svc/manifest/network/rpc group=sys
+dir path=var/svc/manifest/network/security group=sys
 dir path=var/svc/manifest/network/shares group=sys
 dir path=var/svc/manifest/network/ssl group=sys
 dir path=var/svc/manifest/platform group=sys
 $(sparc_ONLY)dir path=var/svc/manifest/platform/sun4u group=sys
-dir path=var/svc/manifest/site group=sys
+$(sparc_ONLY)dir path=var/svc/manifest/platform/sun4v group=sys
 dir path=var/svc/manifest/system group=sys
 dir path=var/svc/manifest/system/device group=sys
 dir path=var/svc/manifest/system/filesystem group=sys
 dir path=var/svc/manifest/system/security group=sys
 dir path=var/svc/manifest/system/svc group=sys
+dir path=var/svc/manifest/site group=sys
 dir path=var/svc/profile group=sys
 dir path=var/tmp group=sys mode=1777
 driver name=dump perms="dump 0660 root sys"
@@ -462,7 +490,6 @@
 file path=lib/inet/nwamd mode=0555
 file path=lib/svc/bin/lsvcrun group=sys mode=0555
 file path=lib/svc/bin/mfstscan group=sys mode=0555
-file path=lib/svc/bin/prophist group=sys mode=0555
 file path=lib/svc/bin/restore_repository group=sys mode=0555
 file path=lib/svc/bin/sqlite group=sys mode=0555
 file path=lib/svc/bin/svc.configd group=sys mode=0555
@@ -516,7 +543,6 @@
 file path=lib/svc/share/README mode=0444
 file path=lib/svc/share/fs_include.sh mode=0444
 file path=lib/svc/share/ipf_include.sh mode=0444
-file path=lib/svc/share/manifest_cleanup.ksh mode=0444
 file path=lib/svc/share/mfsthistory mode=0444
 file path=lib/svc/share/net_include.sh mode=0444
 file path=lib/svc/share/routing_include.sh mode=0444
@@ -1887,95 +1913,95 @@
 file path=var/saf/zsmon/log group=sys preserve=true
 file path=var/spool/cron/crontabs/adm group=sys mode=0600 preserve=true
 file path=var/spool/cron/crontabs/root group=sys mode=0600 preserve=true
-file path=var/svc/manifest/milestone/multi-user-server.xml group=sys mode=0444
-file path=var/svc/manifest/milestone/multi-user.xml group=sys mode=0444
-file path=var/svc/manifest/milestone/name-services.xml group=sys mode=0444
-file path=var/svc/manifest/milestone/network.xml group=sys mode=0444
-file path=var/svc/manifest/milestone/single-user.xml group=sys mode=0444
-file path=var/svc/manifest/milestone/sysconfig.xml group=sys mode=0444
-file path=var/svc/manifest/network/dlmgmt.xml group=sys mode=0444
-file path=var/svc/manifest/network/dns/client.xml group=sys mode=0444
-file path=var/svc/manifest/network/forwarding.xml group=sys mode=0444
-file path=var/svc/manifest/network/inetd-upgrade.xml group=sys mode=0444
-file path=var/svc/manifest/network/inetd.xml group=sys mode=0444
-file path=var/svc/manifest/network/ipsec/ike.xml group=sys mode=0444
-file path=var/svc/manifest/network/ipsec/ipsecalgs.xml group=sys mode=0444
-file path=var/svc/manifest/network/ipsec/manual-key.xml group=sys mode=0444
-file path=var/svc/manifest/network/ipsec/policy.xml group=sys mode=0444
-file path=var/svc/manifest/network/ldap/client.xml group=sys mode=0444
-file path=var/svc/manifest/network/network-initial.xml group=sys mode=0444
-file path=var/svc/manifest/network/network-ipqos.xml group=sys mode=0444
-file path=var/svc/manifest/network/network-iptun.xml group=sys mode=0444
-file path=var/svc/manifest/network/network-location.xml group=sys mode=0444
-file path=var/svc/manifest/network/network-loopback.xml group=sys mode=0444
-file path=var/svc/manifest/network/network-netcfg.xml group=sys mode=0444
-file path=var/svc/manifest/network/network-netmask.xml group=sys mode=0444
-file path=var/svc/manifest/network/network-physical.xml group=sys mode=0444
-file path=var/svc/manifest/network/network-routing-setup.xml group=sys mode=0444
-file path=var/svc/manifest/network/network-service.xml group=sys mode=0444
-file path=var/svc/manifest/network/routing/legacy-routing.xml group=sys \
+file path=lib/svc/manifest/milestone/multi-user-server.xml group=sys mode=0444
+file path=lib/svc/manifest/milestone/multi-user.xml group=sys mode=0444
+file path=lib/svc/manifest/milestone/name-services.xml group=sys mode=0444
+file path=lib/svc/manifest/milestone/network.xml group=sys mode=0444
+file path=lib/svc/manifest/milestone/single-user.xml group=sys mode=0444
+file path=lib/svc/manifest/milestone/sysconfig.xml group=sys mode=0444
+file path=lib/svc/manifest/network/dlmgmt.xml group=sys mode=0444
+file path=lib/svc/manifest/network/dns/client.xml group=sys mode=0444
+file path=lib/svc/manifest/network/forwarding.xml group=sys mode=0444
+file path=lib/svc/manifest/network/inetd-upgrade.xml group=sys mode=0444
+file path=lib/svc/manifest/network/inetd.xml group=sys mode=0444
+file path=lib/svc/manifest/network/ipsec/ike.xml group=sys mode=0444
+file path=lib/svc/manifest/network/ipsec/ipsecalgs.xml group=sys mode=0444
+file path=lib/svc/manifest/network/ipsec/manual-key.xml group=sys mode=0444
+file path=lib/svc/manifest/network/ipsec/policy.xml group=sys mode=0444
+file path=lib/svc/manifest/network/ldap/client.xml group=sys mode=0444
+file path=lib/svc/manifest/network/network-initial.xml group=sys mode=0444
+file path=lib/svc/manifest/network/network-ipqos.xml group=sys mode=0444
+file path=lib/svc/manifest/network/network-iptun.xml group=sys mode=0444
+file path=lib/svc/manifest/network/network-location.xml group=sys mode=0444
+file path=lib/svc/manifest/network/network-loopback.xml group=sys mode=0444
+file path=lib/svc/manifest/network/network-netcfg.xml group=sys mode=0444
+file path=lib/svc/manifest/network/network-netmask.xml group=sys mode=0444
+file path=lib/svc/manifest/network/network-physical.xml group=sys mode=0444
+file path=lib/svc/manifest/network/network-routing-setup.xml group=sys mode=0444
+file path=lib/svc/manifest/network/network-service.xml group=sys mode=0444
+file path=lib/svc/manifest/network/routing/legacy-routing.xml group=sys \
     mode=0444
-file path=var/svc/manifest/network/rpc/bind.xml group=sys mode=0444
-file path=var/svc/manifest/network/rpc/keyserv.xml group=sys mode=0444
-file path=var/svc/manifest/network/shares/group.xml group=sys mode=0444
-file path=var/svc/manifest/network/shares/reparsed.xml group=sys mode=0444
-file path=var/svc/manifest/network/ssl/kssl-proxy.xml group=sys mode=0444
-file path=var/svc/manifest/system/auditd.xml group=sys mode=0444
-file path=var/svc/manifest/system/boot-archive-update.xml group=sys mode=0444
-file path=var/svc/manifest/system/boot-archive.xml group=sys mode=0444
-file path=var/svc/manifest/system/boot-config.xml group=sys mode=0444
-file path=var/svc/manifest/system/consadm.xml group=sys mode=0444
-file path=var/svc/manifest/system/console-login.xml group=sys mode=0444
-file path=var/svc/manifest/system/coreadm.xml group=sys mode=0444
-file path=var/svc/manifest/system/cron.xml group=sys mode=0444
-file path=var/svc/manifest/system/cryptosvc.xml group=sys mode=0444
-file path=var/svc/manifest/system/device/devices-audio.xml group=sys mode=0444
-file path=var/svc/manifest/system/device/devices-local.xml group=sys mode=0444
-file path=var/svc/manifest/system/device/mpxio-upgrade.xml group=sys mode=0444
-file path=var/svc/manifest/system/extended-accounting.xml group=sys mode=0444
-file path=var/svc/manifest/system/filesystem/local-fs.xml group=sys mode=0444
-file path=var/svc/manifest/system/filesystem/minimal-fs.xml group=sys mode=0444
-file path=var/svc/manifest/system/filesystem/root-fs.xml group=sys mode=0444
-file path=var/svc/manifest/system/filesystem/usr-fs.xml group=sys mode=0444
-$(i386_ONLY)file path=var/svc/manifest/system/hostid.xml group=sys mode=0444
-file path=var/svc/manifest/system/hotplug.xml group=sys mode=0444
-file path=var/svc/manifest/system/identity.xml group=sys mode=0444
-file path=var/svc/manifest/system/idmap.xml group=sys mode=0444
-file path=var/svc/manifest/system/keymap.xml group=sys mode=0444
-file path=var/svc/manifest/system/manifest-import.xml group=sys mode=0444
-file path=var/svc/manifest/system/name-service-cache.xml group=sys mode=0444
-file path=var/svc/manifest/system/rbac.xml group=sys mode=0444
-file path=var/svc/manifest/system/rmtmpfiles.xml group=sys mode=0444
-file path=var/svc/manifest/system/sac.xml group=sys mode=0444
-file path=var/svc/manifest/system/svc/global.xml group=sys mode=0444
-file path=var/svc/manifest/system/svc/restarter.xml group=sys mode=0444
-file path=var/svc/manifest/system/system-log.xml group=sys mode=0444
-file path=var/svc/manifest/system/utmp.xml group=sys mode=0444
-file path=var/svc/manifest/system/vtdaemon.xml group=sys mode=0444
-file path=var/svc/profile/generic_limited_net.xml group=sys mode=0444
-file path=var/svc/profile/generic_open.xml group=sys mode=0444
-file path=var/svc/profile/inetd_generic.xml group=sys mode=0444
-file path=var/svc/profile/inetd_upgrade.xml group=sys mode=0444
-file path=var/svc/profile/ns_dns.xml group=sys mode=0444
-file path=var/svc/profile/ns_files.xml group=sys mode=0444
-file path=var/svc/profile/ns_ldap.xml group=sys mode=0444
-file path=var/svc/profile/ns_nis.xml group=sys mode=0444
-file path=var/svc/profile/ns_none.xml group=sys mode=0444
-$(sparc_ONLY)file path=var/svc/profile/platform_SUNW,SPARC-Enterprise.xml \
+file path=lib/svc/manifest/network/rpc/bind.xml group=sys mode=0444
+file path=lib/svc/manifest/network/rpc/keyserv.xml group=sys mode=0444
+file path=lib/svc/manifest/network/shares/group.xml group=sys mode=0444
+file path=lib/svc/manifest/network/shares/reparsed.xml group=sys mode=0444
+file path=lib/svc/manifest/network/ssl/kssl-proxy.xml group=sys mode=0444
+file path=lib/svc/manifest/system/auditd.xml group=sys mode=0444
+file path=lib/svc/manifest/system/boot-archive-update.xml group=sys mode=0444
+file path=lib/svc/manifest/system/boot-archive.xml group=sys mode=0444
+file path=lib/svc/manifest/system/boot-config.xml group=sys mode=0444
+file path=lib/svc/manifest/system/consadm.xml group=sys mode=0444
+file path=lib/svc/manifest/system/console-login.xml group=sys mode=0444
+file path=lib/svc/manifest/system/coreadm.xml group=sys mode=0444
+file path=lib/svc/manifest/system/cron.xml group=sys mode=0444
+file path=lib/svc/manifest/system/cryptosvc.xml group=sys mode=0444
+file path=lib/svc/manifest/system/device/devices-audio.xml group=sys mode=0444
+file path=lib/svc/manifest/system/device/devices-local.xml group=sys mode=0444
+file path=lib/svc/manifest/system/device/mpxio-upgrade.xml group=sys mode=0444
+file path=lib/svc/manifest/system/extended-accounting.xml group=sys mode=0444
+file path=lib/svc/manifest/system/filesystem/local-fs.xml group=sys mode=0444
+file path=lib/svc/manifest/system/filesystem/minimal-fs.xml group=sys mode=0444
+file path=lib/svc/manifest/system/filesystem/root-fs.xml group=sys mode=0444
+file path=lib/svc/manifest/system/filesystem/usr-fs.xml group=sys mode=0444
+$(i386_ONLY)file path=lib/svc/manifest/system/hostid.xml group=sys mode=0444
+file path=lib/svc/manifest/system/hotplug.xml group=sys mode=0444
+file path=lib/svc/manifest/system/identity.xml group=sys mode=0444
+file path=lib/svc/manifest/system/idmap.xml group=sys mode=0444
+file path=lib/svc/manifest/system/keymap.xml group=sys mode=0444
+file path=lib/svc/manifest/system/early-manifest-import.xml group=sys mode=0444
+file path=lib/svc/manifest/system/manifest-import.xml group=sys mode=0444
+file path=lib/svc/manifest/system/name-service-cache.xml group=sys mode=0444
+file path=lib/svc/manifest/system/rbac.xml group=sys mode=0444
+file path=lib/svc/manifest/system/rmtmpfiles.xml group=sys mode=0444
+file path=lib/svc/manifest/system/sac.xml group=sys mode=0444
+file path=lib/svc/manifest/system/svc/global.xml group=sys mode=0444
+file path=lib/svc/manifest/system/svc/restarter.xml group=sys mode=0444
+file path=lib/svc/manifest/system/system-log.xml group=sys mode=0444
+file path=lib/svc/manifest/system/utmp.xml group=sys mode=0444
+file path=lib/svc/manifest/system/vtdaemon.xml group=sys mode=0444
+file path=etc/svc/profile/generic_limited_net.xml group=sys mode=0444
+file path=etc/svc/profile/generic_open.xml group=sys mode=0444
+file path=etc/svc/profile/inetd_generic.xml group=sys mode=0444
+file path=etc/svc/profile/inetd_upgrade.xml group=sys mode=0444
+file path=etc/svc/profile/ns_dns.xml group=sys mode=0444
+file path=etc/svc/profile/ns_files.xml group=sys mode=0444
+file path=etc/svc/profile/ns_ldap.xml group=sys mode=0444
+file path=etc/svc/profile/ns_nis.xml group=sys mode=0444
+file path=etc/svc/profile/ns_none.xml group=sys mode=0444
+$(sparc_ONLY)file path=etc/svc/profile/platform_SUNW,SPARC-Enterprise.xml \
     group=sys mode=0444
-$(sparc_ONLY)file path=var/svc/profile/platform_SUNW,Sun-Fire-15000.xml \
+$(sparc_ONLY)file path=etc/svc/profile/platform_SUNW,Sun-Fire-15000.xml \
     group=sys mode=0444
-$(sparc_ONLY)file path=var/svc/profile/platform_SUNW,Sun-Fire-880.xml group=sys \
+$(sparc_ONLY)file path=etc/svc/profile/platform_SUNW,Sun-Fire-880.xml group=sys \
     mode=0444
-$(sparc_ONLY)file path=var/svc/profile/platform_SUNW,Sun-Fire.xml group=sys \
+$(sparc_ONLY)file path=etc/svc/profile/platform_SUNW,Sun-Fire.xml group=sys \
     mode=0444
-$(sparc_ONLY)file path=var/svc/profile/platform_SUNW,Ultra-Enterprise-10000.xml \
-    group=sys mode=0444
-$(sparc_ONLY)file path=var/svc/profile/platform_SUNW,UltraSPARC-IIi-Netract.xml \
+$(sparc_ONLY)file path=etc/svc/profile/platform_SUNW,Ultra-Enterprise-10000.xml \
     group=sys mode=0444
-file path=var/svc/profile/platform_none.xml group=sys mode=0444
-$(sparc_ONLY)file path=var/svc/profile/platform_sun4v.xml group=sys mode=0444
-file path=var/svc/profile/prophist.SUNWcsr group=sys mode=0444
+$(sparc_ONLY)file path=etc/svc/profile/platform_SUNW,UltraSPARC-IIi-Netract.xml \
+    group=sys mode=0444
+file path=etc/svc/profile/platform_none.xml group=sys mode=0444
+$(sparc_ONLY)file path=etc/svc/profile/platform_sun4v.xml group=sys mode=0444
 hardlink path=etc/crypto/certs/SUNWObjectCA \
     target=../../../etc/certs/SUNWObjectCA
 hardlink path=etc/rc2.d/S20sysetup target=../../etc/init.d/sysetup
@@ -2483,13 +2509,13 @@
     target=../../../../usr/share/lib/zoneinfo/Europe/Moscow
 hardlink path=usr/share/lib/zoneinfo/Zulu \
     target=../../../../usr/share/lib/zoneinfo/Etc/UTC
-$(sparc_ONLY)hardlink path=var/svc/profile/platform_SUNW,Sun-Fire-V890.xml \
+$(sparc_ONLY)hardlink path=etc/svc/profile/platform_SUNW,Sun-Fire-V890.xml \
     target=./platform_SUNW,Sun-Fire-880.xml
 $(sparc_ONLY)hardlink \
-    path=var/svc/profile/platform_SUNW,UltraSPARC-IIe-NetraCT-40.xml \
+    path=etc/svc/profile/platform_SUNW,UltraSPARC-IIe-NetraCT-40.xml \
     target=./platform_SUNW,UltraSPARC-IIi-Netract.xml
 $(sparc_ONLY)hardlink \
-    path=var/svc/profile/platform_SUNW,UltraSPARC-IIe-NetraCT-60.xml \
+    path=etc/svc/profile/platform_SUNW,UltraSPARC-IIe-NetraCT-60.xml \
     target=./platform_SUNW,UltraSPARC-IIi-Netract.xml
 legacy pkg=SUNWcsr arch=$(ARCH) category=system \
     desc="core software for a specific instruction-set architecture" \
--- a/usr/src/pkg/manifests/SUNWcsd.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/SUNWcsd.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -60,10 +60,8 @@
 dir path=lib
 dir path=lib/svc
 dir path=lib/svc/method
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/system group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/system group=sys
 file path=etc/dacf.conf group=sys
 file path=etc/devlink.tab group=sys preserve=true
 file path=etc/driver_aliases group=sys preserve=true
@@ -77,7 +75,7 @@
 file path=etc/security/device_policy group=sys preserve=true
 file path=etc/security/extra_privs group=sys preserve=true
 file path=lib/svc/method/svc-syseventd mode=0555
-file path=var/svc/manifest/system/sysevent.xml group=sys mode=0444
+file path=lib/svc/manifest/system/sysevent.xml group=sys mode=0444
 legacy pkg=SUNWcsd arch=$(ARCH) category=system \
     desc="core entries for /dev and /devices needed for the initial boot of Solaris" \
     hotline="Please contact your local service provider" \
--- a/usr/src/pkg/manifests/driver-network-srpt.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/driver-network-srpt.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -48,14 +48,11 @@
 dir path=usr/lib/mdb group=sys
 dir path=usr/lib/mdb/kvm group=sys
 dir path=usr/lib/mdb/kvm/$(ARCH64) group=sys
-dir path=var group=sys opensolaris.zone=global variant.opensolaris.zone=global
-dir path=var/svc group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/system group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest/system group=sys opensolaris.zone=global \
-    variant.opensolaris.zone=global
-dir path=var/svc/manifest/system/ibsrp group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/system/ibsrp group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
 driver name=srpt perms="* 0644 root sys"
 file path=kernel/drv/$(ARCH64)/srpt group=sys opensolaris.zone=global \
@@ -72,7 +69,7 @@
     variant.opensolaris.zone=global
 file path=usr/lib/mdb/kvm/$(ARCH64)/srpt.so group=sys mode=0555
 $(i386_ONLY)file path=usr/lib/mdb/kvm/srpt.so group=sys mode=0555
-file path=var/svc/manifest/system/ibsrp/target.xml group=sys mode=0444 \
+file path=lib/svc/manifest/system/ibsrp/target.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
 legacy pkg=SUNWsrptr arch=$(ARCH) category=system \
     desc="Sun SRP COMSTAR Port Provider (Root)" \
--- a/usr/src/pkg/manifests/driver-storage-sv.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/driver-storage-sv.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -61,10 +61,8 @@
 dir path=usr/lib/mdb/kvm group=sys
 dir path=usr/lib/mdb/kvm/$(ARCH64) group=sys
 dir path=usr/sbin
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/system group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/system group=sys
 driver name=sv devlink=type=ddi_pseudo;name=sv\t\D perms="* 0666 root sys" \
     privs=sys_config privs=sys_devices
 file path=etc/init.d/sv mode=0744
@@ -79,7 +77,7 @@
 file path=usr/kernel/drv/sv.conf group=sys
 file path=usr/lib/mdb/kvm/$(ARCH64)/sv.so group=sys mode=0555
 $(i386_ONLY)file path=usr/lib/mdb/kvm/sv.so group=sys mode=0555
-file path=var/svc/manifest/system/nws_sv.xml group=sys mode=0444
+file path=lib/svc/manifest/system/nws_sv.xml group=sys mode=0444
 hardlink path=lib/svc/method/svc-sv target=../../../etc/init.d/sv
 hardlink path=usr/sbin/svadm target=../bin/svadm
 hardlink path=usr/sbin/svboot target=../bin/svboot
--- a/usr/src/pkg/manifests/driver-usb.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/driver-usb.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -51,10 +51,8 @@
 dir path=lib/svc
 dir path=lib/svc/method
 dir path=sbin group=sys
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/system group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/system group=sys
 driver name=ehci alias=pciclass,0c0320 perms="* 0644 root sys"
 driver name=hid alias=usbif,class3 perms="* 0600 root sys"
 driver name=hubd alias=usbif,class9 perms="* 0644 root sys"
@@ -137,7 +135,7 @@
     reboot-needed=true
 file path=lib/svc/method/svc-wusb mode=0555
 file path=sbin/wusbadm mode=0555
-file path=var/svc/manifest/system/wusb.xml group=sys mode=0444
+file path=lib/svc/manifest/system/wusb.xml group=sys mode=0444
 legacy pkg=SUNWusb arch=$(ARCH) category=system \
     desc="USBA (USB framework) and USB Device Drivers" \
     hotline="Please contact your local service provider" \
--- a/usr/src/pkg/manifests/network-bridging.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/network-bridging.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -30,18 +30,18 @@
 set name=info.classification value=org.opensolaris.category.2008:System/Core
 set name=variant.arch value=$(ARCH)
 set name=variant.opensolaris.zone value=global value=nonglobal
+dir path=lib
+dir path=lib/svc
 dir path=usr group=sys
 dir path=usr/lib
 dir path=usr/lib/rcm
 dir path=usr/lib/rcm/modules
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/network group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/network group=sys
 file path=usr/lib/bridged mode=0555
 file path=usr/lib/librstp.so.1
 file path=usr/lib/rcm/modules/SUNW_bridge_rcm.so mode=0555
-file path=var/svc/manifest/network/bridge.xml group=sys mode=0444
+file path=lib/svc/manifest/network/bridge.xml group=sys mode=0444
 legacy pkg=SUNWbridger arch=$(ARCH) category=system \
     desc="Datalink layer bridging support" \
     hotline="Please contact your local service provider" \
--- a/usr/src/pkg/manifests/network-ipfilter.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/network-ipfilter.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -53,9 +53,8 @@
 dir path=var group=sys
 dir path=var/db group=sys
 dir path=var/db/ipf group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/network group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/network group=sys
 driver name=ipf perms="* 0666 root sys" \
     policy="read_priv_set=sys_ip_config write_priv_set=sys_ip_config"
 file path=etc/ipf/ipf.conf group=sys original_name=SUNWipf:etc/ipf/ipf.conf \
@@ -107,7 +106,7 @@
 file path=usr/share/ipfilter/examples/pool.conf
 file path=usr/share/ipfilter/examples/server
 file path=usr/share/ipfilter/examples/tcpstate
-file path=var/svc/manifest/network/ipfilter.xml group=sys mode=0444
+file path=lib/svc/manifest/network/ipfilter.xml group=sys mode=0444
 hardlink path=usr/lib/ipf/ipftest target=../../../usr/lib/isaexec
 hardlink path=usr/sbin/ipf target=../../usr/lib/isaexec
 hardlink path=usr/sbin/ipfs target=../../usr/lib/isaexec
--- a/usr/src/pkg/manifests/network-iscsi-initiator.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/network-iscsi-initiator.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -46,14 +46,11 @@
 dir path=lib/svc/method opensolaris.zone=global variant.opensolaris.zone=global
 dir path=usr group=sys
 dir path=usr/sbin
-dir path=var group=sys opensolaris.zone=global variant.opensolaris.zone=global
-dir path=var/svc group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/network group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest/network group=sys opensolaris.zone=global \
-    variant.opensolaris.zone=global
-dir path=var/svc/manifest/network/iscsi group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/network/iscsi group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
 driver name=iscsi class=scsi-self-identify perms="* 0600 root sys"
 file path=kernel/drv/$(ARCH64)/iscsi group=sys opensolaris.zone=global \
@@ -66,7 +63,7 @@
 file path=lib/svc/method/iscsi-initiator mode=0555 opensolaris.zone=global \
     variant.opensolaris.zone=global
 file path=usr/sbin/iscsiadm mode=0555
-file path=var/svc/manifest/network/iscsi/iscsi-initiator.xml group=sys mode=0444 \
+file path=lib/svc/manifest/network/iscsi/iscsi-initiator.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
 legacy pkg=SUNWiscsir arch=$(ARCH) category=system \
     desc="Sun iSCSI Device Driver" \
--- a/usr/src/pkg/manifests/network-iscsi-target.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/network-iscsi-target.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -46,14 +46,11 @@
 dir path=usr/lib
 dir path=usr/lib/$(ARCH64)
 dir path=usr/sbin
-dir path=var group=sys opensolaris.zone=global variant.opensolaris.zone=global
-dir path=var/svc group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/network group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest/network group=sys opensolaris.zone=global \
-    variant.opensolaris.zone=global
-dir path=var/svc/manifest/network/iscsi group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/network/iscsi group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
 driver name=iscsit perms="* 0600 root sys"
 file path=kernel/drv/$(ARCH64)/iscsit group=sys opensolaris.zone=global \
@@ -72,7 +69,7 @@
 file path=usr/lib/llib-liscsit
 file path=usr/lib/llib-liscsit.ln
 file path=usr/sbin/itadm mode=0555
-file path=var/svc/manifest/network/iscsi/iscsi-target.xml group=sys mode=0444 \
+file path=lib/svc/manifest/network/iscsi/iscsi-target.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
 legacy pkg=SUNWiscsitr arch=$(ARCH) category=system \
     desc="Sun iSCSI COMSTAR Port Provider" \
--- a/usr/src/pkg/manifests/package-svr4.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/package-svr4.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -31,6 +31,8 @@
     value=org.opensolaris.category.2008:System/Packaging
 set name=variant.arch value=$(ARCH)
 set name=variant.opensolaris.zone value=global value=nonglobal
+dir path=lib
+dir path=lib/svc 
 dir path=usr group=sys
 dir path=usr/bin
 dir path=usr/lib
@@ -48,9 +50,8 @@
 dir path=var/sadm/security group=sys mode=0555
 dir path=var/spool
 dir path=var/spool/pkg mode=1777
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/system group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/system group=sys
 file path=usr/bin/pkgadm mode=0555
 file path=usr/bin/pkgcond group=sys mode=0555
 file path=usr/bin/pkginfo group=sys mode=0555
@@ -78,7 +79,7 @@
 file path=usr/sbin/pkgchk group=sys mode=0555
 file path=usr/sbin/pkgrm group=sys mode=0555
 file path=var/sadm/install/admin/default group=sys mode=0444
-file path=var/svc/manifest/system/pkgserv.xml group=sys mode=0444
+file path=lib/svc/manifest/system/pkgserv.xml group=sys mode=0444
 hardlink path=usr/sadm/install/scripts/i.CONFIG.prsv target=./i.preserve
 hardlink path=usr/sbin/pkgask target=../../usr/sbin/pkgadd
 hardlink path=usr/sbin/removef target=../../usr/sbin/installf
--- a/usr/src/pkg/manifests/print-lp-ipp-ipp-listener.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/print-lp-ipp-ipp-listener.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -33,21 +33,22 @@
 set name=variant.opensolaris.zone value=global value=nonglobal
 dir path=etc group=sys
 dir path=etc/apache
+dir path=lib
+dir path=lib/svc
 dir path=usr group=sys
 dir path=usr/apache
 dir path=usr/apache/libexec
 dir path=var group=sys
 dir path=var/lp group=lp mode=0775 owner=lp
 dir path=var/lp/ipp-listener
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/application group=sys
-dir path=var/svc/manifest/application/print group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/application group=sys
+dir path=lib/svc/manifest/application/print group=sys
 file path=etc/apache/httpd-standalone-ipp.conf \
     original_name=SUNWippl:etc/apache/httpd-standalone-ipp.conf preserve=true
 file path=usr/apache/libexec/mod_ipp.so mode=0555
 file path=var/lp/ipp-listener/index.html mode=0444
-file path=var/svc/manifest/application/print/ipp-listener.xml group=sys \
+file path=lib/svc/manifest/application/print/ipp-listener.xml group=sys \
     mode=0444
 legacy pkg=SUNWipplr arch=$(ARCH) category=system \
     desc="Internet Printing Protocol(IPP) Apache configuration for service module" \
--- a/usr/src/pkg/manifests/print-lp-print-manager-legacy.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/print-lp-print-manager-legacy.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -49,10 +49,9 @@
 dir path=var/lp group=lp mode=0775 owner=lp
 dir path=var/lp/ppd group=lp
 dir path=var/lp/ppd/caches group=lp
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/application group=sys
-dir path=var/svc/manifest/application/print group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/application group=sys
+dir path=lib/svc/manifest/application/print group=sys
 file path=lib/svc/method/ppd-cache-update mode=0555
 file path=usr/lib/lp/bin/getmakes group=lp mode=0555
 file path=usr/lib/lp/bin/getmodels group=lp mode=0555
@@ -66,7 +65,7 @@
 file path=usr/sadm/admin/printmgr/lib/libpmgr.so.1 group=lp
 file path=usr/sbin/ppdmgr group=lp mode=0555
 file path=var/lp/ppd/manufaliases group=lp mode=0444
-file path=var/svc/manifest/application/print/ppd-cache-update.xml group=sys \
+file path=lib/svc/manifest/application/print/ppd-cache-update.xml group=sys \
     mode=0444
 legacy pkg=SUNWppm arch=$(ARCH) category=system \
     desc="Graphical tool for managing printers under Solaris." \
--- a/usr/src/pkg/manifests/print-lp.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/print-lp.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -71,10 +71,9 @@
 dir path=var/spool/lp/requests group=lp mode=0775 owner=lp
 dir path=var/spool/lp/system group=lp mode=0775 owner=lp
 dir path=var/spool/print group=lp
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/application group=sys
-dir path=var/svc/manifest/application/print group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/application group=sys
+dir path=lib/svc/manifest/application/print group=sys
 file path=etc/lp/fd/catv.fd group=lp
 file path=etc/lp/fd/download.fd group=lp
 file path=etc/lp/fd/dpost.fd group=lp
@@ -217,8 +216,8 @@
 file path=usr/share/lib/terminfo/a/att583+basic
 file path=var/spool/cron/crontabs/lp group=root mode=0400 \
     original_name=SUNWps:var/spool/cron/crontabs/lp preserve=true
-file path=var/svc/manifest/application/print/rfc1179.xml group=sys mode=0444
-file path=var/svc/manifest/application/print/server.xml group=sys mode=0444
+file path=lib/svc/manifest/application/print/rfc1179.xml group=sys mode=0444
+file path=lib/svc/manifest/application/print/server.xml group=sys mode=0444
 hardlink path=usr/share/lib/terminfo/4/458 \
     target=../../../../../usr/share/lib/terminfo/4/457
 hardlink path=usr/share/lib/terminfo/4/477qume \
--- a/usr/src/pkg/manifests/service-file-system-nfs.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/service-file-system-nfs.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -53,11 +53,9 @@
 dir path=usr/lib/reparse group=bin
 dir path=usr/lib/reparse/$(ARCH64) group=sys
 dir path=usr/sbin
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/network group=sys
-dir path=var/svc/manifest/network/nfs group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/network group=sys
+dir path=lib/svc/manifest/network/nfs group=sys
 file path=etc/default/nfslogd group=sys \
     original_name=SUNWnfss:etc/default/nfslogd preserve=true
 file path=etc/init.d/nfs.server group=sys mode=0744 \
@@ -79,8 +77,8 @@
 file path=usr/lib/reparse/libnfs_basic.so.1
 file path=usr/sbin/exportfs mode=0555
 file path=usr/sbin/nfsref mode=0555
-file path=var/svc/manifest/network/nfs/rquota.xml group=sys mode=0444
-file path=var/svc/manifest/network/nfs/server.xml group=sys mode=0444
+file path=lib/svc/manifest/network/nfs/rquota.xml group=sys mode=0444
+file path=lib/svc/manifest/network/nfs/server.xml group=sys mode=0444
 legacy pkg=SUNWnfsskr arch=$(ARCH) category=system \
     desc="Network File System (NFS) server kernel support (Root)" \
     hotline="Please contact your local service provider" \
--- a/usr/src/pkg/manifests/service-file-system-smb.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/service-file-system-smb.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -63,9 +63,9 @@
 dir path=var/smb/cvol/windows/system32 group=sys
 dir path=var/smb/cvol/windows/system32/vss group=sys
 dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/network group=sys
-dir path=var/svc/manifest/network/smb group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/network group=sys
+dir path=lib/svc/manifest/network/smb group=sys
 driver name=smbsrv perms="* 0640 root sys"
 file path=kernel/drv/$(ARCH64)/smbsrv group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
@@ -108,7 +108,7 @@
 file path=usr/sbin/smbstat mode=0555
 file path=var/smb/smbpasswd group=sys mode=0400 \
     original_name=SUNWsmbs:var/smb/smbpasswd preserve=true
-file path=var/svc/manifest/network/smb/server.xml group=sys mode=0444
+file path=lib/svc/manifest/network/smb/server.xml group=sys mode=0444
 legacy pkg=SUNWsmbskr arch=$(ARCH) category=system \
     desc="SMB Server kernel root components" \
     hotline="Please contact your local service provider" \
--- a/usr/src/pkg/manifests/service-hal.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/service-hal.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -76,14 +76,11 @@
 dir path=usr/share/lib group=sys
 dir path=usr/share/lib/xml group=sys
 dir path=usr/share/lib/xml/dtd group=sys
-dir path=var group=sys opensolaris.zone=global variant.opensolaris.zone=global
-dir path=var/svc group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/network group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest/network group=sys opensolaris.zone=global \
-    variant.opensolaris.zone=global
-dir path=var/svc/manifest/system group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/system group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
 file path=etc/dbus-1/system.d/hal.conf opensolaris.zone=global \
     variant.opensolaris.zone=global
@@ -183,9 +180,9 @@
 file path=usr/sbin/hal-set-property mode=0555
 file path=usr/sbin/lshal mode=0555
 file path=usr/share/lib/xml/dtd/fdi.dtd.1
-file path=var/svc/manifest/network/network-discovery.xml group=sys mode=0444 \
+file path=lib/svc/manifest/network/network-discovery.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
-file path=var/svc/manifest/system/hal.xml group=sys mode=0444 \
+file path=lib/svc/manifest/system/hal.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
 legacy pkg=SUNWhal arch=$(ARCH) category=system \
     desc="Hardware Abstraction Layer, HAL (freedesktop.org)" \
--- a/usr/src/pkg/manifests/service-key-management-sun-fire-15000.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/service-key-management-sun-fire-15000.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -48,14 +48,11 @@
 dir path=usr/platform group=sys
 dir path=usr/platform/sun4u group=sys
 dir path=usr/platform/sun4u/lib
-dir path=var group=sys opensolaris.zone=global variant.opensolaris.zone=global
-dir path=var/svc group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/platform group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest/platform group=sys opensolaris.zone=global \
-    variant.opensolaris.zone=global
-dir path=var/svc/manifest/platform/sun4u group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/platform/sun4u group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
 driver name=sckmdrv perms="* 0600 root sys"
 file path=lib/svc/method/svc-sckmd mode=0555 opensolaris.zone=global \
@@ -65,7 +62,7 @@
 file path=platform/SUNW,Sun-Fire-15000/kernel/drv/sckmdrv.conf group=sys \
     opensolaris.zone=global reboot-needed=false variant.opensolaris.zone=global
 file path=usr/platform/sun4u/lib/sckmd group=sys mode=0755
-file path=var/svc/manifest/platform/sun4u/sckmd.xml group=sys mode=0444 \
+file path=lib/svc/manifest/platform/sun4u/sckmd.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
 legacy pkg=SUNWsckm.u arch=$(ARCH).sun4u category=system \
     desc="Key Management Modules for Sun Fire 15000" \
--- a/usr/src/pkg/manifests/service-network-dhcp.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/service-network-dhcp.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -34,6 +34,8 @@
 dir path=etc group=sys
 dir path=etc/inet group=sys
 dir path=etc/init.d group=sys
+dir path=lib
+dir path=lib/svc
 dir path=usr group=sys
 dir path=usr/include
 dir path=usr/lib
@@ -43,10 +45,8 @@
 dir path=usr/lib/inet/dhcp/svc
 dir path=usr/lib/inet/dhcp/svcadm
 dir path=usr/sbin
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/network group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/network group=sys
 file path=etc/init.d/dhcp group=sys mode=0744
 file path=usr/include/dhcp_svc_public.h
 file path=usr/lib/inet/dhcp/nsu/rfc2136.so.1
@@ -64,7 +64,7 @@
 file path=usr/sbin/dhcpconfig mode=0555
 file path=usr/sbin/dhtadm mode=0555
 file path=usr/sbin/pntadm mode=0555
-file path=var/svc/manifest/network/dhcp-server.xml group=sys mode=0444
+file path=lib/svc/manifest/network/dhcp-server.xml group=sys mode=0444
 legacy pkg=SUNWdhcsr arch=$(ARCH) category=system \
     desc="Root filesystem portion of the SunOS BOOTP/DHCP service, which uses the BOOT Protocol and/or Dynamic Host Configuration Protocol to provide network configuration parameters to BOOTP/DHCP clients. Administration utilities for the service are included." \
     hotline="Please contact your local service provider" \
--- a/usr/src/pkg/manifests/service-network-dns-mdns.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/service-network-dns-mdns.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -31,6 +31,8 @@
 set name=info.classification value=org.opensolaris.category.2008:System/Services
 set name=variant.arch value=$(ARCH)
 set name=variant.opensolaris.zone value=global value=nonglobal
+dir path=lib
+dir path=lib/svc
 dir path=usr group=sys
 dir path=usr/bin
 dir path=usr/include
@@ -48,11 +50,9 @@
 dir path=usr/share/lib/java/javadoc/dnssd/api/com/apple/dnssd group=other
 dir path=usr/share/lib/java/javadoc/dnssd/api/resources group=other
 dir path=usr/share/lib/java/javadoc/dnssd/examples group=other
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/network group=sys
-dir path=var/svc/manifest/network/dns group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/network group=sys
+dir path=lib/svc/manifest/network/dns group=sys
 file path=usr/bin/dns-sd mode=0555
 file path=usr/include/dns_sd.h
 file path=usr/lib/$(ARCH64)/libdns_sd.so.1
@@ -126,7 +126,7 @@
 file path=usr/share/lib/java/javadoc/dnssd/api/stylesheet.css group=other
 file path=usr/share/lib/java/javadoc/dnssd/examples/BrowserApp.jar group=sys
 file path=usr/share/lib/java/javadoc/dnssd/examples/SimpleChat.jar group=sys
-file path=var/svc/manifest/network/dns/multicast.xml group=sys mode=0444
+file path=lib/svc/manifest/network/dns/multicast.xml group=sys mode=0444
 legacy pkg=SUNWdsdr arch=$(ARCH) category=system \
     desc="Root components for Multicast DNS daemon and service discovery support" \
     hotline="Please contact your local service provider" \
--- a/usr/src/pkg/manifests/service-network-ftp.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/service-network-ftp.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -37,10 +37,8 @@
 dir path=lib/svc/method
 dir path=usr group=sys
 dir path=usr/sbin
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/network group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/network group=sys
 file path=etc/ftpd/ftpaccess group=sys original_name=SUNWftp:etc/ftpd/ftpaccess \
     preserve=true
 file path=etc/ftpd/ftpconversions group=sys \
@@ -59,7 +57,7 @@
 file path=usr/sbin/ftpshut mode=0555
 file path=usr/sbin/in.ftpd mode=0555
 file path=usr/sbin/privatepw mode=0555
-file path=var/svc/manifest/network/ftp.xml group=sys mode=0444
+file path=lib/svc/manifest/network/ftp.xml group=sys mode=0444
 hardlink path=usr/sbin/ftpwho target=../../usr/sbin/ftpcount
 legacy pkg=SUNWftpr arch=$(ARCH) category=system \
     desc="FTP Server Configuration Files" \
--- a/usr/src/pkg/manifests/service-network-legacy.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/service-network-legacy.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -32,23 +32,23 @@
 set name=info.classification value=org.opensolaris.category.2008:System/Services
 set name=variant.arch value=$(ARCH)
 set name=variant.opensolaris.zone value=global value=nonglobal
+dir path=lib
+dir path=lib/svc
 dir path=usr group=sys
 dir path=usr/lib
 dir path=usr/lib/inet
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/network group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/network group=sys
 file path=usr/lib/inet/in.chargend mode=0555
 file path=usr/lib/inet/in.daytimed mode=0555
 file path=usr/lib/inet/in.discardd mode=0555
 file path=usr/lib/inet/in.echod mode=0555
 file path=usr/lib/inet/in.timed mode=0555
-file path=var/svc/manifest/network/chargen.xml group=sys mode=0444
-file path=var/svc/manifest/network/daytime.xml group=sys mode=0444
-file path=var/svc/manifest/network/discard.xml group=sys mode=0444
-file path=var/svc/manifest/network/echo.xml group=sys mode=0444
-file path=var/svc/manifest/network/time.xml group=sys mode=0444
+file path=lib/svc/manifest/network/chargen.xml group=sys mode=0444
+file path=lib/svc/manifest/network/daytime.xml group=sys mode=0444
+file path=lib/svc/manifest/network/discard.xml group=sys mode=0444
+file path=lib/svc/manifest/network/echo.xml group=sys mode=0444
+file path=lib/svc/manifest/network/time.xml group=sys mode=0444
 legacy pkg=SUNWcnsr arch=$(ARCH) category=system \
     desc="Common Network Services (Root): time, daytime, echo, discard, chargen" \
     hotline="Please contact your local service provider" \
--- a/usr/src/pkg/manifests/service-network-load-balancer-ilb.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/service-network-load-balancer-ilb.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -32,6 +32,8 @@
     value="org.opensolaris.category.2008:System/Administration and Configuration"
 set name=variant.arch value=$(ARCH)
 set name=variant.opensolaris.zone value=global value=nonglobal
+dir path=lib
+dir path=lib/svc
 dir path=usr group=sys
 dir path=usr/include
 dir path=usr/lib
@@ -39,11 +41,9 @@
 dir path=usr/lib/inet
 dir path=usr/lib/inet/ilb
 dir path=usr/sbin
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/network group=sys
-dir path=var/svc/manifest/network/loadbalancer group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/network group=sys
+dir path=lib/svc/manifest/network/loadbalancer group=sys
 file path=usr/include/libilb.h
 file path=usr/lib/$(ARCH64)/libilb.so.1
 file path=usr/lib/$(ARCH64)/llib-lilb.ln
@@ -53,7 +53,7 @@
 file path=usr/lib/llib-lilb
 file path=usr/lib/llib-lilb.ln
 file path=usr/sbin/ilbadm mode=0555
-file path=var/svc/manifest/network/loadbalancer/ilbd.xml group=sys mode=0444
+file path=lib/svc/manifest/network/loadbalancer/ilbd.xml group=sys mode=0444
 legacy pkg=SUNWilb arch=$(ARCH) category=system \
     desc="Integrated IP layer 3/4 load balancer for Solaris (usr)" \
     hotline="Please contact your local service provider" \
--- a/usr/src/pkg/manifests/service-network-network-servers.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/service-network-network-servers.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -31,6 +31,8 @@
 set name=info.classification value=org.opensolaris.category.2008:System/Core
 set name=variant.arch value=$(ARCH)
 set name=variant.opensolaris.zone value=global value=nonglobal
+dir path=lib
+dir path=lib/svc
 dir path=etc group=sys
 dir path=usr group=sys
 dir path=usr/bin
@@ -41,11 +43,9 @@
 dir path=usr/lib/netsvc/rwall group=sys
 dir path=usr/lib/netsvc/spray group=sys
 dir path=usr/sbin
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/network group=sys
-dir path=var/svc/manifest/network/rpc group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/network group=sys
+dir path=lib/svc/manifest/network/rpc group=sys
 file path=usr/bin/finger mode=0555
 file path=usr/bin/rwho mode=0555
 file path=usr/bin/talk mode=0555
@@ -60,16 +60,16 @@
 file path=usr/sbin/in.rshd mode=0555
 file path=usr/sbin/in.rwhod mode=0555
 file path=usr/sbin/in.talkd mode=0555
-file path=var/svc/manifest/network/comsat.xml group=sys mode=0444
-file path=var/svc/manifest/network/finger.xml group=sys mode=0444
-file path=var/svc/manifest/network/login.xml group=sys mode=0444
-file path=var/svc/manifest/network/rexec.xml group=sys mode=0444
-file path=var/svc/manifest/network/rpc/rstat.xml group=sys mode=0444
-file path=var/svc/manifest/network/rpc/rusers.xml group=sys mode=0444
-file path=var/svc/manifest/network/rpc/spray.xml group=sys mode=0444
-file path=var/svc/manifest/network/rpc/wall.xml group=sys mode=0444
-file path=var/svc/manifest/network/shell.xml group=sys mode=0444
-file path=var/svc/manifest/network/talk.xml group=sys mode=0444
+file path=lib/svc/manifest/network/comsat.xml group=sys mode=0444
+file path=lib/svc/manifest/network/finger.xml group=sys mode=0444
+file path=lib/svc/manifest/network/login.xml group=sys mode=0444
+file path=lib/svc/manifest/network/rexec.xml group=sys mode=0444
+file path=lib/svc/manifest/network/rpc/rstat.xml group=sys mode=0444
+file path=lib/svc/manifest/network/rpc/rusers.xml group=sys mode=0444
+file path=lib/svc/manifest/network/rpc/spray.xml group=sys mode=0444
+file path=lib/svc/manifest/network/rpc/wall.xml group=sys mode=0444
+file path=lib/svc/manifest/network/shell.xml group=sys mode=0444
+file path=lib/svc/manifest/network/talk.xml group=sys mode=0444
 legacy pkg=SUNWrcmdr arch=$(ARCH) category=system \
     desc="Remote Network Server Commands (Root)" \
     hotline="Please contact your local service provider" \
--- a/usr/src/pkg/manifests/service-network-nis.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/service-network-nis.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -39,10 +39,11 @@
 dir path=usr/lib/netsvc/yp
 dir path=usr/sbin
 dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/network group=sys
-dir path=var/svc/manifest/network/nis group=sys
+dir path=lib
+dir path=lib/svc
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/network group=sys
+dir path=lib/svc/manifest/network/nis group=sys
 dir path=var/yp
 dir path=var/yp/binding
 file path=etc/default/yppasswdd group=sys \
@@ -65,10 +66,10 @@
 file path=usr/lib/netsvc/yp/ypxfrd mode=0555
 file path=usr/sbin/mknetid mode=0555
 file path=usr/sbin/revnetgroup mode=0555
-file path=var/svc/manifest/network/nis/passwd.xml group=sys mode=0444
-file path=var/svc/manifest/network/nis/server.xml group=sys mode=0444
-file path=var/svc/manifest/network/nis/update.xml group=sys mode=0444
-file path=var/svc/manifest/network/nis/xfr.xml group=sys mode=0444
+file path=lib/svc/manifest/network/nis/passwd.xml group=sys mode=0444
+file path=lib/svc/manifest/network/nis/server.xml group=sys mode=0444
+file path=lib/svc/manifest/network/nis/update.xml group=sys mode=0444
+file path=lib/svc/manifest/network/nis/xfr.xml group=sys mode=0444
 file path=var/yp/Makefile mode=0555 original_name=SUNWyp:var/yp/Makefile \
     preserve=renamenew
 file path=var/yp/updaters mode=0500
--- a/usr/src/pkg/manifests/service-network-slp.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/service-network-slp.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -36,6 +36,7 @@
 dir path=etc/init.d group=sys
 dir path=lib
 dir path=lib/svc
+dir path=lib/svc/manifest group=sys
 dir path=lib/svc/method
 dir path=usr group=sys
 dir path=usr/include
@@ -45,10 +46,7 @@
 dir path=usr/share group=sys
 dir path=usr/share/lib group=sys
 dir path=usr/share/lib/slp
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/network group=sys
+dir path=lib/svc/manifest/network group=sys
 file path=etc/inet/slp.conf.example group=sys
 file path=etc/init.d/slpd group=sys mode=0744
 file path=lib/svc/method/slp mode=0555
@@ -61,7 +59,7 @@
 file path=usr/lib/llib-lslp.ln
 file path=usr/share/lib/slp/slp.jar group=sys
 file path=usr/share/lib/slp/slpd.jar group=sys mode=0600
-file path=var/svc/manifest/network/slp.xml group=sys mode=0444
+file path=lib/svc/manifest/network/slp.xml group=sys mode=0444
 legacy pkg=SUNWslpr arch=$(ARCH) category=system \
     desc="Root filesystem portion of the Service Location Protocol (SLP) framework. Includes the SLP configuration file and start scripts for the SLP daemon." \
     hotline="Please contact your local service provider" name="SLP, (Root)" \
--- a/usr/src/pkg/manifests/service-network-smtp-sendmail.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/service-network-smtp-sendmail.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -44,6 +44,7 @@
 dir path=etc/mail/cf/sh group=mail
 dir path=lib
 dir path=lib/svc
+dir path=lib/svc/manifest group=sys
 dir path=lib/svc/method
 dir path=lib/svc/share
 dir path=usr group=sys
@@ -62,9 +63,7 @@
 dir path=var/spool
 dir path=var/spool/clientmqueue group=smmsp mode=0770 owner=smmsp
 dir path=var/spool/mqueue mode=0750
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/network group=sys
+dir path=lib/svc/manifest/network group=sys
 file path=etc/init.d/sendmail group=sys mode=0744 \
     original_name=SUNWsndm:etc/init.d/sendmail preserve=true
 file path=etc/mail/aliases original_name=SUNWsndm:etc/mail/aliases preserve=true
@@ -181,8 +180,8 @@
 file path=usr/sbin/editmap mode=0555
 file path=usr/sbin/etrn mode=0555
 file path=usr/sbin/makemap mode=0555
-file path=var/svc/manifest/network/sendmail-client.xml group=sys mode=0444
-file path=var/svc/manifest/network/smtp-sendmail.xml group=sys mode=0444
+file path=lib/svc/manifest/network/sendmail-client.xml group=sys mode=0444
+file path=lib/svc/manifest/network/smtp-sendmail.xml group=sys mode=0444
 legacy pkg=SUNWsndmr arch=$(ARCH) category=system \
     desc="Sendmail Configuration Files" \
     hotline="Please contact your local service provider" name="Sendmail (root)" \
--- a/usr/src/pkg/manifests/service-network-ssh.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/service-network-ssh.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -34,20 +34,18 @@
 dir path=etc/ssh group=sys
 dir path=lib
 dir path=lib/svc
+dir path=lib/svc/manifest group=sys
 dir path=lib/svc/method
 dir path=usr group=sys
 dir path=usr/lib
 dir path=usr/lib/ssh
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/network group=sys
+dir path=lib/svc/manifest/network group=sys
 file path=etc/ssh/sshd_config group=sys \
     original_name=SUNWsshd:etc/ssh/sshd_config preserve=true
 file path=lib/svc/method/sshd mode=0555
 file path=usr/lib/ssh/sftp-server mode=0555
 file path=usr/lib/ssh/sshd mode=0555
-file path=var/svc/manifest/network/ssh.xml group=sys mode=0444
+file path=lib/svc/manifest/network/ssh.xml group=sys mode=0444
 legacy pkg=SUNWsshdr arch=$(ARCH) category=system \
     desc="Secure Shell protocol Server" \
     hotline="Please contact your local service provider" \
--- a/usr/src/pkg/manifests/service-network-telnet.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/service-network-telnet.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -34,14 +34,14 @@
 dir path=etc/default group=sys
 dir path=usr group=sys
 dir path=usr/sbin
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/network group=sys
+dir path=lib
+dir path=lib/svc
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/network group=sys
 file path=etc/default/telnetd group=sys \
     original_name=SUNWtnetd:etc/default/telnetd preserve=true
 file path=usr/sbin/in.telnetd mode=0555
-file path=var/svc/manifest/network/telnet.xml group=sys mode=0444
+file path=lib/svc/manifest/network/telnet.xml group=sys mode=0444
 legacy pkg=SUNWtnetd arch=$(ARCH) category=system \
     desc="Telnet Server Daemon (Usr)" \
     hotline="Please contact your local service provider" \
--- a/usr/src/pkg/manifests/service-network-uucp.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/service-network-uucp.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -46,9 +46,10 @@
 dir path=var/spool/uucp/.Workspace group=uucp owner=uucp
 dir path=var/spool/uucp/.Xqtdir group=uucp owner=uucp
 dir path=var/spool/uucppublic group=uucp mode=1777 owner=uucp
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/network group=sys
+dir path=lib
+dir path=lib/svc
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/network group=sys
 dir path=var/uucp group=uucp owner=uucp
 dir path=var/uucp/.Admin group=uucp owner=uucp
 dir path=var/uucp/.Log group=uucp owner=uucp
@@ -107,7 +108,7 @@
 file path=usr/lib/uucp/uusched group=uucp mode=4511 owner=uucp
 file path=usr/lib/uucp/uuxqt group=uucp mode=4511 owner=uucp
 file path=usr/sbin/in.uucpd group=uucp mode=0555
-file path=var/svc/manifest/network/uucp.xml group=sys mode=0444
+file path=lib/svc/manifest/network/uucp.xml group=sys mode=0444
 hardlink path=etc/rc2.d/S70uucp target=../../etc/init.d/uucp
 legacy pkg=SUNWbnur arch=$(ARCH) category=system \
     desc="configuration and start-up files for UUCP utilities" \
--- a/usr/src/pkg/manifests/service-network-wpa.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/service-network-wpa.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -34,12 +34,12 @@
 dir path=usr group=sys
 dir path=usr/lib
 dir path=usr/lib/inet
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/network group=sys
+dir path=lib
+dir path=lib/svc
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/network group=sys
 file path=usr/lib/inet/wpad mode=0555
-file path=var/svc/manifest/network/wpa.xml group=sys mode=0444
+file path=lib/svc/manifest/network/wpa.xml group=sys mode=0444
 legacy pkg=SUNWwpar arch=$(ARCH) category=system \
     desc="The service implements the IEEE802.11i (WPA/WPA2) specification." \
     hotline="Please contact your local service provider" \
--- a/usr/src/pkg/manifests/service-picl.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/service-picl.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -131,12 +131,11 @@
 $(sparc_ONLY)dir path=usr/platform/sun4v/lib/picl group=sys
 $(sparc_ONLY)dir path=usr/platform/sun4v/lib/picl/plugins group=sys
 dir path=usr/sbin
-dir path=var group=sys opensolaris.zone=global variant.opensolaris.zone=global
-dir path=var/svc group=sys opensolaris.zone=global \
+dir path=lib opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest group=sys opensolaris.zone=global \
+dir path=lib/svc opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest/system group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
 file path=usr/lib/$(ARCH64)/libpicl.so.1
 file path=usr/lib/$(ARCH64)/llib-lpicl.ln
@@ -616,7 +615,7 @@
 $(sparc_ONLY)file path=usr/platform/sun4v/lib/picl/plugins/libsnmpplugin.so.1 \
     group=sys
 file path=usr/sbin/prtpicl mode=0755
-file path=var/svc/manifest/system/picl.xml group=sys mode=0444 \
+file path=lib/svc/manifest/system/picl.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
 legacy pkg=SUNWpiclr arch=$(ARCH) category=system \
     desc="PICL Framework init scripts" \
--- a/usr/src/pkg/manifests/service-resource-cap.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/service-resource-cap.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -37,15 +37,15 @@
 dir path=usr/lib/rcap/$(ARCH32)
 dir path=usr/lib/rcap/$(ARCH64)
 dir path=usr/sbin
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/system group=sys
+dir path=lib
+dir path=lib/svc
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/system group=sys
 file path=usr/bin/rcapstat mode=0555
 file path=usr/lib/rcap/$(ARCH32)/rcapd mode=0555
 file path=usr/lib/rcap/$(ARCH64)/rcapd mode=0555
 file path=usr/sbin/rcapadm mode=0555
-file path=var/svc/manifest/system/rcap.xml group=sys mode=0444
+file path=lib/svc/manifest/system/rcap.xml group=sys mode=0444
 hardlink path=usr/lib/rcap/rcapd target=../isaexec
 legacy pkg=SUNWrcapr arch=$(ARCH) category=system \
     desc="Solaris Resource Capping Daemon (Root)" \
--- a/usr/src/pkg/manifests/service-resource-pools.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/service-resource-pools.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -53,11 +53,9 @@
     variant.opensolaris.zone=global
 dir path=var/log/pool group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest group=sys opensolaris.zone=global \
-    variant.opensolaris.zone=global
-dir path=var/svc/manifest/system group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/system group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
 driver name=pool perms="pool 0666 root sys" perms="poolctl 0666 root sys"
 file path=lib/svc/method/svc-poold mode=0555 opensolaris.zone=global \
@@ -79,9 +77,9 @@
 file path=usr/sbin/poolbind mode=0555
 file path=usr/sbin/poolcfg mode=0555
 file path=usr/share/lib/xml/dtd/rm_pool.dtd.1
-file path=var/svc/manifest/system/poold.xml group=sys mode=0444 \
+file path=lib/svc/manifest/system/poold.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
-file path=var/svc/manifest/system/pools.xml group=sys mode=0444 \
+file path=lib/svc/manifest/system/pools.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
 legacy pkg=SUNWpool arch=$(ARCH) category=system \
     desc="core software for resource pools" \
--- a/usr/src/pkg/manifests/service-security-gss.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/service-security-gss.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -33,17 +33,17 @@
 set name=variant.opensolaris.zone value=global value=nonglobal
 dir path=etc group=sys
 dir path=etc/gss group=sys
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/network group=sys
-dir path=var/svc/manifest/network/rpc group=sys
+dir path=lib
+dir path=lib/svc
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/network group=sys
+dir path=lib/svc/manifest/network/rpc group=sys
 file path=etc/gss/gsscred.conf group=sys \
     original_name=SUNWgssc:etc/gss/gsscred.conf preserve=true
 file path=etc/gss/mech group=sys original_name=SUNWgssc:etc/gss/mech \
     preserve=true
 file path=etc/gss/qop group=sys original_name=SUNWgssc:etc/gss/qop preserve=true
-file path=var/svc/manifest/network/rpc/gss.xml group=sys mode=0444
+file path=lib/svc/manifest/network/rpc/gss.xml group=sys mode=0444
 legacy pkg=SUNWgssc arch=$(ARCH) category=system \
     desc="Generic Security Service Application Program Interface, Version 2 - config" \
     hotline="Please contact your local service provider" \
--- a/usr/src/pkg/manifests/service-security-kerberos-5.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/service-security-kerberos-5.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -48,10 +48,11 @@
 dir path=var/krb5 group=sys
 dir path=var/krb5/rcache group=sys mode=1777
 dir path=var/krb5/rcache/root group=sys mode=0700
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/network group=sys
-dir path=var/svc/manifest/network/security group=sys
+dir path=lib
+dir path=lib/svc
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/network group=sys
+dir path=lib/svc/manifest/network/security group=sys
 file path=etc/krb5/krb5.conf group=sys original_name=SUNWkrb:etc/krb5/krb5.conf \
     preserve=true
 file path=etc/krb5/warn.conf group=sys original_name=SUNWkrb:etc/krb5/warn.conf \
@@ -75,9 +76,9 @@
 file path=usr/lib/security/$(ARCH64)/pam_krb5_migrate.so.1
 file path=usr/lib/security/pam_krb5.so.1
 file path=usr/lib/security/pam_krb5_migrate.so.1
-file path=var/svc/manifest/network/security/kadmin.xml group=sys mode=0444
-file path=var/svc/manifest/network/security/krb5kdc.xml group=sys mode=0444
-file path=var/svc/manifest/network/security/ktkt_warn.xml group=sys mode=0444
+file path=lib/svc/manifest/network/security/kadmin.xml group=sys mode=0444
+file path=lib/svc/manifest/network/security/krb5kdc.xml group=sys mode=0444
+file path=lib/svc/manifest/network/security/ktkt_warn.xml group=sys mode=0444
 legacy pkg=SUNWkrbr arch=$(ARCH) category=system \
     desc="Kerberos version 5 support (Root)" \
     hotline="Please contact your local service provider" \
--- a/usr/src/pkg/manifests/service-storage-avs-cache-management.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/service-storage-avs-cache-management.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -63,10 +63,8 @@
 dir path=usr/lib/mdb/kvm group=sys
 dir path=usr/lib/mdb/kvm/$(ARCH64) group=sys
 dir path=usr/sbin
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/system group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/system group=sys
 driver name=ncall devlink=type=ddi_pseudo;name=ncall\t\D perms="* 0666 root sys" \
     privs=sys_config privs=sys_devices
 driver name=nsctl devlink=type=ddi_pseudo;name=nsctl\t\D perms="* 0666 root sys" \
@@ -112,7 +110,7 @@
 file path=usr/lib/mdb/kvm/$(ARCH64)/sdbc.so group=sys mode=0555
 $(i386_ONLY)file path=usr/lib/mdb/kvm/nsctl.so group=sys mode=0555
 $(i386_ONLY)file path=usr/lib/mdb/kvm/sdbc.so group=sys mode=0555
-file path=var/svc/manifest/system/nws_scm.xml group=sys mode=0444
+file path=lib/svc/manifest/system/nws_scm.xml group=sys mode=0444
 hardlink path=lib/svc/method/svc-scm target=../../../etc/init.d/scm
 hardlink path=usr/cluster/sbin/dscfg_reconfigure \
     target=../../bin/dscfg_reconfigure.cluster
--- a/usr/src/pkg/manifests/service-storage-fibre-channel-fc-fabric.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/service-storage-fibre-channel-fc-fabric.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -38,20 +38,17 @@
 dir path=usr/lib
 dir path=usr/lib/cfgadm
 dir path=usr/lib/cfgadm/$(ARCH64)
-dir path=var group=sys opensolaris.zone=global variant.opensolaris.zone=global
-dir path=var/svc group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/system group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest/system group=sys opensolaris.zone=global \
-    variant.opensolaris.zone=global
-dir path=var/svc/manifest/system/device group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/system/device group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
 file path=lib/svc/method/fc-fabric mode=0555 opensolaris.zone=global \
     variant.opensolaris.zone=global
 file path=usr/lib/cfgadm/$(ARCH64)/fp.so.1
 file path=usr/lib/cfgadm/fp.so.1
-file path=var/svc/manifest/system/device/devices-fc-fabric.xml group=sys \
+file path=lib/svc/manifest/system/device/devices-fc-fabric.xml group=sys \
     mode=0444 opensolaris.zone=global variant.opensolaris.zone=global
 legacy pkg=SUNWcfpl arch=$(ARCH) category=system \
     desc="Provides the fp plug-in library of libcfgadm." \
--- a/usr/src/pkg/manifests/service-storage-isns.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/service-storage-isns.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -33,13 +33,13 @@
 set name=variant.opensolaris.zone value=global value=nonglobal
 dir path=usr group=sys
 dir path=usr/sbin
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/network group=sys
+dir path=lib
+dir path=lib/svc
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/network group=sys
 file path=usr/sbin/isns mode=0555
 file path=usr/sbin/isnsadm mode=0555
-file path=var/svc/manifest/network/isns_server.xml group=sys mode=0444
+file path=lib/svc/manifest/network/isns_server.xml group=sys mode=0444
 legacy pkg=SUNWisns arch=$(ARCH) category=system \
     desc="Solaris internet Storage Name Service(iSNS) Server" \
     hotline="Please contact your local service provider" \
--- a/usr/src/pkg/manifests/service-storage-media-volume-manager.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/service-storage-media-volume-manager.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -37,14 +37,11 @@
 dir path=usr/bin
 dir path=usr/lib
 dir path=usr/sbin
-dir path=var group=sys opensolaris.zone=global variant.opensolaris.zone=global
-dir path=var/svc group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/system group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest/system group=sys opensolaris.zone=global \
-    variant.opensolaris.zone=global
-dir path=var/svc/manifest/system/filesystem group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/system/filesystem group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
 file path=lib/svc/method/svc-rmvolmgr mode=0555 opensolaris.zone=global \
     variant.opensolaris.zone=global
@@ -53,7 +50,7 @@
 file path=usr/bin/volcheck mode=0555
 file path=usr/bin/volrmmount mode=0555
 file path=usr/lib/rmvolmgr mode=0555
-file path=var/svc/manifest/system/filesystem/rmvolmgr.xml group=sys mode=0444 \
+file path=lib/svc/manifest/system/filesystem/rmvolmgr.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
 legacy pkg=SUNWrmvolmgr arch=$(ARCH) category=system \
     desc="Non-graphical removable volume manager" \
--- a/usr/src/pkg/manifests/service-storage-ndmp.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/service-storage-ndmp.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -46,10 +46,8 @@
 dir path=usr/lib/$(ARCH64)
 dir path=usr/lib/ndmp
 dir path=usr/sbin
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/system group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/system group=sys
 file path=lib/svc/method/svc-ndmp mode=0555
 file path=usr/include/libndmp.h
 file path=usr/lib/$(ARCH64)/libndmp.so.1
@@ -60,7 +58,7 @@
 file path=usr/lib/ndmp/ndmpd mode=0555
 file path=usr/sbin/ndmpadm mode=0555
 file path=usr/sbin/ndmpstat mode=0555
-file path=var/svc/manifest/system/ndmp.xml group=sys mode=0444
+file path=lib/svc/manifest/system/ndmp.xml group=sys mode=0444
 legacy pkg=SUNWndmpr arch=$(ARCH) category=system \
     desc="Network Data Management Protocol Service (root components)" \
     hotline="Please contact your local service provider" \
--- a/usr/src/pkg/manifests/service-storage-removable-media.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/service-storage-removable-media.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -36,11 +36,11 @@
 dir path=usr/lib/$(ARCH64)
 dir path=usr/lib/smedia
 dir path=usr/lib/smedia/$(ARCH64)
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/network group=sys
-dir path=var/svc/manifest/network/rpc group=sys
+dir path=lib
+dir path=lib/svc
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/network group=sys
+dir path=lib/svc/manifest/network/rpc group=sys
 file path=usr/lib/$(ARCH64)/libsmedia.so.1
 file path=usr/lib/$(ARCH64)/llib-lsmedia.ln
 file path=usr/lib/libsmedia.so.1
@@ -53,7 +53,7 @@
 file path=usr/lib/smedia/sm_fd.so.1 mode=0555
 file path=usr/lib/smedia/sm_pcata.so.1 mode=0555
 file path=usr/lib/smedia/sm_scsi.so.1 mode=0555
-file path=var/svc/manifest/network/rpc/smserver.xml group=sys mode=0444
+file path=lib/svc/manifest/network/rpc/smserver.xml group=sys mode=0444
 legacy pkg=SUNWsmedia arch=$(ARCH) category=system \
     desc="Storage media management library" \
     hotline="Please contact your local service provider" \
--- a/usr/src/pkg/manifests/service-storage-virus-scan.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/service-storage-virus-scan.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -42,11 +42,11 @@
 dir path=usr/lib/devfsadm/linkmod group=sys
 dir path=usr/lib/vscan
 dir path=usr/sbin
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/system group=sys
-dir path=var/svc/manifest/system/filesystem group=sys
+dir path=lib
+dir path=lib/svc
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/system group=sys
+dir path=lib/svc/manifest/system/filesystem group=sys
 driver name=vscan perms="* 0640 root sys"
 file path=kernel/drv/$(ARCH64)/vscan group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
@@ -58,7 +58,7 @@
 file path=usr/lib/vscan/libvscan.so.1
 file path=usr/lib/vscan/vscand mode=0555
 file path=usr/sbin/vscanadm mode=0555
-file path=var/svc/manifest/system/filesystem/vscan.xml group=sys mode=0444
+file path=lib/svc/manifest/system/filesystem/vscan.xml group=sys mode=0444
 legacy pkg=SUNWvscankr arch=$(ARCH) category=system \
     desc="Virus Scan Service Kernel Root Components" \
     hotline="Please contact your local service provider" \
--- a/usr/src/pkg/manifests/storage-avs-point-in-time-copy.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/storage-avs-point-in-time-copy.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -62,10 +62,8 @@
 dir path=usr/lib/mdb/kvm group=sys
 dir path=usr/lib/mdb/kvm/$(ARCH64) group=sys
 dir path=usr/sbin
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/system group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/system group=sys
 driver name=ii devlink=type=ddi_pseudo;name=ii\t\D perms="* 0666 root sys" \
     privs=sys_config privs=sys_devices
 file path=etc/init.d/ii mode=0744
@@ -83,7 +81,7 @@
     original_name=SUNWii:usr/kernel/drv/ii.conf preserve=true
 file path=usr/lib/mdb/kvm/$(ARCH64)/ii.so group=sys mode=0555
 $(i386_ONLY)file path=usr/lib/mdb/kvm/ii.so group=sys mode=0555
-file path=var/svc/manifest/system/nws_ii.xml group=sys mode=0444
+file path=lib/svc/manifest/system/nws_ii.xml group=sys mode=0444
 hardlink path=lib/svc/method/svc-ii target=../../../etc/init.d/ii
 legacy pkg=SUNWiir arch=$(ARCH) category=system \
     desc="Point-In-Time Copy and snapshot facility" \
--- a/usr/src/pkg/manifests/storage-avs-remote-mirror.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/storage-avs-remote-mirror.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -63,10 +63,8 @@
 dir path=usr/lib/mdb/kvm group=sys
 dir path=usr/lib/mdb/kvm/$(ARCH64) group=sys
 dir path=usr/sbin
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/system group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/system group=sys
 driver name=rdc devlink=type=ddi_pseudo;name=rdc\t\D perms="* 0666 root sys" \
     privs=sys_config privs=sys_devices
 file path=etc/init.d/rdc mode=0744
@@ -90,8 +88,8 @@
 file path=usr/lib/librdc.so.1
 file path=usr/lib/mdb/kvm/$(ARCH64)/rdc.so group=sys mode=0555
 $(i386_ONLY)file path=usr/lib/mdb/kvm/rdc.so group=sys mode=0555
-file path=var/svc/manifest/system/nws_rdc.xml group=sys mode=0444
-file path=var/svc/manifest/system/nws_rdcsyncd.xml group=sys mode=0444
+file path=lib/svc/manifest/system/nws_rdc.xml group=sys mode=0444
+file path=lib/svc/manifest/system/nws_rdcsyncd.xml group=sys mode=0444
 hardlink path=lib/svc/method/svc-rdc target=../../../etc/init.d/rdc
 hardlink path=lib/svc/method/svc-rdcsyncd target=../../../etc/init.d/rdcfinish
 hardlink path=usr/kernel/misc/$(ARCH64)/rdcsrv target=../../drv/$(ARCH64)/rdcsrv
--- a/usr/src/pkg/manifests/storage-stmf.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/storage-stmf.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -56,12 +56,9 @@
 dir path=usr/lib/mdb/kvm group=sys
 dir path=usr/lib/mdb/kvm/$(ARCH64) group=sys
 dir path=usr/sbin
-dir path=var group=sys opensolaris.zone=global variant.opensolaris.zone=global
-dir path=var/svc group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest group=sys opensolaris.zone=global \
-    variant.opensolaris.zone=global
-dir path=var/svc/manifest/system group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/system group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
 driver name=fct perms="* 0666 root sys"
 driver name=pppt perms="* 0666 root sys"
@@ -128,7 +125,7 @@
 $(i386_ONLY)file path=usr/lib/mdb/kvm/stmf.so group=sys mode=0555
 file path=usr/sbin/sbdadm mode=0555
 file path=usr/sbin/stmfadm mode=0555
-file path=var/svc/manifest/system/stmf.xml group=sys mode=0444 \
+file path=lib/svc/manifest/system/stmf.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
 legacy pkg=SUNWstmf arch=$(ARCH) category=system \
     desc="Sun Common Multiprotocol SCSI Target device drivers" \
--- a/usr/src/pkg/manifests/storage-svm.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/storage-svm.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -60,16 +60,13 @@
 dir path=usr/sbin
 dir path=usr/snadm
 dir path=usr/snadm/lib
-dir path=var group=sys opensolaris.zone=global variant.opensolaris.zone=global
-dir path=var/svc group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/network group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest/network group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/network/rpc group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest/network/rpc group=sys opensolaris.zone=global \
-    variant.opensolaris.zone=global
-dir path=var/svc/manifest/system group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/system group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
 driver name=md policy="admin write_priv_set=sys_config" perms="* 0640 root sys" \
     perms="admin 0644 root sys"
@@ -175,19 +172,19 @@
 file path=usr/sbin/rpc.metamedd mode=0555
 file path=usr/sbin/rpc.metamhd mode=0555
 file path=usr/snadm/lib/libsvm.so.1
-file path=var/svc/manifest/network/rpc/mdcomm.xml group=sys mode=0444 \
+file path=lib/svc/manifest/network/rpc/mdcomm.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
-file path=var/svc/manifest/network/rpc/meta.xml group=sys mode=0444 \
+file path=lib/svc/manifest/network/rpc/meta.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
-file path=var/svc/manifest/network/rpc/metamed.xml group=sys mode=0444 \
+file path=lib/svc/manifest/network/rpc/metamed.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
-file path=var/svc/manifest/network/rpc/metamh.xml group=sys mode=0444 \
+file path=lib/svc/manifest/network/rpc/metamh.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
-file path=var/svc/manifest/system/mdmonitor.xml group=sys mode=0444 \
+file path=lib/svc/manifest/system/mdmonitor.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
-file path=var/svc/manifest/system/metainit.xml group=sys mode=0444 \
+file path=lib/svc/manifest/system/metainit.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
-file path=var/svc/manifest/system/metasync.xml group=sys mode=0444 \
+file path=lib/svc/manifest/system/metasync.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
 legacy pkg=SUNWmdr arch=$(ARCH) category=system \
     desc="Solaris Volume Manager driver" \
--- a/usr/src/pkg/manifests/system-accounting-legacy.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/system-accounting-legacy.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -54,9 +54,8 @@
 dir path=var/spool
 dir path=var/spool/cron group=sys
 dir path=var/spool/cron/crontabs group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/system group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/system group=sys
 file path=etc/acct/holidays original_name=SUNWacc:etc/acct/holidays \
     preserve=true
 file path=etc/init.d/acct group=sys mode=0744 \
@@ -102,7 +101,7 @@
 file path=usr/sbin/sar mode=0555
 file path=var/spool/cron/crontabs/sys group=sys mode=0600 \
     original_name=SUNWacc:var/spool/cron/crontabs/sys preserve=true
-file path=var/svc/manifest/system/sar.xml group=sys mode=0444
+file path=lib/svc/manifest/system/sar.xml group=sys mode=0444
 legacy pkg=SUNWaccr arch=$(ARCH) category=system \
     desc="utilities for accounting and reporting of system activity" \
     hotline="Please contact your local service provider" \
--- a/usr/src/pkg/manifests/system-boot-network.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/system-boot-network.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -32,15 +32,15 @@
 set name=variant.opensolaris.zone value=global value=nonglobal
 dir path=usr group=sys
 dir path=usr/sbin
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/network group=sys
-dir path=var/svc/manifest/network/rpc group=sys
+dir path=lib
+dir path=lib/svc
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/network group=sys
+dir path=lib/svc/manifest/network/rpc group=sys
 file path=usr/sbin/in.rarpd mode=0555
 file path=usr/sbin/rpc.bootparamd mode=0555
-file path=var/svc/manifest/network/rarp.xml group=sys mode=0444
-file path=var/svc/manifest/network/rpc/bootparams.xml group=sys mode=0444
+file path=lib/svc/manifest/network/rarp.xml group=sys mode=0444
+file path=lib/svc/manifest/network/rpc/bootparams.xml group=sys mode=0444
 legacy pkg=SUNWbsr arch=$(ARCH) category=system \
     desc="Boot Server daemons (Root)" \
     hotline="Please contact your local service provider" \
--- a/usr/src/pkg/manifests/system-domain-configuration-sparc-enterprise.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/system-domain-configuration-sparc-enterprise.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -40,14 +40,11 @@
 dir path=usr/platform/SUNW,SPARC-Enterprise group=sys
 dir path=usr/platform/SUNW,SPARC-Enterprise/lib
 dir path=usr/platform/SUNW,SPARC-Enterprise/lib/$(ARCH64)
-dir path=var group=sys opensolaris.zone=global variant.opensolaris.zone=global
-dir path=var/svc group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/platform group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest/platform group=sys opensolaris.zone=global \
-    variant.opensolaris.zone=global
-dir path=var/svc/manifest/platform/sun4u group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/platform/sun4u group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
 file path=lib/svc/method/svc-dcs mode=0555 opensolaris.zone=global \
     variant.opensolaris.zone=global
@@ -55,9 +52,9 @@
     variant.opensolaris.zone=global
 file path=usr/lib/dcs mode=0755
 file path=usr/platform/SUNW,SPARC-Enterprise/lib/$(ARCH64)/oplhpd mode=0755
-file path=var/svc/manifest/platform/sun4u/dcs.xml group=sys mode=0444 \
+file path=lib/svc/manifest/platform/sun4u/dcs.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
-file path=var/svc/manifest/platform/sun4u/oplhpd.xml group=sys mode=0444 \
+file path=lib/svc/manifest/platform/sun4u/oplhpd.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
 legacy pkg=SUNWdcsr arch=$(ARCH) category=system \
     desc="Domain Configuration Server, (Root)" \
--- a/usr/src/pkg/manifests/system-domain-service-processor-protocol-sparc-enterprise.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/system-domain-service-processor-protocol-sparc-enterprise.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -51,11 +51,9 @@
 dir path=usr/platform/SUNW,SPARC-Enterprise group=sys
 dir path=usr/platform/SUNW,SPARC-Enterprise/lib
 dir path=usr/platform/SUNW,SPARC-Enterprise/sbin
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/platform group=sys
-dir path=var/svc/manifest/platform/sun4u group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/platform group=sys
+dir path=lib/svc/manifest/platform/sun4u group=sys
 driver name=dm2s
 driver name=oplkmdrv
 file path=lib/svc/method/svc-dscp mode=0555
@@ -70,7 +68,7 @@
 file path=usr/platform/SUNW,SPARC-Enterprise/lib/libdscp.so.1
 file path=usr/platform/SUNW,SPARC-Enterprise/lib/llib-ldscp.ln group=sys
 file path=usr/platform/SUNW,SPARC-Enterprise/sbin/prtdscp mode=0755
-file path=var/svc/manifest/platform/sun4u/dscp.xml group=sys mode=0444
+file path=lib/svc/manifest/platform/sun4u/dscp.xml group=sys mode=0444
 legacy pkg=SUNWdscpr.u arch=$(ARCH).sun4u category=system \
     desc="Domain to Service Processor Communications Protocol (Root)" \
     hotline="Please contact your local service provider" \
--- a/usr/src/pkg/manifests/system-embedded-fcode-interpreter.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/system-embedded-fcode-interpreter.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -60,16 +60,15 @@
 dir path=usr/lib
 dir path=usr/lib/efcode
 dir path=usr/lib/efcode/$(ARCH64)
-dir path=var group=sys opensolaris.zone=global variant.opensolaris.zone=global
-dir path=var/svc group=sys opensolaris.zone=global \
-    variant.opensolaris.zone=global
-dir path=var/svc/manifest group=sys opensolaris.zone=global \
+dir path=lib opensolaris.zone=global variant.opensolaris.zone=global
+dir path=lib/svc opensolaris.zone=global variant.opensolaris.zone=global
+dir path=lib/svc/manifest group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest/platform group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/platform group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest/platform/sun4u group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/platform/sun4u group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest/platform/sun4v group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/platform/sun4v group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
 driver name=fcode
 file path=etc/flash/postdeployment/efcode.cleanup group=sys mode=0744 \
@@ -99,9 +98,9 @@
 file path=usr/lib/efcode/$(ARCH64)/lfc_upa.so
 file path=usr/lib/efcode/$(ARCH64)/lfc_upa_pci.so
 file path=usr/lib/efcode/efcode.sh mode=0555
-file path=var/svc/manifest/platform/sun4u/efdaemon.xml group=sys mode=0444 \
+file path=lib/svc/manifest/platform/sun4u/efdaemon.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
-file path=var/svc/manifest/platform/sun4v/efdaemon.xml group=sys mode=0444 \
+file path=lib/svc/manifest/platform/sun4v/efdaemon.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
 legacy pkg=SUNWefc.u arch=$(ARCH).sun4u category=system \
     desc="Embedded FCode Interpreter Drivers" \
--- a/usr/src/pkg/manifests/system-file-system-autofs.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/system-file-system-autofs.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -43,11 +43,9 @@
 dir path=usr/lib/fs group=sys
 dir path=usr/lib/fs/autofs group=sys
 dir path=usr/sbin
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/system group=sys
-dir path=var/svc/manifest/system/filesystem group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/system group=sys
+dir path=lib/svc/manifest/system/filesystem group=sys
 file path=etc/auto_home original_name=SUNWatfs:etc/auto_home preserve=true
 file path=etc/auto_master original_name=SUNWatfs:etc/auto_master preserve=true
 file path=etc/default/autofs group=sys original_name=SUNWatfs:etc/default/autofs \
@@ -59,7 +57,7 @@
 file path=usr/lib/fs/autofs/mount mode=0555
 file path=usr/lib/fs/autofs/share mode=0555
 file path=usr/lib/fs/autofs/unshare mode=0555
-file path=var/svc/manifest/system/filesystem/autofs.xml group=sys mode=0444
+file path=lib/svc/manifest/system/filesystem/autofs.xml group=sys mode=0444
 legacy pkg=SUNWatfsr arch=$(ARCH) category=system \
     desc="configuration and start-up files for the AutoFS filesystem" \
     hotline="Please contact your local service provider" name="AutoFS, (Root)" \
--- a/usr/src/pkg/manifests/system-file-system-nfs.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/system-file-system-nfs.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -63,10 +63,9 @@
 dir path=var/nfs
 dir path=var/nfs/v4_oldstate group=daemon owner=daemon
 dir path=var/nfs/v4_state group=daemon owner=daemon
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/network group=sys
-dir path=var/svc/manifest/network/nfs group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/network group=sys
+dir path=lib/svc/manifest/network/nfs group=sys
 file path=etc/default/nfs group=sys original_name=SUNWnfsc:etc/default/nfs \
     preserve=true
 file path=etc/fs/nfs/mount mode=0555
@@ -104,11 +103,11 @@
 file path=usr/lib/nfs/nfs4cbd mode=0555
 file path=usr/lib/nfs/nfsmapid mode=0555
 file path=usr/lib/nfs/statd mode=0555
-file path=var/svc/manifest/network/nfs/cbd.xml group=sys mode=0444
-file path=var/svc/manifest/network/nfs/client.xml group=sys mode=0444
-file path=var/svc/manifest/network/nfs/mapid.xml group=sys mode=0444
-file path=var/svc/manifest/network/nfs/nlockmgr.xml group=sys mode=0444
-file path=var/svc/manifest/network/nfs/status.xml group=sys mode=0444
+file path=lib/svc/manifest/network/nfs/cbd.xml group=sys mode=0444
+file path=lib/svc/manifest/network/nfs/client.xml group=sys mode=0444
+file path=lib/svc/manifest/network/nfs/mapid.xml group=sys mode=0444
+file path=lib/svc/manifest/network/nfs/nlockmgr.xml group=sys mode=0444
+file path=lib/svc/manifest/network/nfs/status.xml group=sys mode=0444
 group groupname=unknown gid=96
 hardlink path=kernel/sys/$(ARCH64)/nfs opensolaris.zone=global \
     target=../../../kernel/fs/$(ARCH64)/nfs variant.opensolaris.zone=global
--- a/usr/src/pkg/manifests/system-file-system-smb.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/system-file-system-smb.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -54,11 +54,9 @@
 dir path=usr/lib/security
 dir path=usr/lib/security/$(ARCH64)
 dir path=usr/lib/smbfs
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/network group=sys
-dir path=var/svc/manifest/network/smb group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/network group=sys
+dir path=lib/svc/manifest/network/smb group=sys
 driver name=nsmb devlink=type=ddi_pseudo;name=nsmb\t\D perms="* 0666 root sys"
 file path=lib/svc/method/smb-client mode=0555
 file path=usr/bin/smbutil mode=0555
@@ -84,7 +82,7 @@
 file path=usr/lib/security/$(ARCH64)/pam_smbfs_login.so.1
 file path=usr/lib/security/pam_smbfs_login.so.1
 file path=usr/lib/smbfs/smbiod mode=0555
-file path=var/svc/manifest/network/smb/client.xml group=sys mode=0444
+file path=lib/svc/manifest/network/smb/client.xml group=sys mode=0444
 legacy pkg=SUNWsmbfskr arch=$(ARCH) category=system \
     desc="SMB/CIFS File System client support (Kernel)" \
     hotline="Please contact your local service provider" \
--- a/usr/src/pkg/manifests/system-floating-point-scrubber.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/system-floating-point-scrubber.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -46,13 +46,13 @@
 dir path=usr/lib/fps/sun4u/UltraSPARC-IIIi
 dir path=usr/lib/fps/sun4u/UltraSPARC-IV
 dir path=usr/lib/fps/sun4u/UltraSPARC-IV+
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/system group=sys
+dir path=lib
+dir path=lib/svc
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/system group=sys
 file path=usr/lib/fps/fpsd mode=0555
 file path=usr/lib/fps/sun4u/UltraSPARC-III/fptest mode=0555
-file path=var/svc/manifest/system/fpsd.xml group=sys mode=0444
+file path=lib/svc/manifest/system/fpsd.xml group=sys mode=0444
 legacy pkg=SUNWfsr arch=$(ARCH) category=system \
     desc="FP Scrubber configuration files (ROOT)" \
     hotline="Please contact your local service provider" \
--- a/usr/src/pkg/manifests/system-kernel-dynamic-reconfiguration-sun-fire-880.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/system-kernel-dynamic-reconfiguration-sun-fire-880.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -41,19 +41,16 @@
 dir path=usr/platform/SUNW,Sun-Fire-880/lib
 dir path=usr/platform/SUNW,Sun-Fire-V890 group=sys
 dir path=usr/platform/SUNW,Sun-Fire-V890/lib
-dir path=var group=sys opensolaris.zone=global variant.opensolaris.zone=global
-dir path=var/svc group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/platform group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest/platform group=sys opensolaris.zone=global \
-    variant.opensolaris.zone=global
-dir path=var/svc/manifest/platform/sun4u group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/platform/sun4u group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
 file path=lib/svc/method/sf880dr mode=0555 opensolaris.zone=global \
     variant.opensolaris.zone=global
 file path=usr/platform/SUNW,Sun-Fire-880/lib/sf880drd group=sys mode=0755
-file path=var/svc/manifest/platform/sun4u/sf880drd.xml group=sys mode=0444 \
+file path=lib/svc/manifest/platform/sun4u/sf880drd.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
 legacy pkg=SUNWsfdr.u arch=$(ARCH).sun4u category=system \
     desc="Sun Fire 880 DR Daemon" \
--- a/usr/src/pkg/manifests/system-kernel-power.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/system-kernel-power.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -45,12 +45,9 @@
 dir path=usr/lib
 dir path=usr/lib/power group=sys
 dir path=usr/sbin
-dir path=var group=sys opensolaris.zone=global variant.opensolaris.zone=global
-dir path=var/svc group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest group=sys opensolaris.zone=global \
-    variant.opensolaris.zone=global
-dir path=var/svc/manifest/system group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/system group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
 driver name=pm perms="* 0666 root sys"
 file path=etc/default/power group=sys opensolaris.zone=global \
@@ -67,7 +64,7 @@
 file path=usr/lib/power/powerd mode=0555
 file path=usr/sbin/pmconfig mode=4555
 file path=usr/sbin/sysidpm group=sys mode=0755
-file path=var/svc/manifest/system/power.xml group=sys mode=0444 \
+file path=lib/svc/manifest/system/power.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
 legacy pkg=SUNWpmr arch=$(ARCH) category=system \
     desc="Power Management config file and rc script" \
--- a/usr/src/pkg/manifests/system-kernel.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/system-kernel.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -77,10 +77,8 @@
 dir path=lib
 dir path=lib/svc
 dir path=lib/svc/method
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/system group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/system group=sys
 $(i386_ONLY)driver name=acpi_drv perms="* 0666 root sys"
 driver name=aggr perms="* 0666 root sys"
 driver name=arp perms="arp 0666 root sys"
@@ -854,10 +852,10 @@
 file path=lib/svc/method/svc-dumpadm mode=0555
 file path=lib/svc/method/svc-intrd mode=0555
 file path=lib/svc/method/svc-scheduler mode=0555
-file path=var/svc/manifest/system/dumpadm.xml group=sys mode=0444
-file path=var/svc/manifest/system/fmd.xml group=sys mode=0444
-file path=var/svc/manifest/system/intrd.xml group=sys mode=0444
-file path=var/svc/manifest/system/scheduler.xml group=sys mode=0444
+file path=lib/svc/manifest/system/dumpadm.xml group=sys mode=0444
+file path=lib/svc/manifest/system/fmd.xml group=sys mode=0444
+file path=lib/svc/manifest/system/intrd.xml group=sys mode=0444
+file path=lib/svc/manifest/system/scheduler.xml group=sys mode=0444
 hardlink path=kernel/misc/$(ARCH64)/md5 \
     target=../../../kernel/crypto/$(ARCH64)/md5
 hardlink path=kernel/misc/$(ARCH64)/sha1 \
--- a/usr/src/pkg/manifests/system-ldoms.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/system-ldoms.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -53,11 +53,9 @@
 dir path=usr/lib/ldoms
 dir path=usr/lib/rcm
 dir path=usr/lib/rcm/scripts
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/platform group=sys
-dir path=var/svc/manifest/platform/sun4v group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/platform group=sys
+dir path=lib/svc/manifest/platform/sun4v group=sys
 driver name=cnex alias=SUNW,sun4v-channel-devices
 driver name=drctl
 driver name=ds_pri
@@ -110,9 +108,9 @@
 file path=usr/lib/libds.so.1
 file path=usr/lib/libpri.so.1
 file path=usr/lib/rcm/scripts/SUNW,vdevices.pl mode=0555
-file path=var/svc/manifest/platform/sun4v/drd.xml group=sys mode=0444
-file path=var/svc/manifest/platform/sun4v/ldoms-agents.xml group=sys mode=0444
-file path=var/svc/manifest/platform/sun4v/vntsd.xml group=sys mode=0444
+file path=lib/svc/manifest/platform/sun4v/drd.xml group=sys mode=0444
+file path=lib/svc/manifest/platform/sun4v/ldoms-agents.xml group=sys mode=0444
+file path=lib/svc/manifest/platform/sun4v/vntsd.xml group=sys mode=0444
 legacy pkg=SUNWldomr.v arch=$(ARCH).sun4v category=system \
     desc="Solaris Logical Domains Configuration Files" \
     hotline="Please contact your local service provider" \
--- a/usr/src/pkg/manifests/system-management-intel-amt.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/system-management-intel-amt.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -40,10 +40,8 @@
 dir path=lib/svc/method
 dir path=usr group=sys
 dir path=usr/lib
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/network group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/network group=sys
 driver name=heci perms="* 0644 root sys" \
     alias=pci8086,2974 \
     alias=pci8086,2984 \
@@ -57,7 +55,7 @@
 file path=kernel/drv/heci group=sys
 file path=lib/svc/method/svc-lms mode=0555
 file path=usr/lib/lms mode=0555
-file path=var/svc/manifest/network/lms.xml group=sys mode=0444
+file path=lib/svc/manifest/network/lms.xml group=sys mode=0444
 legacy pkg=SUNWamt arch=$(ARCH) category=system \
     desc="Solaris support for Intel Active Management Technology" \
     hotline="Please contact your local service provider" \
--- a/usr/src/pkg/manifests/system-management-snmp-sea-sea-config.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/system-management-snmp-sea-sea-config.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -43,10 +43,9 @@
 dir path=var group=sys
 dir path=var/snmp group=sys
 dir path=var/snmp/mib group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/application group=sys
-dir path=var/svc/manifest/application/management group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/application group=sys
+dir path=lib/svc/manifest/application/management group=sys
 file path=etc/init.d/init.snmpdx group=sys mode=0744
 file path=etc/snmp/conf/enterprises.oid group=sys
 file path=etc/snmp/conf/mibiisa.reg group=sys \
@@ -64,7 +63,7 @@
 file path=lib/svc/method/svc-snmpdx mode=0555
 file path=var/snmp/mib/snmpdx.mib group=sys
 file path=var/snmp/mib/sun.mib group=sys
-file path=var/svc/manifest/application/management/snmpdx.xml group=sys mode=0444
+file path=lib/svc/manifest/application/management/snmpdx.xml group=sys mode=0444
 legacy pkg=SUNWsacom arch=$(ARCH) category=system \
     desc="Solstice Enterprise Agents 1.0.3 files for root file system" \
     hotline="Please contact your local service provider" \
--- a/usr/src/pkg/manifests/system-network-console.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/system-network-console.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -50,10 +50,8 @@
 dir path=platform/SUNW,Ultra-Enterprise-10000/kernel/drv group=sys
 dir path=platform/SUNW,Ultra-Enterprise-10000/kernel/drv/$(ARCH64) group=sys
 dir path=platform/SUNW,Ultra-Enterprise-10000/lib
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/system group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/system group=sys
 driver name=cvc perms="* 0600 root sys"
 driver name=cvcredir perms="* 0600 root sys"
 file path=lib/svc/method/svc-cvcd mode=0555
@@ -75,7 +73,7 @@
     group=sys reboot-needed=false
 file path=platform/SUNW,Ultra-Enterprise-10000/lib/cvcd group=sys mode=0700 \
     reboot-needed=true
-file path=var/svc/manifest/system/cvc.xml group=sys mode=0444
+file path=lib/svc/manifest/system/cvc.xml group=sys mode=0444
 legacy pkg=SUNWcvc.u arch=$(ARCH).sun4u category=system desc="Network Console" \
     hotline="Please contact your local service provider" name="Network Console" \
     vendor="Sun Microsystems, Inc." version=11.11,REV=2009.11.11
--- a/usr/src/pkg/manifests/system-network-nis.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/system-network-nis.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -43,11 +43,12 @@
 dir path=usr/sbin
 dir path=var group=sys
 dir path=var/ldap group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/network group=sys
-dir path=var/svc/manifest/network/nis group=sys
-dir path=var/svc/manifest/network/rpc group=sys
+dir path=lib
+dir path=lib/svc
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/network group=sys
+dir path=lib/svc/manifest/network/nis group=sys
+dir path=lib/svc/manifest/network/rpc group=sys
 dir path=var/yp
 dir path=var/yp/binding
 file path=etc/nsswitch.nis group=sys
@@ -75,8 +76,8 @@
 file path=usr/sbin/ypinit mode=0555
 file path=usr/sbin/yppoll mode=0555
 file path=usr/sbin/ypset mode=0555
-file path=var/svc/manifest/network/nis/client.xml group=sys mode=0444
-file path=var/svc/manifest/network/rpc/rex.xml group=sys mode=0444
+file path=lib/svc/manifest/network/nis/client.xml group=sys mode=0444
+file path=lib/svc/manifest/network/rpc/rex.xml group=sys mode=0444
 file path=var/yp/aliases mode=0555 original_name=SUNWnis:var/yp/aliases \
     preserve=true
 file path=var/yp/nicknames original_name=SUNWnis:var/yp/nicknames preserve=true
--- a/usr/src/pkg/manifests/system-network-routing-vrrp.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/system-network-routing-vrrp.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -41,17 +41,15 @@
 dir path=usr/lib/$(ARCH64)
 dir path=usr/lib/inet
 dir path=usr/sbin
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/network group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/network group=sys
 file path=etc/inet/vrrp.conf group=sys
 file path=lib/svc/method/svc-vrrp mode=0555
 file path=usr/lib/$(ARCH64)/libvrrpadm.so.1
 file path=usr/lib/inet/vrrpd mode=0555
 file path=usr/lib/libvrrpadm.so.1
 file path=usr/sbin/vrrpadm mode=0555
-file path=var/svc/manifest/network/vrrp.xml group=sys mode=0444
+file path=lib/svc/manifest/network/vrrp.xml group=sys mode=0444
 legacy pkg=SUNWvrrpr arch=$(ARCH) category=system \
     desc="Solaris VRRP Administration" \
     hotline="Please contact your local service provider" \
--- a/usr/src/pkg/manifests/system-network-routing.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/system-network-routing.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -37,11 +37,9 @@
 dir path=usr/lib
 dir path=usr/lib/inet
 dir path=usr/sbin
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/network group=sys
-dir path=var/svc/manifest/network/routing group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/network group=sys
+dir path=lib/svc/manifest/network/routing group=sys
 file path=lib/svc/method/svc-ndp mode=0555
 file path=lib/svc/method/svc-rdisc mode=0555
 file path=lib/svc/method/svc-ripng mode=0555
@@ -51,10 +49,10 @@
 file path=usr/sbin/in.rdisc mode=0555
 file path=usr/sbin/in.routed mode=0555
 file path=usr/sbin/rtquery mode=0555
-file path=var/svc/manifest/network/routing/ndp.xml group=sys mode=0444
-file path=var/svc/manifest/network/routing/rdisc.xml group=sys mode=0444
-file path=var/svc/manifest/network/routing/ripng.xml group=sys mode=0444
-file path=var/svc/manifest/network/routing/route.xml group=sys mode=0444
+file path=lib/svc/manifest/network/routing/ndp.xml group=sys mode=0444
+file path=lib/svc/manifest/network/routing/rdisc.xml group=sys mode=0444
+file path=lib/svc/manifest/network/routing/ripng.xml group=sys mode=0444
+file path=lib/svc/manifest/network/routing/route.xml group=sys mode=0444
 legacy pkg=SUNWroute arch=$(ARCH) category=system \
     desc="Network Routing daemons/commands (Usr)" \
     hotline="Please contact your local service provider" \
--- a/usr/src/pkg/manifests/system-security-kerberos-5.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/system-security-kerberos-5.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -44,10 +44,11 @@
 dir path=usr/share/lib/ldif group=sys
 dir path=var group=sys
 dir path=var/krb5 group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/network group=sys
-dir path=var/svc/manifest/network/security group=sys
+dir path=lib
+dir path=lib/svc
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/network group=sys
+dir path=lib/svc/manifest/network/security group=sys
 file path=etc/krb5/kadm5.acl group=sys original_name=SUNWkdc:etc/krb5/kadm5.acl \
     preserve=true
 file path=etc/krb5/kdc.conf group=sys original_name=SUNWkdc:etc/krb5/kdc.conf \
@@ -90,7 +91,7 @@
 file path=usr/sbin/kdcmgr mode=0555
 file path=usr/sbin/kproplog mode=0555
 file path=usr/share/lib/ldif/kerberos.ldif
-file path=var/svc/manifest/network/security/krb5_prop.xml group=sys mode=0444
+file path=lib/svc/manifest/network/security/krb5_prop.xml group=sys mode=0444
 legacy pkg=SUNWkdcr arch=$(ARCH) category=system desc="Kerberos V5 KDC (root)" \
     hotline="Please contact your local service provider" \
     name="Kerberos V5 KDC (root)" vendor="Sun Microsystems, Inc." \
--- a/usr/src/pkg/manifests/system-storage-fibre-channel-port-utility.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/system-storage-fibre-channel-port-utility.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -36,14 +36,11 @@
 dir path=lib/svc/method opensolaris.zone=global variant.opensolaris.zone=global
 dir path=usr group=sys
 dir path=usr/sbin
-dir path=var group=sys opensolaris.zone=global variant.opensolaris.zone=global
-dir path=var/svc group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/network group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest/network group=sys opensolaris.zone=global \
-    variant.opensolaris.zone=global
-dir path=var/svc/manifest/system group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/system group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
 file path=lib/svc/method/npivconfig mode=0555 opensolaris.zone=global \
     variant.opensolaris.zone=global
@@ -52,11 +49,11 @@
 file path=lib/svc/method/svc-fcoet mode=0555 opensolaris.zone=global \
     variant.opensolaris.zone=global
 file path=usr/sbin/fcinfo mode=0555
-file path=var/svc/manifest/network/npiv_config.xml group=sys mode=0444 \
+file path=lib/svc/manifest/network/npiv_config.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
-file path=var/svc/manifest/system/fcoe_initiator.xml group=sys mode=0444 \
+file path=lib/svc/manifest/system/fcoe_initiator.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
-file path=var/svc/manifest/system/fcoe_target.xml group=sys mode=0444 \
+file path=lib/svc/manifest/system/fcoe_target.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
 hardlink path=usr/sbin/fcadm target=../../usr/sbin/fcinfo
 legacy pkg=SUNWfcprt arch=$(ARCH) category=system \
--- a/usr/src/pkg/manifests/system-storage-mms.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/system-storage-mms.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -86,13 +86,11 @@
     variant.opensolaris.zone=global
 dir path=var/mms/ssl/pub group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc group=sys opensolaris.zone=global \
-    variant.opensolaris.zone=global
-dir path=var/svc/manifest group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest/application group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/application group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest/application/management group=sys \
+dir path=lib/svc/manifest/application/management group=sys \
     opensolaris.zone=global variant.opensolaris.zone=global
 driver name=dda devlink=type=ddi_pseudo;name=dda\tdda/\N0\M0
 driver name=dmd
@@ -192,7 +190,7 @@
     variant.opensolaris.zone=global
 file path=var/mms/ssl/ca/mms_openssl.cnf group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-file path=var/svc/manifest/application/management/mms.xml group=sys mode=0444 \
+file path=lib/svc/manifest/application/management/mms.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
 legacy pkg=SUNWmmsr arch=$(ARCH) category=system desc="Media Management System" \
     hotline="Please contact your local service provider" \
--- a/usr/src/pkg/manifests/system-trusted-global-zone.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/system-trusted-global-zone.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -45,15 +45,13 @@
 dir path=lib opensolaris.zone=global variant.opensolaris.zone=global
 dir path=lib/svc opensolaris.zone=global variant.opensolaris.zone=global
 dir path=lib/svc/method opensolaris.zone=global variant.opensolaris.zone=global
-dir path=var group=sys opensolaris.zone=global variant.opensolaris.zone=global
-dir path=var/svc group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/network group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest/network group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/system group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest/system group=sys opensolaris.zone=global \
-    variant.opensolaris.zone=global
+dir path=var group=sys opensolaris.zone=global variant.opensolaris.zone=global
 dir path=var/tsol group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
 dir path=var/tsol/doors group=sys opensolaris.zone=global \
@@ -100,11 +98,11 @@
     variant.opensolaris.zone=global
 file path=lib/svc/method/svc-tnd mode=0555 opensolaris.zone=global \
     variant.opensolaris.zone=global
-file path=var/svc/manifest/network/tnctl.xml group=sys mode=0444 \
+file path=lib/svc/manifest/network/tnctl.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
-file path=var/svc/manifest/network/tnd.xml group=sys mode=0444 \
+file path=lib/svc/manifest/network/tnd.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
-file path=var/svc/manifest/system/labeld.xml group=sys mode=0444 \
+file path=lib/svc/manifest/system/labeld.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
 legacy pkg=SUNWtsg arch=$(ARCH) category=system \
     desc="Solaris Trusted Extensions, globalzone-only files" \
--- a/usr/src/pkg/manifests/system-trusted.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/system-trusted.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -56,10 +56,8 @@
 dir path=usr/lib/lp/postscript group=lp
 dir path=usr/lib/zones
 dir path=usr/sbin
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/system group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/system group=sys
 file path=lib/svc/method/svc-tsol-zones mode=0555
 file path=sbin/tnctl group=sys mode=0555
 file path=usr/bin/getlabel mode=0555
@@ -121,7 +119,7 @@
 file path=usr/sbin/tnd group=sys mode=0555
 file path=usr/sbin/tninfo group=sys mode=0555
 file path=usr/sbin/txzonemgr group=sys mode=0555
-file path=var/svc/manifest/system/tsol-zones.xml group=sys mode=0444
+file path=lib/svc/manifest/system/tsol-zones.xml group=sys mode=0444
 hardlink path=usr/sbin/remove_allocatable target=add_allocatable
 legacy pkg=SUNWtsr arch=$(ARCH) category=system \
     desc="Solaris Trusted Extensions, (Root)" \
--- a/usr/src/pkg/manifests/system-xvm-ipagent.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/system-xvm-ipagent.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -44,13 +44,11 @@
 dir path=usr/lib
 dir path=usr/lib/xen
 dir path=usr/lib/xen/bin
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/system group=sys
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/system group=sys
 file path=lib/svc/method/svc-ipagent mode=0555
 file path=usr/lib/xen/bin/ipagent mode=0555
-file path=var/svc/manifest/system/ipagent.xml group=sys mode=0444
+file path=lib/svc/manifest/system/ipagent.xml group=sys mode=0444
 legacy pkg=SUNWxvmipar arch=$(ARCH) category=system \
     desc="xVM PV IP address agent" \
     hotline="Please contact your local service provider" \
--- a/usr/src/pkg/manifests/system-zones.mf	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/manifests/system-zones.mf	Thu Mar 25 14:57:35 2010 -0700
@@ -54,12 +54,9 @@
 dir path=usr/share/lib group=sys
 dir path=usr/share/lib/xml group=sys
 dir path=usr/share/lib/xml/dtd group=sys
-dir path=var group=sys opensolaris.zone=global variant.opensolaris.zone=global
-dir path=var/svc group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
-dir path=var/svc/manifest group=sys opensolaris.zone=global \
-    variant.opensolaris.zone=global
-dir path=var/svc/manifest/system group=sys opensolaris.zone=global \
+dir path=lib/svc/manifest/system group=sys opensolaris.zone=global \
     variant.opensolaris.zone=global
 driver name=zcons
 file path=etc/zones/SUNWblank.xml mode=0444
@@ -89,9 +86,9 @@
 file path=usr/share/lib/xml/dtd/brand.dtd.1 mode=0644
 file path=usr/share/lib/xml/dtd/zone_platform.dtd.1 mode=0644
 file path=usr/share/lib/xml/dtd/zonecfg.dtd.1
-file path=var/svc/manifest/system/resource-mgmt.xml group=sys mode=0444 \
+file path=lib/svc/manifest/system/resource-mgmt.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
-file path=var/svc/manifest/system/zones.xml group=sys mode=0444 \
+file path=lib/svc/manifest/system/zones.xml group=sys mode=0444 \
     opensolaris.zone=global variant.opensolaris.zone=global
 legacy pkg=SUNWzoner arch=$(ARCH) category=system \
     desc="Solaris Zones Configuration Files" \
--- a/usr/src/pkg/transforms/restart_fmri	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/pkg/transforms/restart_fmri	Thu Mar 25 14:57:35 2010 -0700
@@ -25,5 +25,6 @@
 #
 
 <transform file path=var/svc/manifest/.*\.xml -> add restart_fmri svc:/system/manifest-import:default>
+<transform file path=lib/svc/manifest/.*\.xml -> add restart_fmri svc:/system/manifest-import:default>
 <transform file path=etc/security/[^/]+_attr.d/.+ -> add restart_fmri svc:/system/rbac:default>
 <transform file path=etc/user_attr.d/.+ -> add restart_fmri svc:/system/rbac:default>
--- a/usr/src/tools/scripts/bfu.sh	Thu Mar 25 13:21:39 2010 -0700
+++ b/usr/src/tools/scripts/bfu.sh	Thu Mar 25 14:57:35 2010 -0700
@@ -357,46 +357,46 @@
 	usr/platform/SUNW,SPARC-Enterprise/sbin/prtdscp
 	var/adm/pool
 	var/log/pool
-	var/svc/manifest/network/iscsi/iscsi-initiator.xml
-	var/svc/manifest/network/npiv_config.xml
-	var/svc/manifest/network/rpc/mdcomm.xml
-	var/svc/manifest/network/rpc/meta.xml
-	var/svc/manifest/network/rpc/metamed.xml
-	var/svc/manifest/network/rpc/metamh.xml
-	var/svc/manifest/network/tnctl.xml
-	var/svc/manifest/network/tnd.xml
-	var/svc/manifest/platform/i86pc/eeprom.xml
-	var/svc/manifest/platform/sun4u/dcs.xml
-	var/svc/manifest/platform/sun4u/dscp.xml
-	var/svc/manifest/platform/sun4u/efdaemon.xml
-	var/svc/manifest/platform/sun4u/oplhpd.xml
-	var/svc/manifest/platform/sun4u/sckmd.xml
-	var/svc/manifest/platform/sun4u/sf880drd.xml
-	var/svc/manifest/platform/sun4v
-	var/svc/manifest/system/cvc.xml
-	var/svc/manifest/system/device/devices-audio.xml
-	var/svc/manifest/system/device/devices-fc-fabric.xml
-	var/svc/manifest/system/dumpadm.xml
-	var/svc/manifest/system/fcoe_initiator.xml
-	var/svc/manifest/system/fcoe_target.xml
-	var/svc/manifest/system/filesystem/rmvolmgr.xml
-	var/svc/manifest/system/fmd.xml
-	var/svc/manifest/system/hal.xml
-	var/svc/manifest/system/intrd.xml
-	var/svc/manifest/system/labeld.xml
-	var/svc/manifest/system/mdmonitor.xml
-	var/svc/manifest/system/metainit.xml
-	var/svc/manifest/system/metasync.xml
-	var/svc/manifest/system/picl.xml
-	var/svc/manifest/system/poold.xml
-	var/svc/manifest/system/pools.xml
-	var/svc/manifest/system/power.xml
-	var/svc/manifest/system/resource-mgmt.xml
-	var/svc/manifest/system/scheduler.xml
-	var/svc/manifest/system/stmf.xml
-	var/svc/manifest/system/sysevent.xml
-	var/svc/manifest/system/vtdaemon.xml
-	var/svc/manifest/system/zones.xml
+	lib/svc/manifest/network/iscsi/iscsi-initiator.xml
+	lib/svc/manifest/network/npiv_config.xml
+	lib/svc/manifest/network/rpc/mdcomm.xml
+	lib/svc/manifest/network/rpc/meta.xml
+	lib/svc/manifest/network/rpc/metamed.xml
+	lib/svc/manifest/network/rpc/metamh.xml
+	lib/svc/manifest/network/tnctl.xml
+	lib/svc/manifest/network/tnd.xml
+	lib/svc/manifest/platform/i86pc/eeprom.xml
+	lib/svc/manifest/platform/sun4u/dcs.xml
+	lib/svc/manifest/platform/sun4u/dscp.xml
+	lib/svc/manifest/platform/sun4u/efdaemon.xml
+	lib/svc/manifest/platform/sun4u/oplhpd.xml
+	lib/svc/manifest/platform/sun4u/sckmd.xml
+	lib/svc/manifest/platform/sun4u/sf880drd.xml
+	lib/svc/manifest/platform/sun4v
+	lib/svc/manifest/system/cvc.xml
+	lib/svc/manifest/system/device/devices-audio.xml
+	lib/svc/manifest/system/device/devices-fc-fabric.xml
+	lib/svc/manifest/system/dumpadm.xml
+	lib/svc/manifest/system/fcoe_initiator.xml
+	lib/svc/manifest/system/fcoe_target.xml
+	lib/svc/manifest/system/filesystem/rmvolmgr.xml
+	lib/svc/manifest/system/fmd.xml
+	lib/svc/manifest/system/hal.xml
+	lib/svc/manifest/system/intrd.xml
+	lib/svc/manifest/system/labeld.xml
+	lib/svc/manifest/system/mdmonitor.xml
+	lib/svc/manifest/system/metainit.xml
+	lib/svc/manifest/system/metasync.xml
+	lib/svc/manifest/system/picl.xml
+	lib/svc/manifest/system/poold.xml
+	lib/svc/manifest/system/pools.xml
+	lib/svc/manifest/system/power.xml
+	lib/svc/manifest/system/resource-mgmt.xml
+	lib/svc/manifest/system/scheduler.xml
+	lib/svc/manifest/system/stmf.xml
+	lib/svc/manifest/system/sysevent.xml
+	lib/svc/manifest/system/vtdaemon.xml
+	lib/svc/manifest/system/zones.xml
 "
 
 #
@@ -1018,8 +1018,17 @@
 }
 
 check_boomer_bfu() {
+	# It's necessary to check in both the root and lib archives.
+	# The Early Manifest Import project moved the manifest from the
+	# root archive to the lib archive.
+	#
 	$ZCAT $cpiodir/generic.root$ZFIX | cpio -it 2>/dev/null |
 	    grep devices-audio.xml > /dev/null 2>&1
+	if [ $? -eq 0 ] ; then
+		return 0
+	fi
+	$ZCAT $cpiodir/generic.lib$ZFIX | cpio -it 2>/dev/null |
+	    grep devices-audio.xml > /dev/null 2>&1
 }
 
 check_austr_sys() {
@@ -1577,9 +1586,8 @@
 
 	# platform_SUNW,Sun-Fire.xml (and other new and
 	# corrected platforms) were delivered in Build 68.
-	if [ ! -f \
-		$rootprefix/var/svc/profile/platform_SUNW,Sun-Fire.xml \
-		]; then
+	if [ ! -f $rootprefix/var/svc/profile/platform_SUNW,Sun-Fire.xml -a \
+	     ! -f $rootprefix/etc/svc/profile/platform_SUNW,Sun-Fire.xml ]; then
 		for pfx in " " "v"; do
 			for plname in \
 			    none \
@@ -1603,7 +1611,7 @@
 	# default-enabled-in-profile services.  If so, add a command
 	# such that they are enabled.
 	#
-	if [ ! -f $rootprefix/var/svc/profile/system/sac.xml ]; then
+	if [ ! -f $rootprefix/lib/svc/manifest/system/sac.xml ]; then
 		echo /usr/sbin/svcadm enable system/sac >> \
 		    $rootprefix/var/svc/profile/upgrade
 	fi
@@ -1758,7 +1766,10 @@
 
 smf_cleanup_boomer() {
 	(
-		smf_delete_manifest var/src/manifest/system/devices-audio.xml
+		for boomer_dir in lib/svc/manifest var/svc/manifest ; do
+			boomer_mfst=$boomer_dir/system/devices-audio.xml
+			smf_delete_manifest $boomer_mfst
+		done
 		cd $root
 		rm -f lib/svc/method/devices-audio
 
@@ -1768,6 +1779,11 @@
 
 old_mfst_dir="var/svc/manifest.orig"
 new_mfst_dir="var/svc/manifest"
+moved_mfst_dir="lib/svc/manifest"
+
+old_profile_dir="var/svc/profile.orig"
+new_profile_dir="var/svc/profile"
+moved_profile_dir="etc/svc/profile"
 
 smf_enable() {
 	echo "svcadm enable $*" >> $rootprefix/var/svc/profile/upgrade
@@ -2023,14 +2039,22 @@
 
 smf_apply_conf () {
 	#
-	# Go thru the original manifests and move any that were unchanged
-	# (or are not system-provided) back to their proper location.  This
-	# will avoid superfluous re-import on reboot, as the inode and mtime
-	# are both part of the hash.
+	# Go thru the original manifests and move any that are not
+	# system-provided) back to their proper location.
 	#
 	if [ -d $rootprefix/$old_mfst_dir ]; then
 		for f in `cd $rootprefix/$old_mfst_dir ; find . -type f`
 		do
+			#
+			# Don't restore if manifest is moved to
+			# /lib/svc/manifest 
+			#
+			moved=$rootprefix/$moved_mfst_dir/$f
+			[ -f "$moved" ] && continue
+
+			[ "$zone" != "global" -a \
+			    -f "/$moved_mfst_dir/$f" ] && continue
+
 			old=$rootprefix/$old_mfst_dir/$f
 			new=$rootprefix/$new_mfst_dir/$f
 			if [ ! -f $new ]; then
@@ -2038,11 +2062,46 @@
 				mv $old $new
 				continue
 			fi
-			cmp -s $old $new && mv $old $new
 		done
 		rm -rf $rootprefix/$old_mfst_dir
 	fi
 
+	#
+	# Do the same for profiles
+	#
+	if [ -d $rootprefix/$old_profile_dir ]; then
+		for f in `cd $rootprefix/$old_profile_dir ; find . -type f`
+		do
+			#
+			# Don't restore if profile is moved to
+			# /etc/svc/profile
+			#
+			moved=$rootprefix/$moved_profile_dir/$f
+			[ -f "$moved" ] && continue
+
+			old=$rootprefix/$old_profile_dir/$f
+			new=$rootprefix/$new_profile_dir/$f
+			if [ ! -f $new ]; then
+				mkdir -m 0755 -p `dirname $new`
+				mv $old $new
+				continue
+			fi
+		done
+
+		#
+		# Handle generic profile here before removing the old dir. This
+		# is only done during the first time we move generic profiles
+		# to /etc/svc/profiles
+		#
+		if [ -f $rootprefix/$old_profile_dir/generic.xml ]; then
+			rm -f $rootprefix/etc/svc/profile/generic.xml
+			mv $rootprefix/$old_profile_dir/generic.xml \
+			    $rootprefix/etc/svc/profile/
+		fi
+
+		rm -rf $rootprefix/$old_profile_dir
+	fi
+
 	if [ -f $rootprefix/etc/init.d/inetd ]; then
 		#
 		# BFUing to non-SMF system -- undo our previous changes,
@@ -2116,7 +2175,7 @@
 
 	print "Connecting platform and name service profiles ..."
 
-	rm -f $rootprefix/var/svc/profile/name_service.xml
+	rm -f $rootprefix/etc/svc/profile/name_service.xml
 
 	grep ldap $rootprefix/etc/nsswitch.conf >/dev/null 2>&1
 	is_ldap=$?
@@ -2131,10 +2190,10 @@
 		ns_profile=ns_files.xml
 	fi
 
-	ln -s $ns_profile $rootprefix/var/svc/profile/name_service.xml
-
-	rm -f $rootprefix/var/svc/profile/inetd_services.xml
-	ln -s inetd_upgrade.xml $rootprefix/var/svc/profile/inetd_services.xml
+	ln -s $ns_profile $rootprefix/etc/svc/profile/name_service.xml
+
+	rm -f $rootprefix/etc/svc/profile/inetd_services.xml
+	ln -s inetd_upgrade.xml $rootprefix/etc/svc/profile/inetd_services.xml
 
 	print "Marking converted services as enabled ..."
 
@@ -2443,8 +2502,6 @@
 		smf_enable network/rpc/bootparams
 	fi
 
-	touch $rootprefix/var/svc/profile/.upgrade_prophist
-
 	cat >> $rootprefix/var/svc/profile/upgrade <<EOF
 	# We are deleting and reimporting dcs's manifest, because we
 	# need to change the restarter.
@@ -8056,6 +8113,13 @@
 	[ -d $root/$new_mfst_dir ] && mv $root/$new_mfst_dir $root/$old_mfst_dir
 
 	#
+	# Do the same for profiles in old location
+	rm -rf $root/$old_profile_dir
+	if [ -d $root/$new_profile_dir ]; then
+	    mv $root/$new_profile_dir $root/$old_profile_dir
+	fi
+
+	#
 	# Remove obsolete sum.h
 	#
 	rm -f $usr/include/sum.h