The patches for 3.3.0.
[rsync-patches.git] / checksum-reading.diff
index efaf35c08cc2663905e2d16e6bee9018409cf301..50ac08aca1f76f8f5a33d09d17894e569903c86e 100644 (file)
@@ -16,7 +16,7 @@ To use this patch, run these commands for a successful build:
     ./configure                               (optional if already run)
     make
 
-based-on: db5bfe67a5d022f9ad25340db6bc2cca2cbbdb65
+based-on: 6c8ca91c731b7bf2b081694bda85b7dadc2b7aff
 diff --git a/clientserver.c b/clientserver.c
 --- a/clientserver.c
 +++ b/clientserver.c
@@ -29,7 +29,7 @@ diff --git a/clientserver.c b/clientserver.c
  extern int io_timeout;
  extern int no_detach;
  extern int write_batch;
-@@ -1093,6 +1095,9 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char
+@@ -1106,6 +1108,9 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char
        } else if (am_root < 0) /* Treat --fake-super from client as --super. */
                am_root = 2;
  
@@ -66,10 +66,10 @@ diff --git a/flist.c b/flist.c
  extern int inc_recurse;
  extern int always_checksum;
 +extern int basis_dir_cnt;
- extern int checksum_type;
  extern int module_id;
  extern int ignore_errors;
-@@ -63,6 +65,7 @@ extern int implied_dirs;
+ extern int numeric_ids;
+@@ -62,6 +64,7 @@ extern int implied_dirs;
  extern int ignore_perishable;
  extern int non_perishable_cnt;
  extern int prune_empty_dirs;
@@ -77,7 +77,7 @@ diff --git a/flist.c b/flist.c
  extern int copy_links;
  extern int copy_unsafe_links;
  extern int protocol_version;
-@@ -75,6 +78,7 @@ extern int output_needs_newline;
+@@ -74,6 +77,7 @@ extern int output_needs_newline;
  extern int sender_keeps_checksum;
  extern int trust_sender_filter;
  extern int unsort_ndx;
@@ -85,7 +85,7 @@ diff --git a/flist.c b/flist.c
  extern uid_t our_uid;
  extern struct stats stats;
  extern char *filesfrom_host;
-@@ -91,6 +95,20 @@ extern int filesfrom_convert;
+@@ -92,6 +96,20 @@ extern int filesfrom_convert;
  extern iconv_t ic_send, ic_recv;
  #endif
  
@@ -106,7 +106,7 @@ diff --git a/flist.c b/flist.c
  #define PTR_SIZE (sizeof (struct file_struct *))
  
  int io_error;
-@@ -135,8 +153,12 @@ static char empty_sum[MAX_DIGEST_LEN];
+@@ -136,8 +154,12 @@ static char empty_sum[MAX_DIGEST_LEN];
  static int flist_count_offset; /* for --delete --progress */
  static int show_filelist_progress;
  
@@ -120,7 +120,7 @@ diff --git a/flist.c b/flist.c
  static void output_flist(struct file_list *flist);
  
  void init_flist(void)
-@@ -327,6 +349,235 @@ static void flist_done_allocating(struct file_list *flist)
+@@ -329,6 +351,235 @@ static void flist_done_allocating(struct file_list *flist)
                flist->pool_boundary = ptr;
  }
  
