Skip to content

Commit 6a30862

Browse files
committed
Cleaned up some text, handled -R.
Signed-off-by: Rich Ercolani <[email protected]>
1 parent 11ea574 commit 6a30862

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

cmd/zfs/zfs_main.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -727,23 +727,30 @@ finish_progress(char *done)
727727
pt_header = NULL;
728728
}
729729

730+
// This function checks if the passed fd refers to /dev/null or /dev/zero
730731
static int
731-
is_dev_fs(int fd)
732+
is_dev_files(int fd)
732733
{
733734
int nfd = open("/dev/null", O_WRONLY);
734735
struct stat st, nst;
735736
fstat(fd, &st);
736737
fstat(nfd, &nst);
737738
int res = (st.st_dev == nst.st_dev);
738739
close(nfd);
740+
if (res != 1) {
741+
nfd = open("/dev/zero", O_WRONLY);
742+
fstat(nfd, &nst);
743+
res = (st.st_dev == nst.st_dev);
744+
close(nfd);
745+
}
739746
return (res);
740747
}
741748

742749
static int
743750
is_dev_error(int err, int fd)
744751
{
745752
#ifdef __linux__
746-
if (err == EINVAL && is_dev_fs(fd)) {
753+
if (err == EINVAL && is_dev_files(fd)) {
747754
return (1);
748755
}
749756
#endif
@@ -4596,8 +4603,8 @@ zfs_do_send(int argc, char **argv)
45964603
resume_token);
45974604
if (err != 0 && is_dev_error(errno, STDOUT_FILENO)) {
45984605
(void) fprintf(stderr,
4599-
gettext("Error: Stream cannot be written to /dev/"
4600-
" files.\n"));
4606+
gettext("Error: Stream cannot be written to "
4607+
"/dev/{null,zero} files.\n"));
46014608

46024609
}
46034610
zfs_close(zhp);
@@ -4607,8 +4614,8 @@ zfs_do_send(int argc, char **argv)
46074614
resume_token);
46084615
if (err != 0 && is_dev_error(errno, STDOUT_FILENO)) {
46094616
(void) fprintf(stderr,
4610-
gettext("Error: Stream cannot be written to /dev/"
4611-
" files.\n"));
4617+
gettext("Error: Stream cannot be written to "
4618+
"/dev/{null,zero} files.\n"));
46124619
}
46134620
return (err);
46144621
}
@@ -4663,8 +4670,8 @@ zfs_do_send(int argc, char **argv)
46634670
zfs_close(zhp);
46644671
if (err != 0 && is_dev_error(errno, STDOUT_FILENO)) {
46654672
(void) fprintf(stderr,
4666-
gettext("Error: Stream cannot be written to /dev/"
4667-
" files.\n"));
4673+
gettext("Error: Stream cannot be written to "
4674+
"/dev/{null,zero} files.\n"));
46684675
}
46694676
return (err != 0);
46704677
}
@@ -4742,10 +4749,10 @@ zfs_do_send(int argc, char **argv)
47424749
nvlist_free(dbgnv);
47434750
}
47444751
zfs_close(zhp);
4745-
if (err != 0 && is_dev_error(errno, STDOUT_FILENO)) {
4752+
if (is_dev_error(errno, STDOUT_FILENO)) {
47464753
(void) fprintf(stderr,
4747-
gettext("Error: Stream cannot be written to /dev/ "
4748-
"files.\n"));
4754+
gettext("Error: Stream cannot be written to "
4755+
"/dev/{null,zero} files.\n"));
47494756
}
47504757

47514758
return (err != 0);

lib/libzfs/libzfs_sendrecv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,7 @@ dump_ioctl(zfs_handle_t *zhp, const char *fromsnap, uint64_t fromsnap_obj,
849849
case ERANGE:
850850
case EFAULT:
851851
case EROFS:
852+
case EINVAL:
852853
zfs_error_aux(hdl, strerror(errno));
853854
return (zfs_error(hdl, EZFS_BADBACKUP, errbuf));
854855

0 commit comments

Comments
 (0)