From: Wayne Davison Date: Sat, 26 Jun 2021 19:10:08 +0000 (-0700) Subject: Fix compiling without ftruncate. X-Git-Tag: v3.2.4pre1~82 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c529782a8d272c54642ed317ee9807dab7c1f06d;p=thirdparty%2Frsync.git Fix compiling without ftruncate. --- 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) {