From c529782a8d272c54642ed317ee9807dab7c1f06d Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Sat, 26 Jun 2021 12:10:08 -0700 Subject: [PATCH] Fix compiling without ftruncate. --- util1.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/util1.c b/util1.c index b2b19892..0daf9b04 100644 --- a/util1.c +++ b/util1.c @@ -406,10 +406,15 @@ int copy_file(const char *source, const char *dest, int ofd, mode_t mode) /* Source file might have shrunk since we fstatted it. * Cut off any extra preallocated zeros from dest file. */ - if (offset < prealloc_len && do_ftruncate(ofd, offset) < 0) { + if (offset < prealloc_len) { +#ifdef HAVE_FTRUNCATE /* If we fail to truncate, the dest file may be wrong, so we * must trigger the "partial transfer" error. */ - rsyserr(FERROR_XFER, errno, "ftruncate %s", full_fname(dest)); + if (do_ftruncate(ofd, offset) < 0) + rsyserr(FERROR_XFER, errno, "ftruncate %s", full_fname(dest)); +#else + rprintf(FERROR_XFER, "no ftruncate for over-long pre-alloc: %s", full_fname(dest)); +#endif } if (close(ofd) < 0) { -- 2.47.2