--- old/usr/src/lib/libshare/common/libshare.c	2013-09-10 06:31:57.813571487 +0100
+++ new/usr/src/lib/libshare/common/libshare.c	2013-09-10 06:31:57.836669859 +0100
@@ -21,6 +21,7 @@
 
 /*
  * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013 RackTop Systems.
  */
 
 /*
@@ -65,19 +66,19 @@
 
 /* current SMF/SVC repository handle */
 extern void getlegacyconfig(sa_handle_t, char *, xmlNodePtr *);
-extern int gettransients(sa_handle_impl_t, xmlNodePtr *);
+extern int gettransients(sa_handle_t, xmlNodePtr *);
 extern char *sa_fstype(char *);
-extern int sa_is_share(void *);
-extern int sa_is_resource(void *);
+extern boolean_t sa_is_share(void *);
+extern boolean_t sa_is_resource(void *);
 extern ssize_t scf_max_name_len; /* defined in scfutil during initialization */
-extern int sa_group_is_zfs(sa_group_t);
-extern int sa_path_is_zfs(char *);
+extern boolean_t sa_group_is_zfs(sa_group_t);
+extern boolean_t sa_path_is_zfs(char *);
 extern int sa_zfs_set_sharenfs(sa_group_t, char *, int);
 extern int sa_zfs_set_sharesmb(sa_group_t, char *, int);
 extern void update_legacy_config(sa_handle_t);
 extern int issubdir(char *, char *);
-extern int sa_zfs_init(sa_handle_impl_t);
-extern void sa_zfs_fini(sa_handle_impl_t);
+extern int sa_zfs_init(sa_handle_t);
+extern void sa_zfs_fini(sa_handle_t);
 extern void sablocksigs(sigset_t *);
 extern void saunblocksigs(sigset_t *);
 static sa_group_t sa_get_optionset_parent(sa_optionset_t);
@@ -95,7 +96,7 @@
 struct doc2handle {
 	struct doc2handle	*next;
 	xmlNodePtr		root;
-	sa_handle_impl_t	handle;
+	sa_handle_t		handle;
 };
 
 mutex_t sa_dfstab_lock;
@@ -239,7 +240,7 @@
  * item per thread that has called sa_init().
  */
 
-sa_handle_impl_t
+sa_handle_t
 get_handle_for_root(xmlNodePtr root)
 {
 	struct doc2handle *item;
@@ -256,7 +257,7 @@
 }
 
 static int
-add_handle_for_root(xmlNodePtr root, sa_handle_impl_t handle)
+add_handle_for_root(xmlNodePtr root, sa_handle_t handle)
 {
 	struct doc2handle *item;
 	int ret = SA_NO_MEMORY;
@@ -319,7 +320,7 @@
 	while (node != NULL) {
 		if (strcmp((char *)(node->name), "sharecfg") == 0) {
 			/* have the root so get the handle */
-			handle = (sa_handle_t)get_handle_for_root(node);
+			handle = get_handle_for_root(node);
 			return (handle);
 		}
 		node = node->parent;
@@ -340,7 +341,7 @@
 {
 	xmlNodePtr node;
 	xmlChar *lpath = NULL;
-	sa_handle_impl_t handle;
+	sa_handle_t handle;
 
 	/* Have to have a handle or else we weren't initialized. */
 	handle = get_handle_for_root(root);
@@ -600,23 +601,23 @@
  * works since both thse types are also void *.
  * If the share is a ZFS share, mark it as persistent.
  */
-int
+boolean_t
 sa_is_persistent(void *group)
 {
 	char *type;
-	int persist = 1;
+	boolean_t persist = B_TRUE;
 	sa_group_t grp;
 
 	type = sa_get_group_attr((sa_group_t)group, "type");
 	if (type != NULL) {
 		if (strcmp(type, "transient") == 0)
-			persist = 0;
+			persist = B_FALSE;
 		sa_free_attr_string(type);
 	}
 
 	grp = (sa_is_share(group)) ? sa_get_parent_group(group) : group;
 	if (sa_group_is_zfs(grp))
-		persist = 1;
+		persist = B_TRUE;
 
 	return (persist);
 }
@@ -833,10 +834,10 @@
 	sigset_t old;
 	int updatelegacy = B_FALSE;
 	scf_simple_prop_t *prop;
-	sa_handle_impl_t handle;
+	sa_handle_t handle;
 	int err;
 
-	handle = calloc(sizeof (struct sa_handle_impl), 1);
+	handle = calloc(sizeof (struct sa_handle), 1);
 
 	if (handle != NULL) {
 		/*
@@ -989,7 +990,7 @@
 
 				if (updatelegacy == B_TRUE) {
 					sablocksigs(&old);
-					getlegacyconfig((sa_handle_t)handle,
+					getlegacyconfig(handle,
 					    SA_LEGACY_DFSTAB, &handle->tree);
 					if (stat(SA_LEGACY_DFSTAB, &st) >= 0)
 						set_legacy_timestamp(
@@ -1006,7 +1007,7 @@
 					(void) close(lockfd);
 				}
 				/* Get sharetab timestamp */
-				sa_update_sharetab_ts((sa_handle_t)handle);
+				sa_update_sharetab_ts(handle);
 
 				/* Get lastupdate (transaction) timestamp */
 				prop = scf_simple_prop_get(
@@ -1029,7 +1030,7 @@
 			}
 		}
 	}
-	return ((sa_handle_t)handle);
+	return (handle);
 }
 
 /*
@@ -1041,18 +1042,16 @@
 void
 sa_fini(sa_handle_t handle)
 {
-	sa_handle_impl_t impl_handle = (sa_handle_impl_t)handle;
-
-	if (impl_handle != NULL) {
+	if (handle != NULL) {
 		/*
 		 * Free the config trees and any other data structures
 		 * used in the handle.
 		 */
-		if (impl_handle->doc != NULL)
-			xmlFreeDoc(impl_handle->doc);
+		if (handle->doc != NULL)
+			xmlFreeDoc(handle->doc);
 
 		/* Remove and free the entry in the global list. */
-		remove_handle_for_root(impl_handle->tree);
+		remove_handle_for_root(handle->tree);
 
 		/*
 		 * If this was the last handle to release, unload the
@@ -1064,11 +1063,11 @@
 			(void) proto_plugin_fini();
 		(void) mutex_unlock(&sa_global_lock);
 
-		sa_scf_fini(impl_handle->scfhandle);
-		sa_zfs_fini(impl_handle);
+		sa_scf_fini(handle->scfhandle);
+		sa_zfs_fini(handle);
 
 		/* Make sure we free the handle */
-		free(impl_handle);
+		free(handle);
 
 	}
 }
@@ -1155,9 +1154,8 @@
 	xmlNodePtr node = NULL;
 	char *subgroup = NULL;
 	char *group = NULL;
-	sa_handle_impl_t impl_handle = (sa_handle_impl_t)handle;
 
