Codereview comments from Mark Powers
authorDarren Moffat <Darren.Moffat@Sun.COM>
Wed, 17 Sep 2008 11:29:02 +0100
changeset 13379 d6b57c3cce0b
parent 13378 a73d1d10b351
child 13380 f9f096bdd133
Codereview comments from Mark Powers
usr/src/cmd/zdb/zdb.c
usr/src/cmd/zpool/zpool_main.c
--- a/usr/src/cmd/zdb/zdb.c	Wed Sep 17 11:24:10 2008 +0100
+++ b/usr/src/cmd/zdb/zdb.c	Wed Sep 17 11:29:02 2008 +0100
@@ -1075,9 +1075,10 @@
 		    zio_compress_table[doi.doi_compress].ci_name);
 	}
 
-	if (doi.doi_crypt != ZIO_CRYPT_INHERIT || verbosity >= 6)
+	if (doi.doi_crypt != ZIO_CRYPT_INHERIT || verbosity >= 6) {
 		(void) snprintf(aux + strlen(aux), sizeof (aux), " (E=%s)",
-		zio_crypt_table[doi.doi_crypt].ci_name);
+		    zio_crypt_table[doi.doi_crypt].ci_name);
+	}
 
 	(void) printf("%10lld  %3u  %5s  %5s  %5s  %5s  %s%s\n",
 	    (u_longlong_t)object, doi.doi_indirection, iblk, dblk, lsize,
--- a/usr/src/cmd/zpool/zpool_main.c	Wed Sep 17 11:24:10 2008 +0100
+++ b/usr/src/cmd/zpool/zpool_main.c	Wed Sep 17 11:29:02 2008 +0100
@@ -815,6 +815,7 @@
 zpool_do_destroy(int argc, char **argv)
 {
 	boolean_t force = B_FALSE;
+	boolean_t encrypted_only = B_FALSE;
 	int c;
 	char *pool;
 	zpool_handle_t *zhp;
@@ -859,7 +860,7 @@
 		return (1);
 	}
 
-	if (zpool_disable_datasets(zhp, force, B_FALSE) != 0) {
+	if (zpool_disable_datasets(zhp, force, encrypted_only) != 0) {
 		(void) fprintf(stderr, gettext("could not destroy '%s': "
 		    "could not unmount datasets\n"), zpool_get_name(zhp));
 		return (1);
@@ -885,6 +886,7 @@
 zpool_do_export(int argc, char **argv)
 {
 	boolean_t force = B_FALSE;
+	boolean_t encrypted_only = B_FALSE;
 	int c;
 	zpool_handle_t *zhp;
 	int ret;
@@ -919,7 +921,7 @@
 			continue;
 		}
 
-		if (zpool_disable_datasets(zhp, force, B_FALSE) != 0) {
+		if (zpool_disable_datasets(zhp, force, encrypted_only) != 0) {
 			ret = 1;
 			zpool_close(zhp);
 			continue;
@@ -1263,6 +1265,7 @@
 do_import(nvlist_t *config, const char *newname, const char *mntopts,
     int force, nvlist_t *props, boolean_t allowfaulted)
 {
+	boolean_t encrypted_only = B_FALSE;
 	zpool_handle_t *zhp;
 	char *name;
 	uint64_t state;
@@ -1327,7 +1330,7 @@
 	 * Attempt to load the crypto keys before mounting up the datasets
 	 * Note that depending of the value of the keysource property
 	 * this could cause us to go interactive.
-	 * We don't mind if this fails though and continue to enable what
+	 * We don't mind if this falls though and continue to enable what
 	 * datasets we can if it does.
 	 *
 	 * Use zpool_load_key() and tell it we are doing an import rather than
@@ -1345,7 +1348,7 @@
 		    libzfs_error_description(zpool_hdl));
 	}
 
-	if (zpool_enable_datasets(zhp, mntopts, 0, B_FALSE) != 0) {
+	if (zpool_enable_datasets(zhp, mntopts, 0, encrypted_only) != 0) {
 		zpool_close(zhp);
 		return (1);
 	}
@@ -3891,7 +3894,7 @@
 }
 
 
-int
+static int
 /* LINTED E_FUNC_ARG_UNUSED */
 set_callback_key_load(zpool_handle_t *zhp, void *data)
 {
@@ -3905,7 +3908,7 @@
 	return (0);
 }
 
-int
+static int
 /* LINTED E_FUNC_ARG_UNUSED */
 set_callback_key_unload(zpool_handle_t *zhp, void *data)
 {
@@ -3914,13 +3917,7 @@
 }
 
 
-int
-set_callback_key_change(zpool_handle_t *zhp, void *data)
-{
-	return (zpool_cmd_key_change(zhp, (nvlist_t *)data));
-}
-
-int
+static int
 zpool_do_key(int argc, char **argv)
 {
 	int error = 1, options = 0;
@@ -3957,6 +3954,13 @@
 
 			*propval = '\0';
 			propval++;
+			if (strcmp(optarg, "keysource") != 0) {
+				(void) fprintf(stderr, gettext(
+				    "Invalid property for key change: "
+				    "\"%s\"\n"),
+				    optarg);
+				return (error);
+			}
 			if (add_prop_list(optarg, propval, &props, B_TRUE))
 				return (error);