The patches for 3.0.9.
[rsync.git/patches.git] / checksum-reading.diff
index 0520dc7bba3ba313d1133124dba9600152616cf0..5eae0246f7a323979eed12eef94c4706f9afcfa6 100644 (file)
@@ -16,11 +16,11 @@ To use this patch, run these commands for a successful build:
     ./configure                               (optional if already run)
     make
 
-based-on: 2f01fb11526f4a8fed3e5e6189706845c04136f3
+based-on: 40afd365cc8ca968fd16e161d24df5b8a8a520cc
 diff --git a/checksum.c b/checksum.c
 --- a/checksum.c
 +++ b/checksum.c
-@@ -100,7 +100,7 @@ void get_checksum2(char *buf, int32 len, char *sum)
+@@ -98,7 +98,7 @@ void get_checksum2(char *buf, int32 len, char *sum)
        }
  }
  
@@ -41,7 +41,7 @@ diff --git a/clientserver.c b/clientserver.c
  extern int io_timeout;
  extern int no_detach;
  extern int write_batch;
-@@ -781,6 +783,9 @@ static int rsync_module(int f_in, int f_out, int i, char *addr, char *host)
+@@ -789,6 +791,9 @@ static int rsync_module(int f_in, int f_out, int i, char *addr, char *host)
        } else if (am_root < 0) /* Treat --fake-super from client as --super. */
                am_root = 2;
  
@@ -62,7 +62,7 @@ diff --git a/flist.c b/flist.c
  extern int module_id;
  extern int ignore_errors;
  extern int numeric_ids;
-@@ -61,6 +62,7 @@ extern int file_extra_cnt;
+@@ -58,6 +59,7 @@ extern int implied_dirs;
  extern int ignore_perishable;
  extern int non_perishable_cnt;
  extern int prune_empty_dirs;
@@ -70,15 +70,15 @@ diff --git a/flist.c b/flist.c
  extern int copy_links;
  extern int copy_unsafe_links;
  extern int protocol_version;
-@@ -70,6 +72,7 @@ extern int use_safe_inc_flist;
+@@ -67,6 +69,7 @@ extern int use_safe_inc_flist;
  extern int need_unsorted_flist;
  extern int sender_symlink_iconv;
  extern int unsort_ndx;
 +extern char *basis_dir[];
+ extern uid_t our_uid;
  extern struct stats stats;
  extern char *filesfrom_host;
-@@ -85,6 +88,12 @@ extern int filesfrom_convert;
+@@ -83,6 +86,12 @@ extern int filesfrom_convert;
  extern iconv_t ic_send, ic_recv;
  #endif
  
@@ -91,7 +91,7 @@ diff --git a/flist.c b/flist.c
  #define PTR_SIZE (sizeof (struct file_struct *))
  
  int io_error;
-@@ -126,7 +135,11 @@ static char empty_sum[MAX_DIGEST_LEN];
+@@ -124,7 +133,11 @@ static char empty_sum[MAX_DIGEST_LEN];
  static int flist_count_offset; /* for --delete --progress */
  static int dir_count = 0;
  
@@ -104,7 +104,7 @@ diff --git a/flist.c b/flist.c
  static void output_flist(struct file_list *flist);
  
  void init_flist(void)
-@@ -340,6 +353,238 @@ static void flist_done_allocating(struct file_list *flist)
+@@ -338,6 +351,238 @@ static void flist_done_allocating(struct file_list *flist)
                flist->pool_boundary = ptr;
  }
  
@@ -343,7 +343,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
-@@ -1078,7 +1323,7 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1077,7 +1322,7 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
                              STRUCT_STAT *stp, int flags, int filter_level)
  {
        static char *lastdir;
@@ -352,7 +352,7 @@ diff --git a/flist.c b/flist.c
        struct file_struct *file;
        char thisname[MAXPATHLEN];
        char linkname[MAXPATHLEN];
-@@ -1217,9 +1462,16 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1216,9 +1461,16 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
                        memcpy(lastdir, thisname, len);
                        lastdir[len] = '\0';
                        lastdir_len = len;
@@ -370,7 +370,7 @@ diff --git a/flist.c b/flist.c
        basename_len = strlen(basename) + 1; /* count the '\0' */
  
  #ifdef SUPPORT_LINKS
-@@ -1297,14 +1549,18 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1298,14 +1550,18 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
                memcpy(bp + basename_len, linkname, linkname_len);
  #endif
  
@@ -392,7 +392,7 @@ diff --git a/flist.c b/flist.c
        if (basename_len == 0+1) {
                if (!pool)
                        unmake_file(file);
-@@ -2297,7 +2553,8 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
+@@ -2307,7 +2563,8 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
                         * file-list to check if this is a 1-file xfer. */
                        send_extra_file_list(f, 1);
                }
@@ -402,7 +402,7 @@ diff --git a/flist.c b/flist.c
  
        return flist;
  }
