cmd/zfs: redact: better error message for common usage errors
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Matt Ahrens <matt@delphix.com> Signed-off-by: Christian Schwarz <me@cschwarz.com> Closes #9867
This commit is contained in:
parent
7b53e2e5a9
commit
f658f61c72
|
@ -3746,8 +3746,13 @@ zfs_do_redact(int argc, char **argv)
|
|||
"specified\n"));
|
||||
break;
|
||||
case EINVAL:
|
||||
(void) fprintf(stderr, gettext("redaction snapshot must be "
|
||||
"descendent of snapshot being redacted\n"));
|
||||
if (strchr(bookname, '#') != NULL)
|
||||
(void) fprintf(stderr, gettext(
|
||||
"redaction bookmark name must not contain '#'\n"));
|
||||
else
|
||||
(void) fprintf(stderr, gettext(
|
||||
"redaction snapshot must be descendent of "
|
||||
"snapshot being redacted\n"));
|
||||
break;
|
||||
case EALREADY:
|
||||
(void) fprintf(stderr, gettext("attempted to redact redacted "
|
||||
|
@ -3757,6 +3762,10 @@ zfs_do_redact(int argc, char **argv)
|
|||
(void) fprintf(stderr, gettext("redaction bookmarks feature "
|
||||
"not enabled\n"));
|
||||
break;
|
||||
case EXDEV:
|
||||
(void) fprintf(stderr, gettext("potentially invalid redaction "
|
||||
"snapshot; full dataset names required\n"));
|
||||
break;
|
||||
default:
|
||||
(void) fprintf(stderr, gettext("internal error: %s\n"),
|
||||
strerror(errno));
|
||||
|
|
|
@ -77,4 +77,12 @@ log_mustnot zfs redact $recvfs@snap book5 $clone3@snap
|
|||
# Nor may a redacted dataset appear in the redaction list.
|
||||
log_mustnot zfs redact testpool2/recvfs@snap2 book7 testpool2/recvfs@snap
|
||||
|
||||
# Error messages for common usage errors
|
||||
log_mustnot_expect "not contain '#'" zfs redact $sendfs@snap1 \#book $sendfs@snap2
|
||||
log_mustnot_expect "not contain '#'" zfs redact $sendfs@snap1 $sendfs#book $sendfs@snap2
|
||||
log_mustnot_expect "full dataset names" zfs redact $sendfs@snap1 book @snap2
|
||||
log_mustnot_expect "full dataset names" zfs redact $sendfs@snap1 book @snap2
|
||||
log_mustnot_expect "full dataset names" zfs redact $sendfs@snap1 \#book @snap2
|
||||
log_mustnot_expect "descendent of snapshot" zfs redact $sendfs@snap2 book $sendfs@snap1
|
||||
|
||||
log_pass "Verify that redacted send correctly detects invalid arguments."
|
||||
|
|
Loading…
Reference in New Issue