]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Zdb should be able to open the root dataset
authorTim Chase <tim@chase2k.com>
Thu, 14 May 2015 17:45:56 +0000 (12:45 -0500)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 15 May 2015 17:52:46 +0000 (10:52 -0700)
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 <tim@chase2k.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3415

cmd/zdb/zdb.c
man/man8/zdb.8

index 0740b5ca6e24a0132b4a355e8470a40e7fdf5e7f..d0bebbe60f70574ce867a10a501e1cdc7ccce043 100644 (file)
@@ -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) {
index 2bfe9683b1697bc50456fc6e282db95ae2088b60..d19e4a39ff1624a2e307e1ea7a03a078e0661bac 100644 (file)
@@ -55,6 +55,11 @@ The output of this command in general reflects the on-disk structure of a ZFS
 pool, and is inherently unstable. The precise output of most invocations is
 not documented, a knowledge of ZFS internals is assumed.
 
+.P
+If the \fIdataset\fR argument does not contain any \fB/\fR or \fB@\fR
+characters, it is interpreted as a pool name.  The root dataset can be
+specified as \fIpool\fB/\fR (pool name followed by a slash).
+
 .P
 When operating on an imported and active pool it is possible, though unlikely,
 that zdb may interpret inconsistent pool data and behave erratically.