6975309 PSARC2007_393 Move /etc/default/{nfs/autofs} parameters to SMF
authorPavan Mettu - Oracle Corporation - Menlo Park United States <Pavan.Mettu@Oracle.COM>
Wed, 11 Aug 2010 17:11:30 -0500
changeset 13092 fcc1e406c13f
parent 13091 9116acef0349
child 13093 431da7fc1d0a
6975309 PSARC2007_393 Move /etc/default/{nfs/autofs} parameters to SMF PSARC 2007/393 converting /etc/default/{nfs,autofs} to SMF properties
exception_lists/packaging
usr/src/cmd/fs.d/autofs/Makefile
usr/src/cmd/fs.d/autofs/auto_subr.c
usr/src/cmd/fs.d/autofs/autod_main.c
usr/src/cmd/fs.d/autofs/autod_nfs.c
usr/src/cmd/fs.d/autofs/autofs.dfl
usr/src/cmd/fs.d/autofs/autofs.xml
usr/src/cmd/fs.d/autofs/automount.c
usr/src/cmd/fs.d/nfs/etc/nfs.dfl
usr/src/cmd/fs.d/nfs/lib/smfcfg.c
usr/src/cmd/fs.d/nfs/lib/smfcfg.h
usr/src/cmd/fs.d/nfs/mount/Makefile
usr/src/cmd/fs.d/nfs/mount/mount.c
usr/src/cmd/fs.d/nfs/mountd/Makefile
usr/src/cmd/fs.d/nfs/mountd/mountd.c
usr/src/cmd/fs.d/nfs/nfsd/Makefile
usr/src/cmd/fs.d/nfs/nfsd/nfsd.c
usr/src/cmd/fs.d/nfs/nfsmapid/nfsmapid_server.c
usr/src/cmd/fs.d/nfs/svc/client.xml
usr/src/cmd/fs.d/nfs/svc/mapid.xml
usr/src/cmd/fs.d/nfs/svc/nfs-server
usr/src/cmd/fs.d/nfs/svc/nlockmgr.xml
usr/src/cmd/fs.d/nfs/svc/server.xml
usr/src/cmd/svc/milestone/net-loc
usr/src/cmd/svc/milestone/net-nwam
usr/src/lib/libmapid/Makefile.com
usr/src/lib/libmapid/common/mapid.c
usr/src/lib/libmapid/common/mapid.h
usr/src/lib/libshare/Makefile
usr/src/lib/libshare/autofs/Makefile
usr/src/lib/libshare/autofs/Makefile.com
usr/src/lib/libshare/autofs/amd64/Makefile
usr/src/lib/libshare/autofs/i386/Makefile
usr/src/lib/libshare/autofs/libshare_autofs.c
usr/src/lib/libshare/autofs/mapfile-vers
usr/src/lib/libshare/autofs/sparc/Makefile
usr/src/lib/libshare/autofs/sparcv9/Makefile
usr/src/lib/libshare/nfs/Makefile.com
usr/src/lib/libshare/nfs/libshare_nfs.c
usr/src/lib/libshare/nfs/libshare_nfs.h
usr/src/pkg/manifests/SUNWcs.mf
usr/src/pkg/manifests/system-file-system-autofs.mf
usr/src/pkg/manifests/system-file-system-nfs.mf
usr/src/uts/common/nfs/nfs.h
--- a/exception_lists/packaging	Wed Aug 11 14:15:47 2010 -0700
+++ b/exception_lists/packaging	Wed Aug 11 17:11:30 2010 -0500
@@ -662,6 +662,9 @@
 usr/lib/libshare.so
 usr/lib/amd64/libshare.so		i386
 usr/lib/sparcv9/libshare.so		sparc
+usr/lib/fs/autofs/libshare_autofs.so
+usr/lib/fs/autofs/amd64/libshare_autofs.so		i386
+usr/lib/fs/autofs/sparcv9/libshare_autofs.so		sparc
 usr/lib/fs/nfs/libshare_nfs.so
 usr/lib/fs/nfs/amd64/libshare_nfs.so		i386
 usr/lib/fs/nfs/sparcv9/libshare_nfs.so		sparc
--- a/usr/src/cmd/fs.d/autofs/Makefile	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/cmd/fs.d/autofs/Makefile	Wed Aug 11 17:11:30 2010 -0500
@@ -61,13 +61,14 @@
 COMMON=		ns_generic.o ns_files.o ns_nis.o \
 		ns_ldap.o auto_mnttab.o auto_subr.o $(REAL_COMMON)
 
-AUTOOBJS=	automount.o $(COMMON) $(FSLIB)
+AUTOOBJS=	automount.o $(COMMON) $(FSLIB) smfcfg.o
 
 MOUNTOBJS=	mount.o $(FSLIB) $(REAL_COMMON)
 
 LOCAL=		autod_main.o \
 		autod_parse.o autod_mount.o autod_nfs.o nfs_cast.o \
-		autod_autofs.o autod_xdr.o autod_readdir.o autod_lookup.o
+		autod_autofs.o autod_xdr.o autod_readdir.o autod_lookup.o \
+		smfcfg.o
 
 TYPEOBJS=	$(LOCAL) $(COMMON) replica.o nfs_sec.o nfs_resolve.o nfs_subr.o \
 		$(FSLIB) webnfs_xdr.o webnfs_client.o selfcheck.o
@@ -95,7 +96,7 @@
 TYPESRCS=	$(LOCAL:%.o=%.c) $(COMMON:%.o=%.c) \
 		../nfs/lib/replica.c ../nfs/lib/nfs_sec.c \
 		../nfs/lib/nfs_subr.c $(FSLIBSRC) ../nfs/lib/selfcheck.c \
-		../nfs/lib/nfs_resolve.c
+		../nfs/lib/nfs_resolve.c ../nfs/lib/smfcfg.c
 SHARESRCS=	$(SHARE:%=%.c)
 UNSHARESRCS=	$(UNSHARE:%=%.c)
 DFSHARESSRCS=	$(DFSHARES:%=%.sh)
@@ -167,6 +168,9 @@
 selfcheck.o:	../nfs/lib/selfcheck.c
 		$(COMPILE.c) ../nfs/lib/selfcheck.c
 
+smfcfg.o: ../nfs/lib/smfcfg.c
+		$(COMPILE.c) ../nfs/lib/smfcfg.c
+
 nfs_resolve.o:	../nfs/lib/nfs_resolve.c
 		$(COMPILE.c) ../nfs/lib/nfs_resolve.c
 
--- a/usr/src/cmd/fs.d/autofs/auto_subr.c	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/cmd/fs.d/autofs/auto_subr.c	Wed Aug 11 17:11:30 2010 -0500
@@ -19,11 +19,9 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
 
 #include <ctype.h>
 #include <stdio.h>
@@ -35,6 +33,7 @@
 #include <string.h>
 #include <stdarg.h>
 #include <dirent.h>
+#include <limits.h>
 #include <thread.h>
 #include <sys/param.h>
 #include <sys/time.h>
@@ -51,12 +50,16 @@
 #include <sys/utsname.h>
 #include <rpc/rpc.h>
 #include <rpcsvc/nfs_prot.h>
+#include <rpcsvc/daemon_utils.h>
 #include <assert.h>
 #include "automount.h"
 #include <deflt.h>
 #include <zone.h>
 #include <priv.h>
 #include <fcntl.h>
+#include <libshare.h>
+#include <libscf.h>
+#include "smfcfg.h"
 
 static char *check_hier(char *);
 static int arch(char *, size_t, bool_t);
@@ -192,7 +195,7 @@
 	}
 	if (p = check_hier(mntpnt)) {
 		pr_msg("hierarchical mountpoint: %s and %s",
-			p, mntpnt);
+		    p, mntpnt);
 		return;
 	}
 
@@ -314,8 +317,8 @@
 		(*p)++, (*pq)++;
 
 	while (**p &&
-		!((delim == ' ' ? isspace(**p) : **p == delim) &&
-			**pq == ' ')) {
+	    !((delim == ' ' ? isspace(**p) : **p == delim) &&
+	    **pq == ' ')) {
 		if (--count <= 0) {
 			*tmp = '\0';
 			*tmpq = '\0';
@@ -419,8 +422,8 @@
 			}
 		}
 		syslog(LOG_ERR,
-			"map %s: line too long (max %d chars)",
-			map, linesz-1);
+		    "map %s: line too long (max %d chars)",
+		    map, linesz-1);
 		*line = '\0';
 	}
 
@@ -881,7 +884,7 @@
 		 */
 		/* LINTED pointer alignment */
 		e = (struct dir_entry *)
-			auto_rddir_malloc(sizeof (struct dir_entry));
+		    auto_rddir_malloc(sizeof (struct dir_entry));
 		if (e == NULL)
 			return (ENOMEM);
 		(void) memset((char *)e, 0, sizeof (*e));
