Updated patches to work with the current trunk.
[rsync/rsync-patches.git] / checksum-updating.diff
index 195cdf6..621118b 100644 (file)
@@ -18,17 +18,18 @@ TODO:
  - Fix the code that removes .rsyncsums files when a dir becomes empty.
 
 diff --git a/flist.c b/flist.c
+index 8a42d80..d65c475 100644
 --- a/flist.c
 +++ b/flist.c
-@@ -26,6 +26,7 @@
+@@ -27,6 +27,7 @@
+ #include "inums.h"
  #include "io.h"
  
- extern int verbose;
 +extern int dry_run;
  extern int am_root;
  extern int am_server;
  extern int am_daemon;
-@@ -95,6 +96,9 @@ extern iconv_t ic_send, ic_recv;
+@@ -99,6 +100,9 @@ extern iconv_t ic_send, ic_recv;
  
  #define PTR_SIZE (sizeof (struct file_struct *))
  
@@ -38,9 +39,9 @@ diff --git a/flist.c b/flist.c
  int io_error;
  int checksum_len;
  dev_t filesystem_dev; /* used to implement -x */
-@@ -134,8 +138,13 @@ static char empty_sum[MAX_DIGEST_LEN];
+@@ -137,8 +141,13 @@ static char tmp_sum[MAX_DIGEST_LEN];
+ static char empty_sum[MAX_DIGEST_LEN];
  static int flist_count_offset; /* for --delete --progress */
- static int dir_count = 0;
  
 +#define REGULAR_SKIPPED(flist) ((flist)->to_redo)
 +
@@ -52,7 +53,7 @@ diff --git a/flist.c b/flist.c
  } *csum_cache = NULL;
  
  static void flist_sort_and_clean(struct file_list *flist, int flags);
-@@ -352,7 +361,79 @@ static void flist_done_allocating(struct file_list *flist)
+@@ -356,7 +365,79 @@ static void flist_done_allocating(struct file_list *flist)
                flist->pool_boundary = ptr;
  }
  
@@ -133,7 +134,7 @@ diff --git a/flist.c b/flist.c
  {
        int slot, slots = am_sender ? 1 : basis_dir_cnt + 1;
  
-@@ -366,6 +447,9 @@ void reset_checksum_cache()
+@@ -370,6 +451,9 @@ void reset_checksum_cache()
                struct file_list *flist = csum_cache[slot].flist;
  
                if (flist) {
@@ -143,7 +144,7 @@ diff --git a/flist.c b/flist.c
                        /* Reset the pool memory and empty the file-list array. */
                        pool_free_old(flist->file_pool,
                                      pool_boundary(flist->file_pool, 0));
-@@ -376,6 +460,10 @@ void reset_checksum_cache()
+@@ -380,6 +464,10 @@ void reset_checksum_cache()
                flist->low = 0;
                flist->high = -1;
                flist->next = NULL;
@@ -154,7 +155,7 @@ diff --git a/flist.c b/flist.c
        }
  }
  