-	if (impl_handle != NULL && impl_handle->tree != NULL) {
+	if (handle != NULL && handle->tree != NULL) {
 		if (groupname != NULL) {
 			group = strdup(groupname);
 			if (group != NULL) {
@@ -1174,7 +1172,7 @@
 		 * the internal list.
 		 */
 		if (group != NULL || groupname == NULL)
-			node = find_group_by_name(impl_handle->tree,
+			node = find_group_by_name(handle->tree,
 			    (xmlChar *)group);
 
 		/* if a subgroup, find it before returning */
@@ -1182,7 +1180,7 @@
 			node = find_group_by_name(node, (xmlChar *)subgroup);
 	}
 	if (node != NULL && (char *)group != NULL)
-		(void) sa_get_instance(impl_handle->scfhandle, (char *)group);
+		(void) sa_get_instance(handle->scfhandle, (char *)group);
 	if (group != NULL)
 		free(group);
 	return ((sa_group_t)(node));
@@ -1502,11 +1500,9 @@
 			else if (sa_get_optionset(group, "smb") != NULL)
 				err = sa_zfs_set_sharesmb(group, sharepath, 1);
 		} else {
-			sa_handle_impl_t impl_handle;
-			impl_handle =
-			    (sa_handle_impl_t)sa_find_group_handle(group);
-			if (impl_handle != NULL) {
-				err = sa_commit_share(impl_handle->scfhandle,
+			sa_handle_t handle = sa_find_group_handle(group);
+			if (handle != NULL) {
+				err = sa_commit_share(handle->scfhandle,
 				    group, (sa_share_t)node);
 			} else {
 				err = SA_SYSTEM_ERR;
@@ -1741,12 +1737,11 @@
 		ret = sa_delete_legacy(share, NULL);
 		if (ret == SA_OK) {
 			if (!sa_group_is_zfs(group)) {
-				sa_handle_impl_t impl_handle;
-				impl_handle = (sa_handle_impl_t)
+				sa_handle_t handle =
 				    sa_find_group_handle(group);
-				if (impl_handle != NULL) {
+				if (handle != NULL) {
 					ret = sa_delete_share(
-					    impl_handle->scfhandle, group,
+					    handle->scfhandle, group,
 					    share);
 				} else {
 					ret = SA_SYSTEM_ERR;
@@ -1789,7 +1784,7 @@
 
 	oldgroup = sa_get_parent_group(share);
 	if (oldgroup != group) {
-		sa_handle_impl_t impl_handle;
+		sa_handle_t handle;
 		xmlUnlinkNode((xmlNodePtr)share);
 		/*
 		 * now that the share isn't in its old group, add to
@@ -1797,18 +1792,18 @@
 		 */
 		(void) xmlAddChild((xmlNodePtr)group, (xmlNodePtr)share);
 		/* need to deal with SMF */
-		impl_handle = (sa_handle_impl_t)sa_find_group_handle(group);
-		if (impl_handle != NULL) {
+		handle = sa_find_group_handle(group);
+		if (handle != NULL) {
 			/*
 			 * need to remove from old group first and then add to
 			 * new group. Ideally, we would do the other order but
 			 * need to avoid having the share in two groups at the
 			 * same time.
 			 */
-			ret = sa_delete_share(impl_handle->scfhandle, oldgroup,
+			ret = sa_delete_share(handle->scfhandle, oldgroup,
 			    share);
 			if (ret == SA_OK)
-				ret = sa_commit_share(impl_handle->scfhandle,
+				ret = sa_commit_share(handle->scfhandle,
 				    group, share);
 		} else {
 			ret = SA_SYSTEM_ERR;
@@ -1843,19 +1838,19 @@
 }
 
 /*
- * _sa_create_group(impl_handle, groupname)
+ * _sa_create_group(handle, groupname)
  *
  * Create a group in the document. The caller will need to deal with
  * configuration store and activation.
  */
 
 sa_group_t
-_sa_create_group(sa_handle_impl_t impl_handle, char *groupname)
+_sa_create_group(sa_handle_t handle, char *groupname)
 {
 	xmlNodePtr node = NULL;
 
 	if (sa_valid_group_name(groupname)) {
-		node = xmlNewChild(impl_handle->tree, NULL, (xmlChar *)"group",
+		node = xmlNewChild(handle->tree, NULL, (xmlChar *)"group",
 		    NULL);
 		if (node != NULL) {
 			(void) xmlSetProp(node, (xmlChar *)"name",
@@ -1906,11 +1901,10 @@
 	sa_group_t group;
 	int ret;
 	char rbacstr[SA_STRSIZE];
-	sa_handle_impl_t impl_handle = (sa_handle_impl_t)handle;
 
 	ret = SA_OK;
 
-	if (impl_handle == NULL || impl_handle->scfhandle == NULL) {
+	if (handle == NULL || handle->scfhandle == NULL) {
 		ret = SA_SYSTEM_ERR;
 		goto err;
 	}
@@ -1920,7 +1914,7 @@
 		ret = SA_DUPLICATE_NAME;
 	} else {
 		if (sa_valid_group_name(groupname)) {
-			node = xmlNewChild(impl_handle->tree, NULL,
+			node = xmlNewChild(handle->tree, NULL,
 			    (xmlChar *)"group", NULL);
 			if (node != NULL) {
 				(void) xmlSetProp(node, (xmlChar *)"name",
@@ -1928,37 +1922,37 @@
 				/* default to the group being enabled */
 				(void) xmlSetProp(node, (xmlChar *)"state",
 				    (xmlChar *)"enabled");
-				ret = sa_create_instance(impl_handle->scfhandle,
+				ret = sa_create_instance(handle->scfhandle,
 				    groupname);
 				if (ret == SA_OK) {
 					ret = sa_start_transaction(
-					    impl_handle->scfhandle,
+					    handle->scfhandle,
 					    "operation");
 				}
 				if (ret == SA_OK) {
 					ret = sa_set_property(
-					    impl_handle->scfhandle,
+					    handle->scfhandle,
 					    "state", "enabled");
 					if (ret == SA_OK) {
 						ret = sa_end_transaction(
-						    impl_handle->scfhandle,
-						    impl_handle);
+						    handle->scfhandle,
+						    handle);
 					} else {
 						sa_abort_transaction(
-						    impl_handle->scfhandle);
+						    handle->scfhandle);
 					}
 				}
 				if (ret == SA_OK) {
 					/* initialize the RBAC strings */
 					ret = sa_start_transaction(
-					    impl_handle->scfhandle,
+					    handle->scfhandle,
 					    "general");
 					if (ret == SA_OK) {
 						(void) snprintf(rbacstr,
 						    sizeof (rbacstr), "%s.%s",
 						    SA_RBAC_MANAGE, groupname);
 						ret = sa_set_property(
-						    impl_handle->scfhandle,
+						    handle->scfhandle,
 						    "action_authorization",
 						    rbacstr);
 					}
@@ -1967,17 +1961,17 @@
 						    sizeof (rbacstr), "%s.%s",
 						    SA_RBAC_VALUE, groupname);
 						ret = sa_set_property(
-						    impl_handle->scfhandle,
+						    handle->scfhandle,
 						    "value_authorization",
 						    rbacstr);
 					}
 					if (ret == SA_OK) {
 						ret = sa_end_transaction(
-						    impl_handle->scfhandle,
-						    impl_handle);
+						    handle->scfhandle,
+						    handle);
 					} else {
 						sa_abort_transaction(
-						    impl_handle->scfhandle);
+						    handle->scfhandle);
 					}
 				}
 				if (ret != SA_OK) {
@@ -2015,13 +2009,13 @@
 {
 	char *name;
 	int ret = SA_OK;
-	sa_handle_impl_t impl_handle;
+	sa_handle_t handle;
 
-	impl_handle = (sa_handle_impl_t)sa_find_group_handle(group);
-	if (impl_handle != NULL) {
+	handle = sa_find_group_handle(group);
+	if (handle != NULL) {
 		name = sa_get_group_attr(group, "name");
 		if (name != NULL) {
-			ret = sa_delete_instance(impl_handle->scfhandle, name);
+			ret = sa_delete_instance(handle->scfhandle, name);
 			sa_free_attr_string(name);
 		}
 		xmlUnlinkNode((xmlNodePtr)group); /* make sure unlinked */
@@ -2118,7 +2112,7 @@
 {
 	int ret;
 	char *groupname;
-	sa_handle_impl_t impl_handle;
+	sa_handle_t handle;
 
 	/*
 	 * ZFS group/subgroup doesn't need the handle so shortcut.
@@ -2128,24 +2122,24 @@
 		return (SA_OK);
 	}
 
-	impl_handle = (sa_handle_impl_t)sa_find_group_handle(group);
-	if (impl_handle != NULL) {
+	handle = sa_find_group_handle(group);
+	if (handle != NULL) {
 		groupname = sa_get_group_attr(group, "name");
-		ret = sa_get_instance(impl_handle->scfhandle, groupname);
+		ret = sa_get_instance(handle->scfhandle, groupname);
 		if (ret == SA_OK) {
 			set_node_attr((void *)group, tag, value);
-			ret = sa_start_transaction(impl_handle->scfhandle,
+			ret = sa_start_transaction(handle->scfhandle,
 			    "operation");
 			if (ret == SA_OK) {
-				ret = sa_set_property(impl_handle->scfhandle,
+				ret = sa_set_property(handle->scfhandle,
 				    tag, value);
 				if (ret == SA_OK)
 					ret = sa_end_transaction(
-					    impl_handle->scfhandle,
-					    impl_handle);
+					    handle->scfhandle,
+					    handle);
 				else
 					sa_abort_transaction(
-					    impl_handle->scfhandle);
+					    handle->scfhandle);
 			}
 			if (ret == SA_SYSTEM_ERR)
 				ret = SA_NO_PERMISSION;
@@ -2226,13 +2220,11 @@
 			/* we can probably optimize this some */
 			type = sa_get_share_attr(share, "type");
 			if (type == NULL || strcmp(type, "transient") != 0) {
-				sa_handle_impl_t impl_handle;
-				impl_handle =
-				    (sa_handle_impl_t)sa_find_group_handle(
+				sa_handle_t handle = sa_find_group_handle(
 				    group);
-				if (impl_handle != NULL) {
+				if (handle != NULL) {
 					ret = sa_commit_share(
-					    impl_handle->scfhandle, group,
+					    handle->scfhandle, group,
 					    share);
 				} else {
 					ret = SA_SYSTEM_ERR;
@@ -2527,10 +2519,9 @@
 	group = sa_get_parent_group(share);
 	if (group != NULL &&
 	    sa_is_persistent(share) && (!sa_group_is_zfs(group))) {
-		sa_handle_impl_t impl_handle;
-		impl_handle = (sa_handle_impl_t)sa_find_group_handle(group);
-		if (impl_handle != NULL) {
-			ret = sa_commit_share(impl_handle->scfhandle, group,
+		sa_handle_t handle = sa_find_group_handle(group);
+		if (handle != NULL) {
+			ret = sa_commit_share(handle->scfhandle, group,
 			    share);
 		} else {
 			ret = SA_SYSTEM_ERR;
@@ -2673,16 +2664,14 @@
 			    sizeof (oname), id);
 			groupname = sa_get_group_attr(parent, "name");
 			if (groupname != NULL && sa_is_persistent(group)) {
-				sa_handle_impl_t impl_handle;
-				impl_handle =
-				    (sa_handle_impl_t)sa_find_group_handle(
+				sa_handle_t handle = sa_find_group_handle(
 				    group);
-				assert(impl_handle != NULL);
-				if (impl_handle != NULL) {
+				assert(handle != NULL);
+				if (handle != NULL) {
 					(void) sa_get_instance(
-					    impl_handle->scfhandle, groupname);
+					    handle->scfhandle, groupname);
 					(void) sa_create_pgroup(
-					    impl_handle->scfhandle, oname);
+					    handle->scfhandle, oname);
 				}
 			}
 			if (groupname != NULL)
@@ -2781,7 +2770,7 @@
 	int zfs = 0;
 	int needsupdate = 0;
 	int ret = SA_OK;
-	sa_handle_impl_t impl_handle;
+	sa_handle_t handle;
 
 	group = sa_get_optionset_parent(optionset);
 	if (group != NULL && (sa_is_share(group) || is_zfs_group(group))) {
@@ -2797,14 +2786,14 @@
 		if (!clear && needsupdate)
 			ret = sa_zfs_update((sa_share_t)group);
 	} else {
-		impl_handle = (sa_handle_impl_t)sa_find_group_handle(group);
-		if (impl_handle != NULL) {
+		handle = sa_find_group_handle(group);
+		if (handle != NULL) {
 			if (clear) {
 				(void) sa_abort_transaction(
-				    impl_handle->scfhandle);
+				    handle->scfhandle);
 			} else {
 				ret = sa_end_transaction(
-				    impl_handle->scfhandle, impl_handle);
+				    handle->scfhandle, handle);
 			}
 		} else {
 			ret = SA_SYSTEM_ERR;
@@ -2844,12 +2833,11 @@
 		ispersist = sa_is_persistent(group);
 	}
 	if (ispersist) {
-		sa_handle_impl_t impl_handle;
+		sa_handle_t handle = sa_find_group_handle(group);
 		len = sa_optionset_name(optionset, name, sizeof (name), id);
-		impl_handle = (sa_handle_impl_t)sa_find_group_handle(group);
-		if (impl_handle != NULL) {
+		if (handle != NULL) {
 			if (len > 0) {
-				ret = sa_delete_pgroup(impl_handle->scfhandle,
+				ret = sa_delete_pgroup(handle->scfhandle,
 				    name);
 			}
 		} else {
@@ -2913,15 +2901,13 @@
 			(void) sa_security_name(security, oname,
 			    sizeof (oname), id);
 			if (groupname != NULL && sa_is_persistent(group)) {
-				sa_handle_impl_t impl_handle;
-				impl_handle =
-				    (sa_handle_impl_t)sa_find_group_handle(
+				sa_handle_t handle = sa_find_group_handle(
 				    group);
-				if (impl_handle != NULL) {
+				if (handle != NULL) {
 					(void) sa_get_instance(
-					    impl_handle->scfhandle, groupname);
+					    handle->scfhandle, groupname);
 					(void) sa_create_pgroup(
-					    impl_handle->scfhandle, oname);
+					    handle->scfhandle, oname);
 				}
 			}
 		}
@@ -2964,11 +2950,9 @@
 	if (ispersist) {
 		len = sa_security_name(security, name, sizeof (name), id);
 		if (!iszfs && len > 0) {
-			sa_handle_impl_t impl_handle;
-			impl_handle =
-			    (sa_handle_impl_t)sa_find_group_handle(group);
-			if (impl_handle != NULL) {
-				ret = sa_delete_pgroup(impl_handle->scfhandle,
+			sa_handle_t handle = sa_find_group_handle(group);
+			if (handle != NULL) {
+				ret = sa_delete_pgroup(handle->scfhandle,
 				    name);
 			} else {
 				ret = SA_SYSTEM_ERR;
@@ -3077,7 +3061,7 @@
 	int iszfs = 0;
 	sa_group_t parent = NULL;
 	sa_share_t share = NULL;
-	sa_handle_impl_t impl_handle;
+	sa_handle_t handle;
 	scfutilhandle_t  *scf_handle;
 
 	if (!sa_is_persistent(group)) {
@@ -3087,10 +3071,10 @@
 		 */
 		return (SA_OK);
 	}
-	impl_handle = (sa_handle_impl_t)sa_find_group_handle(group);
-	if (impl_handle == NULL || impl_handle->scfhandle == NULL)
+	handle = sa_find_group_handle(group);
+	if (handle == NULL || handle->scfhandle == NULL)
 		return (SA_SYSTEM_ERR);
-	scf_handle = impl_handle->scfhandle;
+	scf_handle = handle->scfhandle;
 	name = sa_get_property_attr(prop, "type");
 	valstr = sa_get_property_attr(prop, "value");
 	entry = scf_entry_create(scf_handle->handle);
@@ -3288,16 +3272,15 @@
 
 		if (!is_zfs_group(group)) {
 			char *id = NULL;
-			sa_handle_impl_t impl_handle;
+			sa_handle_t handle;
 			scfutilhandle_t  *scf_handle;
 
-			impl_handle = (sa_handle_impl_t)sa_find_group_handle(
-			    group);
-			if (impl_handle == NULL ||
-			    impl_handle->scfhandle == NULL)
+			handle = sa_find_group_handle(group);
+			if (handle == NULL ||
+			    handle->scfhandle == NULL)
 				ret = SA_SYSTEM_ERR;
 			if (ret == SA_OK) {
-				scf_handle = impl_handle->scfhandle;
+				scf_handle = handle->scfhandle;
 				if (sa_is_share((sa_group_t)parent)) {
 					id = sa_get_share_attr(
 					    (sa_share_t)parent, "id");
@@ -3796,14 +3779,13 @@
 
 				if (!sa_group_is_zfs(group)) {
 					/* ZFS doesn't use resource names */
-					sa_handle_impl_t ihandle;
+					sa_handle_t handle;
 
-					ihandle = (sa_handle_impl_t)
-					    sa_find_group_handle(
+					handle = sa_find_group_handle(
 					    group);
-					if (ihandle != NULL)
+					if (handle != NULL)
 						err = sa_commit_share(
-						    ihandle->scfhandle, group,
+						    handle->scfhandle, group,
 						    share);
 					else
 						err = SA_SYSTEM_ERR;
@@ -3864,10 +3846,9 @@
 		return (ret);
 
 	if (!sa_group_is_zfs(group)) {
-		sa_handle_impl_t ihandle;
-		ihandle = (sa_handle_impl_t)sa_find_group_handle(group);
-		if (ihandle != NULL)
-			ret = sa_commit_share(ihandle->scfhandle, group, share);
+		sa_handle_t handle = sa_find_group_handle(group);
+		if (handle != NULL)
+			ret = sa_commit_share(handle->scfhandle, group, share);
 		else
 			ret = SA_SYSTEM_ERR;
 	} else {
@@ -3930,7 +3911,7 @@
 	if (group == NULL)
 		return (ret);
 
-	handle = (sa_handle_impl_t)sa_find_group_handle(group);
+	handle = sa_find_group_handle(group);
 	if (handle == NULL)
 		return (ret);
 
@@ -3950,8 +3931,7 @@
 			return (ret);
 
 		if (!sa_group_is_zfs(group)) {
-			sa_handle_impl_t ihandle = (sa_handle_impl_t)handle;
-			ret = sa_commit_share(ihandle->scfhandle, group,
+			ret = sa_commit_share(handle->scfhandle, group,
 			    share);
 		} else {
 			ret = sa_zfs_update((sa_share_t)group);
@@ -4364,10 +4344,9 @@
 	group = sa_get_parent_group(share);
 	if (group != NULL &&
 	    sa_is_persistent(share) && (!sa_group_is_zfs(group))) {
-		sa_handle_impl_t impl_handle;
-		impl_handle = (sa_handle_impl_t)sa_find_group_handle(group);
-		if (impl_handle != NULL)
-			ret = sa_commit_share(impl_handle->scfhandle,
+		sa_handle_t handle = sa_find_group_handle(group);
+		if (handle != NULL)
+			ret = sa_commit_share(handle->scfhandle,
 			    group, share);
 		else
 			ret = SA_SYSTEM_ERR;
--- old/usr/src/lib/libshare/common/libshare.h	2013-09-10 06:31:58.323525398 +0100
+++ new/usr/src/lib/libshare/common/libshare.h	2013-09-10 06:31:58.333802974 +0100
@@ -21,6 +21,7 @@
 
 /*
  * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013 RackTop Systems.
  */
 
 /*
@@ -48,7 +49,7 @@
 typedef void *sa_protocol_properties_t;
 typedef void *sa_resource_t;
 
-typedef void *sa_handle_t;	/* opaque handle to access core functions */
+typedef struct sa_handle *sa_handle_t;	/* opaque handle to access core functions */
 
 /*
  * defined error values
@@ -177,7 +178,7 @@
 extern int sa_set_share_description(sa_share_t, char *);
 extern int sa_enable_share(sa_group_t, char *);
 extern int sa_disable_share(sa_share_t, char *);
-extern int sa_is_share(void *);
+extern boolean_t sa_is_share(void *);
 
 /* resource name related */
 extern sa_resource_t sa_find_resource(sa_handle_t, char *);
@@ -222,7 +223,7 @@
 extern int sa_remove_property(sa_property_t);
 extern int sa_commit_properties(sa_optionset_t, int);
 extern int sa_valid_property(sa_handle_t, void *, char *, sa_property_t);
-extern int sa_is_persistent(void *);
+extern boolean_t sa_is_persistent(void *);
 
 /* security control */
 extern sa_security_t sa_get_security(sa_group_t, char *, char *);
@@ -238,7 +239,7 @@
 /* protocol specific interfaces */
 extern int sa_parse_legacy_options(sa_group_t, char *, char *);
 extern char *sa_proto_legacy_format(char *, sa_group_t, int);
-extern int sa_is_security(char *, char *);
+extern boolean_t sa_is_security(char *, char *);
 extern sa_protocol_properties_t sa_proto_get_properties(char *);
 extern uint64_t sa_proto_get_featureset(char *);
 extern sa_property_t sa_get_protocol_section(sa_protocol_properties_t, char *);
@@ -266,9 +267,9 @@
 extern int sa_delete_sharetab(sa_handle_t, char *, char *);
 
 /* ZFS functions */
-extern int sa_zfs_is_shared(sa_handle_t, char *);
-extern int sa_group_is_zfs(sa_group_t);
-extern int sa_path_is_zfs(char *);
+extern boolean_t sa_zfs_is_shared(sa_handle_t, char *);
+extern boolean_t sa_group_is_zfs(sa_group_t);
+extern boolean_t sa_path_is_zfs(char *);
 extern int sa_zfs_setprop(sa_handle_t, char *, nvlist_t *);
 
 /* SA Handle specific functions */
--- old/usr/src/lib/libshare/common/libshare_impl.h	2013-09-10 06:31:58.599830467 +0100
+++ new/usr/src/lib/libshare/common/libshare_impl.h	2013-09-10 06:31:58.609802614 +0100
@@ -25,6 +25,10 @@
  */
 
 /*
+ * Copyright (c) 2013 RackTop Systems.
+ */
+
+/*
  * basic declarations for implementation of the share management
  * libraries.
  */
@@ -100,7 +104,7 @@
 } property_list_t;
 
 /* internal version of sa_handle_t */
-typedef struct sa_handle_impl {
+struct sa_handle {
 	uint64_t	flags;
 	scfutilhandle_t	*scfhandle;
 	libzfs_handle_t *zfs_libhandle;
@@ -110,7 +114,7 @@
 	xmlDocPtr	doc;
 	uint64_t	tssharetab;
 	uint64_t	tstrans;
-} *sa_handle_impl_t;
+};
 
 extern int sa_proto_share(char *, sa_share_t);
 extern int sa_proto_unshare(sa_share_t, char *, char *);
@@ -129,7 +133,7 @@
 extern void sa_free_derived_security(sa_security_t);
 extern sa_protocol_properties_t sa_create_protocol_properties(char *);
 extern int sa_start_transaction(scfutilhandle_t *, char *);
-extern int sa_end_transaction(scfutilhandle_t *, sa_handle_impl_t);
+extern int sa_end_transaction(scfutilhandle_t *, sa_handle_t);
 extern void sa_abort_transaction(scfutilhandle_t *);
 extern int sa_commit_share(scfutilhandle_t *, sa_group_t, sa_share_t);
 extern int sa_set_property(scfutilhandle_t *, char *, char *);
--- old/usr/src/lib/libshare/common/libshare_zfs.c	2013-09-10 06:31:58.873079212 +0100
+++ new/usr/src/lib/libshare/common/libshare_zfs.c	2013-09-10 06:31:58.884322398 +0100
@@ -21,9 +21,8 @@
 
 /*
  * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
- */
-/*
  * Copyright 2012 Nexenta Systems, Inc.  All rights reserved.
+ * Copyright (c) 2013 RackTop Systems.
  */
 
 #include <stdio.h>
@@ -41,7 +40,7 @@
 extern sa_group_t _sa_create_zfs_group(sa_group_t, char *);
 extern char *sa_fstype(char *);
 extern void set_node_attr(void *, char *, char *);
-extern int sa_is_share(void *);
+extern boolean_t sa_is_share(void *);
 extern void sa_update_sharetab_ts(sa_handle_t);
 
 /*
@@ -58,7 +57,7 @@
 } get_all_cbdata_t;
 
 /*
- * sa_zfs_init(impl_handle)
+ * sa_zfs_init(handle)
  *
  * Initialize an access handle into libzfs.  The handle needs to stay
  * around until sa_zfs_fini() in order to maintain the cache of
@@ -66,45 +65,45 @@
  */
 
 int
-sa_zfs_init(sa_handle_impl_t impl_handle)
+sa_zfs_init(sa_handle_t handle)
 {
-	impl_handle->zfs_libhandle = libzfs_init();
-	if (impl_handle->zfs_libhandle != NULL) {
-		libzfs_print_on_error(impl_handle->zfs_libhandle, B_TRUE);
+	handle->zfs_libhandle = libzfs_init();
+	if (handle->zfs_libhandle != NULL) {
+		libzfs_print_on_error(handle->zfs_libhandle, B_TRUE);
 		return (B_TRUE);
 	}
 	return (B_FALSE);
 }
 
 /*
- * sa_zfs_fini(impl_handle)
+ * sa_zfs_fini(handle)
  *
  * cleanup data structures and the libzfs handle used for accessing
  * zfs file share info.
  */
 
 void
-sa_zfs_fini(sa_handle_impl_t impl_handle)
+sa_zfs_fini(sa_handle_t handle)
 {
-	if (impl_handle->zfs_libhandle != NULL) {
-		if (impl_handle->zfs_list != NULL) {
-			zfs_handle_t **zhp = impl_handle->zfs_list;
+	if (handle->zfs_libhandle != NULL) {
+		if (handle->zfs_list != NULL) {
+			zfs_handle_t **zhp = handle->zfs_list;
 			size_t i;
 
 			/*
 			 * Contents of zfs_list need to be freed so we
 			 * don't lose ZFS handles.
 			 */
-			for (i = 0; i < impl_handle->zfs_list_count; i++) {
+			for (i = 0; i < handle->zfs_list_count; i++) {
 				zfs_close(zhp[i]);
 			}
-			free(impl_handle->zfs_list);
-			impl_handle->zfs_list = NULL;
-			impl_handle->zfs_list_count = 0;
+			free(handle->zfs_list);
+			handle->zfs_list = NULL;
+			handle->zfs_list_count = 0;
 		}
 
-		libzfs_fini(impl_handle->zfs_libhandle);
-		impl_handle->zfs_libhandle = NULL;
+		libzfs_fini(handle->zfs_libhandle);
+		handle->zfs_libhandle = NULL;
 	}
 }
 
@@ -183,23 +182,23 @@
  */
 
 static void
-get_all_filesystems(sa_handle_impl_t impl_handle,
+get_all_filesystems(sa_handle_t handle,
 			zfs_handle_t ***fslist, size_t *count)
 {
 	get_all_cbdata_t cb = { 0 };
 	cb.cb_types = ZFS_TYPE_FILESYSTEM;
 
-	if (impl_handle->zfs_list != NULL) {
-		*fslist = impl_handle->zfs_list;
-		*count = impl_handle->zfs_list_count;
+	if (handle->zfs_list != NULL) {
+		*fslist = handle->zfs_list;
+		*count = handle->zfs_list_count;
 		return;
 	}
 
-	(void) zfs_iter_root(impl_handle->zfs_libhandle,
+	(void) zfs_iter_root(handle->zfs_libhandle,
 	    get_one_filesystem, &cb);
 
-	impl_handle->zfs_list = *fslist = cb.cb_handles;
-	impl_handle->zfs_list_count = *count = cb.cb_used;
+	handle->zfs_list = *fslist = cb.cb_handles;
+	handle->zfs_list_count = *count = cb.cb_used;
 }
 
 /*
@@ -261,7 +260,7 @@
 }
 
 /*
- * get_zfs_dataset(impl_handle, path)
+ * get_zfs_dataset(handle, path)
  *
  * get the name of the ZFS dataset the path is equivalent to.  The
  * dataset name is used for get/set of ZFS properties since libzfs
@@ -269,7 +268,7 @@
  */
 
 static char *
-get_zfs_dataset(sa_handle_impl_t impl_handle, char *path,
+get_zfs_dataset(sa_handle_t handle, char *path,
     boolean_t search_mnttab)
 {
 	size_t i, count = 0;
@@ -278,7 +277,7 @@
 	char mountpoint[ZFS_MAXPROPLEN];
 	char canmount[ZFS_MAXPROPLEN];
 
-	get_all_filesystems(impl_handle, &zlist, &count);
+	get_all_filesystems(handle, &zlist, &count);
 	qsort(zlist, count, sizeof (void *), mountpoint_compare);
 	for (i = 0; i < count; i++) {
 		/* must have a mountpoint */
@@ -335,26 +334,20 @@
  */
 
 static char *
-get_zfs_property(char *dataset, zfs_prop_t property)
+get_zfs_property(sa_handle_t handle, char *dataset, zfs_prop_t property)
 {
-	zfs_handle_t *handle = NULL;
+	zfs_handle_t *z_fs;
 	char shareopts[ZFS_MAXPROPLEN];
-	libzfs_handle_t *libhandle;
 
-	libhandle = libzfs_init();
-	if (libhandle != NULL) {
-		handle = zfs_open(libhandle, dataset, ZFS_TYPE_FILESYSTEM);
-		if (handle != NULL) {
-			if (zfs_prop_get(handle, property, shareopts,
-			    sizeof (shareopts), NULL, NULL, 0,
-			    B_FALSE) == 0) {
-				zfs_close(handle);
-				libzfs_fini(libhandle);
-				return (strdup(shareopts));
-			}
-			zfs_close(handle);
+	z_fs = zfs_open(handle->zfs_libhandle, dataset, ZFS_TYPE_FILESYSTEM);
+	if (z_fs != NULL) {
+		if (zfs_prop_get(z_fs, property, shareopts,
+		    sizeof (shareopts), NULL, NULL, 0,
+		    B_FALSE) == 0) {
+			zfs_close(z_fs);
+			return (strdup(shareopts));
 		}
-		libzfs_fini(libhandle);
+		zfs_close(z_fs);
 	}
 	return (NULL);
 }
@@ -366,31 +359,26 @@
  * or not.
  */
 
-int
-sa_zfs_is_shared(sa_handle_t sahandle, char *path)
+boolean_t
+sa_zfs_is_shared(sa_handle_t handle, char *path)
 {
-	int ret = 0;
+	int ret = B_FALSE;
 	char *dataset;
-	zfs_handle_t *handle = NULL;
+	zfs_handle_t *z_fs = NULL;
 	char shareopts[ZFS_MAXPROPLEN];
-	libzfs_handle_t *libhandle;
 
-	dataset = get_zfs_dataset((sa_handle_t)sahandle, path, B_FALSE);
+	dataset = get_zfs_dataset(handle, path, B_FALSE);
 	if (dataset != NULL) {
-		libhandle = libzfs_init();
-		if (libhandle != NULL) {
-			handle = zfs_open(libhandle, dataset,
-			    ZFS_TYPE_FILESYSTEM);
-			if (handle != NULL) {
-				if (zfs_prop_get(handle, ZFS_PROP_SHARENFS,
-				    shareopts, sizeof (shareopts), NULL, NULL,
-				    0, B_FALSE) == 0 &&
-				    strcmp(shareopts, "off") != 0) {
-					ret = 1; /* it is shared */
-				}
-				zfs_close(handle);
+		z_fs = zfs_open(handle->zfs_libhandle, dataset,
+		    ZFS_TYPE_FILESYSTEM);
+		if (z_fs != NULL) {
+			if (zfs_prop_get(z_fs, ZFS_PROP_SHARENFS,
+			    shareopts, sizeof (shareopts), NULL, NULL,
+			    0, B_FALSE) == 0 &&
+			    strcmp(shareopts, "off") != 0) {
+				ret = B_TRUE; /* it is shared */
 			}
-			libzfs_fini(libhandle);
+			zfs_close(z_fs);
 		}
 		free(dataset);
 	}
@@ -763,7 +751,7 @@
 	/*
 	 * If we can't access libzfs, don't bother doing anything.
 	 */
-	zfs_libhandle = ((sa_handle_impl_t)handle)->zfs_libhandle;
+	zfs_libhandle = handle->zfs_libhandle;
 	if (zfs_libhandle == NULL)
 		return (SA_SYSTEM_ERR);
 
@@ -776,7 +764,7 @@
 	 * need to walk the mounted ZFS pools and datasets to
 	 * find shares that are possible.
 	 */
-	get_all_filesystems((sa_handle_impl_t)handle, &zlist, &count);
+	get_all_filesystems(handle, &zlist, &count);
 	qsort(zlist, count, sizeof (void *), mountpoint_compare);
 
 	for (i = 0; i < count; i++) {
@@ -932,7 +920,7 @@
 		char *opts = NULL;
 		char *dataset = NULL;
 		FILE *pfile;
-		sa_handle_impl_t impl_handle;
+		sa_handle_t handle;
 		/* for now, NFS is always available for "zfs" */
 		if (on) {
 			opts = sa_proto_legacy_format("nfs", group, 1);
@@ -942,10 +930,10 @@
 			}
 		}
 
-		impl_handle = (sa_handle_impl_t)sa_find_group_handle(group);
-		assert(impl_handle != NULL);
-		if (impl_handle != NULL)
-			dataset = get_zfs_dataset(impl_handle, path, B_FALSE);
+		handle = sa_find_group_handle(group);
+		assert(handle != NULL);
+		if (handle != NULL)
+			dataset = get_zfs_dataset(handle, path, B_FALSE);
 		else
 			ret = SA_SYSTEM_ERR;
 
@@ -1043,7 +1031,7 @@
 		char *opts = NULL;
 		char *dataset = NULL;
 		FILE *pfile;
-		sa_handle_impl_t impl_handle;
+		sa_handle_t handle;
 
 		if (on) {
 			char *newopt;
@@ -1059,10 +1047,10 @@
 			opts = newopt;
 		}
 
-		impl_handle = (sa_handle_impl_t)sa_find_group_handle(group);
-		assert(impl_handle != NULL);
-		if (impl_handle != NULL)
-			dataset = get_zfs_dataset(impl_handle, path, B_FALSE);
+		handle = sa_find_group_handle(group);
+		assert(handle != NULL);
+		if (handle != NULL)
+			dataset = get_zfs_dataset(handle, path, B_FALSE);
 		else
 			ret = SA_SYSTEM_ERR;
 
@@ -1126,13 +1114,13 @@
 				path = sa_get_share_attr((sa_share_t)group,
 				    "path");
 				if (path != NULL) {
-					sa_handle_impl_t impl_handle;
+					sa_handle_t handle;
 
-					impl_handle = sa_find_group_handle(
+					handle = sa_find_group_handle(
 					    group);
-					if (impl_handle != NULL)
+					if (handle != NULL)
 						dataset = get_zfs_dataset(
-						    impl_handle, path, B_FALSE);
+						    handle, path, B_FALSE);
 					else
 						ret = SA_SYSTEM_ERR;
 
@@ -1144,9 +1132,12 @@
 			/* update only when there is an optstring found */
 			doupdate = 0;
 			if (proto != NULL && dataset != NULL) {
+				sa_handle_t handle;
+
 				optstring = sa_proto_legacy_format(proto,
 				    group, 1);
-				zfsopts = get_zfs_property(dataset,
+				handle = sa_find_group_handle(group);
+				zfsopts = get_zfs_property(handle, dataset,
 				    ZFS_PROP_SHARENFS);
 
 				if (optstring != NULL && zfsopts != NULL) {
@@ -1204,15 +1195,15 @@
  * Given the group, determine if the zfs attribute is set.
  */
 
-int
+boolean_t
 sa_group_is_zfs(sa_group_t group)
 {
 	char *zfs;
-	int ret = 0;
+	int ret = B_FALSE;
 
 	zfs = sa_get_group_attr(group, "zfs");
 	if (zfs != NULL) {
-		ret = 1;
+		ret = B_TRUE;
 		sa_free_attr_string(zfs);
 	}
 	return (ret);
@@ -1224,15 +1215,15 @@
  * Check to see if the file system path represents is of type "zfs".
  */
 
-int
+boolean_t
 sa_path_is_zfs(char *path)
 {
 	char *fstype;
-	int ret = 0;
+	int ret = B_FALSE;
 
 	fstype = sa_fstype(path);
 	if (fstype != NULL && strcmp(fstype, "zfs") == 0)
-		ret = 1;
+		ret = B_TRUE;
 	if (fstype != NULL)
 		sa_free_fstype(fstype);
 	return (ret);
@@ -1264,14 +1255,14 @@
 sa_share_zfs(sa_share_t share, sa_resource_t resource, char *path, share_t *sh,
     void *exportdata, zfs_share_op_t operation)
 {
-	libzfs_handle_t *libhandle;
 	sa_group_t group;
-	sa_handle_t sahandle;
+	sa_handle_t handle;
 	char *dataset;
 	int err = EINVAL;
 	int i, j;
 	char newpath[MAXPATHLEN];
 	char *pathp;
+	char *resource_name;
 
 	/*
 	 * First find the dataset name
@@ -1279,7 +1270,7 @@
 	if ((group = sa_get_parent_group(share)) == NULL)  {
 		return (EINVAL);
 	}
-	if ((sahandle = sa_find_group_handle(group)) == NULL) {
+	if ((handle = sa_find_group_handle(group)) == NULL) {
 		return (EINVAL);
 	}
 
@@ -1288,7 +1279,7 @@
 	 */
 
 	pathp = path;
-	while ((dataset = get_zfs_dataset(sahandle, pathp, B_TRUE)) == NULL) {
+	while ((dataset = get_zfs_dataset(handle, pathp, B_TRUE)) == NULL) {
 		char *p;
 
 		if (pathp == path) {
@@ -1322,42 +1313,36 @@
 		}
 	}
 
-	libhandle = libzfs_init();
-	if (libhandle != NULL) {
-		char *resource_name;
-
-		i = (sh->sh_path ? strlen(sh->sh_path) : 0);
-		sh->sh_size = i;
-
-		j = (sh->sh_res ? strlen(sh->sh_res) : 0);
-		sh->sh_size += j;
-		SMAX(i, j);
-
-		j = (sh->sh_fstype ? strlen(sh->sh_fstype) : 0);
-		sh->sh_size += j;
-		SMAX(i, j);
-
-		j = (sh->sh_opts ? strlen(sh->sh_opts) : 0);
-		sh->sh_size += j;
-		SMAX(i, j);
-
-		j = (sh->sh_descr ? strlen(sh->sh_descr) : 0);
-		sh->sh_size += j;
-		SMAX(i, j);
-
-		resource_name = sa_get_resource_attr(resource, "name");
-
-		err = zfs_deleg_share_nfs(libhandle, dataset, path,
-		    resource_name, exportdata, sh, i, operation);
-		if (err == SA_OK)
-			sa_update_sharetab_ts(sahandle);
-		else
-			err = errno;
-		if (resource_name)
-			sa_free_attr_string(resource_name);
+	i = (sh->sh_path ? strlen(sh->sh_path) : 0);
+	sh->sh_size = i;
+
+	j = (sh->sh_res ? strlen(sh->sh_res) : 0);
+	sh->sh_size += j;
+	SMAX(i, j);
+
+	j = (sh->sh_fstype ? strlen(sh->sh_fstype) : 0);
+	sh->sh_size += j;
+	SMAX(i, j);
+
+	j = (sh->sh_opts ? strlen(sh->sh_opts) : 0);
+	sh->sh_size += j;
+	SMAX(i, j);
+
+	j = (sh->sh_descr ? strlen(sh->sh_descr) : 0);
+	sh->sh_size += j;
+	SMAX(i, j);
+
+	resource_name = sa_get_resource_attr(resource, "name");
+
+	err = zfs_deleg_share_nfs(handle->zfs_libhandle, dataset, path,
+	    resource_name, exportdata, sh, i, operation);
+	if (err == SA_OK)
+		sa_update_sharetab_ts(handle);
+	else
+		err = errno;
+	if (resource_name != NULL)
+		sa_free_attr_string(resource_name);
 
-		libzfs_fini(libhandle);
-	}
 	free(dataset);
 	return (err);
 }
@@ -1373,89 +1358,7 @@
 libzfs_handle_t *
 sa_get_zfs_handle(sa_handle_t handle)
 {
-	sa_handle_impl_t implhandle = (sa_handle_impl_t)handle;
-
-	return (implhandle->zfs_libhandle);
-}
-
-/*
- * sa_get_zfs_info(libzfs, path, mountpoint, dataset)
- *
- * Find the ZFS dataset and mountpoint for a given path
- */
-int
-sa_zfs_get_info(libzfs_handle_t *libzfs, char *path, char *mountpointp,
-    char *datasetp)
-{
-	get_all_cbdata_t cb = { 0 };
-	int i;
-	char mountpoint[ZFS_MAXPROPLEN];
-	char dataset[ZFS_MAXPROPLEN];
-	char canmount[ZFS_MAXPROPLEN];
-	char *dp;
-	int count;
-	int ret = 0;
-
-	cb.cb_types = ZFS_TYPE_FILESYSTEM;
-
-	if (libzfs == NULL)
-		return (0);
-
-	(void) zfs_iter_root(libzfs, get_one_filesystem, &cb);
-	count = cb.cb_used;
-
-	qsort(cb.cb_handles, count, sizeof (void *), mountpoint_compare);
-	for (i = 0; i < count; i++) {
-		/* must have a mountpoint */
-		if (zfs_prop_get(cb.cb_handles[i], ZFS_PROP_MOUNTPOINT,
-		    mountpoint, sizeof (mountpoint),
-		    NULL, NULL, 0, B_FALSE) != 0) {
-			/* no mountpoint */
-			continue;
-		}
-
-		/* mountpoint must be a path */
-		if (strcmp(mountpoint, ZFS_MOUNTPOINT_NONE) == 0 ||
-		    strcmp(mountpoint, ZFS_MOUNTPOINT_LEGACY) == 0) {
-			/*
-			 * Search mmttab for mountpoint
-			 */
-
-			if (get_legacy_mountpoint(path, dataset,
-			    ZFS_MAXPROPLEN, mountpoint,
-			    ZFS_MAXPROPLEN) == 0) {
-				ret = 1;
-				break;
-			}
-			continue;
-		}
-
-		/* canmount must be set */
-		canmount[0] = '\0';
-		if (zfs_prop_get(cb.cb_handles[i], ZFS_PROP_CANMOUNT, canmount,
-		    sizeof (canmount), NULL, NULL, 0, B_FALSE) != 0 ||
-		    strcmp(canmount, "off") == 0)
-			continue;
-
-		/*
-		 * have a mountable handle but want to skip those marked none
-		 * and legacy
-		 */
-		if (strcmp(mountpoint, path) == 0) {
-			dp = (char *)zfs_get_name(cb.cb_handles[i]);
-			if (dp != NULL) {
-				if (datasetp != NULL)
-					(void) strcpy(datasetp, dp);
-				if (mountpointp != NULL)
-					(void) strcpy(mountpointp, mountpoint);
-				ret = 1;
-			}
-			break;
-		}
-
-	}
-
-	return (ret);
+	return (handle->zfs_libhandle);
 }
 
 /*
@@ -1465,7 +1368,7 @@
 static int
 sa_zfs_sprintf_new_prop(nvlist_t *nvl, char *sharesmb_val)
 {
-	char cur_val[MAXPATHLEN];
+	char cur_val[ZFS_MAXPROPLEN];
 	char *name, *val;
 	nvpair_t *cur;
 	int err = 0;
@@ -1477,8 +1380,8 @@
 		if ((err != 0) || (name == NULL) || (val == NULL))
 			return (-1);
 
-		(void) snprintf(cur_val, MAXPATHLEN, "%s=%s,", name, val);
-		(void) strlcat(sharesmb_val, cur_val, MAXPATHLEN);
+		(void) snprintf(cur_val, ZFS_MAXPROPLEN, "%s=%s,", name, val);
+		(void) strlcat(sharesmb_val, cur_val, ZFS_MAXPROPLEN);
 
 		cur = nvlist_next_nvpair(nvl, cur);
 	}
@@ -1497,7 +1400,7 @@
 static int
 sa_zfs_sprintf_existing_prop(zfs_handle_t *handle, char *sharesmb_val)
 {
-	char shareopts[ZFS_MAXPROPLEN], cur_val[MAXPATHLEN];
+	char shareopts[ZFS_MAXPROPLEN], cur_val[ZFS_MAXPROPLEN];
 	char *token, *last, *value;
 
 	if (zfs_prop_get(handle, ZFS_PROP_SHARESMB, shareopts,
@@ -1514,11 +1417,11 @@
 			return (-1);
 		*value++ = '\0';
 
-		(void) snprintf(cur_val, MAXPATHLEN, "%s=", token);
+		(void) snprintf(cur_val, ZFS_MAXPROPLEN, "%s=", token);
 		if (strstr(sharesmb_val, cur_val) == NULL) {
-			(void) strlcat(cur_val, value, MAXPATHLEN);
-			(void) strlcat(cur_val, ",", MAXPATHLEN);
-			(void) strlcat(sharesmb_val, cur_val, MAXPATHLEN);
+			(void) strlcat(cur_val, value, ZFS_MAXPROPLEN);
+			(void) strlcat(cur_val, ",", ZFS_MAXPROPLEN);
+			(void) strlcat(sharesmb_val, cur_val, ZFS_MAXPROPLEN);
 		}
 	}
 
@@ -1540,8 +1443,7 @@
 sa_zfs_setprop(sa_handle_t handle, char *path, nvlist_t *nvl)
 {
 	zfs_handle_t *z_fs;
-	libzfs_handle_t *z_lib;
-	char sharesmb_val[MAXPATHLEN];
+	char sharesmb_val[ZFS_MAXPROPLEN];
 	char *dataset, *lastcomma;
 
 	if (nvlist_empty(nvl))
@@ -1553,30 +1455,22 @@
 	if ((dataset = get_zfs_dataset(handle, path, B_FALSE)) == NULL)
 		return (-1);
 
-	if ((z_lib = libzfs_init()) == NULL) {
-		free(dataset);
-		return (-1);
-	}
-
-	z_fs = zfs_open(z_lib, dataset, ZFS_TYPE_DATASET);
+	z_fs = zfs_open(handle->zfs_libhandle, dataset, ZFS_TYPE_DATASET);
 	if (z_fs == NULL) {
 		free(dataset);
-		libzfs_fini(z_lib);
 		return (-1);
 	}
 
-	bzero(sharesmb_val, MAXPATHLEN);
+	bzero(sharesmb_val, ZFS_MAXPROPLEN);
 	if (sa_zfs_sprintf_new_prop(nvl, sharesmb_val) != 0) {
 		free(dataset);
 		zfs_close(z_fs);
-		libzfs_fini(z_lib);
 		return (-1);
 	}
 
 	if (sa_zfs_sprintf_existing_prop(z_fs, sharesmb_val) != 0) {
 		free(dataset);
 		zfs_close(z_fs);
-		libzfs_fini(z_lib);
 		return (-1);
 	}
 
@@ -1588,7 +1482,6 @@
 	    sharesmb_val);
 	free(dataset);
 	zfs_close(z_fs);
-	libzfs_fini(z_lib);
 
 	return (0);
 }
--- old/usr/src/lib/libshare/common/libsharecore.c	2013-09-10 06:31:59.189364253 +0100
+++ new/usr/src/lib/libshare/common/libsharecore.c	2013-09-10 06:31:59.196688053 +0100
@@ -21,6 +21,7 @@
 
 /*
  * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013 RackTop Systems.
  */
 
 /*
@@ -90,7 +91,7 @@
 /* prototypes */
 void getlegacyconfig(sa_handle_t, char *, xmlNodePtr *);
 extern sa_share_t _sa_add_share(sa_group_t, char *, int, int *, uint64_t);
-extern sa_group_t _sa_create_group(sa_handle_impl_t, char *);
+extern sa_group_t _sa_create_group(sa_handle_t, char *);
 static void outdfstab(FILE *, xfs_sharelist_t *);
 extern int _sa_remove_optionset(sa_optionset_t);
 extern int set_node_share(void *, char *, char *);
@@ -741,10 +742,10 @@
  * property for the specified protocol.
  */
 
-int
+boolean_t
 sa_is_security(char *optname, char *proto)
 {
-	int ret = 0;
+	int ret = B_FALSE;
 	if (proto != NULL)
 		ret = sa_proto_security_prop(proto, optname);
 	return (ret);
@@ -775,14 +776,14 @@
  * returns true of the object is of type "share".
  */
 
-int
+boolean_t
 sa_is_share(void *object)
 {
 	if (object != NULL) {
 		if (strcmp((char *)((xmlNodePtr)object)->name, "share") == 0)
-		return (1);
+		return (B_TRUE);
 	}
-	return (0);
+	return (B_FALSE);
 }
 /*
  * sa_is_resource(object)
@@ -790,14 +791,14 @@
  * returns true of the object is of type "share".
  */
 
-int
+boolean_t
 sa_is_resource(void *object)
 {
 	if (object != NULL) {
 		if (strcmp((char *)((xmlNodePtr)object)->name, "resource") == 0)
-			return (1);
+			return (B_TRUE);
 	}
-	return (0);
+	return (B_FALSE);
 }
 
 /*
@@ -1518,9 +1519,7 @@
 					if (group == NULL &&
 					    err == SA_NO_PERMISSION) {
 						group = _sa_create_group(
-						    (sa_handle_impl_t)
-						    handle,
-						    "zfs");
+						    handle, "zfs");
 					}
 					if (group != NULL) {
 						(void) sa_create_optionset(
@@ -1575,7 +1574,7 @@
  * in a repository.
  */
 int
-gettransients(sa_handle_impl_t ihandle, xmlNodePtr *root)
+gettransients(sa_handle_t handle, xmlNodePtr *root)
 {
 	int legacy = 0;
 	int numproto;
@@ -1586,11 +1585,11 @@
 		if (*root == NULL)
 			*root = xmlNewNode(NULL, (xmlChar *)"sharecfg");
 		if (*root != NULL) {
-			legacy = parse_sharetab(ihandle);
+			legacy = parse_sharetab(handle);
 			numproto = sa_get_protocols(&protocols);
 			for (i = 0; i < numproto; i++)
 				legacy |= sa_proto_get_transients(
-				    (sa_handle_t)ihandle, protocols[i]);
+				    handle, protocols[i]);
 			if (protocols != NULL)
 				free(protocols);
 		}
@@ -2089,10 +2088,9 @@
 sa_update_sharetab_ts(sa_handle_t handle)
 {
 	struct stat st;
-	sa_handle_impl_t implhandle = (sa_handle_impl_t)handle;
 
-	if (implhandle != NULL && stat(SA_LEGACY_SHARETAB, &st) == 0)
-		implhandle->tssharetab = TSTAMP(st.st_mtim);
+	if (handle != NULL && stat(SA_LEGACY_SHARETAB, &st) == 0)
+		handle->tssharetab = TSTAMP(st.st_mtim);
 }
 
 /*
@@ -2175,7 +2173,6 @@
 boolean_t
 sa_needs_refresh(sa_handle_t handle)
 {
-	sa_handle_impl_t implhandle = (sa_handle_impl_t)handle;
 	struct stat st;
 	char *str;
 	uint64_t tstamp;
@@ -2191,7 +2188,7 @@
 	 * caught.
 	 */
 	if (stat(SA_LEGACY_SHARETAB, &st) == 0 &&
-	    TSTAMP(st.st_mtim) != implhandle->tssharetab)
+	    TSTAMP(st.st_mtim) != handle->tssharetab)
 		return (B_TRUE);
 
 	/*
@@ -2199,7 +2196,7 @@
 	 * SMF transactions that modified the config but didn't
 	 * initiate a share.  This is less common but does happen.
 	 */
-	prop = scf_simple_prop_get(implhandle->scfhandle->handle,
+	prop = scf_simple_prop_get(handle->scfhandle->handle,
 	    (const char *)SA_SVC_FMRI_BASE ":default", "state",
 	    "lastupdate");
 	if (prop != NULL) {
@@ -2209,7 +2206,7 @@
 		else
 			tstamp = 0;
 		scf_simple_prop_free(prop);
-		if (tstamp != implhandle->tstrans)
+		if (tstamp != handle->tstrans)
 			return (B_TRUE);
 	}
 
--- old/usr/src/lib/libshare/common/scfutil.c	2013-09-10 06:31:59.539151228 +0100
+++ new/usr/src/lib/libshare/common/scfutil.c	2013-09-10 06:31:59.549188091 +0100
@@ -24,6 +24,10 @@
  * Use is subject to license terms.
  */
 
+/*
+ * Copyright (c) 2013 RackTop Systems.
+ */
+
 /* helper functions for using libscf with sharemgr */
 
 #include <libscf.h>
@@ -43,8 +47,8 @@
 
 ssize_t scf_max_name_len;
 extern struct sa_proto_plugin *sap_proto_list;
-extern sa_handle_impl_t get_handle_for_root(xmlNodePtr);
-static void set_transaction_tstamp(sa_handle_impl_t);
+extern sa_handle_t get_handle_for_root(xmlNodePtr);
+static void set_transaction_tstamp(sa_handle_t);
 /*
  * The SMF facility uses some properties that must exist. We want to
  * skip over these when processing protocol options.
@@ -97,7 +101,7 @@
  */
 
 scfutilhandle_t *
-sa_scf_init(sa_handle_impl_t ihandle)
+sa_scf_init(sa_handle_t ihandle)
 {
 	scfutilhandle_t *handle;
 
@@ -141,7 +145,7 @@
 	handle->scf_state = SCH_STATE_INIT;
 	if (sa_get_instance(handle, "default") != SA_OK) {
 		sa_group_t defgrp;
-		defgrp = sa_create_group((sa_handle_t)ihandle, "default", NULL);
+		defgrp = sa_create_group(ihandle, "default", NULL);
 		/* Only NFS enabled for "default" group. */
 		if (defgrp != NULL)
 			(void) sa_create_optionset(defgrp, "nfs");
@@ -1349,7 +1353,7 @@
  */
 
 int
-sa_end_transaction(scfutilhandle_t *handle, sa_handle_impl_t sahandle)
+sa_end_transaction(scfutilhandle_t *handle, sa_handle_t sahandle)
 {
 	int ret = SA_OK;
 
@@ -1392,7 +1396,7 @@
  * last transaction. This lets us detect changes from other processes.
  */
 static void
-set_transaction_tstamp(sa_handle_impl_t sahandle)
+set_transaction_tstamp(sa_handle_t sahandle)
 {
 	char tstring[32];
 	struct timeval tv;
@@ -1776,9 +1780,8 @@
 			}
 			/* Make sure we cleanup the transaction */
 			if (ret == SA_OK) {
-				sa_handle_impl_t sahandle;
-				sahandle = (sa_handle_impl_t)
-				    sa_find_group_handle(group);
+				sa_handle_t sahandle;
+				sahandle = sa_find_group_handle(group);
 				if (sahandle != NULL)
 					ret = sa_end_transaction(handle,
 					    sahandle);
