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 <behlendorf1@llnl.gov> Signed-off-by: Paul Dagnelie <pcd@delphix.com> Closes #11426 Closes #14496
This commit is contained in:
parent
28251d81d7
commit
d9e64a4030
|
@ -3882,10 +3882,25 @@ zfs_do_redact(int argc, char **argv)
|
||||||
switch (err) {
|
switch (err) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case ENOENT:
|
case ENOENT: {
|
||||||
(void) fprintf(stderr,
|
zfs_handle_t *zhp = zfs_open(g_zfs, snap, ZFS_TYPE_SNAPSHOT);
|
||||||
gettext("provided snapshot %s does not exist\n"), snap);
|
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;
|
break;
|
||||||
|
}
|
||||||
case EEXIST:
|
case EEXIST:
|
||||||
(void) fprintf(stderr, gettext("specified redaction bookmark "
|
(void) fprintf(stderr, gettext("specified redaction bookmark "
|
||||||
"(%s) provided already exists\n"), bookname);
|
"(%s) provided already exists\n"), bookname);
|
||||||
|
|
Loading…
Reference in New Issue