The patches for 3.0.0pre6.
[rsync/rsync-patches.git] / preallocate.diff
index 476b4da..6c43dbe 100644 (file)
@@ -9,9 +9,10 @@ To use this patch, run these commands for a successful build:
     ./configure
     make
 
     ./configure
     make
 
---- old/configure.in
-+++ new/configure.in
-@@ -547,7 +547,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 \
      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 getxattr \
      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 getxattr \
@@ -20,8 +21,9 @@ To use this patch, run these commands for a successful build:
  
  AC_CHECK_FUNCS(getpgrp tcgetpgrp)
  if test $ac_cv_func_getpgrp = yes; then
  
  AC_CHECK_FUNCS(getpgrp tcgetpgrp)
  if test $ac_cv_func_getpgrp = yes; then
---- old/options.c
-+++ new/options.c
+diff --git a/options.c b/options.c
+--- a/options.c
++++ b/options.c
 @@ -71,6 +71,7 @@ int remove_source_files = 0;
  int one_file_system = 0;
  int protocol_version = PROTOCOL_VERSION;
 @@ -71,6 +71,7 @@ int remove_source_files = 0;
  int one_file_system = 0;
  int protocol_version = PROTOCOL_VERSION;
@@ -30,7 +32,7 @@ To use this patch, run these commands for a successful build:
  int do_compression = 0;
  int def_compress_level = Z_DEFAULT_COMPRESSION;
  int am_root = 0; /* 0 = normal, 1 = root, 2 = --super, -1 = --fake-super */
  int do_compression = 0;
  int def_compress_level = Z_DEFAULT_COMPRESSION;
  int am_root = 0; /* 0 = normal, 1 = root, 2 = --super, -1 = --fake-super */
