---- old/configure.in
-+++ new/configure.in
-@@ -560,7 +560,7 @@ AC_CHECK_FUNCS(waitpid wait4 getcwd strd
+diff --git a/configure.in b/configure.in
+--- a/configure.in
++++ b/configure.in
+@@ -552,7 +552,7 @@ AC_CHECK_FUNCS(waitpid wait4 getcwd strdup chown chmod lchmod mknod mkfifo \
- strerror putenv iconv_open locale_charset nl_langinfo \
-- sigaction sigprocmask)
-+ sigaction sigprocmask posix_fallocate)
+ strerror putenv iconv_open locale_charset nl_langinfo getxattr \
+- extattr_get_link sigaction sigprocmask setattrlist)
++ extattr_get_link sigaction sigprocmask setattrlist posix_fallocate)
- AC_CHECK_FUNCS(getpgrp tcgetpgrp)
- if test $ac_cv_func_getpgrp = yes; then
---- old/options.c
-+++ new/options.c
-@@ -69,6 +69,7 @@ int remove_source_files = 0;
+ dnl cygwin iconv.h defines iconv_open as libiconv_open
+ if test x"$ac_cv_func_iconv_open" != x"yes"; then
+diff --git a/options.c b/options.c
+--- a/options.c
++++ b/options.c
+@@ -72,6 +72,7 @@ int remove_source_files = 0;
int one_file_system = 0;
int protocol_version = PROTOCOL_VERSION;
int sparse_files = 0;
+int preallocate_files = 0;
int do_compression = 0;
int def_compress_level = Z_DEFAULT_COMPRESSION;
int one_file_system = 0;
int protocol_version = PROTOCOL_VERSION;
int sparse_files = 0;
+int preallocate_files = 0;
int do_compression = 0;
int def_compress_level = Z_DEFAULT_COMPRESSION;
- int am_root = 0;
-@@ -202,6 +203,7 @@ static void print_rsync_version(enum log
- char const *acls = "no ";
+ int am_root = 0; /* 0 = normal, 1 = root, 2 = --super, -1 = --fake-super */
+@@ -223,6 +224,7 @@ static void print_rsync_version(enum logcode f)
- #ifdef HAVE_SOCKETPAIR
-@@ -228,6 +230,10 @@ static void print_rsync_version(enum log
- ipv6 = "";
+ #if SUBPROTOCOL_VERSION != 0
+@@ -252,6 +254,9 @@ static void print_rsync_version(enum logcode f)
+ #ifdef ICONV_OPTION
+ iconv = "";
-+
- rprintf(f, "%s version %s protocol version %d\n",
- RSYNC_NAME, RSYNC_VERSION, PROTOCOL_VERSION);
- rprintf(f, "Copyright (C) 1996-2007 by Andrew Tridgell, Wayne Davison, and others.\n");
-@@ -238,8 +244,8 @@ static void print_rsync_version(enum log
+
+ rprintf(f, "%s version %s protocol version %d%s\n",
+ RSYNC_NAME, RSYNC_VERSION, PROTOCOL_VERSION, subprotocol);
+@@ -265,8 +270,8 @@ static void print_rsync_version(enum logcode f)
(int)(sizeof (int64) * 8));
rprintf(f, " %ssocketpairs, %shardlinks, %ssymlinks, %sIPv6, batchfiles, %sinplace,\n",
got_socketpair, hardlinks, links, ipv6, have_inplace);
(int)(sizeof (int64) * 8));
rprintf(f, " %ssocketpairs, %shardlinks, %ssymlinks, %sIPv6, batchfiles, %sinplace,\n",
got_socketpair, hardlinks, links, ipv6, have_inplace);
-- rprintf(f, " %sappend, %sACLs\n",
-- have_inplace, acls);
-+ rprintf(f, " %sappend, %sACLs, %spreallocation\n",
-+ have_inplace, acls, preallocation);
+- rprintf(f, " %sappend, %sACLs, %sxattrs, %siconv\n",
+- have_inplace, acls, xattrs, iconv);
++ rprintf(f, " %sappend, %sACLs, %sxattrs, %siconv, %spreallocation\n",
++ have_inplace, acls, xattrs, iconv, preallocation);
-@@ -319,6 +325,9 @@ void usage(enum logcode F)
- rprintf(F," -O, --omit-dir-times omit directories when preserving times\n");
- rprintf(F," --super receiver attempts super-user activities\n");
+@@ -353,6 +358,9 @@ void usage(enum logcode F)
+ rprintf(F," --fake-super store/recover privileged attrs using xattrs\n");
+ #endif
rprintf(F," -S, --sparse handle sparse files efficiently\n");
+#ifdef SUPPORT_PREALLOCATION
+ rprintf(F," --preallocate posix_fallocate dest files before writing them\n");
+#endif
rprintf(F," -S, --sparse handle sparse files efficiently\n");
+#ifdef SUPPORT_PREALLOCATION
+ rprintf(F," --preallocate posix_fallocate dest files before writing them\n");
+#endif
- rprintf(F," -n, --dry-run show what would have been transferred\n");
- rprintf(F," -W, --whole-file copy files whole (without rsync algorithm)\n");
+ rprintf(F," -n, --dry-run perform a trial run with no changes made\n");
+ rprintf(F," -W, --whole-file copy files whole (without delta-xfer algorithm)\n");
{"max-size", 0, POPT_ARG_STRING, &max_size_arg, OPT_MAX_SIZE, 0, 0 },
{"min-size", 0, POPT_ARG_STRING, &min_size_arg, OPT_MIN_SIZE, 0, 0 },
{"sparse", 'S', POPT_ARG_NONE, &sparse_files, 0, 0, 0 },
+ {"preallocate", 0, POPT_ARG_NONE, &preallocate_files, 0, 0, 0},
{"inplace", 0, POPT_ARG_NONE, &inplace, 0, 0, 0 },
{"max-size", 0, POPT_ARG_STRING, &max_size_arg, OPT_MAX_SIZE, 0, 0 },
{"min-size", 0, POPT_ARG_STRING, &min_size_arg, OPT_MIN_SIZE, 0, 0 },
{"sparse", 'S', POPT_ARG_NONE, &sparse_files, 0, 0, 0 },
+ {"preallocate", 0, POPT_ARG_NONE, &preallocate_files, 0, 0, 0},
{"inplace", 0, POPT_ARG_NONE, &inplace, 0, 0, 0 },
- {"append", 0, POPT_ARG_VAL, &append_mode, 1, 0, 0 },
- {"del", 0, POPT_ARG_NONE, &delete_during, 0, 0, 0 },
-@@ -1161,6 +1171,15 @@ int parse_arguments(int *argc, const cha
+ {"append", 0, POPT_ARG_NONE, 0, OPT_APPEND, 0, 0 },
+ {"append-verify", 0, POPT_ARG_VAL, &append_mode, 2, 0, 0 },
+@@ -1289,6 +1298,15 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
if (write_batch && read_batch) {
snprintf(err_buf, sizeof err_buf,
"--write-batch and --read-batch can not be used together\n");
if (write_batch && read_batch) {
snprintf(err_buf, sizeof err_buf,
"--write-batch and --read-batch can not be used together\n");
-@@ -1808,6 +1827,9 @@ void server_options(char **args,int *arg
+@@ -1999,6 +2017,9 @@ void server_options(char **args, int *argc_p)
else if (remove_source_files)
args[ac++] = "--remove-sent-files";
+ if (preallocate_files && am_sender)
+ args[ac++] = "--preallocate";
+
else if (remove_source_files)
args[ac++] = "--remove-sent-files";
+ if (preallocate_files && am_sender)
+ args[ac++] = "--preallocate";
+
---- old/receiver.c
-+++ new/receiver.c
-@@ -43,6 +43,7 @@ extern int cleanup_got_literal;
+diff --git a/receiver.c b/receiver.c
+--- a/receiver.c
++++ b/receiver.c
+@@ -45,6 +45,7 @@ extern int cleanup_got_literal;
-@@ -136,6 +137,19 @@ static int receive_data(int f_in, char *
+@@ -175,6 +176,19 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
-@@ -243,8 +257,18 @@ static int receive_data(int f_in, char *
+@@ -284,8 +298,18 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
+ if (ftruncate(fd, offset) < 0)
+ /* If we fail to truncate, the dest file may be wrong, so we
+ * must trigger the "partial transfer" error. */
+ if (ftruncate(fd, offset) < 0)
+ /* If we fail to truncate, the dest file may be wrong, so we
+ * must trigger the "partial transfer" error. */
-+ rsyserr(FERROR, errno, "ftruncate %s", full_fname(fname));
++ rsyserr(FERROR_XFER, errno, "ftruncate %s", full_fname(fname));
---- old/rsync.yo
-+++ new/rsync.yo
-@@ -333,6 +333,7 @@ to the detailed description below for a
- -O, --omit-dir-times omit directories when preserving times
+ int32 num;
+ uint32 unum;
+diff --git a/rsync.yo b/rsync.yo
+--- a/rsync.yo
++++ b/rsync.yo
+@@ -352,6 +352,7 @@ to the detailed description below for a complete description. verb(
-S, --sparse handle sparse files efficiently
+ --preallocate posix_fallocate dest files before writing
-S, --sparse handle sparse files efficiently
+ --preallocate posix_fallocate dest files before writing
- -n, --dry-run show what would have been transferred
- -W, --whole-file copy files whole (without rsync algorithm)
+ -n, --dry-run perform a trial run with no changes made
+ -W, --whole-file copy files whole (w/o delta-xfer algorithm)
- dit(bf(-n, --dry-run)) This tells rsync to not do any file transfers,
- instead it will just report the actions it would have taken.
-
---- old/t_stub.c
-+++ new/t_stub.c
+ dit(bf(-n, --dry-run)) This makes rsync perform a trial run that doesn't
+ make any changes (and produces mostly the same output as a real run). It
+ is most commonly used in combination with the bf(-v, --verbose) and/or
+diff --git a/t_stub.c b/t_stub.c
+--- a/t_stub.c
++++ b/t_stub.c
-@@ -269,6 +270,10 @@ int copy_file(const char *source, const
- int ofd;
+@@ -273,6 +274,10 @@ int copy_file(const char *source, const char *dest, int ofd,
+ int ifd;
- ifd = do_open(source, O_RDONLY, 0);
- if (ifd == -1) {
-@@ -288,7 +293,27 @@ int copy_file(const char *source, const
- return -1;
+ if ((ifd = do_open(source, O_RDONLY, 0)) < 0) {
+ rsyserr(FERROR_XFER, errno, "open %s", full_fname(source));
+@@ -294,7 +299,27 @@ int copy_file(const char *source, const char *dest, int ofd,
+ }
-@@ -309,6 +334,16 @@ int copy_file(const char *source, const
+@@ -315,6 +340,16 @@ int copy_file(const char *source, const char *dest, int ofd,
+ if (ftruncate(ofd, offset) < 0)
+ /* If we fail to truncate, the dest file may be wrong, so we
+ * must trigger the "partial transfer" error. */
+ if (ftruncate(ofd, offset) < 0)
+ /* If we fail to truncate, the dest file may be wrong, so we
+ * must trigger the "partial transfer" error. */
-+ rsyserr(FERROR, errno, "ftruncate %s", full_fname(dest));
++ rsyserr(FERROR_XFER, errno, "ftruncate %s", full_fname(dest));