-@@ -2415,7 +2672,7 @@ struct file_list *recv_file_list(int f)
+@@ -2425,7 +2682,7 @@ struct file_list *recv_file_list(int f)
        else if (f >= 0)
                recv_id_list(f, flist);
  
@@ -411,7 +411,7 @@ diff --git a/flist.c b/flist.c
  
        if (protocol_version < 30) {
                /* Recv the io_error flag */
-@@ -2635,7 +2892,7 @@ void flist_free(struct file_list *flist)
+@@ -2645,7 +2902,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. */
@@ -420,7 +420,7 @@ diff --git a/flist.c b/flist.c
  {
        char fbuf[MAXPATHLEN];
        int i, prev_i;
-@@ -2686,7 +2943,7 @@ static void flist_sort_and_clean(struct file_list *flist, int strip_root)
+@@ -2696,7 +2953,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. */
@@ -429,7 +429,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;
-@@ -2702,8 +2959,8 @@ static void flist_sort_and_clean(struct file_list *flist, int strip_root)
+@@ -2712,8 +2969,8 @@ static void flist_sort_and_clean(struct file_list *flist, int strip_root)
                        } else
                                keep = j, drop = i;
  
@@ -440,7 +440,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);
-@@ -2725,7 +2982,7 @@ static void flist_sort_and_clean(struct file_list *flist, int strip_root)
+@@ -2735,7 +2992,7 @@ static void flist_sort_and_clean(struct file_list *flist, int strip_root)
        }
        flist->high = prev_i;
  
@@ -452,7 +452,7 @@ diff --git a/flist.c b/flist.c
 diff --git a/generator.c b/generator.c
 --- a/generator.c
 +++ b/generator.c
-@@ -52,6 +52,7 @@ extern int delete_during;
+@@ -50,6 +50,7 @@ extern int delete_during;
  extern int delete_after;
  extern int msgdone_cnt;
  extern int ignore_errors;
@@ -460,7 +460,7 @@ diff --git a/generator.c b/generator.c
  extern int remove_source_files;
  extern int delay_updates;
  extern int update_only;
