aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndriy Gapon <avg@FreeBSD.org>2016-07-20 11:15:32 +0000
committerAndriy Gapon <avg@FreeBSD.org>2016-07-20 11:15:32 +0000
commit7ad541f1f855c9674129379af3a3dbe397cd9024 (patch)
treec8d04a160a37687e4e05bba3a5c4f2a3b99ee6aa
parent037140a44bd0ba6b80c67fa8f4c965b7580133c6 (diff)
parent053b1b4d5960e4a0899a818876331fef7120a37f (diff)
downloadsrc-7ad541f1f855c9674129379af3a3dbe397cd9024.tar.gz
src-7ad541f1f855c9674129379af3a3dbe397cd9024.zip
MFV r303083: 7164 zdb should be able to open the root dataset
Note: conversion of the manual page change from roff to mdoc is mine. illumos/illumos-gate@b702644a6eb66615d67b492fd73ecd9efa11fc7d https://github.com/illumos/illumos-gate/commit/b702644a6eb66615d67b492fd73ecd9efa11fc7d https://www.illumos.org/issues/7164 If the pool/dataset command-line argument is specified with a trailing slash, for example, "tank/", we should interpret it as the topmost dataset (rather than the whole pool) Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com> Reviewed by: Matthew Ahrens <mahrens@delphix.com> Approved by: Robert Mustacchi <rm@joyent.com> Author: Tim Chase <tim@chase2k.com> PR: 204661 MFC after: 1 week Relnotes: yes
Notes
Notes: svn path=/head/; revision=303086
-rw-r--r--cddl/contrib/opensolaris/cmd/zdb/zdb.811
-rw-r--r--cddl/contrib/opensolaris/cmd/zdb/zdb.c18
2 files changed, 28 insertions, 1 deletions
diff --git a/cddl/contrib/opensolaris/cmd/zdb/zdb.8 b/cddl/contrib/opensolaris/cmd/zdb/zdb.8
index 4ef437e9daa1..6ae25c398f2d 100644
--- a/cddl/contrib/opensolaris/cmd/zdb/zdb.8
+++ b/cddl/contrib/opensolaris/cmd/zdb/zdb.8
@@ -86,6 +86,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
diff --git a/cddl/contrib/opensolaris/cmd/zdb/zdb.c b/cddl/contrib/opensolaris/cmd/zdb/zdb.c
index 49311364a73c..893e6a268ffe 100644
--- a/cddl/contrib/opensolaris/cmd/zdb/zdb.c
+++ b/cddl/contrib/opensolaris/cmd/zdb/zdb.c
@@ -3559,6 +3559,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);
@@ -3738,8 +3739,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) {