diff options
| author | Allan Jude <allan@klarasystems.com> | 2025-12-18 17:25:09 +0000 |
|---|---|---|
| committer | Tony Hutter <hutter2@llnl.gov> | 2026-02-05 21:48:31 +0000 |
| commit | ccb7c82aa15b1b3cb5b9e24e1ce56ec5aadbcd0d (patch) | |
| tree | ba37fae82f16f59829534de81202fd58aba83e64 | |
| parent | 0de2da6a376c52f6b68422ffac33920720168652 (diff) | |
zdb: Add -O option for -r to specify object-id
"zdb -r -O pool/dataset obj-id destination" will copy
the file with object-id obj-id to the named destination;
without -O it'll still be interpreted as a pathname.
Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Akash B <akash-b@hpe.com>
Signed-off-by: Sean Eric Fagan <sean.fagan@klarasystems.com>
Closes #16307
| -rw-r--r-- | cmd/zdb/zdb.c | 11 | ||||
| -rw-r--r-- | man/man8/zdb.8 | 11 |
2 files changed, 19 insertions, 3 deletions
diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index fa8e7fa691db..988bb09ebb93 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -738,13 +738,14 @@ usage(void) "[-U <cache>]\n\t\t<poolname> [<vdev> [<metaslab> ...]]\n" "\t%s -O [-K <key>] <dataset> <path>\n" "\t%s -r [-K <key>] <dataset> <path> <destination>\n" + "\t%s -r [-K <key>] -O <dataset> <object-id> <destination>\n" "\t%s -R [-A] [-e [-V] [-p <path> ...]] [-U <cache>]\n" "\t\t<poolname> <vdev>:<offset>:<size>[:<flags>]\n" "\t%s -E [-A] word0:word1:...:word15\n" "\t%s -S [-AP] [-e [-V] [-p <path> ...]] [-U <cache>] " "<poolname>\n\n", cmdname, cmdname, cmdname, cmdname, cmdname, cmdname, cmdname, - cmdname, cmdname, cmdname, cmdname, cmdname); + cmdname, cmdname, cmdname, cmdname, cmdname, cmdname); (void) fprintf(stderr, " Dataset name must include at least one " "separator character '/' or '@'\n"); @@ -9955,7 +9956,7 @@ main(int argc, char **argv) * which imports the pool to the namespace if it's * not in the cachefile. */ - if (dump_opt['O']) { + if (dump_opt['O'] && !dump_opt['r']) { if (argc != 2) usage(); dump_opt['v'] = verbose + 3; @@ -9968,7 +9969,11 @@ main(int argc, char **argv) if (argc != 3) usage(); dump_opt['v'] = verbose; - error = dump_path(argv[0], argv[1], &object); + if (dump_opt['O']) { + object = strtoull(argv[1], NULL, 0); + } else { + error = dump_path(argv[0], argv[1], &object); + } if (error != 0) fatal("internal error: %s", strerror(error)); } diff --git a/man/man8/zdb.8 b/man/man8/zdb.8 index f51e24fa849c..2d1742811fb8 100644 --- a/man/man8/zdb.8 +++ b/man/man8/zdb.8 @@ -84,6 +84,11 @@ .Op Fl K Ar key .Ar dataset path destination .Nm +.Fl r +.Fl O +.Op Fl K Ar key +.Ar dataset object-id destination +.Nm .Fl R .Op Fl A .Op Fl e Oo Fl V Oc Oo Fl p Ar path Oc Ns … @@ -376,6 +381,12 @@ Specified .Ar path must be relative to the root of .Ar dataset . +When used with +.Fl O , +the +.Ar path +argument is interpreted as an object identifier, +not a path. This option can be combined with .Fl v for increasing verbosity. |
