Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Aug 2016 08:49:32 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r304119 - stable/9/cddl/contrib/opensolaris/cmd/zdb
Message-ID:  <201608150849.u7F8nWIa053047@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avg
Date: Mon Aug 15 08:49:31 2016
New Revision: 304119
URL: https://svnweb.freebsd.org/changeset/base/304119

Log:
  MFC r303086: 7164 zdb should be able to open the root dataset

Modified:
  stable/9/cddl/contrib/opensolaris/cmd/zdb/zdb.8
  stable/9/cddl/contrib/opensolaris/cmd/zdb/zdb.c
Directory Properties:
  stable/9/cddl/contrib/opensolaris/cmd/zdb/   (props changed)

Modified: stable/9/cddl/contrib/opensolaris/cmd/zdb/zdb.8
==============================================================================
--- stable/9/cddl/contrib/opensolaris/cmd/zdb/zdb.8	Mon Aug 15 08:49:07 2016	(r304118)
+++ stable/9/cddl/contrib/opensolaris/cmd/zdb/zdb.8	Mon Aug 15 08:49:31 2016	(r304119)
@@ -85,6 +85,17 @@ pool, and is inherently unstable.
 The precise output of most invocations is not documented, a knowledge of ZFS
 internals is assumed.
 .Pp
+If the
+.Ar dataset
+argument does not contain any
+.Sy /
+or
+.Sy @
+characters, it is interpreted as a pool name.
+The root dataset can be specified as
+.Pa pool Ns Sy /
+(pool name followed by a slash).
+.Pp
 When operating on an imported and active pool it is possible, though unlikely,
 that zdb may interpret inconsistent pool data and behave erratically.
 .Sh OPTIONS

Modified: stable/9/cddl/contrib/opensolaris/cmd/zdb/zdb.c
==============================================================================
--- stable/9/cddl/contrib/opensolaris/cmd/zdb/zdb.c	Mon Aug 15 08:49:07 2016	(r304118)
+++ stable/9/cddl/contrib/opensolaris/cmd/zdb/zdb.c	Mon Aug 15 08:49:31 2016	(r304119)
@@ -3274,6 +3274,7 @@ main(int argc, char **argv)
 	uint64_t max_txg = UINT64_MAX;
 	int rewind = ZPOOL_NEVER_REWIND;
 	char *spa_config_path_env;
+	boolean_t target_is_spa = B_TRUE;
 
 	(void) setrlimit(RLIMIT_NOFILE, &rl);
 	(void) enable_extended_FILE_stdio(-1, -1);
@@ -3434,8 +3435,23 @@ main(int argc, char **argv)
 		}
 	}
 
+	if (strpbrk(target, "/@") != NULL) {
+		size_t targetlen;
+
+		target_is_spa = B_FALSE;
+		/*
+		 * Remove any trailing slash.  Later code would get confused
+		 * by it, but we want to allow it so that "pool/" can
+		 * indicate that we want to dump the topmost filesystem,
+		 * rather than the whole pool.
+		 */
+		targetlen = strlen(target);
+		if (targetlen != 0 && target[targetlen - 1] == '/')
+			target[targetlen - 1] = '\0';
+	}
+
 	if (error == 0) {
-		if (strpbrk(target, "/@") == NULL || dump_opt['R']) {
+		if (target_is_spa || dump_opt['R']) {
 			error = spa_open_rewind(target, &spa, FTAG, policy,
 			    NULL);
 			if (error) {



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