diff --git a/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c index 87bc4ea66..fd9fbd658 100644 --- a/lib/libzfs/libzfs_dataset.c +++ b/lib/libzfs/libzfs_dataset.c @@ -690,6 +690,7 @@ zfs_open(libzfs_handle_t *hdl, const char *path, int types) */ if (!zfs_validate_name(hdl, path, types, B_FALSE)) { (void) zfs_error(hdl, EZFS_INVALIDNAME, errbuf); + errno = EINVAL; return (NULL); } @@ -737,6 +738,7 @@ zfs_open(libzfs_handle_t *hdl, const char *path, int types) &cb_data) == 0) && (cb_data.zhp == NULL)) { (void) zfs_error(hdl, EZFS_NOENT, errbuf); zfs_close(pzhp); + errno = ENOENT; return (NULL); } if (cb_data.zhp == NULL) { @@ -755,6 +757,7 @@ zfs_open(libzfs_handle_t *hdl, const char *path, int types) if (!(types & zhp->zfs_type)) { (void) zfs_error(hdl, EZFS_BADTYPE, errbuf); zfs_close(zhp); + errno = EINVAL; return (NULL); } diff --git a/lib/libzfs/libzfs_sendrecv.c b/lib/libzfs/libzfs_sendrecv.c index b53acdcea..089d46b13 100644 --- a/lib/libzfs/libzfs_sendrecv.c +++ b/lib/libzfs/libzfs_sendrecv.c @@ -1289,7 +1289,7 @@ dump_filesystem(zfs_handle_t *zhp, send_dump_data_t *sdd) if (snap != NULL) rv = dump_snapshot(snap, sdd); else - rv = -1; + rv = errno; } /* Dump tosnap. */ @@ -1301,7 +1301,7 @@ dump_filesystem(zfs_handle_t *zhp, send_dump_data_t *sdd) if (snap != NULL) rv = dump_snapshot(snap, sdd); else - rv = -1; + rv = errno; } }