Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 31 Jul 2012 17:28:29 +0000 (UTC)
From:      Martin Matuska <mm@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r238950 - head/cddl/contrib/opensolaris/cmd/zpool
Message-ID:  <201207311728.q6VHSTlh051656@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mm
Date: Tue Jul 31 17:28:28 2012
New Revision: 238950
URL: http://svn.freebsd.org/changeset/base/238950

Log:
  Fix reporting of root pool upgrade notice.
  
  MFC after:	2 weeks

Modified:
  head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c

Modified: head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
==============================================================================
--- head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c	Tue Jul 31 17:08:29 2012	(r238949)
+++ head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c	Tue Jul 31 17:28:28 2012	(r238950)
@@ -4409,6 +4409,7 @@ typedef struct upgrade_cbdata {
 	char	**cb_argv;
 } upgrade_cbdata_t;
 
+#ifdef __FreeBSD__
 static int
 is_root_pool(zpool_handle_t *zhp)
 {
@@ -4434,6 +4435,14 @@ is_root_pool(zpool_handle_t *zhp)
 	return (poolname != NULL && strcmp(poolname, zpool_get_name(zhp)) == 0);
 }
 
+static void
+root_pool_upgrade_check(zpool_handle_t *zhp, char *poolname, int size) {
+
+	if (poolname[0] == '\0' && is_root_pool(zhp))
+		(void) strlcpy(poolname, zpool_get_name(zhp), size);
+}
+#endif	/* FreeBSD */
+
 static int
 upgrade_version(zpool_handle_t *zhp, uint64_t version)
 {
@@ -4524,12 +4533,8 @@ upgrade_cb(zpool_handle_t *zhp, void *ar
 		if (ret != 0)
 			return (ret);
 #ifdef __FreeBSD__
-		if (cbp->cb_poolname[0] == '\0' &&
-		    is_root_pool(zhp)) {
-			(void) strlcpy(cbp->cb_poolname,
-			    zpool_get_name(zhp),
-			    sizeof(cbp->cb_poolname));
-		}
+		root_pool_upgrade_check(zhp, cbp->cb_poolname,
+		    sizeof(cbp->cb_poolname));
 #endif	/* ___FreeBSD__ */
 		printnl = B_TRUE;
 
@@ -4682,17 +4687,12 @@ upgrade_one(zpool_handle_t *zhp, void *d
 	if (cur_version != cbp->cb_version) {
 		printnl = B_TRUE;
 		ret = upgrade_version(zhp, cbp->cb_version);
-		if (ret != 0) {
+		if (ret != 0)
+			return (ret);
 #ifdef __FreeBSD__
-			if (cbp->cb_poolname[0] == '\0' &&
-			    is_root_pool(zhp)) {
-				(void) strlcpy(cbp->cb_poolname,
-				    zpool_get_name(zhp),
-				    sizeof(cbp->cb_poolname));
-			}
+		root_pool_upgrade_check(zhp, cbp->cb_poolname,
+		    sizeof(cbp->cb_poolname));
 #endif	/* ___FreeBSD__ */
-			return (ret);
-		}
 	}
 
 	if (cbp->cb_version >= SPA_VERSION_FEATURES) {
@@ -4703,15 +4703,15 @@ upgrade_one(zpool_handle_t *zhp, void *d
 
 		if (count != 0) {
 			printnl = B_TRUE;
+#ifdef __FreeBSD__
+		root_pool_upgrade_check(zhp, cbp->cb_poolname,
+		    sizeof(cbp->cb_poolname));
+#endif	/* __FreeBSD __*/
 		} else if (cur_version == SPA_VERSION) {
 			(void) printf(gettext("Pool '%s' already has all "
 			    "supported features enabled.\n"),
 			    zpool_get_name(zhp));
 		}
-		if (cbp->cb_poolname[0] == '\0' && is_root_pool(zhp)) {
-			(void) strlcpy(cbp->cb_poolname, zpool_get_name(zhp),
-			    sizeof(cbp->cb_poolname));
-		}
 	}
 
 	if (printnl) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201207311728.q6VHSTlh051656>