X-Git-Url: https://mattmccutchen.net/rsync/rsync-patches.git/blobdiff_plain/f2376a081a5dbb2434b0658fcda35a473acc0aae..8871c12ac6de6b52f034946d009f0f9f5f5b808d:/preallocate.diff diff --git a/preallocate.diff b/preallocate.diff index 39ad416..6bc918c 100644 --- a/preallocate.diff +++ b/preallocate.diff @@ -11,58 +11,57 @@ To use this patch, run these commands for a successful build: --- old/configure.in +++ new/configure.in -@@ -555,7 +555,7 @@ AC_CHECK_FUNCS(waitpid wait4 getcwd strd +@@ -561,7 +561,7 @@ AC_CHECK_FUNCS(waitpid wait4 getcwd strd strlcat strlcpy strtol mallinfo getgroups setgroups geteuid getegid \ setlocale setmode open64 lseek64 mkstemp64 mtrace va_copy __va_copy \ - 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) ++ extattr_get_link sigaction sigprocmask 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; +@@ -70,6 +70,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 am_root = 0; -@@ -201,6 +202,7 @@ static void print_rsync_version(enum log - char const *hardlinks = "no "; + int am_root = 0; /* 0 = normal, 1 = root, 2 = --super, -1 = --fake-super */ +@@ -220,6 +221,7 @@ static void print_rsync_version(enum log char const *links = "no "; + char const *iconv = "no "; char const *ipv6 = "no "; + char const *preallocation = "no "; STRUCT_STAT *dumstat; - #ifdef HAVE_SOCKETPAIR -@@ -223,6 +225,10 @@ static void print_rsync_version(enum log - ipv6 = ""; + #if SUBPROTOCOL_VERSION != 0 +@@ -249,6 +251,9 @@ static void print_rsync_version(enum log + #ifdef ICONV_OPTION + iconv = ""; #endif - +#ifdef SUPPORT_PREALLOCATION + preallocation = ""; +#endif -+ - rprintf(f, "%s version %s protocol version %d\n", - RSYNC_NAME, RSYNC_VERSION, PROTOCOL_VERSION); - rprintf(f, "Copyright (C) 1996-2006 by Andrew Tridgell, Wayne Davison, and others.\n"); -@@ -233,8 +239,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); +@@ -262,8 +267,8 @@ static void print_rsync_version(enum log (int)(sizeof (int64) * 8)); rprintf(f, " %ssocketpairs, %shardlinks, %ssymlinks, %sIPv6, batchfiles, %sinplace,\n", got_socketpair, hardlinks, links, ipv6, have_inplace); -- rprintf(f, " %sappend\n", -- have_inplace); -+ rprintf(f, " %sappend, %spreallocation\n", -+ have_inplace, 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); #ifdef MAINTAINER_MODE rprintf(f, "Panic Action: \"%s\"\n", get_panic_action()); -@@ -311,6 +317,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"); +@@ -350,6 +355,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"); @@ -70,15 +69,15 @@ To use this patch, run these commands for a successful build: 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," -x, --one-file-system don't cross filesystem boundaries\n"); -@@ -468,6 +477,7 @@ static struct poptOption long_options[] +@@ -525,6 +533,7 @@ static struct poptOption long_options[] {"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 }, -@@ -1132,6 +1142,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 }, +@@ -1279,6 +1288,15 @@ int parse_arguments(int *argc_p, const c } #endif @@ -94,19 +93,19 @@ To use this patch, run these commands for a successful build: if (write_batch && read_batch) { snprintf(err_buf, sizeof err_buf, "--write-batch and --read-batch can not be used together\n"); -@@ -1779,6 +1798,9 @@ void server_options(char **args,int *arg +@@ -1978,6 +1996,9 @@ void server_options(char **args, int *ar else if (remove_source_files) args[ac++] = "--remove-sent-files"; + if (preallocate_files && am_sender) + args[ac++] = "--preallocate"; + - *argc = ac; + *argc_p = ac; return; --- old/receiver.c +++ new/receiver.c -@@ -44,6 +44,7 @@ extern int cleanup_got_literal; +@@ -45,6 +45,7 @@ extern int cleanup_got_literal; extern int remove_source_files; extern int append_mode; extern int sparse_files; @@ -114,7 +113,7 @@ To use this patch, run these commands for a successful build: extern int keep_partial; extern int checksum_seed; extern int inplace; -@@ -137,6 +138,19 @@ static int receive_data(int f_in, char * +@@ -138,6 +139,19 @@ static int receive_data(int f_in, char * int32 i; char *map = NULL; @@ -134,7 +133,7 @@ To use this patch, run these commands for a successful build: read_sum_head(f_in, &sum); if (fd_r >= 0 && size_r > 0) { -@@ -244,8 +258,18 @@ static int receive_data(int f_in, char * +@@ -247,8 +261,18 @@ static int receive_data(int f_in, char * goto report_write_error; #ifdef HAVE_FTRUNCATE @@ -157,28 +156,28 @@ To use this patch, run these commands for a successful build: if (do_progress) --- old/rsync.h +++ new/rsync.h -@@ -546,6 +546,10 @@ struct idev_node { - #define IN_LOOPBACKNET 127 +@@ -555,6 +555,10 @@ struct ht_int64_node { + #define ACLS_NEED_MASK 1 #endif +#if defined HAVE_FTRUNCATE && defined HAVE_POSIX_FALLOCATE +#define SUPPORT_PREALLOCATION 1 +#endif + - #define GID_NONE ((gid_t)-1) - union file_extras { + int32 num; + uint32 unum; --- old/rsync.yo +++ new/rsync.yo -@@ -332,6 +332,7 @@ to the detailed description below for a - -O, --omit-dir-times omit directories when preserving times +@@ -357,6 +357,7 @@ to the detailed description below for a --super receiver attempts super-user activities + --fake-super store/recover privileged attrs using xattrs -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) -x, --one-file-system don't cross filesystem boundaries -@@ -888,6 +889,19 @@ NOTE: Don't use this option when the des +@@ -993,6 +994,19 @@ NOTE: Don't use this option when the des filesystem. It doesn't seem to handle seeks over null regions correctly and ends up corrupting the files. @@ -200,7 +199,7 @@ To use this patch, run these commands for a successful build: --- old/t_stub.c +++ new/t_stub.c -@@ -23,6 +23,7 @@ +@@ -22,6 +22,7 @@ #include "rsync.h" int modify_window = 0; @@ -210,7 +209,7 @@ To use this patch, run these commands for a successful build: int human_readable = 0; --- old/util.c +++ new/util.c -@@ -25,6 +25,7 @@ +@@ -24,6 +24,7 @@ extern int verbose; extern int dry_run;