@@ -1063,21 +1066,40 @@
 }
 
 /*
- * Set environment variables specified in /etc/default/autofs.
+ * Set environment variables
  */
 void
 put_automountd_env(void)
 {
-	char *defval;
-	int defflags;
+	char defval[PATH_MAX], *p, *a, *c;
+	int ret = 0, bufsz = PATH_MAX;
 
-	if ((defval = defread("AUTOMOUNTD_ENV=")) != NULL) {
-		(void) putenv(strdup(defval));
-		defflags = defcntl(DC_GETFLAGS, 0);
-		TURNON(defflags, DC_NOREWIND);
-		defflags = defcntl(DC_SETFLAGS, defflags);
-		while ((defval = defread("AUTOMOUNTD_ENV=")) != NULL)
-			(void) putenv(strdup(defval));
-		(void) defcntl(DC_SETFLAGS, defflags);
+	ret = autofs_smf_get_prop("environment", defval, DEFAULT_INSTANCE,
+	    SCF_TYPE_ASTRING, AUTOMOUNTD, &bufsz);
+	if (ret == SA_OK) {
+		a = c = defval;
+		if (*a == NULL)
+			return;
+		/*
+		 * Environment variables can have more than one value
+		 * seperated by a comma and there can be multiple
+		 * environment variables. * a=b\,c,d=e. For multiple
+		 * valued environment variable, values are seperated
+		 * with an escape character.
+		 */
+		while ((p = strchr(c, ',')) != NULL) {
+			if (*(p - 1) == '\\') {
+				c = p + 1;
+				continue;
+			}
+			*p = '\0';
+			if ((c = strchr(a, '=')) != NULL)
+				putenv(strdup(a));
+			a = c = p + 1;
+		}
+		if (*a != NULL) {
+			if ((c = strchr(a, '=')) != NULL)
+				putenv(strdup(a));
+		}
 	}
 }
--- a/usr/src/cmd/fs.d/autofs/autod_main.c	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/cmd/fs.d/autofs/autod_main.c	Wed Aug 11 17:11:30 2010 -0500
@@ -19,11 +19,9 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
 
 #include <stdio.h>
 #include <stdio_ext.h>
@@ -47,6 +45,7 @@
 #include <thread.h>
 #include <locale.h>
 #include <door.h>
+#include <limits.h>
 #include "automount.h"
 #include <sys/vfs.h>
 #include <sys/mnttab.h>
@@ -61,6 +60,9 @@
 #include <nfs/rnode.h>
 #include <nfs/nfs.h>
 #include <wait.h>
+#include <libshare.h>
+#include <libscf.h>
+#include "smfcfg.h"
 
 static void autofs_doorfunc(void *, char *, size_t, door_desc_t *, uint_t);
 static void autofs_setdoor(int);
@@ -112,7 +114,8 @@
 	pid_t pid;
 	int c, error;
 	struct rlimit rlset;
-	char *defval;
+	char defval[6];
+	int ret = 0, bufsz;
 
 	if (geteuid() != 0) {
 		(void) fprintf(stderr, "%s must be run as root\n", argv[0]);
@@ -120,33 +123,37 @@
 	}
 
 	/*
-	 * Read in the values from config file first before we check
+	 * Read in the values from SMF first before we check
 	 * commandline options so the options override the file.
 	 */
-	if ((defopen(AUTOFSADMIN)) == 0) {
-		if ((defval = defread("AUTOMOUNTD_VERBOSE=")) != NULL) {
-			if (strncasecmp("true", defval, 4) == 0)
-				verbose = TRUE;
-			else
-				verbose = FALSE;
-		}
-		if ((defval = defread("AUTOMOUNTD_NOBROWSE=")) != NULL) {
-			if (strncasecmp("true", defval, 4) == 0)
-				automountd_nobrowse = TRUE;
-			else
-				automountd_nobrowse = FALSE;
-		}
-		if ((defval = defread("AUTOMOUNTD_TRACE=")) != NULL) {
-			errno = 0;
-			trace = strtol(defval, (char **)NULL, 10);
-			if (errno != 0)
-				trace = 0;
-		}
-		put_automountd_env();
-
-		/* close defaults file */
-		defopen(NULL);
+	bufsz = 6;
+	ret = autofs_smf_get_prop("automountd_verbose", defval,
+	    DEFAULT_INSTANCE, SCF_TYPE_BOOLEAN, AUTOMOUNTD, &bufsz);
+	if (ret == SA_OK) {
+		if (strncasecmp("true", defval, 4) == 0)
+			verbose = TRUE;
+		else
+			verbose = FALSE;
 	}
+	bufsz = 6;
+	ret = autofs_smf_get_prop("nobrowse", defval, DEFAULT_INSTANCE,
+	    SCF_TYPE_BOOLEAN, AUTOMOUNTD, &bufsz);
+	if (ret == SA_OK) {
+		if (strncasecmp("true", defval, 4) == 0)
+			automountd_nobrowse = TRUE;
+		else
+			automountd_nobrowse = FALSE;
+	}
+	bufsz = 6;
+	ret = autofs_smf_get_prop("trace", defval, DEFAULT_INSTANCE,
+	    SCF_TYPE_INTEGER, AUTOMOUNTD, &bufsz);
+	if (ret == SA_OK) {
+		errno = 0;
+		trace = strtol(defval, (char **)NULL, 10);
+		if (errno != 0)
+			trace = 0;
+	}
+	put_automountd_env();
 
 	while ((c = getopt(argc, argv, "vnTD:")) != EOF) {
 		switch (c) {
--- a/usr/src/cmd/fs.d/autofs/autod_nfs.c	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/cmd/fs.d/autofs/autod_nfs.c	Wed Aug 11 17:11:30 2010 -0500
@@ -81,6 +81,10 @@
 #include <strings.h>
 #include <tsol/label.h>
 #include <zone.h>
+#include <limits.h>
+#include <libscf.h>
+#include <libshare.h>
+#include "smfcfg.h"
 
 extern void set_nfsv4_ephemeral_mount_to(void);
 
@@ -4020,76 +4024,66 @@
 #endif /* CACHE_DEBUG */
 
 /*
- * Read the /etc/default/nfs configuration file to determine if the
+ * Read the NFS SMF properties to determine if the
  * client has been configured for a new min/max for the NFS version to
  * use.
  */
 
-#define	NFS_DEFAULT_CHECK 60  /* Seconds to check for nfs default changes */
+#define	SVC_NFS_CLIENT	"svc:/network/nfs/client"
 
 static void
 read_default_nfs(void)
 {
 	static time_t lastread = 0;
 	struct stat buf;
-	char *defval;
-	int errno;
-	int tmp;
-
-	/*
-	 * Fail silently if we can't stat the default nfs config file
-	 */
-	if (stat(NFSADMIN, &buf))
-		return;
-
-	if (buf.st_mtime == lastread)
-		return;
+	char defval[4];
+	int errno, bufsz;
+	int tmp, ret = 0;
+
+	bufsz = 4;
+	ret = nfs_smf_get_prop("client_versmin", defval, DEFAULT_INSTANCE,
+	    SCF_TYPE_INTEGER, SVC_NFS_CLIENT, &bufsz);
+	if (ret == SA_OK) {
+		errno = 0;
+		tmp = strtol(defval, (char **)NULL, 10);
+		if (errno == 0) {
+			vers_min_default = tmp;
+		}
+	}
+
+	bufsz = 4;
+	ret = nfs_smf_get_prop("client_versmax", defval, DEFAULT_INSTANCE,
+	    SCF_TYPE_INTEGER, SVC_NFS_CLIENT, &bufsz);
+	if (ret == SA_OK) {
+		errno = 0;
+		tmp = strtol(defval, (char **)NULL, 10);
+		if (errno == 0) {
+			vers_max_default = tmp;
+		}
+	}
+
+	lastread = buf.st_mtime;
 
 	/*
-	 * Fail silently if error in opening the default nfs config file
-	 * We'll check back in NFS_DEFAULT_CHECK seconds
+	 * Quick sanity check on the values picked up from the
+	 * defaults file.  Make sure that a mistake wasn't
+	 * made that will confuse things later on.
+	 * If so, reset to compiled-in defaults
 	 */
-	if ((defopen(NFSADMIN)) == 0) {
-		if ((defval = defread("NFS_CLIENT_VERSMIN=")) != NULL) {
-			errno = 0;
-			tmp = strtol(defval, (char **)NULL, 10);
-			if (errno == 0) {
-				vers_min_default = tmp;
-			}
-		}
-		if ((defval = defread("NFS_CLIENT_VERSMAX=")) != NULL) {
-			errno = 0;
-			tmp = strtol(defval, (char **)NULL, 10);
-			if (errno == 0) {
-				vers_max_default = tmp;
-			}
+	if (vers_min_default > vers_max_default ||
+	    vers_min_default < NFS_VERSMIN ||
+	    vers_max_default > NFS_VERSMAX) {
+		if (trace > 1) {
+			trace_prt(1,
+	"  read_default: version minimum/maximum incorrectly configured\n");
+			trace_prt(1,
+"  read_default: config is min=%d, max%d. Resetting to min=%d, max%d\n",
+			    vers_min_default, vers_max_default,
+			    NFS_VERSMIN_DEFAULT,
+			    NFS_VERSMAX_DEFAULT);
 		}
-		/* close defaults file */
-		defopen(NULL);
-
-		lastread = buf.st_mtime;
-
-		/*
-		 * Quick sanity check on the values picked up from the
-		 * defaults file.  Make sure that a mistake wasn't
-		 * made that will confuse things later on.
-		 * If so, reset to compiled-in defaults
-		 */
-		if (vers_min_default > vers_max_default ||
-		    vers_min_default < NFS_VERSMIN ||
-		    vers_max_default > NFS_VERSMAX) {
-			if (trace > 1) {
-				trace_prt(1,
-	"  read_default: version minimum/maximum incorrectly configured\n");
-				trace_prt(1,
-"  read_default: config is min=%d, max%d. Resetting to min=%d, max%d\n",
-				    vers_min_default, vers_max_default,
-				    NFS_VERSMIN_DEFAULT,
-				    NFS_VERSMAX_DEFAULT);
-			}
-			vers_min_default = NFS_VERSMIN_DEFAULT;
-			vers_max_default = NFS_VERSMAX_DEFAULT;
-		}
+		vers_min_default = NFS_VERSMIN_DEFAULT;
+		vers_max_default = NFS_VERSMAX_DEFAULT;
 	}
 }
 
--- a/usr/src/cmd/fs.d/autofs/autofs.dfl	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/cmd/fs.d/autofs/autofs.dfl	Wed Aug 11 17:11:30 2010 -0500
@@ -1,14 +1,9 @@
-#ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright 2005 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, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
+# 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.
@@ -23,28 +18,10 @@
 #
 # CDDL HEADER END
 #
-
-# The duration in which a file system will remain idle before being
-# unmounted.  This is equivalent to the "-t" argument to automount.
-#AUTOMOUNT_TIMEOUT=600
-
-# Verbose mode.  Notifies of autofs mounts, unmounts, or other
-# non-essential events.  This equivalent to the "-v" argument.
-#AUTOMOUNT_VERBOSE=FALSE
-
-# Verbose.  Log status messagess to the console.
-# This is equivalent to the "-v" argument.
-#AUTOMOUNTD_VERBOSE=FALSE
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
 
-# Turn on or off browsing for all autofs mount points.
-# This is equivalent to the "-n" argument.
-#AUTOMOUNTD_NOBROWSE=FALSE
-
-# Trace.  Expand each RPC call and display it on standard output.
-# This is equivalent to the "-T" argument.
-#AUTOMOUNTD_TRACE=0
-
-# Environment variables.  The format is AUTOMOUNTD_ENV=ENV=value.
-# There should be one line per environment variable to be set and
-# there can be as many of these lines as are required.
-#AUTOMOUNTD_ENV=
+#
+# Moved to SMF. Use sharectl(1M) to manage AUTOFS properties.
+#
--- a/usr/src/cmd/fs.d/autofs/autofs.xml	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/cmd/fs.d/autofs/autofs.xml	Wed Aug 11 17:11:30 2010 -0500
@@ -1,30 +1,26 @@
 <?xml version="1.0"?>
 <!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
 <!--
- Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
- Use is subject to license terms.
-
- CDDL HEADER START
+    CDDL HEADER START
 
- The contents of this file are subject to the terms of the
- Common Development and Distribution License, Version 1.0 only
- (the "License").  You may not use this file except in compliance
- with the License.
+    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.
+    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]
+    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
+    CDDL HEADER END
 
-    ident	"%Z%%M%	%I%	%E% SMI"
+    Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
 
     NOTE:  This service manifest is not editable; its contents will
     be overwritten by package or patch operations, including
@@ -43,10 +39,6 @@
 	type='service'
 	version='1'>
 
-	<create_default_instance enabled='false' />
-
-	<single_instance />
-
 	<dependency
 		name='fs'
 		type='service'
@@ -112,6 +104,17 @@
 		<propval name='auto_enable' type='boolean' value='true' />
 	</property_group>
 
+	<instance name='default' enabled='false'>
+	  <property_group name='autofs-props' type='com.oracle.autofs,props'>
+	    <propval name='timeout' type='integer' value='600'/>
+	    <propval name='automount_verbose' type='boolean' value='false'/>
+	    <propval name='trace' type='integer' value='0'/>
+	    <propval name='nobrowse' type='boolean' value='false'/>
+	    <propval name='automountd_verbose' type='boolean' value='false'/>
+	    <propval name='environment' type='astring' value=''/>
+	  </property_group>
+	</instance>
+
 	<stability value='Stable' />
 
 	<template>
--- a/usr/src/cmd/fs.d/autofs/automount.c	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/cmd/fs.d/autofs/automount.c	Wed Aug 11 17:11:30 2010 -0500
@@ -21,11 +21,9 @@
 /*
  *	automount.c
  *
- * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
 
 #include <ctype.h>
 #include <stdio.h>
@@ -38,6 +36,8 @@
 #include <dirent.h>
 #include <signal.h>
 #include <syslog.h>
+#include <libshare.h>
+#include <libscf.h>
 #include <sys/param.h>
 #include <sys/time.h>
 #include <sys/vfs.h>
@@ -54,6 +54,7 @@
 #include <deflt.h>
 #include <rpcsvc/daemon_utils.h>
 #include "automount.h"
+#include "smfcfg.h"
 
 static int mkdir_r(char *);
 struct autodir *dir_head;
@@ -99,6 +100,8 @@
 	char **stkptr;
 	char *defval;
 	struct sigaction sigintact;
+	int ret = 0, bufsz = 0;
+	char valbuf[6];
 
 	/*
 	 * protect this command from session termination when run in background
@@ -111,28 +114,29 @@
 	}
 
 	/*
-	 * Read in the values from config file first before we check
-	 * commandline options so the options override the file.
+	 * Read in the values from SMF first before we check
+	 * commandline options so the options override the SMF values.
 	 */
-	if ((defopen(AUTOFSADMIN)) == 0) {
-		if ((defval = defread("AUTOMOUNT_TIMEOUT=")) != NULL) {
-			errno = 0;
-			mount_timeout = strtol(defval, (char **)NULL, 10);
-			if (errno != 0)
-				mount_timeout = AUTOFS_MOUNT_TIMEOUT;
-		}
-		if ((defval = defread("AUTOMOUNT_VERBOSE=")) != NULL) {
-			if (strncasecmp("true", defval, 4) == 0)
-				verbose = TRUE;
-			else
-				verbose = FALSE;
-		}
-		put_automountd_env();
+	bufsz = 6;
+	ret = autofs_smf_get_prop("timeout", valbuf, DEFAULT_INSTANCE,
+	    SCF_TYPE_INTEGER, AUTOMOUNTD, &bufsz);
+	if (ret == SA_OK)
+		/*
+		 * Ignore errno.  In event of failure, mount_timeout is
+		 * already initialized to the correct value.
+		 */
+		mount_timeout = strtol(valbuf, (char **)NULL, 10);
 
-		/* close defaults file */
-		defopen(NULL);
+	bufsz = 6;
+	ret = autofs_smf_get_prop("automount_verbose", valbuf, DEFAULT_INSTANCE,
+	    SCF_TYPE_BOOLEAN, AUTOMOUNTD, &bufsz);
+	if (ret == SA_OK) {
+		if (strncasecmp("true", valbuf, 4) == 0)
+			verbose = TRUE;
 	}
 
+	put_automountd_env();
+
 	while ((c = getopt(argc, argv, "mM:D:f:t:v?")) != EOF) {
 		switch (c) {
 		case 'm':
@@ -166,8 +170,7 @@
 
 	if (optind < argc) {
 		pr_msg("%s: command line mountpoints/maps "
-			"no longer supported",
-			argv[optind]);
+		    "no longer supported", argv[optind]);
 		usage();
 	}
 
@@ -237,7 +240,7 @@
 			 */
 			if (strcmp(mntp->mnt_fstype, MNTTYPE_AUTOFS) != 0) {
 				pr_msg("%s: already mounted",
-					mntp->mnt_mountp);
+				    mntp->mnt_mountp);
 				continue;
 			}
 
@@ -248,8 +251,8 @@
 			 * with a remount.
 			 */
 			if (strcmp(mntp->mnt_special, dir->dir_map) == 0 &&
-				compare_opts(dir->dir_opts,
-					mntp->mnt_mntopts) == 0) {
+			    compare_opts(dir->dir_opts,
+			    mntp->mnt_mntopts) == 0) {
 				continue;	/* no change */
 			}
 
@@ -264,7 +267,7 @@
 				if (hasmntopt(omntp, "direct") == NULL) {
 					if (verbose)
 						pr_msg("%s: cannot remount",
-							dir->dir_name);
+						    dir->dir_name);
 					continue;
 				}
 			}
@@ -301,15 +304,15 @@
 			ai.key = "";
 
 		(void) sprintf(mntopts, "ignore,%s",
-			dir->dir_direct  ? "direct" : "indirect");
+		    dir->dir_direct  ? "direct" : "indirect");
 		if (dir->dir_opts && *dir->dir_opts) {
 			(void) strcat(mntopts, ",");
 			(void) strcat(mntopts, dir->dir_opts);
 		}
 		mntflgs = MS_OPTIONSTR | (dir->dir_remount ? MS_REMOUNT : 0);
 		if (mount(dir->dir_map, dir->dir_name, MS_DATA | mntflgs,
-				MNTTYPE_AUTOFS, &ai, sizeof (ai), mntopts,
-				MAX_MNTOPT_STR) < 0) {
+		    MNTTYPE_AUTOFS, &ai, sizeof (ai), mntopts,
+		    MAX_MNTOPT_STR) < 0) {
 			pr_msg("mount %s: %m", dir->dir_name);
 			continue;
 		}
@@ -520,7 +523,7 @@
 		if (umount(mnt->mnt_mountp) == 0) {
 			if (verbose) {
 				pr_msg("%s unmounted",
-					mnt->mnt_mountp);
+				    mnt->mnt_mountp);
 			}
 			count++;
 		}
--- a/usr/src/cmd/fs.d/nfs/etc/nfs.dfl	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/cmd/fs.d/nfs/etc/nfs.dfl	Wed Aug 11 17:11:30 2010 -0500
@@ -1,14 +1,9 @@
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright 2005 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, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
+# 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.
@@ -23,81 +18,10 @@
 #
 # CDDL HEADER END
 #
-
-# Sets the maximum number of concurrent connection oriented connections.
-# Default is unlimited and is obtained by not setting NFSD_MAX_CONNECTIONS.
-# Equivalent to -c.
-#NFSD_MAX_CONNECTIONS=
-
-# Set connection queue length for the NFS over a connection-oriented 
-# transport. The default value is 32 entries.
-# Equivalent to -l.
-NFSD_LISTEN_BACKLOG=32
-
-# Start NFS daemon over the specified protocol only.
-# Equivalent to -p, ALL is equivalent to -a on the nfsd command line.
-# Mutually exclusive with NFSD_DEVICE.
-NFSD_PROTOCOL=ALL
-
-# Start NFS daemon for the transport specified by the given device only.
-# Equivalent to -t.
-# Mutually exclusive with setting NFSD_PROTOCOL.
-#NFSD_DEVICE=
-
-# Maximum number of concurrent NFS requests.
-# Equivalent to last numeric argument on nfsd command line.
-NFSD_SERVERS=16
-
-# Set connection queue length for lockd over a connection-oriented transport.
-# Default and minimum value is 32.
-LOCKD_LISTEN_BACKLOG=32
-
-# Maximum number of concurrent lockd requests.
-# Default is 20.
-LOCKD_SERVERS=20
-
-# Retransmit Timeout before lockd tries again.
-# Default is 5.
-LOCKD_RETRANSMIT_TIMEOUT=5
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
 
-# Grace period in seconds that all clients (both NLM & NFSv4) have to
-# reclaim locks after a server reboot. Also controls the NFSv4 lease
-# interval.
-# Overrides the deprecated setting LOCKD_GRACE_PERIOD.
-# Default is 90 seconds.
-GRACE_PERIOD=90
-
-# Deprecated.
-# As for GRACE_PERIOD, above.
-# Default is 90 seconds.
-#LOCKD_GRACE_PERIOD=90
-
-# Sets the minimum version of the NFS protocol that will be registered
-# and offered by the server.  The default is 2.
-#NFS_SERVER_VERSMIN=2
-
-# Sets the maximum version of the NFS protocol that will be registered
-# and offered by the server.  The default is 4.
-#NFS_SERVER_VERSMAX=4
-
-# Sets the minimum version of the NFS protocol that will be used by
-# the NFS client.  Can be overridden by the "vers=" NFS mount option.
-# The default is 2.
-#NFS_CLIENT_VERSMIN=2
-
-# Sets the maximum version of the NFS protocol that will be used by
-# the NFS client.  Can be overridden by the "vers=" NFS mount option.
-# If "vers=" is not specified for an NFS mount, this is the version
-# that will be attempted first.  The default is 4.
-#NFS_CLIENT_VERSMAX=4
-
-# Determines if the NFS version 4 delegation feature will be enabled
-# for the server.  If it is enabled, the server will attempt to
-# provide delegations to the NFS version 4 client. The default is on.
-#NFS_SERVER_DELEGATION=on
-
-# Specifies to nfsmapid daemon that it is to override its default
-# behavior of using the DNS domain, and that it is to use 'domain' as
-# the domain to append to outbound attribute strings, and that it is to
-# use 'domain' to compare against inbound attribute strings.
-#NFSMAPID_DOMAIN=domain
+#
+# Moved to SMF. Use sharectl(1M) to manage NFS properties.
+#
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/fs.d/nfs/lib/smfcfg.c	Wed Aug 11 17:11:30 2010 -0500
@@ -0,0 +1,393 @@
+/*
+ * 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 (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <syslog.h>
+#include <stdarg.h>
+#include "smfcfg.h"
+
+fs_smfhandle_t *
+fs_smf_init(char *fmri, char *instance)
+{
+	fs_smfhandle_t *handle = NULL;
+	char *svcname, srv[MAXPATHLEN];
+
+	/*
+	 * svc name is of the form svc://network/fs/server:instance1
+	 * FMRI portion is /network/fs/server
+	 */
+	snprintf(srv, MAXPATHLEN, "%s", fmri + strlen("svc:/"));
+	svcname = strrchr(srv, ':');
+	if (svcname != NULL)
+		*svcname = '\0';
+	svcname = srv;
+
+	handle = calloc(1, sizeof (fs_smfhandle_t));
+	if (handle != NULL) {
+		handle->fs_handle = scf_handle_create(SCF_VERSION);
+		if (handle->fs_handle == NULL)
+			goto out;
+		if (scf_handle_bind(handle->fs_handle) != 0)
+			goto out;
+		handle->fs_service =
+		    scf_service_create(handle->fs_handle);
+		handle->fs_scope =
+		    scf_scope_create(handle->fs_handle);
+		if (scf_handle_get_local_scope(handle->fs_handle,
+		    handle->fs_scope) != 0)
+			goto out;
+		if (scf_scope_get_service(handle->fs_scope,
+		    svcname, handle->fs_service)  != SCF_SUCCESS) {
+			goto out;
+		}
+		handle->fs_pg =
+		    scf_pg_create(handle->fs_handle);
+		handle->fs_instance =
+		    scf_instance_create(handle->fs_handle);
+		handle->fs_property =
+		    scf_property_create(handle->fs_handle);
+		handle->fs_value =
+		    scf_value_create(handle->fs_handle);
+	} else {
+		fprintf(stderr,
+		    gettext("Cannot access SMF repository: %s\n"), fmri);
+	}
+	return (handle);
+
+out:
+	fs_smf_fini(handle);
+	fprintf(stderr, gettext("SMF Initialization problems..%s\n"), fmri);
+	return (NULL);
+}
+
+
+void
+fs_smf_fini(fs_smfhandle_t *handle)
+{
+	if (handle != NULL) {
+		scf_scope_destroy(handle->fs_scope);
+		scf_instance_destroy(handle->fs_instance);
+		scf_service_destroy(handle->fs_service);
+		scf_pg_destroy(handle->fs_pg);
+		scf_property_destroy(handle->fs_property);
+		scf_value_destroy(handle->fs_value);
+		if (handle->fs_handle != NULL) {
+			scf_handle_unbind(handle->fs_handle);
+			scf_handle_destroy(handle->fs_handle);
+		}
+		free(handle);
+	}
+}
+
+int
+fs_smf_set_prop(smf_fstype_t fstype, char *prop_name, char *valbuf,
+    char *instance, scf_type_t sctype, char *fmri)
+{
+	fs_smfhandle_t *phandle;
+	scf_handle_t *handle;
+	scf_propertygroup_t *pg;
+	scf_property_t *prop;
+	scf_transaction_t *tran;
+	scf_transaction_entry_t *entry;
+	scf_instance_t *inst;
+	scf_value_t *val;
+	int valint;
+	int index = 0;
+	int ret = 0;
+	char *p = NULL;
+	char *svcname, srv[MAXPATHLEN];
+	const char *pgname;
+
+	/*
+	 * The SVC names we are using currently are already
+	 * appended by default. Fix this for instances project.
+	 */
+	snprintf(srv, MAXPATHLEN, "%s", fmri);
+	p = strstr(fmri, ":default");
+	if (p == NULL) {
+		strcat(srv, ":");
+		if (instance == NULL)
+			instance = "default";
+		if (strlen(srv) + strlen(instance) > MAXPATHLEN)
+			goto out;
+		strncat(srv, instance, strlen(instance));
+	}
+	svcname = srv;
+	phandle = fs_smf_init(fmri, instance);
+	if (phandle == NULL) {
+		return (SMF_SYSTEM_ERR);
+	}
+	handle = phandle->fs_handle;
+	pg = phandle->fs_pg;
+	prop = phandle->fs_property;
+	inst = phandle->fs_instance;
+	val = phandle->fs_value;
+	tran = scf_transaction_create(handle);
+	entry = scf_entry_create(handle);
+
+	if (handle == NULL || pg == NULL || prop == NULL ||
+	    val == NULL|| tran == NULL || entry == NULL || inst == NULL) {
+		ret = SMF_SYSTEM_ERR;
+		goto out;
+	}
+
+	if (scf_handle_decode_fmri(handle, svcname, phandle->fs_scope,
+	    phandle->fs_service, inst, NULL, NULL, 0) != 0) {
+		ret = scf_error();
+		goto out;
+	}
+	if (fstype == AUTOFS_SMF)
+		pgname = AUTOFS_PROPS_PGNAME;
+	else
+		pgname = NFS_PROPS_PGNAME;
+
+	if (scf_instance_get_pg(inst, pgname,
+	    pg) != -1) {
+		uint8_t	vint;
+		if (scf_transaction_start(tran, pg) == -1) {
+			ret = scf_error();
+			goto out;
+		}
+		switch (sctype) {
+		case SCF_TYPE_INTEGER:
+			errno = 0;
+			valint = strtoul(valbuf, NULL, 0);
+			if (errno != 0) {
+				ret = SMF_SYSTEM_ERR;
+				goto out;
+			}
+			if (scf_transaction_property_change(tran,
+			    entry, prop_name, SCF_TYPE_INTEGER) == 0) {
+				scf_value_set_integer(val, valint);
+				if (scf_entry_add_value(entry, val) < 0) {
+					ret = scf_error();
+					goto out;
+				}
+			}
+			break;
+		case SCF_TYPE_ASTRING:
+			if (scf_transaction_property_change(tran, entry,
+			    prop_name, SCF_TYPE_ASTRING) == 0) {
+				if (scf_value_set_astring(val,
+				    valbuf) == 0) {
+					if (scf_entry_add_value(entry,
+					    val) != 0) {
+						ret = scf_error();
+						goto out;
+					}
+				} else
+					ret = SMF_SYSTEM_ERR;
+			} else
+				ret = SMF_SYSTEM_ERR;
+			break;
+		case SCF_TYPE_BOOLEAN:
+			if (strcmp(valbuf, "1") == 0) {
+				vint = 1;
+			} else if (strcmp(valbuf, "0") == 0) {
+				vint = 0;
+			} else  {
+				ret = SMF_SYSTEM_ERR;
+				break;
+			}
+			if (scf_transaction_property_change(tran, entry,
+			    prop_name, SCF_TYPE_BOOLEAN) == 0) {
+				scf_value_set_boolean(val, (uint8_t)vint);
+				if (scf_entry_add_value(entry, val) != 0) {
+					ret = scf_error();
+					goto out;
+				}
+			} else {
+				ret = SMF_SYSTEM_ERR;
+			}
+			break;
+		}
+		if (ret != SMF_SYSTEM_ERR)
+			scf_transaction_commit(tran);
+	}
+out:
+	if (tran != NULL)
+		scf_transaction_destroy(tran);
+	if (entry != NULL)
+		scf_entry_destroy(entry);
+	fs_smf_fini(phandle);
+	return (ret);
+}
+
+int
+fs_smf_get_prop(smf_fstype_t fstype, char *prop_name, char *cbuf,
+    char *instance, scf_type_t sctype, char *fmri, int *bufsz)
+{
+	fs_smfhandle_t *phandle;
+	scf_handle_t *handle;
+	scf_propertygroup_t *pg;
+	scf_property_t *prop;
+	scf_value_t *val;
+	scf_instance_t *inst;
+	int ret = 0, len = 0, length;
+	int64_t valint = 0;
+	char srv[MAXPATHLEN], *p, *svcname;
+	const char *pgname;
+	uint8_t bval;
+
+	/*
+	 * The SVC names we are using currently are already
+	 * appended by default. Fix this for instances project.
+	 */
+	snprintf(srv, MAXPATHLEN, "%s", fmri);
+	p = strstr(fmri, ":default");
+	if (p == NULL) {
+		strcat(srv, ":");
+		if (instance == NULL)
+			instance = "default";
+		if (strlen(srv) + strlen(instance) > MAXPATHLEN)
+			goto out;
+		strncat(srv, instance, strlen(instance));
+	}
+	svcname = srv;
+	phandle = fs_smf_init(fmri, instance);
+	if (phandle == NULL)
+		return (SMF_SYSTEM_ERR);
+	handle = phandle->fs_handle;
+	pg = phandle->fs_pg;
+	inst = phandle->fs_instance;
+	prop = phandle->fs_property;
+	val = phandle->fs_value;
+
+	if (handle == NULL || pg == NULL || prop == NULL || val == NULL ||
+	    inst == NULL)  {
+		return (SMF_SYSTEM_ERR);
+	}
+
+
+	if (scf_handle_decode_fmri(handle, svcname, phandle->fs_scope,
+	    phandle->fs_service, inst, NULL, NULL, 0) != 0) {
+		ret = scf_error();
+		goto out;
+	}
+
+	if (fstype == AUTOFS_SMF)
+		pgname = AUTOFS_PROPS_PGNAME;
+	else
+		pgname = NFS_PROPS_PGNAME;
+
+	if (scf_instance_get_pg(inst, pgname, pg) != -1) {
+		if (scf_pg_get_property(pg, prop_name,
+		    prop) != SCF_SUCCESS) {
+			ret = scf_error();
+			goto out;
+		}
+		if (scf_property_get_value(prop, val) != SCF_SUCCESS) {
+			ret = scf_error();
+			goto out;
+		}
+		switch (sctype) {
+		case SCF_TYPE_ASTRING:
+			len = scf_value_get_astring(val, cbuf, *bufsz);
+			if (len < 0 || len > *bufsz) {
+				ret = scf_error();
+				goto out;
+			}
+			ret = 0;
+			*bufsz = len;
+		break;
+		case SCF_TYPE_INTEGER:
+			if (scf_value_get_integer(val, &valint) != 0) {
+				ret = scf_error();
+				goto out;
+			}
+			length =  snprintf(cbuf, *bufsz, "%lld", valint);
+			if (length < 0 || length > *bufsz) {
+				ret = SA_BAD_VALUE;
+				goto out;
+			}
+			ret = 0;
+		break;
+		case SCF_TYPE_BOOLEAN:
+			if (scf_value_get_boolean(val, &bval) != 0) {
+				ret = scf_error();
+				goto out;
+			}
+			if (bval == 1) {
+				length = snprintf(cbuf, *bufsz, "%s", "true");
+			} else {
+				length = snprintf(cbuf, *bufsz, "%s", "false");
+			}
+			if (length < 0 || length > *bufsz) {
+				ret = SA_BAD_VALUE;
+				goto out;
+			}
+		break;
+		}
+	} else {
+		ret = scf_error();
+	}
+	if ((ret != 0) && scf_error() != SCF_ERROR_NONE)
+		fprintf(stdout, gettext("%s\n"), scf_strerror(ret));
+out:
+	fs_smf_fini(phandle);
+	return (ret);
+}
+
+
+int
+nfs_smf_get_prop(char *prop_name, char *propbuf, char *instance,
+    scf_type_t sctype, char *svc_name, int *bufsz)
+{
+	return (fs_smf_get_prop(NFS_SMF, prop_name, propbuf,
+	    instance, sctype, svc_name, bufsz));
+}
+
+int
+nfs_smf_set_prop(char *prop_name, char *value, char *instance,
+    scf_type_t type, char *svc_name)
+{
+	return (fs_smf_set_prop(NFS_SMF, prop_name, value, instance,
+	    type, svc_name));
+}
+
+int
+autofs_smf_set_prop(char *prop_name, char *value, char *instance,
+    scf_type_t type, char *svc_name)
+{
+	return (fs_smf_set_prop(AUTOFS_SMF, prop_name, value, instance,
+	    type, svc_name));
+}
+
+int
+autofs_smf_get_prop(char *prop_name, char *propbuf, char *instance,
+    scf_type_t sctype, char *svc_name, int *bufsz)
+{
+	return (fs_smf_get_prop(AUTOFS_SMF, prop_name, propbuf,
+	    instance, sctype, svc_name, bufsz));
+}
+
+boolean_t
+string_to_boolean(const char *str)
+{
+	if (strcasecmp(str, "true") == 0 || atoi(str) == 1 ||
+	    strcasecmp(str, "on") == 0 || strcasecmp(str, "yes") == 0) {
+		return (B_TRUE);
+	} else
+		return (B_FALSE);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/fs.d/nfs/lib/smfcfg.h	Wed Aug 11 17:11:30 2010 -0500
@@ -0,0 +1,109 @@
+/*
+ * 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 (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef	_SMFCFG_H
+#define	_SMFCFG_H
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <syslog.h>
+#include <stdarg.h>
+#include <rpc/rpc.h>
+#include <synch.h>
+#include <thread.h>
+#include <libintl.h>
+#include <strings.h>
+#include <inttypes.h>
+#include <limits.h>
+#include <assert.h>
+#include <libscf.h>
+#include <libshare.h>
+#include <locale.h>
+#include <errno.h>
+#include <sys/types.h>
+
+#ifdef	__cplusplus
+extern	"C" {
+#endif
+
+typedef enum {
+	NFS_SMF = 1,
+	AUTOFS_SMF
+} smf_fstype_t;
+
+typedef struct fs_smfhandle {
+	scf_handle_t		*fs_handle;
+	scf_service_t		*fs_service;
+	scf_scope_t		*fs_scope;
+	scf_instance_t		*fs_instance;
+	scf_propertygroup_t	*fs_pg;
+	scf_property_t		*fs_property;
+	scf_value_t		*fs_value;
+} fs_smfhandle_t;
+
+#define	DEFAULT_INSTANCE	"default"
+
+/*
+ * NFS Property Group names.
+ */
+#define	SMF_PG_NFSPROPS		((const char *)"com.oracle.nfs,props")
+#define	NFS_PROPS_PGNAME	((const char *)"nfs-props")
+#define	SVC_NFS_CLIENT		"svc:/network/nfs/client"
+
+/*
+ * AUTOFS Property Group Names.
+ */
+#define	SMF_PG_AUTOFS		((const char *)"com.oracle.autofs,props")
+#define	AUTOFS_PROPS_PGNAME	((const char *)"autofs-props")
+
+#define	AUTOFS_FMRI		"svc:/system/filesystem/autofs"
+#define	AUTOFS_DEFAULT_FMRI	"svc:/system/filesystem/autofs:default"
+#define	MAXDIGITS	32
+
+/*
+ * ERRORS
+ */
+#define	SMF_OK			0
+#define	SMF_SYSTEM_ERR		-1
+#define	STATE_INITIALIZING	1
+#define	SMF_NO_PERMISSION	2
+#define	SMF_NO_PGTYPE		3
+
+extern int nfs_smf_get_prop(char *, char *, char *, scf_type_t, char *, int *);
+extern int fs_smf_get_prop(smf_fstype_t,  char *, char *, char *, scf_type_t,
+	char *, int *);
+extern int nfs_smf_set_prop(char *, char *, char *, scf_type_t, char *);
+extern int fs_smf_set_prop(smf_fstype_t, char *, char *,
+    char *, scf_type_t, char *);
+extern int autofs_smf_set_prop(char *, char *, char *, scf_type_t, char *);
+extern int autofs_smf_get_prop(char *, char *, char *, scf_type_t,
+    char *, int *);
+extern void fs_smf_fini(fs_smfhandle_t *);
+extern boolean_t string_to_boolean(const char *);
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif	/* _SMFCFG_H */
--- a/usr/src/cmd/fs.d/nfs/mount/Makefile	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/cmd/fs.d/nfs/mount/Makefile	Wed Aug 11 17:11:30 2010 -0500
@@ -34,10 +34,11 @@
 
 include		../../Makefile.fstype
 
-COMMON= $(FSLIB) nfs_sec.o replica.o nfs_subr.o selfcheck.o
+COMMON= $(FSLIB) nfs_sec.o replica.o nfs_subr.o selfcheck.o smfcfg.o
 OBJS=	$(LIBPROG).o $(COMMON) webnfs_client.o webnfs_xdr.o
 SRCS=	$(LIBPROG).c $(FSLIBSRC) ../lib/nfs_sec.c ../lib/replica.c \
-	../lib/nfs_subr.c webnfs_xdr.c webnfs_client.c ../lib/selfcheck.c
+	../lib/nfs_subr.c webnfs_xdr.c webnfs_client.c ../lib/selfcheck.c \
+	../lib/smfcfg.c
 
 UNCHECKED_HDRS=	webnfs.h
 
@@ -78,6 +79,9 @@
 nfs_tbind.o:	../lib/nfs_tbind.c
 		$(COMPILE.c) ../lib/nfs_tbind.c
 
+smfcfg.o:	../lib/smfcfg.c
+		$(COMPILE.c) ../lib/smfcfg.c
+
 webnfs_xdr.c:	webnfs.x
 	$(RPCGEN) -M -C -c -o $@ webnfs.x
 
--- a/usr/src/cmd/fs.d/nfs/mount/mount.c	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/cmd/fs.d/nfs/mount/mount.c	Wed Aug 11 17:11:30 2010 -0500
@@ -80,6 +80,9 @@
 #include "webnfs.h"
 #include <rpcsvc/nfs4_prot.h>
 #include <limits.h>
+#include <libscf.h>
+#include <libshare.h>
+#include "smfcfg.h"
 
 #include <nfs/nfssys.h>
 extern int _nfssys(enum nfssys_op, void *);
@@ -214,7 +217,7 @@
  * There are the defaults (range) for the client when determining
  * which NFS version to use when probing the server (see above).
  * These will only be used when the vers mount option is not used and
- * these may be reset if /etc/default/nfs is configured to do so.
+ * these may be reset if NFS SMF is configured to do so.
  */
 static rpcvers_t vers_max_default = NFS_VERSMAX_DEFAULT;
 static rpcvers_t vers_min_default = NFS_VERSMIN_DEFAULT;
@@ -317,7 +320,7 @@
 		(void) setpflags(NET_MAC_AWARE, 1);
 
 	/*
-	 * Read the defaults file to see if the min/max versions have
+	 * Read the NFS SMF defaults to see if the min/max versions have
 	 * been set and therefore would override the encoded defaults.
 	 * Then check to make sure that if they were set that the
 	 * values are reasonable.
@@ -326,10 +329,9 @@
 	if (vers_min_default > vers_max_default ||
 	    vers_min_default < NFS_VERSMIN ||
 	    vers_max_default > NFS_VERSMAX) {
-		pr_err("%s %s\n%s %s\n",
+		pr_err("%s\n%s %s\n",
 		    gettext("Incorrect configuration of client\'s"),
-		    NFSADMIN,
-		    gettext("NFS_CLIENT_VERSMIN or NFS_CLIENT_VERSMAX"),
+		    gettext("client_versmin or client_versmax"),
 		    gettext("is either out of range or overlaps."));
 	}
 
@@ -2608,35 +2610,39 @@
 }
 
 /*
- * Read the /etc/default/nfs configuration file to determine if the
+ * Read the NFS SMF Parameters  to determine if the
  * client has been configured for a new min/max for the NFS version to
  * use.
  */
 static void
 read_default(void)
 {
-	char *defval;
+	char value[4];
 	int errno;
-	int tmp;
+	int tmp = 0, bufsz = 0, ret = 0;
 
-	/* Fail silently if error in opening the default nfs config file */
-	if ((defopen(NFSADMIN)) == 0) {
-		if ((defval = defread("NFS_CLIENT_VERSMIN=")) != NULL) {
-			errno = 0;
-			tmp = strtol(defval, (char **)NULL, 10);
-			if (errno == 0) {
-				vers_min_default = tmp;
-			}
+	/* Maximum number of bytes expected. */
+	bufsz = 4;
+	ret = nfs_smf_get_prop("client_versmin", value, DEFAULT_INSTANCE,
+	    SCF_TYPE_INTEGER, SVC_NFS_CLIENT, &bufsz);
+	if (ret == SA_OK) {
+		errno = 0;
+		tmp = strtol(value, (char **)NULL, 10);
+		if (errno == 0) {
+			vers_min_default = tmp;
 		}
-		if ((defval = defread("NFS_CLIENT_VERSMAX=")) != NULL) {
-			errno = 0;
-			tmp = strtol(defval, (char **)NULL, 10);
-			if (errno == 0) {
-				vers_max_default = tmp;
-			}
+	}
+
+	/* Maximum number of bytes expected. */
+	bufsz = 4;
+	ret = nfs_smf_get_prop("client_versmax", value, DEFAULT_INSTANCE,
+	    SCF_TYPE_INTEGER, SVC_NFS_CLIENT, &bufsz);
+	if (ret == SA_OK) {
+		errno = 0;
+		tmp = strtol(value, (char **)NULL, 10);
+		if (errno == 0) {
+			vers_max_default = tmp;
 		}
-		/* close defaults file */
-		defopen(NULL);
 	}
 }
 
--- a/usr/src/cmd/fs.d/nfs/mountd/Makefile	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/cmd/fs.d/nfs/mountd/Makefile	Wed Aug 11 17:11:30 2010 -0500
@@ -28,16 +28,16 @@
 
 include		../../Makefile.fstype
 
-COMMON	  =	$(FSLIB) nfs_sec.o sharetab.o daemon.o
+COMMON	  =	$(FSLIB) nfs_sec.o sharetab.o daemon.o smfcfg.o
 LOCAL	  =	mountd.o netgroup.o rmtab.o nfsauth.o \
 		nfsauth_xdr.o exportlist.o hashset.o nfs_cmd.o
 OBJS	  = 	$(LOCAL) $(COMMON)
 SRCS	  =	$(LOCAL:%.o=%.c) $(FSLIBSRC) ../lib/nfs_sec.c \
-		../lib/sharetab.c ../lib/daemon.c
+		../lib/sharetab.c ../lib/daemon.c ../lib/smfcfg.c
 DSRC	  =	mountd_dt.d
 DOBJ	  =	$(DSRC:%.d=%.o)
-LDLIBS	 +=	-lrpcsvc -lnsl -lbsm -lsocket -ltsnet -ltsol -lnvpair
-CPPFLAGS +=	-D_REENTRANT
+LDLIBS	 +=	-lrpcsvc -lnsl -lbsm -lsocket -ltsnet -ltsol -lnvpair -lscf
+CPPFLAGS +=	-D_REENTRANT -I../lib
 
 $(TYPEPROG):	$(OBJS)
 		$(COMPILE.d) -s $(DSRC) -o $(DOBJ) $(OBJS)
@@ -53,6 +53,9 @@
 daemon.o:	../lib/daemon.c
 		$(COMPILE.c) ../lib/daemon.c
 
+smfcfg.o:	../lib/smfcfg.c
+		$(COMPILE.c) ../lib/smfcfg.c
+
 lint:
 	$(LINT.c) $(SRCS) $(LDLIBS)
 
--- a/usr/src/cmd/fs.d/nfs/mountd/mountd.c	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/cmd/fs.d/nfs/mountd/mountd.c	Wed Aug 11 17:11:30 2010 -0500
@@ -76,8 +76,11 @@
 #include <sys/tsol/label_macro.h>
 #include <libtsnet.h>
 #include <sys/sdt.h>
+#include <libscf.h>
+#include <limits.h>
 #include <sys/nvpair.h>
 #include <attr.h>
+#include "smfcfg.h"
 
 extern int daemonize_init(void);
 extern void daemonize_fini(int fd);
@@ -361,6 +364,8 @@
 	bool_t	exclbind = TRUE;
 	bool_t	can_do_mlp;
 	long	thr_flags = (THR_NEW_LWP|THR_DAEMON);
+	char defval[4];
+	int defvers, ret, bufsz;
 
 	int	pipe_fd = -1;
 
@@ -412,33 +417,32 @@
 	/*
 	 * Read in the NFS version values from config file.
 	 */
-	if ((defopen(NFSADMIN)) == 0) {
-		char *defval;
-		int defvers;
+	bufsz = 4;
+	ret = nfs_smf_get_prop("server_versmin", defval, DEFAULT_INSTANCE,
+	    SCF_TYPE_INTEGER, NFSD, &bufsz);
+	if (ret == SA_OK) {
+		errno = 0;
+		defvers = strtol(defval, (char **)NULL, 10);
+		if (errno == 0) {
+			mount_vers_min = defvers;
+			/*
+			 * special because NFSv2 is
+			 * supported by mount v1 & v2
+			 */
+			if (defvers == NFS_VERSION)
+				mount_vers_min = MOUNTVERS;
+		}
+	}
 
-		if ((defval = defread("NFS_SERVER_VERSMIN=")) != NULL) {
-			errno = 0;
-			defvers = strtol(defval, (char **)NULL, 10);
-			if (errno == 0) {
-				mount_vers_min = defvers;
-				/*
-				 * special because NFSv2 is
-				 * supported by mount v1 & v2
-				 */
-				if (defvers == NFS_VERSION)
-					mount_vers_min = MOUNTVERS;
-			}
+	bufsz = 4;
+	ret = nfs_smf_get_prop("server_versmax", defval, DEFAULT_INSTANCE,
+	    SCF_TYPE_INTEGER, NFSD, &bufsz);
+	if (ret == SA_OK) {
+		errno = 0;
+		defvers = strtol(defval, (char **)NULL, 10);
+		if (errno == 0) {
+			mount_vers_max = defvers;
 		}
-		if ((defval = defread("NFS_SERVER_VERSMAX=")) != NULL) {
-			errno = 0;
-			defvers = strtol(defval, (char **)NULL, 10);
-			if (errno == 0) {
-				mount_vers_max = defvers;
-			}
-		}
-
-		/* close defaults file */
-		defopen(NULL);
 	}
 
 	/*
@@ -447,7 +451,7 @@
 	 * to start nfsauth service, so continue on regardless of values.
 	 */
 	if (mount_vers_min > mount_vers_max) {
-		fprintf(stderr, "NFS_SERVER_VERSMIN > NFS_SERVER_VERSMAX");
+		fprintf(stderr, "server_versmin > server_versmax");
 		mount_vers_max = mount_vers_min;
 	}
 	(void) setlocale(LC_ALL, "");
--- a/usr/src/cmd/fs.d/nfs/nfsd/Makefile	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/cmd/fs.d/nfs/nfsd/Makefile	Wed Aug 11 17:11:30 2010 -0500
@@ -19,10 +19,8 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
 #
-# ident	"%Z%%M%	%I%	%E% SMI"
 #
 
 FSTYPE=		nfs
@@ -31,13 +29,16 @@
 
 include		../../Makefile.fstype
 
-LDLIBS +=	-lnsl -lnvpair
+LDLIBS +=	-lnsl -lnvpair  -lscf
 
 LOCAL=		nfsd.o
-OBJS=		$(LOCAL) nfs_tbind.o thrpool.o daemon.o
-SRCS=		$(LOCAL:%.o=%.c) ../lib/nfs_tbind.c ../lib/thrpool.c ../lib/daemon.c
+OBJS=		$(LOCAL) nfs_tbind.o thrpool.o daemon.o smfcfg.o
+SRCS=		$(LOCAL:%.o=%.c) ../lib/nfs_tbind.c ../lib/thrpool.c ../lib/daemon.c \
+		../lib/smfcfg.c
+
 CPPFLAGS +=	-I../lib
 
+
 $(TYPEPROG):	$(OBJS)
 		$(CC) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS)
 		$(POST_PROCESS)
@@ -51,6 +52,9 @@
 daemon.o:	../lib/daemon.c
 		$(COMPILE.c) ../lib/daemon.c
 
+smfcfg.o:	../lib/smfcfg.c
+		$(COMPILE.c) ../lib/smfcfg.c
+
 clean:
 		$(RM) $(OBJS)
 
--- a/usr/src/cmd/fs.d/nfs/nfsd/nfsd.c	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/cmd/fs.d/nfs/nfsd/nfsd.c	Wed Aug 11 17:11:30 2010 -0500
@@ -62,6 +62,7 @@
 #include <netdir.h>
 #include <string.h>
 #include <unistd.h>
+#include <limits.h>
 #include <stropts.h>
 #include <sys/tihdr.h>
 #include <sys/wait.h>
@@ -73,8 +74,11 @@
 #include <rpcsvc/daemon_utils.h>
 #include <rpcsvc/nfs4_prot.h>
 #include <libnvpair.h>
+#include <libscf.h>
+#include <libshare.h>
 #include "nfs_tbind.h"
 #include "thrpool.h"
+#include "smfcfg.h"
 
 /* quiesce requests will be ignored if nfs_server_vers_max < QUIESCE_VERSMIN */
 #define	QUIESCE_VERSMIN	4
@@ -150,6 +154,8 @@
 	uint_t dss_npaths = 0;
 	char **dss_pathnames = NULL;
 	sigset_t sgset;
+	char name[PATH_MAX], value[PATH_MAX];
+	int ret, bufsz;
 
 	int pipe_fd = -1;
 
@@ -173,82 +179,92 @@
 	(void) enable_extended_FILE_stdio(-1, -1);
 
 	/*
-	 * Read in the values from config file first before we check
-	 * command line options so the options override the file.
+	 * Read in the values from SMF first before we check
+	 * command line options so the options override SMF values.
 	 */
-	if ((defopen(NFSADMIN)) == 0) {
-		if ((defval = defread("NFSD_MAX_CONNECTIONS=")) != NULL) {
-			errno = 0;
-			max_conns_allowed = strtol(defval, (char **)NULL, 10);
-			if (errno != 0) {
-				max_conns_allowed = -1;
-			}
+	bufsz = PATH_MAX;
+	ret = nfs_smf_get_prop("max_connections", value, DEFAULT_INSTANCE,
+	    SCF_TYPE_INTEGER, NFSD, &bufsz);
+	if (ret == SA_OK) {
+		errno = 0;
+		max_conns_allowed = strtol(value, (char **)NULL, 10);
+		if (errno != 0)
+			max_conns_allowed = -1;
+	}
+
+	bufsz = PATH_MAX;
+	ret = nfs_smf_get_prop("listen_backlog", value, DEFAULT_INSTANCE,
+	    SCF_TYPE_INTEGER, NFSD, &bufsz);
+	if (ret == SA_OK) {
+		errno = 0;
+		listen_backlog = strtol(value, (char **)NULL, 10);
+		if (errno != 0) {
+			listen_backlog = 32;
 		}
-		if ((defval = defread("NFSD_LISTEN_BACKLOG=")) != NULL) {
-			errno = 0;
-			listen_backlog = strtol(defval, (char **)NULL, 10);
-			if (errno != 0) {
-				listen_backlog = 32;
-			}
-		}
-		if ((defval = defread("NFSD_PROTOCOL=")) != NULL) {
-			df_proto = strdup(defval);
-			opt_cnt++;
-			if (strncasecmp("ALL", defval, 3) == 0) {
-				free(df_proto);
-				df_proto = NULL;
-				df_allflag = 1;
-			}
-		}
-		if ((defval = defread("NFSD_DEVICE=")) != NULL) {
-			df_provider = strdup(defval);
-			opt_cnt++;
+	}
+
+	bufsz = PATH_MAX;
+	ret = nfs_smf_get_prop("protocol", value, DEFAULT_INSTANCE,
+	    SCF_TYPE_ASTRING, NFSD, &bufsz);
+	if ((ret == SA_OK) && strlen(value) > 0) {
+		df_proto = strdup(value);
+		opt_cnt++;
+		if (strncasecmp("ALL", value, 3) == 0) {
+			free(df_proto);
+			df_proto = NULL;
+			df_allflag = 1;
 		}
-		if ((defval = defread("NFSD_SERVERS=")) != NULL) {
-			errno = 0;
-			maxservers = strtol(defval, (char **)NULL, 10);
-			if (errno != 0) {
-				maxservers = 1;
-			} else {
-				maxservers_set = 1;
-			}
-		}
-		if ((defval = defread("NFS_SERVER_VERSMIN=")) != NULL) {
-			errno = 0;
-			nfs_server_vers_min =
-			    strtol(defval, (char **)NULL, 10);
-			if (errno != 0) {
-				nfs_server_vers_min = NFS_VERSMIN_DEFAULT;
-			}
-		}
-		if ((defval = defread("NFS_SERVER_VERSMAX=")) != NULL) {
-			errno = 0;
-			nfs_server_vers_max =
-			    strtol(defval, (char **)NULL, 10);
-			if (errno != 0) {
-				nfs_server_vers_max = NFS_VERSMAX_DEFAULT;
-			}
-		}
-		if ((defval = defread("NFS_SERVER_DELEGATION=")) != NULL) {
-			if (strcmp(defval, "off") == 0) {
-				nfs_server_delegation = FALSE;
-			}
-		}
+	}
+
+	bufsz = PATH_MAX;
+	ret = nfs_smf_get_prop("device", value, DEFAULT_INSTANCE,
+	    SCF_TYPE_ASTRING, NFSD, &bufsz);
+	if ((ret == SA_OK) && strlen(value) > 0) {
+		df_provider = strdup(value);
+		opt_cnt++;
+	}
 
-		/* close defaults file */
-		defopen(NULL);
+	bufsz = PATH_MAX;
+	ret = nfs_smf_get_prop("servers", value, DEFAULT_INSTANCE,
+	    SCF_TYPE_INTEGER, NFSD, &bufsz);
+	if (ret == SA_OK) {
+		errno = 0;
+		maxservers = strtol(value, (char **)NULL, 10);
+		if (errno != 0)
+			maxservers = 1;
+		else
+			maxservers_set = 1;
 	}
 
+	bufsz = 4;
+	ret = nfs_smf_get_prop("server_versmin", value, DEFAULT_INSTANCE,
+	    SCF_TYPE_INTEGER, NFSD, &bufsz);
+	if (ret == SA_OK)
+		nfs_server_vers_min = strtol(value, (char **)NULL, 10);
+
+	bufsz = 4;
+	ret = nfs_smf_get_prop("server_versmax", value, DEFAULT_INSTANCE,
+	    SCF_TYPE_INTEGER, NFSD, &bufsz);
+	if (ret == SA_OK)
+		nfs_server_vers_max = strtol(value, (char **)NULL, 10);
+
+	bufsz = PATH_MAX;
+	ret = nfs_smf_get_prop("server_delegation", value, DEFAULT_INSTANCE,
+	    SCF_TYPE_ASTRING, NFSD, &bufsz);
+	if (ret == SA_OK)
+		if (strncasecmp(value, "off", 3) == 0)
+			nfs_server_delegation = FALSE;
+
 	/*
 	 * Conflict options error messages.
 	 */
 	if (opt_cnt > 1) {
 		(void) fprintf(stderr, "\nConflicting options, only one of "
 		    "the following options can be specified\n"
-		    "in " NFSADMIN ":\n"
-		    "\tNFSD_PROTOCOL=ALL\n"
-		    "\tNFSD_PROTOCOL=protocol\n"
-		    "\tNFSD_DEVICE=device\n\n");
+		    "in SMF:\n"
+		    "\tprotocol=ALL\n"
+		    "\tprotocol=protocol\n"
+		    "\tdevice=devicename\n\n");
 		usage();
 	}
 	opt_cnt = 0;
--- a/usr/src/cmd/fs.d/nfs/nfsmapid/nfsmapid_server.c	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/cmd/fs.d/nfs/nfsmapid/nfsmapid_server.c	Wed Aug 11 17:11:30 2010 -0500
@@ -19,8 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
 
@@ -800,7 +799,7 @@
 /*
  * Get the current NFS domain.
  *
- * If NFSMAPID_DOMAIN is set in /etc/default/nfs, then it is the NFS domain;
+ * If nfsmapid_domain is set in NFS SMF, then it is the NFS domain;
  * otherwise, the DNS domain is used.
  */
 void
--- a/usr/src/cmd/fs.d/nfs/svc/client.xml	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/cmd/fs.d/nfs/svc/client.xml	Wed Aug 11 17:11:30 2010 -0500
@@ -1,35 +1,31 @@
 <?xml version="1.0"?>
 <!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
 <!--
- Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
- Use is subject to license terms.
-
- CDDL HEADER START
+    CDDL HEADER START
 
- The contents of this file are subject to the terms of the
- Common Development and Distribution License, Version 1.0 only
- (the "License").  You may not use this file except in compliance
- with the License.
+    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.
+    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]
+    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
+    CDDL HEADER END
 
-	ident	"%Z%%M%	%I%	%E% SMI"
+    Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
 
-	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.
+    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='SUNWnfscr:nfs-client'>
@@ -39,10 +35,6 @@
 	type='service'
 	version='1'>
 
-	<create_default_instance enabled='false' />
-
-	<single_instance />
-
 	<dependency name='network'
 	    grouping='require_any'
 	    restart_on='error'
@@ -129,6 +121,12 @@
 		<propval name='duration' type='astring' value='transient' />
 	</property_group>
 
+	<instance name='default' enabled='false'>
+	  <property_group name='nfs-props' type='com.oracle.nfs,props'>
+	    <propval name='client_versmax' type='integer' value='4'/>
+	    <propval name='client_versmin' type='integer' value='2'/>
+	  </property_group>
+	</instance>
 	<stability value='Unstable' />
 
 	<template>
--- a/usr/src/cmd/fs.d/nfs/svc/mapid.xml	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/cmd/fs.d/nfs/svc/mapid.xml	Wed Aug 11 17:11:30 2010 -0500
@@ -1,38 +1,35 @@
 <?xml version="1.0"?>
 <!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
 <!--
- Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
- Use is subject to license terms.
-
- CDDL HEADER START
+    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.
+    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.
+    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]
+    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
+    CDDL HEADER END
 
-	ident	"%Z%%M%	%I%	%E% SMI"
+    Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 
 
-	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.
+    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.
 
-	Note: if this service is modified to consist of anything other
-	than a single instance named 'default', you must make changes to
-	$SRC/head/rpcsvc/daemon_utils.h and libnsl:open_daemon_lock().
+    Note: if this service is modified to consist of anything other
+    than a single instance named 'default', you must make changes to
+    $SRC/head/rpcsvc/daemon_utils.h and libnsl:open_daemon_lock().
 -->
 
 <service_bundle type='manifest' name='SUNWnfscr:nfs-mapid'>
@@ -42,10 +39,6 @@
 	type='service'
 	version='1'>
 
-	<create_default_instance enabled='false' />
-
-	<single_instance />
-
 	<dependency name='network'
 	    grouping='require_any'
 	    restart_on='error'
@@ -103,6 +96,11 @@
 		<stability value='Evolving' />
 		<propval name='auto_enable' type='boolean' value='true' />
 	</property_group>
+	<instance name='default' enabled='false'>
+	  <property_group name='nfs-props' type='com.oracle.nfs,props'>
+	    <propval name='nfsmapid_domain' type='astring' value=''/>
+	  </property_group>
+	</instance>
 
 	<stability value='Stable' />
 
--- a/usr/src/cmd/fs.d/nfs/svc/nfs-server	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/cmd/fs.d/nfs/svc/nfs-server	Wed Aug 11 17:11:30 2010 -0500
@@ -20,8 +20,7 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
 #
 
 # Start/stop processes required for server NFS
@@ -93,7 +92,7 @@
 		startnfsd=1
 	fi
 
-	# Options for nfsd are now set in /etc/default/nfs
+	# Options for nfsd are now set in SMF
 	if [ $startnfsd -ne 0 ]; then
 		/usr/lib/nfs/mountd
 		rc=$?
--- a/usr/src/cmd/fs.d/nfs/svc/nlockmgr.xml	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/cmd/fs.d/nfs/svc/nlockmgr.xml	Wed Aug 11 17:11:30 2010 -0500
@@ -1,9 +1,6 @@
 <?xml version="1.0"?>
 <!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
 <!--
- Copyright 2009 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
@@ -23,6 +20,8 @@
 
  CDDL HEADER END
 
+	Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+
 	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
@@ -40,10 +39,6 @@
 	type='service'
 	version='1'>
 
-	<create_default_instance enabled='false' />
-
-	<single_instance />
-
 	<dependency name='network'
 	    grouping='require_any'
 	    restart_on='error'
@@ -95,7 +90,14 @@
 		<stability value='Evolving' />
 		<propval name='auto_enable' type='boolean' value='true' />
 	</property_group>
-
+	<instance name='default' enabled='false'>
+	  <property_group name='nfs-props' type='com.oracle.nfs,props'>
+	    <propval name='grace_period' type='integer' value='90'/>
+	    <propval name='lockd_listen_backlog' type='integer' value='32'/>
+	    <propval name='lockd_retransmit_timeout' type='integer' value='5'/>
+	    <propval name='lockd_servers' type='integer' value='20'/>
+	  </property_group>
+	</instance>
 	<stability value='Stable' />
 
 	<template>
--- a/usr/src/cmd/fs.d/nfs/svc/server.xml	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/cmd/fs.d/nfs/svc/server.xml	Wed Aug 11 17:11:30 2010 -0500
@@ -21,8 +21,7 @@
 
  CDDL HEADER END
 
-	Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
-	Use is subject to license terms.
+	Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
 
 	NOTE:  This service manifest is not editable; its contents will
 	be overwritten by package or patch operations, including
@@ -41,10 +40,6 @@
 	type='service'
 	version='1'>
 
-	<create_default_instance enabled='false' />
-
-	<single_instance />
-
 	<dependency name='network'
 	    grouping='require_any'
 	    restart_on='error'
@@ -162,6 +157,18 @@
 		<propval name='value_authorization' type='astring'
 			value='solaris.smf.value.firewall.config' />
 	</property_group>
+	<instance name='default' enabled='false'>
+	 <property_group name='nfs-props' type='com.oracle.nfs,props'>
+	   <propval name='device' type='astring' value=''/>
+	   <propval name='listen_backlog' type='integer' value='32'/>
+	   <propval name='max_connections' type='integer' value='-1'/>
+	   <propval name='protocol' type='astring' value='ALL'/>
+	   <propval name='server_delegation' type='astring' value='on'/>
+	   <propval name='server_versmax' type='integer' value='4'/>
+	   <propval name='server_versmin' type='integer' value='2'/>
+	   <propval name='servers' type='integer' value='16'/>
+	 </property_group>
+	</instance>
 
 	<stability value='Stable' />
 
--- a/usr/src/cmd/svc/milestone/net-loc	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/cmd/svc/milestone/net-loc	Wed Aug 11 17:11:30 2010 -0500
@@ -509,45 +509,9 @@
 }
 
 #
-# update_nfs_file <new nfsv4 domain>
-#
-update_nfs_file () {
-	domain=$1
-	file=/etc/default/nfs
-
-	#
-	# For non-commented-out lines that set NFSMAPID_DOMAIN:
-	#	if not previously added by nwam, comment out with a note
-	#	if previously added by nwam, remove
-	# For commented-out lines that set NFSMAPID_DOMAIN:
-	#	if not commented out by NWAM, leave as-is
-	#	if commented out by NWAM, remove
-	# All other lines: leave as-is
-	#
-	$NAWK ' \
-		$0 ~ /^NFSMAPID_DOMAIN=/ {
-			if (index($0, "# Added by NWAM") == 0)
-				printf("#%s # Commented out by NWAM\n", $0);
-		}
-		$0 ~ /^#NFSMAPID_DOMAIN=/ {
-			if ($0 !~ /"# Commented out by NWAM"/)
-				printf("%s\n", $0);
-		}
-		$1 !~ /NFSMAPID_DOMAIN=/ {
-			printf("%s\n", $0);
-		}' $file >$file.$$
-
-	# Now add the desired value
-	echo "NFSMAPID_DOMAIN=$domain # Added by NWAM" >> $file.$$
-
-	# Finally, copy our working version to the real thing
-	$MV -f $file.$$ $file
-}
-
-#
 # do_nfsv4 <location>
 #
-# Updates NFSv4 domain for location
+# Updates NFSv4 domain for location in SMF
 #
 # Returns 0 on success, 1 on failure
 #
@@ -556,7 +520,8 @@
 
 	nfsv4domain=`nwam_get_loc_prop $loc nfsv4-domain`
 	if [ $? -eq 0 ]; then
-		update_nfs_file $nfsv4domain
+		set_smf_prop $MAPID_FMRI \
+		    nfs-props/nfsmapid_domain $nfsv4domain
 		start_svc $MAPID_FMRI
 	else
 		stop_svc $MAPID_FMRI
--- a/usr/src/cmd/svc/milestone/net-nwam	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/cmd/svc/milestone/net-nwam	Wed Aug 11 17:11:30 2010 -0500
@@ -34,6 +34,7 @@
 NET_PHYS_FMRI="svc:/network/physical:default"
 NET_NWAM_FMRI="svc:/network/physical:nwam"
 NET_LOC_FMRI="svc:/network/location:default"
+NFS_MAPID_FMRI="svc:/network/nfs/mapid:default"
 
 #
 # Default *.conf files
@@ -233,11 +234,10 @@
 	    $CREATE_LOC_LEGACY_FILE
 	write_loc_prop "default-domain" $DEFAULT_DOMAIN $CREATE_LOC_LEGACY_FILE
 
-	# Retrieve NFSv4 domain.
-	if [ -f /etc/default/nfs ]; then
-		copy_to_legacy_loc /etc/default/nfs
-		NFS_DOMAIN=`$NAWK '/^NFSMAPID_DOMAIN.*/ { FS="=" ; print $2 }' \
-		    < /etc/default/nfs`
+	# Retrieve NFSv4 domain from SMF.
+	if service_is_enabled $NFS_MAPID_FMRI; then
+		NFS_DOMAIN=`get_smf_prop NFS_MAPID_FMRI \
+		    nfs-props/nfsmapid_domain`    
 		write_loc_prop "nfsv4-domain" \
 		    $NFS_DOMAIN $CREATE_LOC_LEGACY_FILE
 	fi
@@ -377,8 +377,14 @@
 		$SVCADM enable ldap/client
 	fi
 
-	# Copy back nfs file
-        copy_from_legacy_loc /etc/default/nfs
+	# Copy back nfs NFSMAPID_DOMAIN
+	NFSMAPID_DOMAIN=`nwam_get_loc_prop Legacy nfsv4-domain`
+	if [ -n "$NFSMAPID_DOMAIN" ]; then
+		set_smf_prop $NFS_MAPID_FMRI \
+		    nfs-props/nfsmapid_domain $NFSMAPID_DOMAIN
+		$SVCADM refresh $NFS_MAPID_FMRI
+		$SVCADM enable $NFS_MAPID_FMRI
+	fi
 
 	# IPFilter, IPsec, and IKE
 	ipf_file=`nwam_get_loc_prop Legacy ipfilter-config-file`
--- a/usr/src/lib/libmapid/Makefile.com	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/lib/libmapid/Makefile.com	Wed Aug 11 17:11:30 2010 -0500
@@ -19,15 +19,17 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
 #
-# ident	"%Z%%M%	%I%	%E% SMI"
 #
 
 LIBRARY =	libmapid.a
 VERS	=	.1
-OBJECTS =	mapid.o
+SMF_DIR	=	$(SRC)/cmd/fs.d/nfs/lib
+
+LIBOBJS	=	mapid.o
+OTHOBJS	=	smfcfg.o
+OBJECTS =	$(LIBOBJS) $(OTHOBJS)
 
 include $(SRC)/lib/Makefile.lib
 
@@ -43,17 +45,29 @@
 # SRCS is defined to be $(OBJECTS:%.o=$(SRCDIR)/%.c)
 #
 SRCDIR	=	../common
-$(LINTLIB) :=	SRCS = $(SRCDIR)/$(LINTSRC)
+LIBSRCS	= $(LIBOBJS:%.o=$(SRCDIR)/%.c)
+$(LINTLIB) := SRCS = $(LINTSRC:%=$(SRCDIR)/%)
+lintcheck  :=	SRCS = $(LIBSRCS)
 
-LDLIBS	+=	-lresolv -lc
+LDLIBS	+=	-lresolv -lc -lscf
 
 CFLAGS	+=	$(CCVERBOSE)
-CPPFLAGS+=	-I$(SRCDIR) -D_REENTRANT
+CPPFLAGS +=	-I$(SRCDIR) -I$(SMF_DIR) -D_REENTRANT
+
 
 .KEEP_STATE:
 
-all:
+all:  $(LIBS)
+
+install: $(ROOTLIBDIR) all
+
+lint:	$(LINTLIB) lintcheck
 
-lint: lintcheck
+pics/%.o:	$(SMF_DIR)/%.c
+	$(COMPILE.c) -o $@ $<
+	$(POST_PROCESS_O)
 
-include $(SRC)/lib/Makefile.targ
+$(ROOTLIBDIR):
+	$(INS.dir)
+
+include ../../Makefile.targ
--- a/usr/src/lib/libmapid/common/mapid.c	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/lib/libmapid/common/mapid.c	Wed Aug 11 17:11:30 2010 -0500
@@ -19,8 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
 /*
@@ -68,6 +67,12 @@
  */
 #define	__LIBMAPID_IMPL
 #include <nfs/mapid.h>
+#include <libshare.h>
+#include <libscf.h>
+#include <limits.h>
+#include <rpcsvc/daemon_utils.h>
+#include "smfcfg.h"
+
 #pragma	init(_lib_init)
 #pragma	fini(_lib_fini)
 
@@ -945,37 +950,21 @@
 static void
 get_nfs_domain(void)
 {
-	char		*ndomain;
-	timestruc_t	 ntime;
-	void	*defp;
+	char value[NS_MAXCDNAME];
+	int	ret, bufsz = NS_MAXCDNAME;
 
 	/*
-	 * If we can't get stats for the config file, then
-	 * zap the NFS domain info.  If mtime hasn't changed,
-	 * then there's no work to do, so just return.
+	 * Get NFSMAPID_DOMAIN property value from SMF.
 	 */
-	if (get_mtime(NFSADMIN, &ntime) != 0) {
-		ZAP_DOMAIN(nfs);
-		return;
-	}
-
-	if (TIMESTRUC_EQ(ntime, nfs_mtime))
-		return;
-
-	/*
-	 * Get NFSMAPID_DOMAIN value from /etc/default/nfs for now.
-	 * Note: defread_r() returns a ptr to libc internal malloc.
-	 */
-	if ((defp = defopen_r(NFSADMIN)) != NULL) {
-		char	*dp = NULL;
-#ifdef	DEBUG
-		char	*whoami = "get_nfs_domain";
-		char	 orig[NS_MAXCDNAME] = {0};
-#endif
-		ndomain = defread_r("NFSMAPID_DOMAIN=", defp);
-#ifdef	DEBUG
-		if (ndomain)
-			(void) strncpy(orig, ndomain, NS_MAXCDNAME);
+	bzero(value, NS_MAXCDNAME);
+	ret = nfs_smf_get_prop("nfsmapid_domain", value, DEFAULT_INSTANCE,
+	    SCF_TYPE_ASTRING, NFSMAPID, &bufsz);
+	if (ret == SA_OK && *value != NULL) {
+		char *dp = NULL;
+#ifdef DEBUG
+		char    *whoami = "get_nfs_domain";
+		char	orig[NS_MAXCDNAME] = {0};
+		(void) strncpy(orig, value, NS_MAXCDNAME);
 #endif
 		/*
 		 * NFSMAPID_DOMAIN was set, so it's time for validation. If
@@ -983,29 +972,25 @@
 		 * bail (syslog in DEBUG). We make nfsmapid more a bit
 		 * more forgiving of trailing and leading white space.
 		 */
-		if ((dp = trim_wspace(ndomain)) != NULL) {
+		if ((dp = trim_wspace(value)) != NULL) {
 			if (mapid_stdchk_domain(dp) > 0) {
 				nfs_domain_len = strlen(dp);
 				(void) strncpy(nfs_domain, dp, NS_MAXCDNAME);
 				nfs_domain[NS_MAXCDNAME] = '\0';
-				nfs_mtime = ntime;
-				defclose_r(defp);
 				return;
 			}
 		}
-		defclose_r(defp);
 #ifdef	DEBUG
 		if (orig[0] != '\0') {
 			syslog(LOG_ERR, gettext("%s: Invalid domain name \"%s\""
-			    " found in configuration file."), whoami, orig);
+			    " found in SMF."), whoami, orig);
 		}
 #endif
 	}
-
 	/*
-	 * So the NFS config file changed but it couldn't be opened or
-	 * it didn't specify NFSMAPID_DOMAIN or it specified an invalid
-	 * NFSMAPID_DOMAIN.  Time to zap current NFS domain info.
+	 * So the NFS SMF parameter nfsmapid_domain cannot be obtained or
+	 * there is an invalid nfsmapid_domain property value.
+	 * Time to zap current NFS domain info.
 	 */
 	ZAP_DOMAIN(nfs);
 }
--- a/usr/src/lib/libmapid/common/mapid.h	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/lib/libmapid/common/mapid.h	Wed Aug 11 17:11:30 2010 -0500
@@ -19,8 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
 #ifndef	_MAPID_H
@@ -150,7 +149,7 @@
  *			domain configured for use in decoding/encoding
  *			outbound and inbound attr strings, accordingly.
  *
- * nfs_domain:		If /etc/default/nfs NFSMAPID_DOMAIN var
+ * nfs_domain:		If nfsmapid_domain var in SMF
  *			has been set, nfs_domain will hold this
  *			value for the duration of the instance;
  *			If the value ever changes, the change is
--- a/usr/src/lib/libshare/Makefile	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/lib/libshare/Makefile	Wed Aug 11 17:11:30 2010 -0500
@@ -19,10 +19,8 @@
 # CDDL HEADER END
 #
 #
-# ident	"%Z%%M%	%I%	%E% SMI"
 #
-# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
 #
 
 include ../Makefile.lib
@@ -35,7 +33,7 @@
 
 # Add plugin module directories here. They need to build after the libshare
 # objects are built.
-PLUGINS =	nfs smb smbfs
+PLUGINS =	nfs smb smbfs autofs
 $(PLUGINS):	$(MACHS)
 
 SUBDIRS =	$(MACHS) $(PLUGINS)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libshare/autofs/Makefile	Wed Aug 11 17:11:30 2010 -0500
@@ -0,0 +1,54 @@
+#
+# 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 (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+include ../../Makefile.lib
+
+SUBDIRS =	$(MACH)
+$(BUILD64)SUBDIRS += $(MACH64)
+
+MSGFILES = 	libshare_autofs.c
+POFILE  =	libshare_autofs.po
+
+all	:=	TARGET= all
+clean	:=	TARGET= clean
+clobber	:=	TARGET= clobber
+install	:=	TARGET= install
+lint	:=	TARGET= lint
+
+.KEEP_STATE:
+
+all clean clobber install lint:	$(SUBDIRS)
+
+$(POFILE): 	$(MSGFILES)
+	$(BUILDPO.msgfiles)
+
+_msg:	$(MSGDOMAINPOFILE)
+
+$(SUBDIRS):	FRC
+	@cd $@; pwd; $(MAKE) $(TARGET)
+
+FRC:
+
+include ../../Makefile.targ
+include ../../../Makefile.msg.targ
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libshare/autofs/Makefile.com	Wed Aug 11 17:11:30 2010 -0500
@@ -0,0 +1,70 @@
+#
+# 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 (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+#
+
+LIBRARY =	libshare_autofs.a
+VERS =		.1
+AUTOFSSMFLIB_DIR = $(SRC)/cmd/fs.d/nfs/lib
+
+LIBOBJS =	libshare_autofs.o
+OTHOBJS =	smfcfg.o
+OBJECTS =	$(LIBOBJS) $(OTHOBJS)
+
+include ../../../Makefile.lib
+
+ROOTLIBDIR =	$(ROOT)/usr/lib/fs/autofs
+ROOTLIBDIR64 =	$(ROOT)/usr/lib/fs/autofs/$(MACH64)
+
+LIBSRCS = $(LIBOBJS:%.o=$(SRCDIR)/%.c)
+# we don't want to lint the sources for OTHOBJS since they are pre-existing files
+# that are not lint free.
+lintcheck := SRCS = $(LIBSRCS)
+
+LIBS =		$(DYNLIB)
+LDLIBS +=	-lshare -lscf -lumem -lc -lxml2
+
+#add nfs/lib directory as part of the include path
+CFLAGS +=	$(CCVERBOSE)
+CPPFLAGS +=	-D_REENTRANT -I$(AUTOFSSMFLIB_DIR) -I/usr/include/libxml2 \
+			-I$(SRCDIR)../common
+
+.KEEP_STATE:
+
+all: $(LIBS)
+
+install: $(ROOTLIBDIR) $(ROOTLIBDIR64) all
+
+lint: lintcheck
+
+pics/%.o:       $(AUTOFSSMFLIB_DIR)/%.c
+	$(COMPILE.c) -o $@ $<
+	$(POST_PROCESS_O)
+
+$(ROOTLIBDIR):
+	$(INS.dir)
+ 
+$(ROOTLIBDIR64):
+	$(INS.dir)
+
+include ../../../Makefile.targ
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libshare/autofs/amd64/Makefile	Wed Aug 11 17:11:30 2010 -0500
@@ -0,0 +1,29 @@
+#
+# 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 (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+include ../Makefile.com
+include ../../../Makefile.lib.64
+
+install: all $(ROOTLIBS64) $(ROOTLINKS64)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libshare/autofs/i386/Makefile	Wed Aug 11 17:11:30 2010 -0500
@@ -0,0 +1,28 @@
+#
+# 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 (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+include ../Makefile.com
+
+install: all $(ROOTLIBS) $(ROOTLINKS)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libshare/autofs/libshare_autofs.c	Wed Aug 11 17:11:30 2010 -0500
@@ -0,0 +1,600 @@
+/*
+ * 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 (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/*
+ * AUTOMOUNT specific functions
+ */
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <zone.h>
+#include <errno.h>
+#include <locale.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <syslog.h>
+#include "libshare.h"
+#include "libshare_impl.h"
+#include <pwd.h>
+#include <limits.h>
+#include <libscf.h>
+#include <strings.h>
+#include <libdlpi.h>
+#include "smfcfg.h"
+
+
+static int autofs_init();
+static void autofs_fini();
+static int autofs_validate_property(sa_handle_t, sa_property_t, sa_optionset_t);
+static int autofs_set_proto_prop(sa_property_t);
+static sa_protocol_properties_t autofs_get_proto_set();
+static char *autofs_get_status();
+static uint64_t autofs_features();
+
+static int initautofsprotofromsmf();
+static int true_false_validator(int index, char *value);
+static int strlen_validator(int index, char *value);
+static int range_check_validator(int index, char *value);
+
+/*
+ * ops vector that provides the protocol specific info and operations
+ * for share management.
+ */
+struct sa_plugin_ops sa_plugin_ops = {
+	SA_PLUGIN_VERSION,
+	"autofs",
+	autofs_init, 		/* Init autofs */
+	autofs_fini, 		/* Fini autofs */
+	NULL,			/* Start Sharing */
+	NULL,			/* stop sharing */
+	autofs_validate_property,
+	NULL,			/* valid_space */
+	NULL,			/* security_prop */
+	NULL,			/* parse optstring */
+	NULL,			/* format optstring */
+	autofs_set_proto_prop,	/* Set properties */
+	autofs_get_proto_set,	/* get properties */
+	autofs_get_status,	/* get status */
+	NULL,			/* space_alias */
+	NULL,			/* update_legacy */
+	NULL,			/* delete_legacy */
+	NULL,			/* change notify */
+	NULL,			/* enable resource */
+	NULL,			/* disable resource */
+	autofs_features,	/* features */
+	NULL,			/* transient shares */
+	NULL,			/* notify resource */
+	NULL,			/* rename resource */
+	NULL,			/* run_command */
+	NULL,			/* command_help */
+	NULL			/* delete_proto_section */
+};
+
+
+static sa_protocol_properties_t protoset;
+
+#define	AUTOMOUNT_VERBOSE_DEFAULT	0
+#define	AUTOMOUNTD_VERBOSE_DEFAULT	0
+#define	AUTOMOUNT_NOBROWSE_DEFAULT	0
+#define	AUTOMOUNT_TIMEOUT_DEFAULT	600
+#define	AUTOMOUNT_TRACE_DEFAULT		0
+/*
+ * Protocol Management functions
+ */
+struct proto_option_defs {
+	char *tag;
+	char *name;	/* display name -- remove protocol identifier */
+	int index;
+	scf_type_t type;
+	union {
+	    int intval;
+	    char *string;
+	} defvalue;
+	int32_t minval;
+	int32_t maxval;
+	int (*check)(int, char *);
+} proto_options[] = {
+#define	PROTO_OPT_AUTOMOUNT_TIMEOUT	0
+	{ "timeout",
+	    "timeout",	PROTO_OPT_AUTOMOUNT_TIMEOUT,
+	    SCF_TYPE_INTEGER, AUTOMOUNT_TIMEOUT_DEFAULT,
+	    1, INT32_MAX, range_check_validator},
+#define	PROTO_OPT_AUTOMOUNT_VERBOSE	1
+	{ "automount_verbose",
+	    "automount_verbose", PROTO_OPT_AUTOMOUNT_VERBOSE,
+	    SCF_TYPE_BOOLEAN, AUTOMOUNT_VERBOSE_DEFAULT, 0, 1,
+	    true_false_validator},
+#define	PROTO_OPT_AUTOMOUNTD_VERBOSE	2
+	{ "automountd_verbose",
+	    "automountd_verbose", PROTO_OPT_AUTOMOUNTD_VERBOSE,
+	    SCF_TYPE_BOOLEAN, AUTOMOUNTD_VERBOSE_DEFAULT, 0, 1,
+	    true_false_validator},
+#define	PROTO_OPT_AUTOMOUNTD_NOBROWSE	3
+	{ "nobrowse",
+	    "nobrowse", PROTO_OPT_AUTOMOUNTD_NOBROWSE, SCF_TYPE_BOOLEAN,
+	    AUTOMOUNT_NOBROWSE_DEFAULT, 0, 1, true_false_validator},
+#define	PROTO_OPT_AUTOMOUNTD_TRACE	4
+	{ "trace",
+	    "trace", PROTO_OPT_AUTOMOUNTD_TRACE,
+	    SCF_TYPE_INTEGER, AUTOMOUNT_TRACE_DEFAULT,
+	    0, 20, range_check_validator},
+#define	PROTO_OPT_AUTOMOUNTD_ENV	5
+	{ "environment",
+	    "environment", PROTO_OPT_AUTOMOUNTD_ENV, SCF_TYPE_ASTRING,
+	    NULL, 0, 1024, strlen_validator},
+	{NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
+};
+
+#define	AUTOFS_PROP_MAX	(sizeof (proto_options) / sizeof (proto_options[0]))
+
+static void
+add_defaults()
+{
+	int i;
+	char number[MAXDIGITS];
+
+	for (i = 0; proto_options[i].tag != NULL; i++) {
+		sa_property_t prop;
+		prop = sa_get_protocol_property(protoset,
+		    proto_options[i].name);
+		if (prop == NULL) {
+			/* add the default value */
+			switch (proto_options[i].type) {
+			case SCF_TYPE_INTEGER:
+				(void) snprintf(number, sizeof (number), "%d",
+				    proto_options[i].defvalue.intval);
+				prop = sa_create_property(proto_options[i].name,
+				    number);
+				break;
+
+			case SCF_TYPE_BOOLEAN:
+				prop = sa_create_property(proto_options[i].name,
+				    proto_options[i].defvalue.intval ?
+				    "true" : "false");
+				break;
+
+			default:
+				/* treat as strings of zero length */
+				prop = sa_create_property(proto_options[i].name,
+				    "");
+				break;
+			}
+			if (prop != NULL)
+				(void) sa_add_protocol_property(protoset, prop);
+		}
+	}
+}
+
+static int
+autofs_init()
+{
+	int ret = SA_OK;
+
+	if (sa_plugin_ops.sa_init != autofs_init) {
+		(void) printf(dgettext(TEXT_DOMAIN,
+		    "AUTOFS plugin not installed properly\n"));
+		return (SA_CONFIG_ERR);
+	}
+
+	ret = initautofsprotofromsmf();
+	if (ret != SA_OK) {
+		(void) printf(dgettext(TEXT_DOMAIN,
+		    "AUTOFS plugin problem with SMF properties: %s\n"),
+		    sa_errorstr(ret));
+		ret = SA_OK;
+	}
+	add_defaults();
+	return (ret);
+}
+
+static void
+free_protoprops()
+{
+	if (protoset != NULL) {
+		xmlFreeNode(protoset);
+		protoset = NULL;
+	}
+}
+
+static void
+autofs_fini()
+{
+	free_protoprops();
+}
+
+static int
+findprotoopt(char *propname)
+{
+	int i;
+
+	for (i = 0; proto_options[i].tag != NULL; i++)
+		if (strcmp(proto_options[i].name, propname) == 0)
+			return (i);
+	return (-1);
+}
+
+static int
+autofs_validate_property(sa_handle_t handle, sa_property_t property,
+    sa_optionset_t parent)
+{
+	int ret = SA_OK;
+	char *propname;
+	int optionindex;
+	char *value;
+
+#ifdef lint
+	handle = handle;
+	parent = parent;
+#endif
+	propname = sa_get_property(property, "type");
+	if (propname == NULL)
+		return (SA_NO_SUCH_PROP);
+
+	if ((optionindex = findprotoopt(propname)) < 0)
+		ret = SA_NO_SUCH_PROP;
+
+	if (ret != SA_OK) {
+		if (propname != NULL)
+			sa_free_attr_string(propname);
+		return (ret);
+	}
+
+	value = sa_get_property_attr(property, "value");
+	if (value != NULL) {
+		/*
+		 * If any property is added to AUTOFS, which is a different
+		 * type than the below list, a case needs to be added for that
+		 * to check the values. For now AUTOFS type are just integers,
+		 * string and boolean properties. Just taking care of them.
+		 */
+		switch (proto_options[optionindex].type) {
+		case SCF_TYPE_INTEGER:
+		case SCF_TYPE_BOOLEAN:
+		case SCF_TYPE_ASTRING:
+			ret = proto_options[optionindex].check(optionindex,
+			    value);
+			break;
+		default:
+			break;
+		}
+	}
+
+	/* Free the value */
+	if (value != NULL)
+		sa_free_attr_string(value);
+	if (propname != NULL)
+		sa_free_attr_string(propname);
+	return (ret);
+}
+
+/*
+ * service_in_state(service, chkstate)
+ *
+ * Want to know if the specified service is in the desired state
+ * (chkstate) or not. Return true (1) if it is and false (0) if it
+ * isn't.
+ */
+static int
+service_in_state(char *service, const char *chkstate)
+{
+	char *state;
+	int ret = B_FALSE;
+
+	state = smf_get_state(service);
+	if (state != NULL) {
+		/* got the state so get the equality for the return value */
+		ret = strcmp(state, chkstate) == 0 ? B_TRUE : B_FALSE;
+		free(state);
+	}
+	return (ret);
+}
+
+static void
+restart_service(char *service)
+{
+	int ret = -1;
+
+	/*
+	 * Only attempt to restart the service if it is
+	 * currently running. In the future, it may be
+	 * desirable to use smf_refresh_instance if the AUTOFS
+	 * services ever implement the refresh method.
+	 */
+	if (service_in_state(service, SCF_STATE_STRING_ONLINE)) {
+		ret = smf_restart_instance(service);
+		/*
+		 * There are only a few SMF errors at this point, but
+		 * it is also possible that a bad value may have put
+		 * the service into maintenance if there wasn't an
+		 * SMF level error.
+		 */
+		if (ret != 0) {
+			(void) fprintf(stderr,
+			    dgettext(TEXT_DOMAIN,
+			    "%s failed to restart: %s\n"),
+			    scf_strerror(scf_error()));
+		} else {
+			/*
+			 * Check whether it has gone to "maintenance"
+			 * mode or not. Maintenance implies something
+			 * went wrong.
+			 */
+			if (service_in_state(service,
+			    SCF_STATE_STRING_MAINT)) {
+				(void) fprintf(stderr,
+				    dgettext(TEXT_DOMAIN,
+				    "%s failed to restart\n"),
+				    service);
+			}
+		}
+	}
+}
+
+static int
+is_a_number(char *number)
+{
+	int ret = 1;
+	int hex = 0;
+
+	if (strncmp(number, "0x", 2) == 0) {
+		number += 2;
+		hex = 1;
+	} else if (*number == '-') {
+		number++; /* skip the minus */
+	}
+	while (ret == 1 && *number != '\0') {
+		if (hex) {
+			ret = isxdigit(*number++);
+		} else {
+			ret = isdigit(*number++);
+		}
+	}
+	return (ret);
+}
+
+/*
+ * fixcaselower(str)
+ *
+ * convert a string to lower case (inplace).
+ */
+
+static void
+fixcaselower(char *str)
+{
+	while (*str) {
+		*str = tolower(*str);
+		str++;
+	}
+}
+
+/*
+ * skipwhitespace(str)
+ *
+ * Skip leading white space. It is assumed that it is called with a
+ * valid pointer.
+ */
+static char *
+skipwhitespace(char *str)
+{
+	while (*str && isspace(*str))
+		str++;
+
+	return (str);
+}
+
+/*
+ * extractprop()
+ *
+ * Extract the property and value out of the line and create the
+ * property in the optionset.
+ */
+static int
+extractprop(char *name, char *value)
+{
+	sa_property_t prop;
+	int index;
+	int ret = SA_OK;
+	/*
+	 * Remove any leading
+	 * white space.
+	 */
+	name = skipwhitespace(name);
+
+	index = findprotoopt(name);
+	if (index >= 0) {
+		fixcaselower(name);
+		prop = sa_create_property(proto_options[index].name, value);
+		if (prop != NULL)
+			ret = sa_add_protocol_property(protoset, prop);
+		else
+			ret = SA_NO_MEMORY;
+	}
+	return (ret);
+}
+
+static int
+initautofsprotofromsmf(void)
+{
+	char name[PATH_MAX];
+	char value[PATH_MAX];
+	int ret = SA_OK, bufsz = 0, i;
+	char *instance = NULL;
+	scf_type_t sctype;
+
+	protoset = sa_create_protocol_properties("autofs");
+	if (protoset != NULL) {
+		for (i = 0; proto_options[i].tag != NULL; i++) {
+			bzero(value, PATH_MAX);
+			(void) strncpy(name, proto_options[i].name, PATH_MAX);
+			sctype = proto_options[i].type;
+			bufsz = PATH_MAX;
+			ret = autofs_smf_get_prop(name, value,
+			    instance, sctype, AUTOFS_FMRI, &bufsz);
+			if (ret == SA_OK) {
+				ret = extractprop(name, value);
+			}
+		}
+	} else {
+		ret = SA_NO_MEMORY;
+	}
+	return (ret);
+}
+
+static int
+range_check_validator(int index, char *value)
+{
+	int ret = SA_OK;
+	if (!is_a_number(value)) {
+		ret = SA_BAD_VALUE;
+	} else {
+		int val;
+		errno = 0;
+		val = strtoul(value, NULL, 0);
+		if (errno != 0)
+			return (SA_BAD_VALUE);
+
+		if (val < proto_options[index].minval ||
+		    val > proto_options[index].maxval)
+			ret = SA_BAD_VALUE;
+	}
+	return (ret);
+}
+
+static int
+true_false_validator(int index, char *value)
+{
+
+#ifdef lint
+	index = index;
+#endif
+	if ((strcasecmp(value, "true") == 0) ||
+	    (strcasecmp(value, "on") == 0) ||
+	    (strcasecmp(value, "yes") == 0) ||
+	    (strcmp(value, "1") == 0) ||
+	    (strcasecmp(value, "false") == 0) ||
+	    (strcasecmp(value, "off") == 0) ||
+	    (strcasecmp(value, "no") == 0) ||
+	    (strcmp(value, "0") == 0)) {
+		return (SA_OK);
+	}
+	return (SA_BAD_VALUE);
+}
+
+static int
+strlen_validator(int index, char *value)
+{
+	int ret = SA_OK;
+	if (value == NULL) {
+		if (proto_options[index].minval == 0) {
+			return (ret);
+		} else {
+			return (SA_BAD_VALUE);
+		}
+	}
+	if (strlen(value) > proto_options[index].maxval ||
+	    strlen(value) < proto_options[index].minval)
+		ret = SA_BAD_VALUE;
+	return (ret);
+}
+
+static int
+autofs_validate_proto_prop(int index, char *name, char *value)
+{
+#ifdef lint
+	name = name;
+#endif
+	return (proto_options[index].check(index, value));
+}
+
+static int
+autofs_set_proto_prop(sa_property_t prop)
+{
+	int ret = SA_OK;
+	char *name;
+	char *value, *instance = NULL;
+	scf_type_t sctype;
+
+	name = sa_get_property_attr(prop, "type");
+	value = sa_get_property_attr(prop, "value");
+	if (name != NULL && value != NULL) {
+		int index = findprotoopt(name);
+		if (index >= 0) {
+			ret = autofs_validate_proto_prop(index, name, value);
+			if (ret == SA_OK) {
+				sctype = proto_options[index].type;
+				if (sctype == SCF_TYPE_BOOLEAN) {
+					if (value != NULL)
+						sa_free_attr_string(value);
+					if (string_to_boolean(value) == 0)
+						value = strdup("0");
+					else
+						value = strdup("1");
+				}
+				ret = autofs_smf_set_prop(name, value,
+				    instance, sctype, AUTOFS_FMRI);
+				/*
+				 * Make an instance based FMRI.
+				 * For now its DEFAULT_AUTOFS_FMRI.
+				 */
+				if (ret == SA_OK)
+					restart_service(AUTOFS_DEFAULT_FMRI);
+			}
+		} else {
+			ret = SA_NO_SUCH_PROP;
+		}
+	} else {
+		ret = SA_CONFIG_ERR;
+	}
+
+	if (name != NULL)
+		sa_free_attr_string(name);
+	if (value != NULL)
+		sa_free_attr_string(value);
+	return (ret);
+}
+
+
+static sa_protocol_properties_t
+autofs_get_proto_set(void)
+{
+	return (protoset);
+}
+
+static uint64_t
+autofs_features(void)
+{
+	return (0);
+}
+
+static char *
+autofs_get_status(void)
+{
+	char *state = NULL;
+	state = smf_get_state(AUTOFS_DEFAULT_FMRI);
+	return (state != NULL ? state : "-");
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libshare/autofs/mapfile-vers	Wed Aug 11 17:11:30 2010 -0500
@@ -0,0 +1,45 @@
+#
+# 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 (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+#
+# MAPFILE HEADER START
+#
+# WARNING:  STOP NOW.  DO NOT MODIFY THIS FILE.
+# Object versioning must comply with the rules detailed in
+#
+#	usr/src/lib/README.mapfiles
+#
+# You should not be making modifications here until you've read the most current
+# copy of that file. If you need help, contact a gatekeeper for guidance.
+#
+# MAPFILE HEADER END
+#
+
+SUNWprivate_1.1 {
+    global:
+	sa_plugin_ops;
+    local:
+	*;
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libshare/autofs/sparc/Makefile	Wed Aug 11 17:11:30 2010 -0500
@@ -0,0 +1,28 @@
+#
+# 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 (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+include ../Makefile.com
+
+install: all $(ROOTLIBS) $(ROOTLINKS)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libshare/autofs/sparcv9/Makefile	Wed Aug 11 17:11:30 2010 -0500
@@ -0,0 +1,28 @@
+#
+# 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 (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+include ../Makefile.com
+include ../../../Makefile.lib.64
+
+install: all $(ROOTLIBS64) $(ROOTLINKS64)
--- a/usr/src/lib/libshare/nfs/Makefile.com	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/lib/libshare/nfs/Makefile.com	Wed Aug 11 17:11:30 2010 -0500
@@ -19,10 +19,8 @@
 # CDDL HEADER END
 #
 #
-# ident	"%Z%%M%	%I%	%E% SMI"
 #
-# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
 #
 
 LIBRARY =	libshare_nfs.a
@@ -30,7 +28,7 @@
 NFSLIB_DIR	= $(SRC)/cmd/fs.d/nfs/lib
 
 LIBOBJS =	libshare_nfs.o
-OTHOBJS =	nfs_sec.o nfslog_config.o nfslogtab.o
+OTHOBJS =	nfs_sec.o nfslog_config.o nfslogtab.o smfcfg.o
 OBJECTS =	$(LIBOBJS) $(OTHOBJS)
 
 include ../../../Makefile.lib
@@ -59,7 +57,7 @@
 
 lint: lintcheck
 
-pics/%.o:       $(NFSLIB_DIR)/%.c
+pics/%.o:  $(NFSLIB_DIR)/%.c
 	$(COMPILE.c) -o $@ $<
 	$(POST_PROCESS_O)
 
--- a/usr/src/lib/libshare/nfs/libshare_nfs.c	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/lib/libshare/nfs/libshare_nfs.c	Wed Aug 11 17:11:30 2010 -0500
@@ -35,18 +35,21 @@
 #include <errno.h>
 #include <locale.h>
 #include <signal.h>
+#include <strings.h>
 #include "libshare.h"
 #include "libshare_impl.h"
 #include <nfs/export.h>
 #include <pwd.h>
 #include <limits.h>
 #include <libscf.h>
+#include <syslog.h>
+#include <rpcsvc/daemon_utils.h>
 #include "nfslog_config.h"
 #include "nfslogtab.h"
 #include "libshare_nfs.h"
-#include <rpcsvc/daemon_utils.h>
 #include <nfs/nfs.h>
 #include <nfs/nfssys.h>
+#include "smfcfg.h"
 
 /* should really be in some global place */
 #define	DEF_WIN	30000
@@ -55,6 +58,7 @@
 int debug = 0;
 
 #define	NFS_SERVER_SVC	"svc:/network/nfs/server:default"
+#define	NFS_CLIENT_SVC	(char *)"svc:/network/nfs/client:default"
 
 /* internal functions */
 static int nfs_init();
@@ -1523,7 +1527,7 @@
 		sa_free_attr_string(sectype);
 	if (options != NULL)
 		sa_free_derived_optionset(options);
-	return (NULL);
+	return (buff);
 }
 
 /*
@@ -2322,7 +2326,6 @@
 	uint32_t svcs;
 	int32_t minval;
 	int32_t maxval;
-	char *file;
 	char *other;
 	int compare;
 #define	OPT_CMP_GE	0
@@ -2332,65 +2335,67 @@
 #define	PROTO_OPT_NFSD_SERVERS			0
 	{"nfsd_servers",
 	    "servers", PROTO_OPT_NFSD_SERVERS, OPT_TYPE_NUMBER, 16, SVC_NFSD,
-	    1, INT32_MAX, NFSADMIN},
+	    1, INT32_MAX},
 #define	PROTO_OPT_LOCKD_LISTEN_BACKLOG		1
 	{"lockd_listen_backlog",
 	    "lockd_listen_backlog", PROTO_OPT_LOCKD_LISTEN_BACKLOG,
-	    OPT_TYPE_NUMBER, 32, SVC_LOCKD, 32, INT32_MAX, NFSADMIN},
+	    OPT_TYPE_NUMBER, 32, SVC_LOCKD, 32, INT32_MAX},
 #define	PROTO_OPT_LOCKD_SERVERS			2
 	{"lockd_servers",
 	    "lockd_servers", PROTO_OPT_LOCKD_SERVERS, OPT_TYPE_NUMBER, 20,
-	    SVC_LOCKD, 1, INT32_MAX, NFSADMIN},
+	    SVC_LOCKD, 1, INT32_MAX},
 #define	PROTO_OPT_LOCKD_RETRANSMIT_TIMEOUT	3
 	{"lockd_retransmit_timeout",
 	    "lockd_retransmit_timeout", PROTO_OPT_LOCKD_RETRANSMIT_TIMEOUT,
-	    OPT_TYPE_NUMBER, 5, SVC_LOCKD, 0, INT32_MAX, NFSADMIN},
+	    OPT_TYPE_NUMBER, 5, SVC_LOCKD, 0, INT32_MAX},
 #define	PROTO_OPT_GRACE_PERIOD			4
 	{"grace_period",
 	    "grace_period", PROTO_OPT_GRACE_PERIOD, OPT_TYPE_NUMBER, 90,
-	    SVC_LOCKD, 0, INT32_MAX, NFSADMIN},
+	    SVC_LOCKD, 0, INT32_MAX},
 #define	PROTO_OPT_NFS_SERVER_VERSMIN		5
 	{"nfs_server_versmin",
 	    "server_versmin", PROTO_OPT_NFS_SERVER_VERSMIN, OPT_TYPE_NUMBER,
 	    (int)NFS_VERSMIN_DEFAULT, SVC_NFSD|SVC_MOUNTD, NFS_VERSMIN,
-	    NFS_VERSMAX, NFSADMIN, "server_versmax", OPT_CMP_LE},
+	    NFS_VERSMAX, "server_versmax", OPT_CMP_LE},
 #define	PROTO_OPT_NFS_SERVER_VERSMAX		6
 	{"nfs_server_versmax",
 	    "server_versmax", PROTO_OPT_NFS_SERVER_VERSMAX, OPT_TYPE_NUMBER,
 	    (int)NFS_VERSMAX_DEFAULT, SVC_NFSD|SVC_MOUNTD, NFS_VERSMIN,
-	    NFS_VERSMAX, NFSADMIN, "server_versmin", OPT_CMP_GE},
+	    NFS_VERSMAX, "server_versmin", OPT_CMP_GE},
 #define	PROTO_OPT_NFS_CLIENT_VERSMIN		7
 	{"nfs_client_versmin",
 	    "client_versmin", PROTO_OPT_NFS_CLIENT_VERSMIN, OPT_TYPE_NUMBER,
-	    (int)NFS_VERSMIN_DEFAULT, NULL, NFS_VERSMIN, NFS_VERSMAX,
-	    NFSADMIN, "client_versmax", OPT_CMP_LE},
+	    (int)NFS_VERSMIN_DEFAULT, SVC_CLIENT, NFS_VERSMIN, NFS_VERSMAX,
+	    "client_versmax", OPT_CMP_LE},
 #define	PROTO_OPT_NFS_CLIENT_VERSMAX		8
 	{"nfs_client_versmax",
 	    "client_versmax", PROTO_OPT_NFS_CLIENT_VERSMAX, OPT_TYPE_NUMBER,
-	    (int)NFS_VERSMAX_DEFAULT, NULL, NFS_VERSMIN, NFS_VERSMAX,
-	    NFSADMIN, "client_versmin", OPT_CMP_GE},
+	    (int)NFS_VERSMAX_DEFAULT, SVC_CLIENT, NFS_VERSMIN, NFS_VERSMAX,
+	    "client_versmin", OPT_CMP_GE},
 #define	PROTO_OPT_NFS_SERVER_DELEGATION		9
 	{"nfs_server_delegation",
 	    "server_delegation", PROTO_OPT_NFS_SERVER_DELEGATION,
-	    OPT_TYPE_ONOFF, NFS_SERVER_DELEGATION_DEFAULT, SVC_NFSD, 0, 0,
-	    NFSADMIN},
+	    OPT_TYPE_ONOFF, NFS_SERVER_DELEGATION_DEFAULT, SVC_NFSD, 0, 0},
 #define	PROTO_OPT_NFSMAPID_DOMAIN		10
 	{"nfsmapid_domain",
 	    "nfsmapid_domain", PROTO_OPT_NFSMAPID_DOMAIN, OPT_TYPE_DOMAIN,
-	    NULL, SVC_NFSMAPID, 0, 0, NFSADMIN},
+	    NULL, SVC_NFSMAPID, 0, 0},
 #define	PROTO_OPT_NFSD_MAX_CONNECTIONS		11
 	{"nfsd_max_connections",
 	    "max_connections", PROTO_OPT_NFSD_MAX_CONNECTIONS,
-	    OPT_TYPE_NUMBER, -1, SVC_NFSD, -1, INT32_MAX, NFSADMIN},
+	    OPT_TYPE_NUMBER, -1, SVC_NFSD, -1, INT32_MAX},
 #define	PROTO_OPT_NFSD_PROTOCOL			12
 	{"nfsd_protocol",
 	    "protocol", PROTO_OPT_NFSD_PROTOCOL, OPT_TYPE_PROTOCOL, 0,
-	    SVC_NFSD, 0, 0, NFSADMIN},
+	    SVC_NFSD, 0, 0},
 #define	PROTO_OPT_NFSD_LISTEN_BACKLOG		13
 	{"nfsd_listen_backlog",
 	    "listen_backlog", PROTO_OPT_NFSD_LISTEN_BACKLOG,
-	    OPT_TYPE_NUMBER, 0,
-	    SVC_LOCKD, 0, INT32_MAX, NFSADMIN},
+	    OPT_TYPE_NUMBER, 0, SVC_NFSD, 0, INT32_MAX},
+#define	PROTO_OPT_NFSD_DEVICE			14
+	{"nfsd_device",
+	    "device", PROTO_OPT_NFSD_DEVICE,
+	    OPT_TYPE_STRING, NULL, SVC_NFSD, 0, 0},
 	{NULL}
 };
 
@@ -2432,21 +2437,6 @@
 }
 
 /*
- * fixcaseupper(str)
- *
- * convert a string to upper case (inplace).
- */
-
-static void
-fixcaseupper(char *str)
-{
-	while (*str) {
-		*str = toupper(*str);
-		str++;
-	}
-}
-
-/*
  * skipwhitespace(str)
  *
  * Skip leading white space. It is assumed that it is called with a
@@ -2480,7 +2470,7 @@
 	 */
 	name = skipwhitespace(name);
 
-	index = findprotoopt(name, 0);
+	index = findprotoopt(name, 1);
 	if (index >= 0) {
 		fixcaselower(name);
 		prop = sa_create_property(proto_options[index].name, value);
@@ -2492,74 +2482,110 @@
 	return (ret);
 }
 
+scf_type_t
+getscftype(int type)
+{
+	scf_type_t ret;
+
+	switch (type) {
+	case OPT_TYPE_NUMBER:
+		ret = SCF_TYPE_INTEGER;
+	break;
+	case OPT_TYPE_BOOLEAN:
+		ret = SCF_TYPE_BOOLEAN;
+	break;
+	default:
+		ret = SCF_TYPE_ASTRING;
+	}
+	return (ret);
+}
+
+char *
+getsvcname(uint32_t svcs)
+{
+	char *service;
+	switch (svcs) {
+		case SVC_LOCKD:
+			service = LOCKD;
+			break;
+		case SVC_STATD:
+			service = STATD;
+			break;
+		case SVC_NFSD:
+			service = NFSD;
+			break;
+		case SVC_CLIENT:
+			service = NFS_CLIENT_SVC;
+			break;
+		case SVC_NFS4CBD:
+			service = NFS4CBD;
+			break;
+		case SVC_NFSMAPID:
+			service = NFSMAPID;
+			break;
+		case SVC_RQUOTAD:
+			service = RQUOTAD;
+			break;
+		case SVC_NFSLOGD:
+			service = NFSLOGD;
+			break;
+		case SVC_REPARSED:
+			service = REPARSED;
+			break;
+		default:
+			service = NFSD;
+	}
+	return (service);
+}
+
 /*
- * initprotofromdefault()
+ * initprotofromsmf()
  *
- * Read the default file(s) and add the defined values to the
+ * Read NFS SMF properties and add the defined values to the
  * protoset.  Note that default values are known from the built in
- * table in case the file doesn't have a definition. Not having the
- * /etc/default/nfs file is OK since we have builtin default
- * values. The default file will get constructed as needed if values
- * are changed from the defaults.
+ * table in case SMF doesn't have a definition. Not having
+ * SMF properties is OK since we have builtin default
+ * values.
  */
-
 static int
-initprotofromdefault()
+initprotofromsmf()
 {
-	FILE *nfs;
-	char buff[BUFSIZ];
-	char *name;
-	char *value;
-	int ret = SA_OK;
+	char name[PATH_MAX];
+	char value[PATH_MAX];
+	int ret = SA_OK, bufsz = 0, i;
 
 	protoset = sa_create_protocol_properties("nfs");
+	if (protoset != NULL) {
+		for (i = 0; proto_options[i].tag != NULL; i++) {
+			scf_type_t ptype;
+			char *svc_name;
 
-	if (protoset != NULL) {
-		nfs = fopen(NFSADMIN, "r");
-		if (nfs != NULL) {
-			while (ret == SA_OK &&
-			    fgets(buff, sizeof (buff), nfs) != NULL) {
-				switch (buff[0]) {
-				case '\n':
-				case '#':
-					/* skip */
-					break;
-				default:
-					name = buff;
-					buff[strlen(buff) - 1] = '\0';
-					value = strchr(name, '=');
-					if (value != NULL) {
-						*value++ = '\0';
-						ret = extractprop(name, value);
-					}
-				}
-			}
-			(void) fclose(nfs);
-		} else {
-			switch (errno) {
-			case EPERM:
-			case EACCES:
-				ret = SA_NO_PERMISSION;
-				break;
-			case ENOENT:
-				break;
-			default:
-				ret = SA_SYSTEM_ERR;
-				break;
+			bzero(value, PATH_MAX);
+			(void) strncpy(name, proto_options[i].name, PATH_MAX);
+			/* Replace NULL with the correct instance */
+			ptype = getscftype(proto_options[i].type);
+			svc_name = getsvcname(proto_options[i].svcs);
+			bufsz = PATH_MAX;
+			ret = nfs_smf_get_prop(name, value,
+			    (char *)DEFAULT_INSTANCE, ptype,
+			    svc_name, &bufsz);
+			if (ret == SA_OK) {
+				ret = extractprop(name, value);
 			}
 		}
 	} else {
 		ret = SA_NO_MEMORY;
 	}
+
 	return (ret);
 }
 
 /*
  * add_defaults()
  *
- * Add the default values for any property not defined in the parsing
- * of the default files. Values are set according to their defined
- * types.
+ * Add the default values for any property not defined
+ * in NFS SMF repository.
+ * Values are set according to their defined types.
  */
 
 static void
@@ -2632,10 +2658,10 @@
 		return (SA_CONFIG_ERR);
 	}
 
-	ret = initprotofromdefault();
+	ret = initprotofromsmf();
 	if (ret != SA_OK) {
 		(void) printf(dgettext(TEXT_DOMAIN,
-		    "NFS plugin problem with default file: %s\n"),
+		    "NFS plugin problem with SMF repository: %s\n"),
 		    sa_errorstr(ret));
 		ret = SA_OK;
 	}
@@ -2669,216 +2695,6 @@
 	return (protoset);
 }
 
-struct deffile {
-	struct deffile *next;
-	char *line;
-};
-
-/*
- * read_default_file(fname)
- *
- * Read the specified default file. We return a list of entries. This
- * get used for adding or removing values.
- */
-
-static struct deffile *
-read_default_file(char *fname)
-{
-	FILE *file;
-	struct deffile *defs = NULL;
-	struct deffile *newdef;
-	struct deffile *prevdef = NULL;
-	char buff[BUFSIZ * 2];
-
-	file = fopen(fname, "r");
-	if (file != NULL) {
-		while (fgets(buff, sizeof (buff), file) != NULL) {
-			newdef = (struct deffile *)calloc(1,
-			    sizeof (struct deffile));
-			if (newdef != NULL) {
-				/* Make sure we skip any leading whitespace. */
-				newdef->line = strdup(skipwhitespace(buff));
-				if (defs == NULL) {
-					prevdef = defs = newdef;
-				} else {
-					prevdef->next = newdef;
-					prevdef = newdef;
-				}
-			}
-		}
-		(void) fclose(file);
-	} else {
-		int ret = SA_OK;
-		switch (errno) {
-		case EPERM:
-		case EACCES:
-			ret = SA_NO_PERMISSION;
-			break;
-		case ENOENT:
-			break;
-		default:
-			ret = SA_SYSTEM_ERR;
-			break;
-		}
-		if (ret == SA_OK) {
-			/* Want at least one comment line */
-			defs = (struct deffile *)
-			    calloc(1, sizeof (struct deffile));
-			defs->line = strdup("# NFS default file\n");
-		}
-	}
-	return (defs);
-}
-
-static void
-free_default_file(struct deffile *defs)
-{
-	struct deffile *curdefs = NULL;
-
-	while (defs != NULL) {
-		curdefs = defs;
-		defs = defs->next;
-		if (curdefs->line != NULL)
-			free(curdefs->line);
-		free(curdefs);
-	}
-}
-
-/*
- * write_default_file(fname, defs)
- *
- * Write the default file back.
- */
-
-static int
-write_default_file(char *fname, struct deffile *defs)
-{
-	FILE *file;
-	int ret = SA_OK;
-	sigset_t old, new;
-
-	file = fopen(fname, "w+");
-	if (file != NULL) {
-		(void) sigprocmask(SIG_BLOCK, NULL, &new);
-		(void) sigaddset(&new, SIGHUP);
-		(void) sigaddset(&new, SIGINT);
-		(void) sigaddset(&new, SIGQUIT);
-		(void) sigaddset(&new, SIGTSTP);
-		(void) sigprocmask(SIG_SETMASK, &new, &old);
-		while (defs != NULL) {
-			(void) fputs(defs->line, file);
-			defs = defs->next;
-		}
-		(void) fsync(fileno(file));
-		(void) sigprocmask(SIG_SETMASK, &old, NULL);
-		(void) fclose(file);
-	} else {
-		switch (errno) {
-		case EPERM:
-		case EACCES:
-			ret = SA_NO_PERMISSION;
-			break;
-		default:
-			ret = SA_SYSTEM_ERR;
-		}
-	}
-	return (ret);
-}
-
-
-/*
- * set_default_file_value(tag, value)
- *
- * Set the default file value for tag to value. Then rewrite the file.
- * tag and value are always set.  The caller must ensure this.
- */
-
-#define	MAX_STRING_LENGTH	256
-static int
-set_default_file_value(char *tag, char *value)
-{
-	int ret = SA_OK;
-	struct deffile *root;
-	struct deffile *defs;
-	struct deffile *prev;
-	char string[MAX_STRING_LENGTH];
-	int len;
-	boolean_t update = B_FALSE;
-
-	(void) snprintf(string, MAX_STRING_LENGTH, "%s=", tag);
-	len = strlen(string);
-
-	root = defs = read_default_file(NFSADMIN);
-	if (root == NULL) {
-		switch (errno) {
-		case EPERM:
-		case EACCES:
-			ret = SA_NO_PERMISSION;
-			break;
-		default:
-			ret = SA_NO_MEMORY;
-			break;
-		}
-		return (ret);
-	}
-
-	while (defs != NULL) {
-		if (defs->line != NULL &&
-		    strncasecmp(defs->line, string, len) == 0) {
-			/* replace with the new value */
-			free(defs->line);
-			fixcaseupper(tag);
-			(void) snprintf(string, sizeof (string),
-			    "%s=%s\n", tag, value);
-			string[MAX_STRING_LENGTH - 1] = '\0';
-			defs->line = strdup(string);
-			update = B_TRUE;
-			break;
-		}
-		defs = defs->next;
-	}
-	if (!update) {
-		defs = root;
-		/* didn't find, so see if it is a comment */
-		(void) snprintf(string, MAX_STRING_LENGTH, "#%s=", tag);
-		len = strlen(string);
-		while (defs != NULL) {
-			if (strncasecmp(defs->line, string, len) == 0) {
-				/* replace with the new value */
-				free(defs->line);
-				fixcaseupper(tag);
-				(void) snprintf(string, sizeof (string),
-				    "%s=%s\n", tag, value);
-				string[MAX_STRING_LENGTH - 1] = '\0';
-				defs->line = strdup(string);
-				update = B_TRUE;
-				break;
-			}
-			defs = defs->next;
-		}
-	}
-	if (!update) {
-		fixcaseupper(tag);
-		(void) snprintf(string, sizeof (string), "%s=%s\n",
-		    tag, value);
-		prev = root;
-		while (prev->next != NULL)
-			prev = prev->next;
-		defs = malloc(sizeof (struct deffile));
-		prev->next = defs;
-		if (defs != NULL) {
-			defs->next = NULL;
-			defs->line = strdup(string);
-			update = B_TRUE;
-		}
-	}
-	if (update) {
-		ret = write_default_file(NFSADMIN, root);
-	}
-	free_default_file(root);
-	return (ret);
-}
-
 /*
  * service_in_state(service, chkstate)
  *
@@ -2946,6 +2762,9 @@
 		case SVC_REPARSED:
 			service = REPARSED;
 			break;
+		case SVC_CLIENT:
+			service = NFS_CLIENT_SVC;
+			break;
 		default:
 			continue;
 		}
@@ -3056,7 +2875,6 @@
 #ifdef lint
 	name = name;
 #endif
-
 	switch (proto_options[index].type) {
 	case OPT_TYPE_NUMBER:
 		if (!is_a_number(value))
@@ -3143,15 +2961,32 @@
 	name = sa_get_property_attr(prop, "type");
 	value = sa_get_property_attr(prop, "value");
 	if (name != NULL && value != NULL) {
+		scf_type_t sctype;
+		char *svc_name;
+		char *instance = NULL;
 		int index = findprotoopt(name, 1);
-		if (index >= 0) {
-			/* should test for valid value */
-			ret = nfs_validate_proto_prop(index, name, value);
-			if (ret == SA_OK)
-				ret = set_default_file_value(
-				    proto_options[index].tag, value);
-			if (ret == SA_OK)
+
+		ret = nfs_validate_proto_prop(index, name, value);
+		if (ret == SA_OK) {
+			sctype = getscftype(proto_options[index].type);
+			svc_name = getsvcname(proto_options[index].svcs);
+			if (sctype == SCF_TYPE_BOOLEAN) {
+				if (value != NULL)
+					sa_free_attr_string(value);
+				if (string_to_boolean(value) == 0)
+					value = strdup("0");
+				else
+					value = strdup("1");
+			}
+			ret = nfs_smf_set_prop(name, value, instance, sctype,
+			    svc_name);
+			if (ret == SA_OK) {
 				restart_service(proto_options[index].svcs);
+			} else {
+				(void) printf(dgettext(TEXT_DOMAIN,
+				    "Cannot restart NFS services : %s\n"),
+				    sa_errorstr(ret));
+			}
 		}
 	}
 	if (name != NULL)
--- a/usr/src/lib/libshare/nfs/libshare_nfs.h	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/lib/libshare/nfs/libshare_nfs.h	Wed Aug 11 17:11:30 2010 -0500
@@ -98,6 +98,17 @@
 #define	SVC_RQUOTAD	0x0040
 #define	SVC_NFSLOGD	0x0080
 #define	SVC_REPARSED	0x0100
+#define	SVC_CLIENT	0x0200
+
+/*
+ * NFS Restart/Refresh options
+ */
+#define	NFSD_REFRESH		0x0001
+#define	NFSD_RESTART		0x0002
+#define	NLOCKMGR_REFESH		0x0003
+#define	NLOCKMGR_RESTART	0x0004
+#define	MAPID_REFRESH		0x0005
+#define	MAPID_RESTART		0x0006
 
 /*
  * place holder for future service -- will move to daemon_utils.h when
--- a/usr/src/pkg/manifests/SUNWcs.mf	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/pkg/manifests/SUNWcs.mf	Wed Aug 11 17:11:30 2010 -0500
@@ -161,6 +161,8 @@
 dir path=usr/lib/devfsadm group=sys
 dir path=usr/lib/devfsadm/linkmod group=sys
 dir path=usr/lib/fs group=sys
+dir path=usr/lib/fs/autofs group=sys
+dir path=usr/lib/fs/autofs/$(ARCH64) group=sys
 dir path=usr/lib/fs/cachefs group=sys
 dir path=usr/lib/fs/ctfs group=sys
 dir path=usr/lib/fs/dev group=sys
--- a/usr/src/pkg/manifests/system-file-system-autofs.mf	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/pkg/manifests/system-file-system-autofs.mf	Wed Aug 11 17:11:30 2010 -0500
@@ -43,16 +43,19 @@
 dir path=usr/lib/autofs group=sys
 dir path=usr/lib/fs group=sys
 dir path=usr/lib/fs/autofs group=sys
+dir path=usr/lib/fs/autofs/$(ARCH64) group=sys
 dir path=usr/sbin
 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 preserve=true
+    original_name=SUNWatfs:etc/default/autofs preserve=renameold
 file path=lib/svc/manifest/system/filesystem/autofs.xml group=sys mode=0444
 file path=lib/svc/method/svc-autofs mode=0555
 file path=usr/lib/autofs/automountd mode=0555
+file path=usr/lib/fs/autofs/$(ARCH64)/libshare_autofs.so.1
 file path=usr/lib/fs/autofs/automount mode=0555
 file path=usr/lib/fs/autofs/dfshares mode=0555
+file path=usr/lib/fs/autofs/libshare_autofs.so.1
 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
--- a/usr/src/pkg/manifests/system-file-system-nfs.mf	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/pkg/manifests/system-file-system-nfs.mf	Wed Aug 11 17:11:30 2010 -0500
@@ -58,7 +58,7 @@
 dir path=var/nfs/v4_oldstate group=daemon owner=daemon
 dir path=var/nfs/v4_state group=daemon owner=daemon
 file path=etc/default/nfs group=sys original_name=SUNWnfsc:etc/default/nfs \
-    preserve=true
+    preserve=renameold
 file path=etc/fs/nfs/mount mode=0555
 file path=etc/nfssec.conf group=sys original_name=SUNWnfsc:etc/nfssec.conf \
     preserve=true
--- a/usr/src/uts/common/nfs/nfs.h	Wed Aug 11 14:15:47 2010 -0700
+++ b/usr/src/uts/common/nfs/nfs.h	Wed Aug 11 17:11:30 2010 -0500
@@ -19,8 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
 /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
@@ -56,11 +55,6 @@
 #endif
 
 /*
- * Solaris NFS daemons configuration file location
- */
-#define	NFSADMIN	"/etc/default/nfs"
-
-/*
  * remote file service numbers
  */
 #define	NFS_PROGRAM	((rpcprog_t)100003)