aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Motin <mav@FreeBSD.org>2022-08-30 14:51:21 +0000
committerAlexander Motin <mav@FreeBSD.org>2022-08-30 14:51:21 +0000
commit35b7759c05cbc65c06d87141da79f0f80af0f458 (patch)
tree5af50249f88a48ca243145c8b1cf374741b86cef
parentcbc5350359b9be916cc0dc1986147013c6f90483 (diff)
downloadsrc-35b7759c05cbc65c06d87141da79f0f80af0f458.tar.gz
src-35b7759c05cbc65c06d87141da79f0f80af0f458.zip
cp: Fix build without VM_AND_BUFFER_CACHE_SYNCHRONIZED.
It allows to not use mmap() for small files, which is not helpful in case of ZFS. Should be no functional change. MFC after: 1 week
-rw-r--r--bin/cp/utils.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/bin/cp/utils.c b/bin/cp/utils.c
index e7ae0c9dd733..07de0495ba9e 100644
--- a/bin/cp/utils.c
+++ b/bin/cp/utils.c
@@ -99,13 +99,12 @@ copy_file(const FTSENT *entp, int dne)
static char *buf = NULL;
static size_t bufsize;
struct stat *fs;
- ssize_t rcount, wcount;
- size_t wresid;
+ ssize_t wcount;
off_t wtotal;
int ch, checkch, from_fd, rval, to_fd;
- char *bufp;
#ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED
- char *p;
+ size_t wresid;
+ char *bufp, *p;
#endif
int use_copy_file_range = 1;
@@ -234,18 +233,18 @@ copy_file(const FTSENT *entp, int dne)
wtotal = 0;
do {
if (use_copy_file_range) {
- rcount = copy_file_range(from_fd, NULL,
+ wcount = copy_file_range(from_fd, NULL,
to_fd, NULL, SSIZE_MAX, 0);
- if (rcount < 0 && errno == EINVAL) {
+ if (wcount < 0 && errno == EINVAL) {
/* Prob a non-seekable FD */
use_copy_file_range = 0;
}
}
if (!use_copy_file_range) {
- rcount = copy_fallback(from_fd, to_fd,
+ wcount = copy_fallback(from_fd, to_fd,
buf, bufsize);
}
- wtotal += rcount;
+ wtotal += wcount;
if (info) {
info = 0;
(void)fprintf(stderr,
@@ -253,8 +252,8 @@ copy_file(const FTSENT *entp, int dne)
entp->fts_path, to.p_path,
cp_pct(wtotal, fs->st_size));
}
- } while (rcount > 0);
- if (rcount < 0) {
+ } while (wcount > 0);
+ if (wcount < 0) {
warn("%s", entp->fts_path);
rval = 1;
}