6590941 zfs set mountpoint should not return 0 when it fails
authorrm160521
Tue, 13 Nov 2007 11:20:53 -0800
changeset 5473 fcdd1931b3aa
parent 5472 adc522112961
child 5474 d1f8ad75584a
6590941 zfs set mountpoint should not return 0 when it fails 6612544 zfs get all pool/vol@snap - internal error: unable to get version property
usr/src/lib/libzfs/common/libzfs_changelist.c
usr/src/lib/libzfs/common/libzfs_dataset.c
--- a/usr/src/lib/libzfs/common/libzfs_changelist.c	Tue Nov 13 06:14:34 2007 -0800
+++ b/usr/src/lib/libzfs/common/libzfs_changelist.c	Tue Nov 13 11:20:53 2007 -0800
@@ -150,7 +150,7 @@
 {
 	prop_changenode_t *cn;
 	char shareopts[ZFS_MAXPROPLEN];
-	int ret = 0;
+	int errors = 0;
 	libzfs_handle_t *hdl;
 
 	/*
@@ -180,7 +180,8 @@
 
 	/*
 	 * We walk the datasets in reverse, because we want to mount any parent
-	 * datasets before mounting the children.
+	 * datasets before mounting the children.  We walk all datasets even if
+	 * there are errors.
 	 */
 	for (cn = uu_list_last(clp->cl_list); cn != NULL;
 	    cn = uu_list_prev(clp->cl_list, cn)) {
@@ -205,7 +206,7 @@
 			if (clp->cl_realprop == ZFS_PROP_NAME &&
 			    zvol_create_link(cn->cn_handle->zfs_hdl,
 			    cn->cn_handle->zfs_name) != 0) {
-				ret = -1;
+				errors++;
 			} else if (cn->cn_shared ||
 			    clp->cl_prop == ZFS_PROP_SHAREISCSI) {
 				if (zfs_prop_get(cn->cn_handle,
@@ -213,9 +214,11 @@
 				    sizeof (shareopts), NULL, NULL, 0,
 				    B_FALSE) == 0 &&
 				    strcmp(shareopts, "off") == 0) {
-					ret = zfs_unshare_iscsi(cn->cn_handle);
+					errors +=
+					    zfs_unshare_iscsi(cn->cn_handle);
 				} else {
-					ret = zfs_share_iscsi(cn->cn_handle);
+					errors +=
+					    zfs_share_iscsi(cn->cn_handle);
 				}
 			}
 
@@ -237,26 +240,23 @@
 		if ((cn->cn_mounted || clp->cl_waslegacy || sharenfs ||
 		    sharesmb) && !zfs_is_mounted(cn->cn_handle, NULL) &&
 		    zfs_mount(cn->cn_handle, NULL, 0) != 0)
-			ret = -1;
+			errors++;
 
 		/*
 		 * We always re-share even if the filesystem is currently
 		 * shared, so that we can adopt any new options.
 		 */
-		if (cn->cn_shared || clp->cl_waslegacy ||
-		    sharenfs || sharesmb) {
-			if (sharenfs)
-				ret = zfs_share_nfs(cn->cn_handle);
-			else
-				ret = zfs_unshare_nfs(cn->cn_handle, NULL);
-			if (sharesmb)
-				ret = zfs_share_smb(cn->cn_handle);
-			else
-				ret = zfs_unshare_smb(cn->cn_handle, NULL);
-		}
+		if (sharenfs)
+			errors += zfs_share_nfs(cn->cn_handle);
+		else if (cn->cn_shared || clp->cl_waslegacy)
+			errors += zfs_unshare_nfs(cn->cn_handle, NULL);
+		if (sharesmb)
+			errors += zfs_share_smb(cn->cn_handle);
+		else if (cn->cn_shared || clp->cl_waslegacy)
+			errors += zfs_unshare_smb(cn->cn_handle, NULL);
 	}
 
-	return (ret);
+	return (errors ? -1 : 0);
 }
 
 /*
--- a/usr/src/lib/libzfs/common/libzfs_dataset.c	Tue Nov 13 06:14:34 2007 -0800
+++ b/usr/src/lib/libzfs/common/libzfs_dataset.c	Tue Nov 13 11:20:53 2007 -0800
@@ -1975,6 +1975,8 @@
 		break;
 
 	case ZFS_PROP_VERSION:
+		if (!zfs_prop_valid_for_type(prop, zhp->zfs_head_type))
+			return (-1);
 		(void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
 		if (zfs_ioctl(zhp->zfs_hdl, ZFS_IOC_OBJSET_VERSION, &zc) ||
 		    (zc.zc_cookie == 0)) {