Skip to content

Commit ee6615e

Browse files
authored
cmd/zfs receive: allow dry-run (-n) to check property args
zfs recv -n does not report some errors it could. The code to bail out of the receive if in dry-run mode came a little early, skipping validation of cmdprops (recv -x and -o) among others. Move the check down to enable these additional checks. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: InsanePrawn <[email protected]> Closes #11862
1 parent 722b7f9 commit ee6615e

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

lib/libzfs/libzfs_sendrecv.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4586,26 +4586,6 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
45864586
(void) fflush(stdout);
45874587
}
45884588

4589-
if (flags->dryrun) {
4590-
void *buf = zfs_alloc(hdl, SPA_MAXBLOCKSIZE);
4591-
4592-
/*
4593-
* We have read the DRR_BEGIN record, but we have
4594-
* not yet read the payload. For non-dryrun sends
4595-
* this will be done by the kernel, so we must
4596-
* emulate that here, before attempting to read
4597-
* more records.
4598-
*/
4599-
err = recv_read(hdl, infd, buf, drr->drr_payloadlen,
4600-
flags->byteswap, NULL);
4601-
free(buf);
4602-
if (err != 0)
4603-
goto out;
4604-
4605-
err = recv_skip(hdl, infd, flags->byteswap);
4606-
goto out;
4607-
}
4608-
46094589
/*
46104590
* If this is the top-level dataset, record it so we can use it
46114591
* for recursive operations later.
@@ -4650,6 +4630,26 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
46504630
zfs_prop_to_name(ZFS_PROP_ENCRYPTION), ZIO_CRYPT_OFF);
46514631
}
46524632

4633+
if (flags->dryrun) {
4634+
void *buf = zfs_alloc(hdl, SPA_MAXBLOCKSIZE);
4635+
4636+
/*
4637+
* We have read the DRR_BEGIN record, but we have
4638+
* not yet read the payload. For non-dryrun sends
4639+
* this will be done by the kernel, so we must
4640+
* emulate that here, before attempting to read
4641+
* more records.
4642+
*/
4643+
err = recv_read(hdl, infd, buf, drr->drr_payloadlen,
4644+
flags->byteswap, NULL);
4645+
free(buf);
4646+
if (err != 0)
4647+
goto out;
4648+
4649+
err = recv_skip(hdl, infd, flags->byteswap);
4650+
goto out;
4651+
}
4652+
46534653
err = ioctl_err = lzc_receive_with_cmdprops(destsnap, rcvprops,
46544654
oxprops, wkeydata, wkeylen, origin, flags->force, flags->resumable,
46554655
raw, infd, drr_noswap, -1, &read_bytes, &errflags,

0 commit comments

Comments
 (0)