]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
Fix compiling without ftruncate.
authorWayne Davison <wayne@opencoder.net>
Sat, 26 Jun 2021 19:10:08 +0000 (12:10 -0700)
committerWayne Davison <wayne@opencoder.net>
Sun, 27 Jun 2021 16:45:41 +0000 (09:45 -0700)
util1.c

diff --git a/util1.c b/util1.c
index b2b19892bc04d8b9a93e9fee2daa54d8b95d372d..0daf9b04a764bcf2ef1e5ca8b444a2300e4b2984 100644 (file)
--- 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) {