-@@ -383,7 +471,7 @@ void reset_checksum_cache()
+@@ -387,7 +475,7 @@ void reset_checksum_cache()
  static int add_checksum(struct file_list *flist, const char *dirname,
                        const char *basename, int basename_len, OFF_T file_length,
                        time_t mtime, uint32 ctime, uint32 inode,
@@ -163,7 +164,7 @@ diff --git a/flist.c b/flist.c
  {
        struct file_struct *file;
        int alloc_len, extra_len;
-@@ -400,7 +488,7 @@ static int add_checksum(struct file_list *flist, const char *dirname,
+@@ -404,7 +492,7 @@ static int add_checksum(struct file_list *flist, const char *dirname,
        if (extra_len & (EXTRA_ROUNDING * EXTRA_LEN))
                extra_len = (extra_len | (EXTRA_ROUNDING * EXTRA_LEN)) + EXTRA_LEN;
  #endif
@@ -172,7 +173,7 @@ diff --git a/flist.c b/flist.c
        bp = pool_alloc(flist->file_pool, alloc_len, "add_checksum");
  
        memset(bp, 0, extra_len + FILE_STRUCT_LEN);
-@@ -409,7 +497,14 @@ static int add_checksum(struct file_list *flist, const char *dirname,
+@@ -413,7 +501,14 @@ static int add_checksum(struct file_list *flist, const char *dirname,
        bp += FILE_STRUCT_LEN;
  
        memcpy(bp, basename, basename_len);
@@ -187,7 +188,7 @@ diff --git a/flist.c b/flist.c
        file->mode = S_IFREG;
        file->modtime = mtime;
        file->len32 = (uint32)file_length;
-@@ -438,10 +533,11 @@ static void read_checksums(int slot, struct file_list *flist, const char *dirnam
+@@ -442,10 +537,11 @@ static void read_checksums(int slot, struct file_list *flist, const char *dirnam
        char line[MAXPATHLEN+1024], fbuf[MAXPATHLEN], sum[MAX_DIGEST_LEN];
        FILE *fp;
        char *cp;
@@ -200,7 +201,7 @@ diff --git a/flist.c b/flist.c
        int dlen = dirname ? strlcpy(fbuf, dirname, sizeof fbuf) : 0;
  
        if (dlen >= (int)(sizeof fbuf - 1 - RSYNCSUMS_LEN))
-@@ -462,7 +558,7 @@ static void read_checksums(int slot, struct file_list *flist, const char *dirnam
+@@ -466,7 +562,7 @@ static void read_checksums(int slot, struct file_list *flist, const char *dirnam
        while (fgets(line, sizeof line, fp)) {
                cp = line;
                if (protocol_version >= 30) {
@@ -209,7 +210,7 @@ diff --git a/flist.c b/flist.c
                        if (*cp == '=')
                                while (*++cp == '=') {}
                        else
-@@ -473,7 +569,14 @@ static void read_checksums(int slot, struct file_list *flist, const char *dirnam
+@@ -477,7 +573,14 @@ static void read_checksums(int slot, struct file_list *flist, const char *dirnam
                }
  
                if (*cp == '=') {
@@ -225,7 +226,7 @@ diff --git a/flist.c b/flist.c
                } else {
                        for (i = 0; i < checksum_len*2; i++, cp++) {
                                int x;
-@@ -491,13 +594,14 @@ static void read_checksums(int slot, struct file_list *flist, const char *dirnam
+@@ -495,13 +598,14 @@ static void read_checksums(int slot, struct file_list *flist, const char *dirnam
                                else
                                        sum[i/2] = x << 4;
                        }
@@ -241,7 +242,7 @@ diff --git a/flist.c b/flist.c
                        if (*cp == '=')
                                while (*++cp == '=') {}
                        else
-@@ -547,24 +651,112 @@ static void read_checksums(int slot, struct file_list *flist, const char *dirnam
+@@ -551,24 +655,112 @@ static void read_checksums(int slot, struct file_list *flist, const char *dirnam
                        continue;
  
                strlcpy(fbuf+dlen, cp, sizeof fbuf - dlen);
@@ -356,7 +357,7 @@ diff --git a/flist.c b/flist.c
                read_checksums(slot, flist, file->dirname);
        }
  
-@@ -576,12 +768,31 @@ void get_cached_checksum(int slot, const char *fname, struct file_struct *file,
+@@ -580,12 +772,31 @@ void get_cached_checksum(int slot, const char *fname, struct file_struct *file,
                 && (checksum_files & CSF_LAX
                  || (F_CTIME(fp) == (uint32)stp->st_ctime
                   && F_INODE(fp) == (uint32)stp->st_ino))) {
@@ -389,7 +390,7 @@ diff --git a/flist.c b/flist.c
  }
  
  /* Call this with EITHER (1) "file, NULL, 0" to chdir() to the file's
-@@ -1407,6 +1618,8 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1452,6 +1663,8 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
        if (is_excluded(thisname, S_ISDIR(st.st_mode) != 0, filter_level)) {
                if (ignore_perishable)
                        non_perishable_cnt++;
@@ -398,7 +399,7 @@ diff --git a/flist.c b/flist.c
                return NULL;
        }
  
-@@ -1453,13 +1666,13 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1498,13 +1711,13 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
                        lastdir[len] = '\0';
                        lastdir_len = len;
                        if (checksum_files && am_sender && flist)
@@ -414,7 +415,7 @@ diff --git a/flist.c b/flist.c
                }
        }
        basename_len = strlen(basename) + 1; /* count the '\0' */
-@@ -1545,7 +1758,7 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1599,7 +1812,7 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
  
        if (always_checksum && am_sender && S_ISREG(st.st_mode)) {
                if (flist && checksum_files)
@@ -422,8 +423,8 @@ diff --git a/flist.c b/flist.c
 +                      get_cached_checksum(0, thisname, file, basename_len, &st, tmp_sum);
                else
                        file_checksum(thisname, st.st_size, tmp_sum);
-       }
-@@ -1898,6 +2111,9 @@ static void send_directory(int f, struct file_list *flist, char *fbuf, int len,
+               if (sender_keeps_checksum)
+@@ -1971,6 +2184,9 @@ static void send_directory(int f, struct file_list *flist, char *fbuf, int len,
  
        closedir(d);
  
@@ -433,7 +434,7 @@ diff --git a/flist.c b/flist.c
        if (f >= 0 && recurse && !divert_dirs) {
                int i, end = flist->used - 1;
                /* send_if_directory() bumps flist->used, so use "end". */
-@@ -2495,6 +2711,9 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
+@@ -2589,6 +2805,9 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
        } else
                flist_eof = 1;
  
@@ -444,17 +445,18 @@ diff --git a/flist.c b/flist.c
  }
  
 diff --git a/generator.c b/generator.c
+index 48a5062..8717ab7 100644
 --- a/generator.c
 +++ b/generator.c
-@@ -114,6 +114,7 @@ static int dir_tweaking;
+@@ -111,6 +111,7 @@ static int dir_tweaking;
  static int symlink_timeset_failed_flags;
  static int need_retouch_dir_times;
  static int need_retouch_dir_perms;
 +static int started_whole_dir, upcoming_whole_dir;
  static const char *solo_file = NULL;
  
- /* For calling delete_item() and delete_dir_contents(). */
-@@ -726,7 +727,7 @@ int unchanged_file(char *fn, struct file_struct *file, STRUCT_STAT *st, int slot
+ enum nonregtype {
+@@ -533,7 +534,7 @@ int unchanged_file(char *fn, struct file_struct *file, STRUCT_STAT *st, int slot
        if (always_checksum > 0 && S_ISREG(st->st_mode)) {
                char sum[MAX_DIGEST_LEN];
                if (checksum_files && slot >= 0)
@@ -463,7 +465,7 @@ diff --git a/generator.c b/generator.c
                else
                        file_checksum(fn, st->st_size, sum);
                return memcmp(sum, F_SUM(file), checksum_len) == 0;
-@@ -1369,7 +1370,8 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1177,7 +1178,8 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                                fuzzy_dirlist = get_dirlist(fnamecmpbuf, -1, 1);
                        }
                        if (checksum_files) {
@@ -473,7 +475,7 @@ diff --git a/generator.c b/generator.c
                        }
                        need_new_dirscan = 0;
                }
-@@ -1519,6 +1521,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1335,6 +1337,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                        else
                                change_local_filter_dir(fname, strlen(fname), F_DEPTH(file));
                }
@@ -481,7 +483,7 @@ diff --git a/generator.c b/generator.c
                goto cleanup;
        }
  
-@@ -1811,6 +1814,8 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1627,6 +1630,8 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                        handle_partial_dir(partialptr, PDIR_DELETE);
                }
                set_file_attrs(fname, file, &sx, NULL, maybe_ATTRS_REPORT);
@@ -490,7 +492,7 @@ diff --git a/generator.c b/generator.c
                if (itemizing)
                        itemize(fnamecmp, file, ndx, statret, &sx, 0, 0, NULL);
  #ifdef SUPPORT_HARD_LINKS
-@@ -2252,6 +2257,7 @@ void generate_files(int f_out, const char *local_name)
+@@ -2068,6 +2073,7 @@ void generate_files(int f_out, const char *local_name)
                                } else
                                        change_local_filter_dir(fbuf, strlen(fbuf), F_DEPTH(fp));
                        }
@@ -498,21 +500,22 @@ diff --git a/generator.c b/generator.c
                }
                for (i = cur_flist->low; i <= cur_flist->high; i++) {
                        struct file_struct *file = cur_flist->sorted[i];
-@@ -2338,6 +2344,9 @@ void generate_files(int f_out, const char *local_name)
+@@ -2162,6 +2168,9 @@ void generate_files(int f_out, const char *local_name)
                        wait_for_receiver();
        }
  
 +      if (checksum_files)
 +              reset_checksum_cache(started_whole_dir);
 +
-       do_progress = save_do_progress;
-       if (delete_during == 2)
-               do_delayed_deletions(fbuf);
+       info_levels[INFO_FLIST] = save_info_flist;
+       info_levels[INFO_PROGRESS] = save_info_progress;
 diff --git a/io.c b/io.c
+index 6a89c8f..50e73b1 100644
 --- a/io.c
 +++ b/io.c
-@@ -50,6 +50,7 @@ extern int read_batch;
- extern int csum_length;
+@@ -49,6 +49,7 @@ extern int list_only;
+ extern int read_batch;
  extern int protect_args;
  extern int checksum_seed;
 +extern int checksum_files;
@@ -530,9 +533,10 @@ diff --git a/io.c b/io.c
                break;
        case FES_REDO:
 diff --git a/loadparm.c b/loadparm.c
+index 899d2b5..3123c93 100644
 --- a/loadparm.c
 +++ b/loadparm.c
-@@ -300,6 +300,10 @@ static struct enum_list enum_csum_modes[] = {
+@@ -311,6 +311,10 @@ static struct enum_list enum_csum_modes[] = {
        { CSF_IGNORE_FILES, "none" },
        { CSF_LAX_MODE, "lax" },
        { CSF_STRICT_MODE, "strict" },
@@ -544,9 +548,10 @@ diff --git a/loadparm.c b/loadparm.c
  };
  
 diff --git a/options.c b/options.c
+index 2e110f3..26d5561 100644
 --- a/options.c
 +++ b/options.c
-@@ -1234,7 +1234,15 @@ int parse_arguments(int *argc_p, const char ***argv_p)
+@@ -1635,7 +1635,15 @@ int parse_arguments(int *argc_p, const char ***argv_p)
  
                case OPT_SUMFILES:
                        arg = poptGetOptArg(pc);
@@ -564,17 +569,18 @@ diff --git a/options.c b/options.c
                                checksum_files |= CSF_LAX_MODE;
                        else if (strcmp(arg, "strict") == 0)
 diff --git a/receiver.c b/receiver.c
+index 4325e30..2cea8fe 100644
 --- a/receiver.c
 +++ b/receiver.c
-@@ -47,6 +47,7 @@ extern int append_mode;
- extern int sparse_files;
+@@ -47,6 +47,7 @@ extern int sparse_files;
  extern int keep_partial;
+ extern int checksum_len;
  extern int checksum_seed;
 +extern int checksum_files;
  extern int inplace;
  extern int delay_updates;
  extern mode_t orig_umask;
-@@ -343,7 +344,7 @@ static void handle_delayed_updates(char *local_name)
+@@ -344,7 +345,7 @@ static void handle_delayed_updates(char *local_name)
                                        "rename failed for %s (from %s)",
                                        full_fname(fname), partialptr);
                        } else {
@@ -583,7 +589,7 @@ diff --git a/receiver.c b/receiver.c
                                 || (preserve_hard_links && F_IS_HLINKED(file)))
                                        send_msg_int(MSG_SUCCESS, ndx);
                                handle_partial_dir(partialptr, PDIR_DELETE);
-@@ -758,7 +759,7 @@ int recv_files(int f_in, char *local_name)
+@@ -794,7 +795,7 @@ int recv_files(int f_in, char *local_name)
                case 2:
                        break;
                case 1:
@@ -593,9 +599,10 @@ diff --git a/receiver.c b/receiver.c
                                send_msg_int(MSG_SUCCESS, ndx);
                        break;
 diff --git a/rsync.h b/rsync.h
+index ba8f3db..89c47bd 100644
 --- a/rsync.h
 +++ b/rsync.h
-@@ -885,6 +885,8 @@ typedef struct {
+@@ -908,6 +908,8 @@ typedef struct {
  
  #define CSF_ENABLE (1<<1)
  #define CSF_LAX (1<<2)
@@ -605,9 +612,10 @@ diff --git a/rsync.h b/rsync.h
  #define CSF_IGNORE_FILES 0
  #define CSF_LAX_MODE (CSF_ENABLE|CSF_LAX)
 diff --git a/rsync.yo b/rsync.yo
+index 7aa62cf..a119ed7 100644
 --- a/rsync.yo
 +++ b/rsync.yo
-@@ -548,9 +548,13 @@ computed just as it would be if bf(--sumfiles) was not specified.
+@@ -596,9 +596,13 @@ computed just as it would be if bf(--sumfiles) was not specified.
  
  The MODE value is either "lax", for relaxed checking (which compares size
  and mtime), "strict" (which also compares ctime and inode), or "none" to
@@ -625,9 +633,10 @@ diff --git a/rsync.yo b/rsync.yo
  This option has no effect unless bf(--checksum, -c) was also specified.  It
  also only affects the current side of the transfer, so if you want the
 diff --git a/rsyncd.conf.yo b/rsyncd.conf.yo
+index 0fc98fd..3024842 100644
 --- a/rsyncd.conf.yo
 +++ b/rsyncd.conf.yo
-@@ -284,13 +284,15 @@ The default is tt(/var/run/rsyncd.lock).
+@@ -295,13 +295,15 @@ The default is tt(/var/run/rsyncd.lock).
  dit(bf(checksum files)) This parameter tells rsync to make use of any cached
  checksum information it finds in per-directory .rsyncsums files when the
  current transfer is using the bf(--checksum) option.  The value can be set