From bdbd5477bcba03b1df1e02b3b89e795c99e2f4c8 Mon Sep 17 00:00:00 2001 From: LOLi Date: Tue, 4 Dec 2018 18:38:55 +0100 Subject: Fix ASSERT in zfs_receive_one() This commit fixes the following ASSERT in zfs_receive_one() when receiving a send stream from a root dataset with the "-e" option: $ sudo zfs snap source@snap $ sudo zfs send source@snap | sudo zfs recv -e destination/recv chopprefix > drrb->drr_toname ASSERT at libzfs_sendrecv.c:3804:zfs_receive_one() Reviewed-by: Tom Caputi Reviewed-by: Brian Behlendorf Reviewed by: Paul Dagnelie Signed-off-by: loli10K Closes #8121 --- cmd/zfs/zfs_main.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'cmd/zfs/zfs_main.c') diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index 2b7fe9303..6b08bb115 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -4240,10 +4240,21 @@ zfs_do_receive(int argc, char **argv) } break; case 'd': + if (flags.istail) { + (void) fprintf(stderr, gettext("invalid option " + "combination: -d and -e are mutually " + "exclusive\n")); + usage(B_FALSE); + } flags.isprefix = B_TRUE; break; case 'e': - flags.isprefix = B_TRUE; + if (flags.isprefix) { + (void) fprintf(stderr, gettext("invalid option " + "combination: -d and -e are mutually " + "exclusive\n")); + usage(B_FALSE); + } flags.istail = B_TRUE; break; case 'n': @@ -4279,6 +4290,10 @@ zfs_do_receive(int argc, char **argv) argc -= optind; argv += optind; + /* zfs recv -e (use "tail" name) implies -d (remove dataset "head") */ + if (flags.istail) + flags.isprefix = B_TRUE; + /* check number of arguments */ if (argc < 1) { (void) fprintf(stderr, gettext("missing snapshot argument\n")); -- cgit v1.2.3