aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/zdb
diff options
context:
space:
mode:
authorTim Chase <[email protected]>2015-05-14 12:45:56 -0500
committerBrian Behlendorf <[email protected]>2015-05-15 10:52:46 -0700
commitb1b85c8772ed28d2c8227e6d32905740817ae2c3 (patch)
treee22e9828d267566a36b75db823a3e0a6cad03ee3 /cmd/zdb
parent79065ed5a454d36492a3006fec69f14ddf83a88f (diff)
Zdb should be able to open the root dataset
If the pool/dataset command-line argument is specified with a trailing slash, for example, "tank/", it is interpreted as the root dataset. Signed-off-by: Tim Chase <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #3415
Diffstat (limited to 'cmd/zdb')
-rw-r--r--cmd/zdb/zdb.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c
index 0740b5ca6..d0bebbe60 100644
--- a/cmd/zdb/zdb.c
+++ b/cmd/zdb/zdb.c
@@ -3572,6 +3572,7 @@ main(int argc, char **argv)
int rewind = ZPOOL_NEVER_REWIND;
char *spa_config_path_env;
const char *opts = "bcdhilmMI:suCDRSAFLXevp:t:U:P";
+ boolean_t target_is_spa = B_TRUE;
(void) setrlimit(RLIMIT_NOFILE, &rl);
(void) enable_extended_FILE_stdio(-1, -1);
@@ -3740,8 +3741,17 @@ main(int argc, char **argv)
}
}
+ if (strpbrk(target, "/@") != NULL) {
+ size_t targetlen;
+
+ target_is_spa = B_FALSE;
+ targetlen = strlen(target);
+ if (targetlen && 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) {