-@@ -715,7 +716,7 @@ void itemize(const char *fnamecmp, struct file_struct *file, int ndx, int statre
+@@ -749,7 +750,7 @@ void itemize(const char *fnamecmp, struct file_struct *file, int ndx, int statre
  
  
  /* Perform our quick-check heuristic for determining if a file is unchanged. */
@@ -469,7 +469,7 @@ diff --git a/generator.c b/generator.c
  {
        if (st->st_size != F_LENGTH(file))
                return 0;
-@@ -724,7 +725,10 @@ int unchanged_file(char *fn, struct file_struct *file, STRUCT_STAT *st)
+@@ -758,7 +759,10 @@ int unchanged_file(char *fn, struct file_struct *file, STRUCT_STAT *st)
           of the file time to determine whether to sync */
        if (always_checksum > 0 && S_ISREG(st->st_mode)) {
                char sum[MAX_DIGEST_LEN];
@@ -481,7 +481,7 @@ diff --git a/generator.c b/generator.c
                return memcmp(sum, F_SUM(file), checksum_len) == 0;
        }
  
-@@ -988,7 +992,7 @@ static int try_dests_reg(struct file_struct *file, char *fname, int ndx,
+@@ -1028,7 +1032,7 @@ static int try_dests_reg(struct file_struct *file, char *fname, int ndx,
                        match_level = 1;
                        /* FALL THROUGH */
                case 1:
@@ -490,7 +490,7 @@ diff --git a/generator.c b/generator.c
                                continue;
                        best_match = j;
                        match_level = 2;
-@@ -1261,7 +1265,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1301,7 +1305,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 = NULL;
@@ -499,7 +499,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;
-@@ -1350,8 +1354,8 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1390,8 +1394,8 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                                flist_free(fuzzy_dirlist);
                                fuzzy_dirlist = NULL;
                        }
@@ -510,18 +510,18 @@ diff --git a/generator.c b/generator.c
  #ifdef SUPPORT_ACLS
                        if (!preserve_perms)
                                dflt_perms = default_perms_for_dir(dn);
-@@ -1359,10 +1363,15 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1399,10 +1403,15 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                }
                parent_dirname = dn;
  
 -              if (need_fuzzy_dirlist && S_ISREG(file->mode)) {
 -                      strlcpy(fnamecmpbuf, dn, sizeof fnamecmpbuf);
--                      fuzzy_dirlist = get_dirlist(fnamecmpbuf, -1, 1);
+-                      fuzzy_dirlist = get_dirlist(fnamecmpbuf, -1, GDL_IGNORE_FILTER_RULES);
 -                      need_fuzzy_dirlist = 0;
 +              if (need_new_dirscan && S_ISREG(file->mode)) {
 +                      if (fuzzy_basis) {
 +                              strlcpy(fnamecmpbuf, dn, sizeof fnamecmpbuf);
-+                              fuzzy_dirlist = get_dirlist(fnamecmpbuf, -1, 1);
++                              fuzzy_dirlist = get_dirlist(fnamecmpbuf, -1, GDL_IGNORE_FILTER_RULES);
 +                      }
 +                      if (checksum_files) {
 +                              reset_checksum_cache();
@@ -530,7 +530,7 @@ diff --git a/generator.c b/generator.c
                }
  
                statret = link_stat(fname, &sx.st, keep_dirlinks && is_dir);
-@@ -1800,7 +1809,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1855,7 +1864,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                ;
        else if (fnamecmp_type == FNAMECMP_FUZZY)
                ;
@@ -542,7 +542,7 @@ diff --git a/generator.c b/generator.c
 diff --git a/hlink.c b/hlink.c
 --- a/hlink.c
 +++ b/hlink.c
-@@ -394,7 +394,7 @@ int hard_link_check(struct file_struct *file, int ndx, const char *fname,
+@@ -395,7 +395,7 @@ int hard_link_check(struct file_struct *file, int ndx, const char *fname,
                                }
                                break;
                        }
@@ -618,7 +618,7 @@ diff --git a/loadparm.c b/loadparm.c
 diff --git a/options.c b/options.c
 --- a/options.c
 +++ b/options.c
-@@ -112,6 +112,7 @@ size_t bwlimit_writemax = 0;
+@@ -111,6 +111,7 @@ size_t bwlimit_writemax = 0;
  int ignore_existing = 0;
  int ignore_non_existing = 0;
  int need_messages_from_generator = 0;
@@ -626,7 +626,7 @@ diff --git a/options.c b/options.c
  int max_delete = INT_MIN;
  OFF_T max_size = 0;
  OFF_T min_size = 0;
-@@ -317,6 +318,7 @@ void usage(enum logcode F)
+@@ -316,6 +317,7 @@ void usage(enum logcode F)
    rprintf(F," -q, --quiet                 suppress non-error messages\n");
    rprintf(F,"     --no-motd               suppress daemon-mode MOTD (see manpage caveat)\n");
    rprintf(F," -c, --checksum              skip based on checksum, not mod-time & size\n");
@@ -634,7 +634,7 @@ diff --git a/options.c b/options.c
    rprintf(F," -a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)\n");
    rprintf(F,"     --no-OPTION             turn off an implied OPTION (e.g. --no-D)\n");
    rprintf(F," -r, --recursive             recurse into directories\n");
-@@ -446,7 +448,7 @@ enum {OPT_VERSION = 1000, OPT_DAEMON, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
+@@ -445,7 +447,7 @@ enum {OPT_VERSION = 1000, OPT_DAEMON, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
        OPT_FILTER, OPT_COMPARE_DEST, OPT_COPY_DEST, OPT_LINK_DEST, OPT_HELP,
        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,
@@ -643,7 +643,7 @@ diff --git a/options.c b/options.c
        OPT_SERVER, OPT_REFUSED_BASE = 9000};
  
  static struct poptOption long_options[] = {
-@@ -574,6 +576,7 @@ static struct poptOption long_options[] = {
+@@ -573,6 +575,7 @@ static struct poptOption long_options[] = {
    {"checksum",        'c', POPT_ARG_VAL,    &always_checksum, 1, 0, 0 },
    {"no-checksum",      0,  POPT_ARG_VAL,    &always_checksum, 0, 0, 0 },
    {"no-c",             0,  POPT_ARG_VAL,    &always_checksum, 0, 0, 0 },
@@ -651,7 +651,7 @@ diff --git a/options.c b/options.c
    {"block-size",      'B', POPT_ARG_LONG,   &block_size, 0, 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 },
-@@ -1228,6 +1231,23 @@ int parse_arguments(int *argc_p, const char ***argv_p)
+@@ -1227,6 +1230,23 @@ int parse_arguments(int *argc_p, const char ***argv_p)
                        }
                        break;
  
@@ -675,7 +675,7 @@ diff --git a/options.c b/options.c
                case OPT_HELP:
                        usage(FINFO);
                        exit_cleanup(0);
-@@ -1332,6 +1352,9 @@ int parse_arguments(int *argc_p, const char ***argv_p)
+@@ -1331,6 +1351,9 @@ int parse_arguments(int *argc_p, const char ***argv_p)
        }
  #endif
  
@@ -688,7 +688,7 @@ diff --git a/options.c b/options.c
 diff --git a/rsync.h b/rsync.h
 --- a/rsync.h
 +++ b/rsync.h
-@@ -693,6 +693,10 @@ extern int xattrs_ndx;
+@@ -712,6 +712,10 @@ extern int xattrs_ndx;
  #define F_SUM(f) ((char*)OPT_EXTRA(f, LEN64_BUMP(f) + HLINK_BUMP(f) \
                                    + SUM_EXTRA_CNT - 1))
  
@@ -699,7 +699,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)
-@@ -880,6 +884,13 @@ typedef struct {
+@@ -899,6 +903,13 @@ typedef struct {
        char fname[1]; /* has variable size */
  } relnamecache;
  
@@ -716,7 +716,7 @@ diff --git a/rsync.h b/rsync.h
 diff --git a/rsync.yo b/rsync.yo
 --- a/rsync.yo
 +++ b/rsync.yo
-@@ -321,6 +321,7 @@ to the detailed description below for a complete description.  verb(
+@@ -334,6 +334,7 @@ to the detailed description below for a complete description.  verb(
   -q, --quiet                 suppress non-error messages
       --no-motd               suppress daemon-mode MOTD (see caveat)
   -c, --checksum              skip based on checksum, not mod-time & size
@@ -724,7 +724,7 @@ diff --git a/rsync.yo b/rsync.yo
   -a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)
       --no-OPTION             turn off an implied OPTION (e.g. --no-D)
   -r, --recursive             recurse into directories
-@@ -520,9 +521,9 @@ uses a "quick check" that (by default) checks if each file's size and time
+@@ -539,9 +540,9 @@ uses a "quick check" that (by default) checks if each file's size and time
  of last modification match between the sender and receiver.  This option
  changes this to compare a 128-bit checksum for each file that has a
  matching size.  Generating the checksums means that both sides will expend
@@ -737,7 +737,7 @@ diff --git a/rsync.yo b/rsync.yo
  
  The sending side generates its checksums while it is doing the file-system
  scan that builds the list of the available files.  The receiver generates
-@@ -530,6 +531,8 @@ its checksums when it is scanning for changed files, and will checksum any
+@@ -549,6 +550,8 @@ its checksums when it is scanning for changed files, and will checksum any
  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.
  
@@ -746,7 +746,7 @@ diff --git a/rsync.yo b/rsync.yo
  Note that rsync always verifies that each em(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
-@@ -539,6 +542,36 @@ option's before-the-transfer "Does this file need to be updated?" check.
+@@ -558,6 +561,36 @@ option's before-the-transfer "Does this file need to be updated?" check.
  For protocol 30 and beyond (first supported in 3.0.0), the checksum used is
  MD5.  For older protocols, the checksum used is MD4.
  
@@ -786,7 +786,7 @@ diff --git a/rsync.yo b/rsync.yo
 diff --git a/rsyncd.conf.yo b/rsyncd.conf.yo
 --- a/rsyncd.conf.yo
 +++ b/rsyncd.conf.yo
-@@ -281,6 +281,17 @@ locking on this file to ensure that the max connections limit is not
+@@ -287,6 +287,17 @@ locking on this file to ensure that the max connections limit is not
  exceeded for the modules sharing the lock file.
  The default is tt(/var/run/rsyncd.lock).