@@ -230,7 +230,7 @@ diff --git a/flist.c b/flist.c
 +
 +      while (fgets(line, sizeof line, fp)) {
 +              cp = line;
-+              if (checksum_type == 5) {
++              if (file_sum_nni->num == CSUM_MD5) {
 +                      char *alt_sum = cp;
 +                      if (*cp == '=')
 +                              while (*++cp == '=') {}
@@ -265,7 +265,7 @@ diff --git a/flist.c b/flist.c
 +                      break;
 +              while (*++cp == ' ') {}
 +
-+              if (checksum_type != 5) {
++              if (file_sum_nni->num < CSUM_MD5) {
 +                      char *alt_sum = cp;
 +                      if (*cp == '=')
 +                              while (*++cp == '=') {}
@@ -356,7 +356,7 @@ diff --git a/flist.c b/flist.c
  /* Call this with EITHER (1) "file, NULL, 0" to chdir() to the file's
   * F_PATHNAME(), or (2) "NULL, dir, dirlen" to chdir() to the supplied dir,
   * with dir == NULL taken to be the starting directory, and dirlen < 0
-@@ -1229,7 +1480,7 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1231,7 +1482,7 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
                              STRUCT_STAT *stp, int flags, int filter_level)
  {
        static char *lastdir;
@@ -365,7 +365,7 @@ diff --git a/flist.c b/flist.c
        struct file_struct *file;
        char thisname[MAXPATHLEN];
        char linkname[MAXPATHLEN];
-@@ -1375,9 +1626,16 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1377,9 +1628,16 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
                        memcpy(lastdir, thisname, len);
                        lastdir[len] = '\0';
                        lastdir_len = len;
@@ -383,7 +383,7 @@ diff --git a/flist.c b/flist.c
        basename_len = strlen(basename) + 1; /* count the '\0' */
  
  #ifdef SUPPORT_LINKS
-@@ -1407,11 +1665,8 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1409,11 +1667,8 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
                extra_len += EXTRA_LEN;
  #endif
  
@@ -397,7 +397,7 @@ diff --git a/flist.c b/flist.c
  
  #if EXTRA_ROUNDING > 0
        if (extra_len & (EXTRA_ROUNDING * EXTRA_LEN))
-@@ -1500,8 +1755,14 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1502,8 +1757,14 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
                return NULL;
        }
  
@@ -414,7 +414,7 @@ diff --git a/flist.c b/flist.c
  
        if (unsort_ndx)
                F_NDX(file) = stats.num_dirs;
-@@ -2718,7 +2979,7 @@ struct file_list *recv_file_list(int f, int dir_ndx)
+@@ -2720,7 +2981,7 @@ struct file_list *recv_file_list(int f, int dir_ndx)
        /* The --relative option sends paths with a leading slash, so we need
         * to specify the strip_root option here.  We rejected leading slashes
         * for a non-relative transfer in recv_file_entry(). */
@@ -423,7 +423,7 @@ diff --git a/flist.c b/flist.c
  
        if (protocol_version < 30) {
                /* Recv the io_error flag */
-@@ -2963,7 +3224,7 @@ void flist_free(struct file_list *flist)
+@@ -2965,7 +3226,7 @@ void flist_free(struct file_list *flist)
  
  /* This routine ensures we don't have any duplicate names in our file list.
   * duplicate names can cause corruption because of the pipelining. */
@@ -432,7 +432,7 @@ diff --git a/flist.c b/flist.c
  {
        char fbuf[MAXPATHLEN];
        int i, prev_i;
-@@ -3014,7 +3275,7 @@ static void flist_sort_and_clean(struct file_list *flist, int strip_root)
+@@ -3016,7 +3277,7 @@ static void flist_sort_and_clean(struct file_list *flist, int strip_root)
                        /* If one is a dir and the other is not, we want to
                         * keep the dir because it might have contents in the
                         * list.  Otherwise keep the first one. */
@@ -441,7 +441,7 @@ diff --git a/flist.c b/flist.c
                                struct file_struct *fp = flist->sorted[j];
                                if (!S_ISDIR(fp->mode))
                                        keep = i, drop = j;
-@@ -3030,8 +3291,8 @@ static void flist_sort_and_clean(struct file_list *flist, int strip_root)
+@@ -3032,8 +3293,8 @@ static void flist_sort_and_clean(struct file_list *flist, int strip_root)
                        } else
                                keep = j, drop = i;
  
@@ -452,7 +452,7 @@ diff --git a/flist.c b/flist.c
                                        rprintf(FINFO,
                                            "removing duplicate name %s from file list (%d)\n",
                                            f_name(file, fbuf), drop + flist->ndx_start);
-@@ -3053,7 +3314,7 @@ static void flist_sort_and_clean(struct file_list *flist, int strip_root)
+@@ -3055,7 +3316,7 @@ static void flist_sort_and_clean(struct file_list *flist, int strip_root)
        }
        flist->high = prev_i;
  
@@ -493,7 +493,7 @@ diff --git a/generator.c b/generator.c
                        return memcmp(sum, F_SUM(file), flist_csum_len) == 0;
                }
  
-@@ -953,7 +957,7 @@ static int try_dests_reg(struct file_struct *file, char *fname, int ndx,
+@@ -956,7 +960,7 @@ static int try_dests_reg(struct file_struct *file, char *fname, int ndx,
                        best_match = j;
                        match_level = 1;
                }
@@ -502,7 +502,7 @@ diff --git a/generator.c b/generator.c
                        continue;
                if (match_level == 1) {
                        best_match = j;
-@@ -1076,7 +1080,7 @@ static int try_dests_non(struct file_struct *file, char *fname, int ndx,
+@@ -1079,7 +1083,7 @@ static int try_dests_non(struct file_struct *file, char *fname, int ndx,
                        match_level = 1;
                        best_match = j;
                }
@@ -511,7 +511,7 @@ diff --git a/generator.c b/generator.c
                        continue;
                if (match_level < 2) {
                        match_level = 2;
-@@ -1212,7 +1216,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1215,7 +1219,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
         * --ignore-non-existing, daemon exclude, or mkdir failure. */
        static struct file_struct *skip_dir = NULL;
        static struct file_list *fuzzy_dirlist[MAX_BASIS_DIRS+1];
@@ -520,7 +520,7 @@ diff --git a/generator.c b/generator.c
        struct file_struct *fuzzy_file = NULL;
        int fd = -1, f_copy = -1;
        stat_x sx, real_sx;
-@@ -1329,8 +1333,9 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1332,8 +1336,9 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                                                fuzzy_dirlist[i] = NULL;
                                        }
                                }
@@ -532,7 +532,7 @@ diff --git a/generator.c b/generator.c
  #ifdef SUPPORT_ACLS
                        if (!preserve_perms)
                                dflt_perms = default_perms_for_dir(dn);
-@@ -1338,6 +1343,24 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1341,6 +1346,24 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                }
                parent_dirname = dn;
  
@@ -557,7 +557,7 @@ diff --git a/generator.c b/generator.c
                statret = link_stat(fname, &sx.st, keep_dirlinks && is_dir);
                stat_errno = errno;
        }
-@@ -1384,7 +1407,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1387,7 +1410,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                        if (INFO_GTE(SKIP, 2)) {
                                if (ftype != stype)
                                        suf = " (type change)";
@@ -566,7 +566,7 @@ diff --git a/generator.c b/generator.c
                                        suf = always_checksum ? " (sum change)" : " (file change)";
                                else if (!unchanged_attrs(fname, file, &sx))
                                        suf = " (attr change)";
-@@ -1555,7 +1578,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1558,7 +1581,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                        goto cleanup;
                }
                if (statret == 0) {
@@ -575,7 +575,7 @@ diff --git a/generator.c b/generator.c
                                /* The link is pointing to the right place. */
                                set_file_attrs(fname, file, &sx, NULL, maybe_ATTRS_REPORT);
                                if (itemizing)
-@@ -1624,7 +1647,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1627,7 +1650,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                if (statret == 0) {
                        if (ftype != stype)
                                statret = -1;
@@ -584,7 +584,7 @@ diff --git a/generator.c b/generator.c
                                /* The device or special file is identical. */
                                set_file_attrs(fname, file, &sx, NULL, maybe_ATTRS_REPORT);
                                if (itemizing)
-@@ -1749,22 +1772,6 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1752,22 +1775,6 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                partialptr = NULL;
  
        if (statret != 0 && fuzzy_basis) {
@@ -607,7 +607,7 @@ diff --git a/generator.c b/generator.c
                /* Sets fnamecmp_type to FNAMECMP_FUZZY or above. */
                fuzzy_file = find_fuzzy(file, fuzzy_dirlist, &fnamecmp_type);
                if (fuzzy_file) {
-@@ -1803,7 +1810,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1806,7 +1813,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                ;
        else if (fnamecmp_type >= FNAMECMP_FUZZY)
                ;
@@ -656,7 +656,7 @@ diff --git a/options.c b/options.c
  int max_delete = INT_MIN;
  OFF_T max_size = -1;
  OFF_T min_size = -1;
-@@ -581,7 +582,7 @@ enum {OPT_SERVER = 1000, OPT_DAEMON, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
+@@ -582,7 +583,7 @@ enum {OPT_SERVER = 1000, OPT_DAEMON, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
        OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_MODIFY_WINDOW, OPT_MIN_SIZE, OPT_CHMOD,
        OPT_READ_BATCH, OPT_WRITE_BATCH, OPT_ONLY_WRITE_BATCH, OPT_MAX_SIZE,
        OPT_NO_D, OPT_APPEND, OPT_NO_ICONV, OPT_INFO, OPT_DEBUG, OPT_BLOCK_SIZE,
@@ -665,7 +665,7 @@ diff --git a/options.c b/options.c
        OPT_OLD_COMPRESS, OPT_NEW_COMPRESS, OPT_NO_COMPRESS, OPT_OLD_ARGS,
        OPT_STOP_AFTER, OPT_STOP_AT,
        OPT_REFUSED_BASE = 9000};
-@@ -738,6 +739,7 @@ static struct poptOption long_options[] = {
+@@ -739,6 +740,7 @@ static struct poptOption long_options[] = {
    {"no-c",             0,  POPT_ARG_VAL,    &always_checksum, 0, 0, 0 },
    {"checksum-choice",  0,  POPT_ARG_STRING, &checksum_choice, 0, 0, 0 },
    {"cc",               0,  POPT_ARG_STRING, &checksum_choice, 0, 0, 0 },
@@ -673,7 +673,7 @@ diff --git a/options.c b/options.c
    {"block-size",      'B', POPT_ARG_STRING, 0, OPT_BLOCK_SIZE, 0, 0 },
    {"compare-dest",     0,  POPT_ARG_STRING, 0, OPT_COMPARE_DEST, 0, 0 },
    {"copy-dest",        0,  POPT_ARG_STRING, 0, OPT_COPY_DEST, 0, 0 },
-@@ -1746,6 +1748,23 @@ int parse_arguments(int *argc_p, const char ***argv_p)
+@@ -1751,6 +1753,23 @@ int parse_arguments(int *argc_p, const char ***argv_p)
                        }
                        break;
  
@@ -697,7 +697,7 @@ diff --git a/options.c b/options.c
                case OPT_INFO:
                        arg = poptGetOptArg(pc);
                        parse_output_words(info_words, info_levels, arg, USER_PRIORITY);
-@@ -2099,6 +2118,9 @@ int parse_arguments(int *argc_p, const char ***argv_p)
+@@ -2118,6 +2137,9 @@ int parse_arguments(int *argc_p, const char ***argv_p)
        }
  #endif
  
@@ -710,7 +710,7 @@ diff --git a/options.c b/options.c
 diff --git a/rsync.1.md b/rsync.1.md
 --- a/rsync.1.md
 +++ b/rsync.1.md
-@@ -386,6 +386,7 @@ has its own detailed description later in this manpage.
+@@ -422,6 +422,7 @@ has its own detailed description later in this manpage.
  --quiet, -q              suppress non-error messages
  --no-motd                suppress daemon-mode MOTD
  --checksum, -c           skip based on checksum, not mod-time & size
@@ -718,7 +718,7 @@ diff --git a/rsync.1.md b/rsync.1.md
  --archive, -a            archive mode is -rlptgoD (no -A,-X,-U,-N,-H)
  --no-OPTION              turn off an implied OPTION (e.g. --no-D)
  --recursive, -r          recurse into directories
-@@ -775,6 +776,8 @@ expand it.
+@@ -814,6 +815,8 @@ expand it.
      file that has the same size as the corresponding sender's file: files with
      either a changed size or a changed checksum are selected for transfer.
  
@@ -727,7 +727,7 @@ diff --git a/rsync.1.md b/rsync.1.md
      Note that rsync always verifies that each _transferred_ file was correctly
      reconstructed on the receiving side by checking a whole-file checksum that
      is generated as the file is transferred, but that automatic
-@@ -786,6 +789,38 @@ expand it.
+@@ -825,6 +828,38 @@ expand it.
      option or an environment variable that is discussed in that option's
      section.
  
@@ -769,7 +769,7 @@ diff --git a/rsync.1.md b/rsync.1.md
 diff --git a/rsync.h b/rsync.h
 --- a/rsync.h
 +++ b/rsync.h
-@@ -902,6 +902,10 @@ extern int xattrs_ndx;
+@@ -897,6 +897,10 @@ extern int file_sum_extra_cnt;
  #define F_SUM(f) ((char*)OPT_EXTRA(f, START_BUMP(f) + HLINK_BUMP(f) \
                                    + SUM_EXTRA_CNT - 1))
  
@@ -780,7 +780,7 @@ diff --git a/rsync.h b/rsync.h
  /* Some utility defines: */
  #define F_IS_ACTIVE(f) (f)->basename[0]
  #define F_IS_HLINKED(f) ((f)->flags & FLAG_HLINKED)
-@@ -1115,6 +1119,13 @@ typedef struct {
+@@ -1111,6 +1115,13 @@ typedef struct {
  #define RELNAMECACHE_LEN (offsetof(relnamecache, fname))
  #endif
  
@@ -797,7 +797,7 @@ diff --git a/rsync.h b/rsync.h
 diff --git a/rsyncd.conf.5.md b/rsyncd.conf.5.md
 --- a/rsyncd.conf.5.md
 +++ b/rsyncd.conf.5.md
-@@ -421,6 +421,19 @@ the values of parameters.  See the GLOBAL PARAMETERS section for more details.
+@@ -453,6 +453,19 @@ in the values of parameters.  See that section for details.
      the max connections limit is not exceeded for the modules sharing the lock
      file.  The default is `/var/run/rsyncd.lock`.