-@@ -221,6 +222,7 @@ static void print_rsync_version(enum log
+@@ -222,6 +223,7 @@ static void print_rsync_version(enum logcode f)
        char const *links = "no ";
        char const *iconv = "no ";
        char const *ipv6 = "no ";
        char const *links = "no ";
        char const *iconv = "no ";
        char const *ipv6 = "no ";
@@ -38,7 +40,7 @@ To use this patch, run these commands for a successful build:
        STRUCT_STAT *dumstat;
  
  #if SUBPROTOCOL_VERSION != 0
        STRUCT_STAT *dumstat;
  
  #if SUBPROTOCOL_VERSION != 0
-@@ -250,6 +252,9 @@ static void print_rsync_version(enum log
+@@ -251,6 +253,9 @@ static void print_rsync_version(enum logcode f)
  #ifdef ICONV_OPTION
        iconv = "";
  #endif
  #ifdef ICONV_OPTION
        iconv = "";
  #endif
@@ -48,7 +50,7 @@ To use this patch, run these commands for a successful build:
  
        rprintf(f, "%s  version %s  protocol version %d%s\n",
                RSYNC_NAME, RSYNC_VERSION, PROTOCOL_VERSION, subprotocol);
  
        rprintf(f, "%s  version %s  protocol version %d%s\n",
                RSYNC_NAME, RSYNC_VERSION, PROTOCOL_VERSION, subprotocol);
-@@ -263,8 +268,8 @@ static void print_rsync_version(enum log
+@@ -264,8 +269,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);
@@ -59,7 +61,7 @@ To use this patch, run these commands for a successful build:
  
  #ifdef MAINTAINER_MODE
        rprintf(f, "Panic Action: \"%s\"\n", get_panic_action());
  
  #ifdef MAINTAINER_MODE
        rprintf(f, "Panic Action: \"%s\"\n", get_panic_action());
-@@ -351,6 +356,9 @@ void usage(enum logcode F)
+@@ -352,6 +357,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");
    rprintf(F,"     --fake-super            store/recover privileged attrs using xattrs\n");
  #endif
    rprintf(F," -S, --sparse                handle sparse files efficiently\n");
@@ -69,7 +71,7 @@ To use this patch, run these commands for a successful build:
    rprintf(F," -n, --dry-run               perform a trial run with no changes made\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");
    rprintf(F," -n, --dry-run               perform a trial run with no changes made\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");
-@@ -528,6 +536,7 @@ static struct poptOption long_options[] 
+@@ -530,6 +538,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 },
    {"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 },
@@ -77,7 +79,7 @@ To use this patch, run these commands for a successful build:
    {"inplace",          0,  POPT_ARG_NONE,   &inplace, 0, 0, 0 },
    {"append",           0,  POPT_ARG_NONE,   0, OPT_APPEND, 0, 0 },
    {"append-verify",    0,  POPT_ARG_VAL,    &append_mode, 2, 0, 0 },
    {"inplace",          0,  POPT_ARG_NONE,   &inplace, 0, 0, 0 },
    {"append",           0,  POPT_ARG_NONE,   0, OPT_APPEND, 0, 0 },
    {"append-verify",    0,  POPT_ARG_VAL,    &append_mode, 2, 0, 0 },
-@@ -1284,6 +1293,15 @@ int parse_arguments(int *argc_p, const c
+@@ -1287,6 +1296,15 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
        }
  #endif
  
        }
  #endif
  
@@ -93,7 +95,7 @@ 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");
        if (write_batch && read_batch) {
                snprintf(err_buf, sizeof err_buf,
                        "--write-batch and --read-batch can not be used together\n");
-@@ -1988,6 +2006,9 @@ void server_options(char **args, int *ar
+@@ -1991,6 +2009,9 @@ void server_options(char **args, int *argc_p)
        else if (remove_source_files)
                args[ac++] = "--remove-sent-files";
  
        else if (remove_source_files)
                args[ac++] = "--remove-sent-files";
  
@@ -103,8 +105,9 @@ To use this patch, run these commands for a successful build:
        *argc_p = ac;
        return;
  
        *argc_p = ac;
        return;
  
---- old/receiver.c
-+++ new/receiver.c
+diff --git a/receiver.c b/receiver.c
+--- a/receiver.c
++++ b/receiver.c
 @@ -45,6 +45,7 @@ extern int cleanup_got_literal;
  extern int remove_source_files;
  extern int append_mode;
 @@ -45,6 +45,7 @@ extern int cleanup_got_literal;
  extern int remove_source_files;
  extern int append_mode;
@@ -113,12 +116,12 @@ To use this patch, run these commands for a successful build:
  extern int keep_partial;
  extern int checksum_seed;
  extern int inplace;
  extern int keep_partial;
  extern int checksum_seed;
  extern int inplace;
-@@ -175,6 +176,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,
        int32 i;
        char *map = NULL;
  
 +#ifdef SUPPORT_PREALLOCATION
        int32 i;
        char *map = NULL;
  
 +#ifdef SUPPORT_PREALLOCATION
-+      int preallocated_len = 0;
++      OFF_T preallocated_len = 0;
 +
 +      if (preallocate_files && fd != -1 && total_size > 0) {
 +              /* Preallocate enough space for file's eventual length if
 +
 +      if (preallocate_files && fd != -1 && total_size > 0) {
 +              /* Preallocate enough space for file's eventual length if
@@ -133,7 +136,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) {
        read_sum_head(f_in, &sum);
  
        if (fd_r >= 0 && size_r > 0) {
-@@ -284,8 +298,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,
                goto report_write_error;
  
  #ifdef HAVE_FTRUNCATE
                goto report_write_error;
  
  #ifdef HAVE_FTRUNCATE
@@ -150,13 +153,14 @@ To use this patch, run these commands for a successful build:
 +              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));
  #endif
  
        if (do_progress)
  #endif
  
        if (do_progress)
---- old/rsync.h
-+++ new/rsync.h
-@@ -590,6 +590,10 @@ struct ht_int64_node {
+diff --git a/rsync.h b/rsync.h
+--- a/rsync.h
++++ b/rsync.h
+@@ -600,6 +600,10 @@ struct ht_int64_node {
  #define ACLS_NEED_MASK 1
  #endif
  
  #define ACLS_NEED_MASK 1
  #endif
  
@@ -167,9 +171,10 @@ To use this patch, run these commands for a successful build:
  union file_extras {
        int32 num;
        uint32 unum;
  union file_extras {
        int32 num;
        uint32 unum;
---- old/rsync.yo
-+++ new/rsync.yo
-@@ -352,6 +352,7 @@ to the detailed description below for a 
+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(
       --super                 receiver attempts super-user activities
       --fake-super            store/recover privileged attrs using xattrs
   -S, --sparse                handle sparse files efficiently
       --super                 receiver attempts super-user activities
       --fake-super            store/recover privileged attrs using xattrs
   -S, --sparse                handle sparse files efficiently
@@ -177,7 +182,7 @@ To use this patch, run these commands for a successful build:
   -n, --dry-run               perform a trial run with no changes made
   -W, --whole-file            copy files whole (without rsync algorithm)
   -x, --one-file-system       don't cross filesystem boundaries
   -n, --dry-run               perform a trial run with no changes made
   -W, --whole-file            copy files whole (without rsync algorithm)
   -x, --one-file-system       don't cross filesystem boundaries
-@@ -1022,6 +1023,19 @@ NOTE: Don't use this option when the des
+@@ -1023,6 +1024,19 @@ NOTE: Don't use this option when the destination is a Solaris "tmpfs"
  filesystem. It doesn't seem to handle seeks over null regions
  correctly and ends up corrupting the files.
  
  filesystem. It doesn't seem to handle seeks over null regions
  correctly and ends up corrupting the files.
  
@@ -197,8 +202,9 @@ To use this patch, run these commands for a successful build:
  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
  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
---- old/t_stub.c
-+++ new/t_stub.c
+diff --git a/t_stub.c b/t_stub.c
+--- a/t_stub.c
++++ b/t_stub.c
 @@ -22,6 +22,7 @@
  #include "rsync.h"
  
 @@ -22,6 +22,7 @@
  #include "rsync.h"
  
@@ -207,8 +213,9 @@ To use this patch, run these commands for a successful build:
  int module_id = -1;
  int relative_paths = 0;
  int human_readable = 0;
  int module_id = -1;
  int relative_paths = 0;
  int human_readable = 0;
---- old/util.c
-+++ new/util.c
+diff --git a/util.c b/util.c
+--- a/util.c
++++ b/util.c
 @@ -25,6 +25,7 @@
  
  extern int verbose;
 @@ -25,6 +25,7 @@
  
  extern int verbose;
@@ -217,18 +224,18 @@ To use this patch, run these commands for a successful build:
  extern int module_id;
  extern int modify_window;
  extern int relative_paths;
  extern int module_id;
  extern int modify_window;
  extern int relative_paths;
-@@ -272,6 +273,10 @@ int copy_file(const char *source, const 
+@@ -272,6 +273,10 @@ int copy_file(const char *source, const char *dest, int ofd,
        int ifd;
        char buf[1024 * 8];
        int len;   /* Number of bytes read into `buf'. */
 +#ifdef SUPPORT_PREALLOCATION
        int ifd;
        char buf[1024 * 8];
        int len;   /* Number of bytes read into `buf'. */
 +#ifdef SUPPORT_PREALLOCATION
-+      int preallocated_len = 0;
-+      int offset = 0;
++      OFF_T preallocated_len = 0;
++      OFF_T offset = 0;
 +#endif
  
        if ((ifd = do_open(source, O_RDONLY, 0)) < 0) {
 +#endif
  
        if ((ifd = do_open(source, O_RDONLY, 0)) < 0) {
-               rsyserr(FERROR, errno, "open %s", full_fname(source));
-@@ -293,7 +298,27 @@ int copy_file(const char *source, const 
+               rsyserr(FERROR_XFER, errno, "open %s", full_fname(source));
+@@ -293,7 +298,27 @@ int copy_file(const char *source, const char *dest, int ofd,
                }
        }
  
                }
        }
  
@@ -254,9 +261,9 @@ To use this patch, run these commands for a successful build:
 +              offset += len;
 +#endif
                if (full_write(ofd, buf, len) < 0) {
 +              offset += len;
 +#endif
                if (full_write(ofd, buf, len) < 0) {
-                       rsyserr(FERROR, errno, "write %s", full_fname(dest));
+                       rsyserr(FERROR_XFER, errno, "write %s", full_fname(dest));
                        close(ifd);
                        close(ifd);
-@@ -314,6 +339,16 @@ int copy_file(const char *source, const 
+@@ -314,6 +339,16 @@ int copy_file(const char *source, const char *dest, int ofd,
                        full_fname(source));
        }
  
                        full_fname(source));
        }
  
@@ -267,9 +274,9 @@ To use this patch, run these commands for a successful build:
 +              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));
 +#endif
 +
        if (close(ofd) < 0) {
 +#endif
 +
        if (close(ofd) < 0) {
-               rsyserr(FERROR, errno, "close failed on %s",
+               rsyserr(FERROR_XFER, errno, "close failed on %s",
                        full_fname(dest));
                        full_fname(dest));