diff options
author | Paul Dagnelie <[email protected]> | 2023-02-21 17:30:05 -0800 |
---|---|---|
committer | GitHub <[email protected]> | 2023-02-21 17:30:05 -0800 |
commit | d9e64a4030d141580af2e8b75e8982637818145a (patch) | |
tree | 88b0e73ff3b78e2384b7b42667daa15eda03696b /cmd/zfs/zfs_main.c | |
parent | 28251d81d723292a6813f93495f2c6c132938945 (diff) |
Improve error message of zfs redact
We improve the error message of zfs redact by checking if the target
snapshot exists, and if all the redaction snapshots exist. As a
future improvement we could iterate over every snapshot provided and
use that to determine which one specifically doesn't exist.
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Paul Dagnelie <[email protected]>
Closes #11426
Closes #14496
Diffstat (limited to 'cmd/zfs/zfs_main.c')
-rw-r--r-- | cmd/zfs/zfs_main.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index 1ffe805aa..437f83c2a 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -3882,10 +3882,25 @@ zfs_do_redact(int argc, char **argv) switch (err) { case 0: break; - case ENOENT: - (void) fprintf(stderr, - gettext("provided snapshot %s does not exist\n"), snap); + case ENOENT: { + zfs_handle_t *zhp = zfs_open(g_zfs, snap, ZFS_TYPE_SNAPSHOT); + if (zhp == NULL) { + (void) fprintf(stderr, gettext("provided snapshot %s " + "does not exist\n"), snap); + } else { + zfs_close(zhp); + } + for (int i = 0; i < numrsnaps; i++) { + zhp = zfs_open(g_zfs, rsnaps[i], ZFS_TYPE_SNAPSHOT); + if (zhp == NULL) { + (void) fprintf(stderr, gettext("provided " + "snapshot %s does not exist\n"), rsnaps[i]); + } else { + zfs_close(zhp); + } + } break; + } case EEXIST: (void) fprintf(stderr, gettext("specified redaction bookmark " "(%s) provided already exists\n"), bookname); |