Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 31 Aug 2010 23:13:06 +0000
From:      "Philip M. Gollucci" <pgollucci@p6m7g8.com>
To:        Pawel Jakub Dawidek <pjd@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r212050 - head/cddl/contrib/opensolaris/cmd/zpool
Message-ID:  <4C7D8C82.5090703@p6m7g8.com>
In-Reply-To: <201008311041.o7VAfrAF028012@svn.freebsd.org>
References:  <201008311041.o7VAfrAF028012@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Nice!



On 08/31/10 10:41, Pawel Jakub Dawidek wrote:
> Author: pjd
> Date: Tue Aug 31 10:41:53 2010
> New Revision: 212050
> URL: http://svn.freebsd.org/changeset/base/212050
> 
> Log:
>   When upgrading a pool which contain root file system, give user a hint that
>   he should update boot code.
>   
>   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 Aug 31 09:38:43 2010	(r212049)
> +++ head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c	Tue Aug 31 10:41:53 2010	(r212050)
> @@ -3333,12 +3333,39 @@ typedef struct upgrade_cbdata {
>  	int	cb_all;
>  	int	cb_first;
>  	int	cb_newer;
> +	char	cb_poolname[ZPOOL_MAXNAMELEN];
>  	int	cb_argc;
>  	uint64_t cb_version;
>  	char	**cb_argv;
>  } upgrade_cbdata_t;
>  
>  static int
> +is_root_pool(zpool_handle_t *zhp)
> +{
> +	static struct statfs sfs;
> +	static char *poolname = NULL;
> +	static boolean_t stated = B_FALSE;
> +	char *slash;
> +
> +	while (!stated) {
> +		stated = B_TRUE;
> +		if (statfs("/", &sfs) == -1) {
> +			(void) fprintf(stderr,
> +			    "Unable to stat root file system: %s.\n",
> +			    strerror(errno));
> +			break;
> +		}
> +		if (strcmp(sfs.f_fstypename, "zfs") != 0)
> +			break;
> +		poolname = sfs.f_mntfromname;
> +		if ((slash = strchr(poolname, '/')) != NULL)
> +			*slash = '\0';
> +		break;
> +	}
> +	return (poolname != NULL && strcmp(poolname, zpool_get_name(zhp)) == 0);
> +}
> +
> +static int
>  upgrade_cb(zpool_handle_t *zhp, void *arg)
>  {
>  	upgrade_cbdata_t *cbp = arg;
> @@ -3371,6 +3398,12 @@ upgrade_cb(zpool_handle_t *zhp, void *ar
>  			if (!ret) {
>  				(void) printf(gettext("Successfully upgraded "
>  				    "'%s'\n\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));
> +				}
>  			}
>  		}
>  	} else if (cbp->cb_newer && version > SPA_VERSION) {
> @@ -3428,6 +3461,10 @@ upgrade_one(zpool_handle_t *zhp, void *d
>  		    "from version %llu to version %llu\n\n"),
>  		    zpool_get_name(zhp), (u_longlong_t)cur_version,
>  		    (u_longlong_t)cbp->cb_version);
> +		if (cbp->cb_poolname[0] == '\0' && is_root_pool(zhp)) {
> +			(void) strlcpy(cbp->cb_poolname, zpool_get_name(zhp),
> +			    sizeof(cbp->cb_poolname));
> +		}
>  	}
>  
>  	return (ret != 0);
> @@ -3569,6 +3606,16 @@ zpool_do_upgrade(int argc, char **argv)
>  		    upgrade_one, &cb);
>  	}
>  
> +	if (cb.cb_poolname[0] != '\0') {
> +		(void) printf(
> +		    "If you boot from pool '%s', don't forget to update boot code.\n"
> +		    "Assuming you use GPT partitioning and da0 is your boot disk\n"
> +		    "the following command will do it:\n"
> +		    "\n"
> +		    "\tgpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 da0\n\n",
> +		    cb.cb_poolname);
> +	}
> +
>  	return (ret);
>  }
>  
> _______________________________________________
> svn-src-all@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/svn-src-all
> To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"


- -- 
- ------------------------------------------------------------------------
1024D/DB9B8C1C B90B FBC3 A3A1 C71A 8E70  3F8C 75B8 8FFB DB9B 8C1C
Philip M. Gollucci (pgollucci@p6m7g8.com) c: 703.336.9354
VP Apache Infrastructure; Member, Apache Software Foundation
Committer,                        FreeBSD Foundation
Consultant,                       P6M7G8 Inc.
Sr. System Admin,                 Ridecharge Inc.

Work like you don't need the money,
love like you'll never get hurt,
and dance like nobody's watching.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (FreeBSD)

iD8DBQFMfYyCdbiP+9ubjBwRAvY2AJ9c8KljK10d+BDUdxhoX+zs5IOrVwCeNqun
xWIPcs2YJT0xAbAryFY8Gvs=
=T0tq
-----END PGP SIGNATURE-----



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