The patches for 3.0.4pre1.
[rsync/rsync-patches.git] / checksum-updating.diff
index 8666a12..bea59fa 100644 (file)
@@ -52,7 +52,7 @@ diff --git a/flist.c b/flist.c
  } *csum_cache = NULL;
  
  static void flist_sort_and_clean(struct file_list *flist, int flags);
  } *csum_cache = NULL;
  
  static void flist_sort_and_clean(struct file_list *flist, int flags);
-@@ -363,7 +372,79 @@ static void flist_done_allocating(struct file_list *flist)
+@@ -351,7 +360,79 @@ static void flist_done_allocating(struct file_list *flist)
                flist->pool_boundary = ptr;
  }
  
                flist->pool_boundary = ptr;
  }
  
@@ -133,7 +133,7 @@ diff --git a/flist.c b/flist.c
  {
        int slot, slots = am_sender ? 1 : basis_dir_cnt + 1;
  
  {
        int slot, slots = am_sender ? 1 : basis_dir_cnt + 1;
  
-@@ -377,6 +458,9 @@ void reset_checksum_cache()
+@@ -365,6 +446,9 @@ void reset_checksum_cache()
                struct file_list *flist = csum_cache[slot].flist;
  
                if (flist) {
                struct file_list *flist = csum_cache[slot].flist;
  
                if (flist) {
@@ -143,7 +143,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));
                        /* Reset the pool memory and empty the file-list array. */
                        pool_free_old(flist->file_pool,
                                      pool_boundary(flist->file_pool, 0));
-@@ -387,6 +471,10 @@ void reset_checksum_cache()
+@@ -375,6 +459,10 @@ void reset_checksum_cache()
                flist->low = 0;
                flist->high = -1;
                flist->next = NULL;
                flist->low = 0;
                flist->high = -1;
                flist->next = NULL;
@@ -154,7 +154,7 @@ diff --git a/flist.c b/flist.c
        }
  }
  
        }
  }
  
-@@ -394,7 +482,7 @@ void reset_checksum_cache()
+@@ -382,7 +470,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,
  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 +163,7 @@ diff --git a/flist.c b/flist.c
  {
        struct file_struct *file;
        int alloc_len, extra_len;
  {
        struct file_struct *file;
        int alloc_len, extra_len;
-@@ -411,7 +499,7 @@ static int add_checksum(struct file_list *flist, const char *dirname,
+@@ -399,7 +487,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
        if (extra_len & (EXTRA_ROUNDING * EXTRA_LEN))
                extra_len = (extra_len | (EXTRA_ROUNDING * EXTRA_LEN)) + EXTRA_LEN;
  #endif
@@ -172,7 +172,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);
        bp = pool_alloc(flist->file_pool, alloc_len, "add_checksum");
  
        memset(bp, 0, extra_len + FILE_STRUCT_LEN);
-@@ -420,7 +508,14 @@ static int add_checksum(struct file_list *flist, const char *dirname,
+@@ -408,7 +496,14 @@ static int add_checksum(struct file_list *flist, const char *dirname,
        bp += FILE_STRUCT_LEN;
  
        memcpy(bp, basename, basename_len);
        bp += FILE_STRUCT_LEN;
  
        memcpy(bp, basename, basename_len);
@@ -187,7 +187,7 @@ diff --git a/flist.c b/flist.c
        file->mode = S_IFREG;
        file->modtime = mtime;
        file->len32 = (uint32)file_length;
        file->mode = S_IFREG;
        file->modtime = mtime;
        file->len32 = (uint32)file_length;
-@@ -449,10 +544,11 @@ static void read_checksums(int slot, struct file_list *flist, const char *dirnam
+@@ -437,10 +532,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;
        char line[MAXPATHLEN+1024], fbuf[MAXPATHLEN], sum[MAX_DIGEST_LEN];
        FILE *fp;
        char *cp;
@@ -200,7 +200,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))
        int dlen = dirname ? strlcpy(fbuf, dirname, sizeof fbuf) : 0;
  
        if (dlen >= (int)(sizeof fbuf - 1 - RSYNCSUMS_LEN))
-@@ -473,7 +569,7 @@ static void read_checksums(int slot, struct file_list *flist, const char *dirnam
+@@ -461,7 +557,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) {
        while (fgets(line, sizeof line, fp)) {
                cp = line;
                if (protocol_version >= 30) {
@@ -209,7 +209,7 @@ diff --git a/flist.c b/flist.c
                        if (*cp == '=')
                                while (*++cp == '=') {}
                        else
                        if (*cp == '=')
                                while (*++cp == '=') {}
                        else
-@@ -484,7 +580,14 @@ static void read_checksums(int slot, struct file_list *flist, const char *dirnam
+@@ -472,7 +568,14 @@ static void read_checksums(int slot, struct file_list *flist, const char *dirnam
                }
  
                if (*cp == '=') {
                }
  
                if (*cp == '=') {
@@ -225,7 +225,7 @@ diff --git a/flist.c b/flist.c
                } else {
                        for (i = 0; i < checksum_len*2; i++, cp++) {
                                int x;
                } else {
                        for (i = 0; i < checksum_len*2; i++, cp++) {
                                int x;
-@@ -502,13 +605,14 @@ static void read_checksums(int slot, struct file_list *flist, const char *dirnam
+@@ -490,13 +593,14 @@ static void read_checksums(int slot, struct file_list *flist, const char *dirnam
                                else
                                        sum[i/2] = x << 4;
                        }
                                else
                                        sum[i/2] = x << 4;
                        }
@@ -241,7 +241,7 @@ diff --git a/flist.c b/flist.c
                        if (*cp == '=')
                                while (*++cp == '=') {}
                        else
                        if (*cp == '=')
                                while (*++cp == '=') {}
                        else
-@@ -558,24 +662,112 @@ static void read_checksums(int slot, struct file_list *flist, const char *dirnam
+@@ -546,24 +650,112 @@ static void read_checksums(int slot, struct file_list *flist, const char *dirnam
                        continue;
  
                strlcpy(fbuf+dlen, cp, sizeof fbuf - dlen);
                        continue;
  
                strlcpy(fbuf+dlen, cp, sizeof fbuf - dlen);
@@ -356,7 +356,7 @@ diff --git a/flist.c b/flist.c
                read_checksums(slot, flist, file->dirname);
        }
  
                read_checksums(slot, flist, file->dirname);
        }
  
-@@ -587,12 +779,31 @@ void get_cached_checksum(int slot, const char *fname, struct file_struct *file,
+@@ -575,12 +767,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))) {
                 && (checksum_files & CSF_LAX
                  || (F_CTIME(fp) == (uint32)stp->st_ctime
                   && F_INODE(fp) == (uint32)stp->st_ino))) {
@@ -388,8 +388,8 @@ diff --git a/flist.c b/flist.c
 +      }
  }
  
 +      }
  }
  
- int push_pathname(const char *dir, int len)
-@@ -1378,6 +1589,8 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+ /* Call this with EITHER (1) "file, NULL, 0" to chdir() to the file's
+@@ -1371,6 +1582,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++;
        if (is_excluded(thisname, S_ISDIR(st.st_mode) != 0, filter_level)) {
                if (ignore_perishable)
                        non_perishable_cnt++;
@@ -398,7 +398,7 @@ diff --git a/flist.c b/flist.c
                return NULL;
        }
  
                return NULL;
        }
  
-@@ -1424,13 +1637,13 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1417,13 +1630,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)
                        lastdir[len] = '\0';
                        lastdir_len = len;
                        if (checksum_files && am_sender && flist)
@@ -414,7 +414,7 @@ diff --git a/flist.c b/flist.c
                }
        }
        basename_len = strlen(basename) + 1; /* count the '\0' */
                }
        }
        basename_len = strlen(basename) + 1; /* count the '\0' */
-@@ -1512,7 +1725,7 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1509,7 +1722,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)
  
        if (always_checksum && am_sender && S_ISREG(st.st_mode)) {
                if (flist && checksum_files)
@@ -423,7 +423,7 @@ diff --git a/flist.c b/flist.c
                else
                        file_checksum(thisname, st.st_size, tmp_sum);
        }
                else
                        file_checksum(thisname, st.st_size, tmp_sum);
        }
-@@ -1804,6 +2017,9 @@ static void send_directory(int f, struct file_list *flist, char *fbuf, int len,
+@@ -1839,6 +2052,9 @@ static void send_directory(int f, struct file_list *flist, char *fbuf, int len,
  
        closedir(d);
  
  
        closedir(d);
  
@@ -433,16 +433,16 @@ 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". */
        if (f >= 0 && recurse && !divert_dirs) {
                int i, end = flist->used - 1;
                /* send_if_directory() bumps flist->used, so use "end". */
-@@ -2389,6 +2605,9 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
-               }
+@@ -2436,6 +2652,9 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
        } else
                flist_eof = 1;
        } else
                flist_eof = 1;
-+      
 +      if (checksum_files & CSF_UPDATE && flist_eof)
 +              reset_checksum_cache(0); /* writes any last updates */
 +      if (checksum_files & CSF_UPDATE && flist_eof)
 +              reset_checksum_cache(0); /* writes any last updates */
++
        return flist;
  }
        return flist;
  }
 diff --git a/generator.c b/generator.c
 --- a/generator.c
 +++ b/generator.c
 diff --git a/generator.c b/generator.c
 --- a/generator.c
 +++ b/generator.c
@@ -454,7 +454,7 @@ diff --git a/generator.c b/generator.c
  static const char *solo_file = NULL;
  
  /* For calling delete_item() and delete_dir_contents(). */
  static const char *solo_file = NULL;
  
  /* For calling delete_item() and delete_dir_contents(). */
-@@ -717,7 +718,7 @@ int unchanged_file(char *fn, struct file_struct *file, STRUCT_STAT *st, int slot
+@@ -723,7 +724,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)
        if (always_checksum > 0 && S_ISREG(st->st_mode)) {
                char sum[MAX_DIGEST_LEN];
                if (checksum_files && slot >= 0)
@@ -463,7 +463,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;
                else
                        file_checksum(fn, st->st_size, sum);
                return memcmp(sum, F_SUM(file), checksum_len) == 0;
-@@ -1350,7 +1351,8 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1366,7 +1367,8 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                                fuzzy_dirlist = get_dirlist(fnamecmpbuf, -1, 1);
                        }
                        if (checksum_files) {
                                fuzzy_dirlist = get_dirlist(fnamecmpbuf, -1, 1);
                        }
                        if (checksum_files) {
@@ -473,23 +473,15 @@ diff --git a/generator.c b/generator.c
                        }
                        need_new_dirscan = 0;
                }
                        }
                        need_new_dirscan = 0;
                }
-@@ -1488,9 +1490,12 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
-                               DEV_MINOR(devp) = minor(real_sx.st.st_dev);
-                       }
+@@ -1516,6 +1518,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+                       else
+                               change_local_filter_dir(fname, strlen(fname), F_DEPTH(file));
                }
                }
--              else if (delete_during && f_out != -1 && !phase
--                  && BITS_SETnUNSET(file->flags, FLAG_CONTENT_DIR, FLAG_MISSING_DIR))
--                      delete_in_dir(fname, file, &real_sx.st.st_dev);
-+              else if (file->flags & FLAG_CONTENT_DIR && f_out != -1) {
-+                      if (delete_during && !phase && !(file->flags & FLAG_MISSING_DIR))
-+                              delete_in_dir(fname, file, &real_sx.st.st_dev);
-+                      upcoming_whole_dir = 1;
-+              } else
-+                      upcoming_whole_dir = 0;
++              upcoming_whole_dir = file->flags & FLAG_CONTENT_DIR && f_out != -1 ? 1 : 0;
                goto cleanup;
        }
  
                goto cleanup;
        }
  
-@@ -1783,6 +1788,8 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1808,6 +1811,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);
                        handle_partial_dir(partialptr, PDIR_DELETE);
                }
                set_file_attrs(fname, file, &sx, NULL, maybe_ATTRS_REPORT);
@@ -498,15 +490,15 @@ diff --git a/generator.c b/generator.c
                if (itemizing)
                        itemize(fnamecmp, file, ndx, statret, &sx, 0, 0, NULL);
  #ifdef SUPPORT_HARD_LINKS
                if (itemizing)
                        itemize(fnamecmp, file, ndx, statret, &sx, 0, 0, NULL);
  #ifdef SUPPORT_HARD_LINKS
-@@ -2195,6 +2202,7 @@ void generate_files(int f_out, const char *local_name)
-                                       delete_in_dir(f_name(fp, fbuf), fp, &dirdev);
-                               }
+@@ -2250,6 +2255,7 @@ void generate_files(int f_out, const char *local_name)
+                               } else
+                                       change_local_filter_dir(fbuf, strlen(fbuf), F_DEPTH(fp));
                        }
 +                      upcoming_whole_dir = fp->flags & FLAG_CONTENT_DIR ? 1 : 0;
                }
                for (i = cur_flist->low; i <= cur_flist->high; i++) {
                        struct file_struct *file = cur_flist->sorted[i];
                        }
 +                      upcoming_whole_dir = fp->flags & FLAG_CONTENT_DIR ? 1 : 0;
                }
                for (i = cur_flist->low; i <= cur_flist->high; i++) {
                        struct file_struct *file = cur_flist->sorted[i];
-@@ -2275,6 +2283,9 @@ void generate_files(int f_out, const char *local_name)
+@@ -2333,6 +2339,9 @@ void generate_files(int f_out, const char *local_name)
                        wait_for_receiver();
        }
  
                        wait_for_receiver();
        }
  
@@ -603,7 +595,7 @@ diff --git a/receiver.c b/receiver.c
 diff --git a/rsync.h b/rsync.h
 --- a/rsync.h
 +++ b/rsync.h
 diff --git a/rsync.h b/rsync.h
 --- a/rsync.h
 +++ b/rsync.h
-@@ -866,6 +866,8 @@ typedef struct {
+@@ -874,6 +874,8 @@ typedef struct {
  
  #define CSF_ENABLE (1<<1)
  #define CSF_LAX (1<<2)
  
  #define CSF_ENABLE (1<<1)
  #define CSF_LAX (1<<2)
@@ -636,7 +628,7 @@ diff --git a/rsyncd.conf.yo b/rsyncd.conf.yo
 --- a/rsyncd.conf.yo
 +++ b/rsyncd.conf.yo
 @@ -284,13 +284,15 @@ The default is tt(/var/run/rsyncd.lock).
 --- a/rsyncd.conf.yo
 +++ b/rsyncd.conf.yo
 @@ -284,13 +284,15 @@ The default is tt(/var/run/rsyncd.lock).
- dit(bf(checksum files)) This option tells rsync to make use of any cached
+ 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
 -to either "lax", "strict", or "none" -- see the client's bf(--sumfiles)
  checksum information it finds in per-directory .rsyncsums files when the
  current transfer is using the bf(--checksum) option.  The value can be set
 -to either "lax", "strict", or "none" -- see the client's bf(--sumfiles)
@@ -653,5 +645,5 @@ diff --git a/rsyncd.conf.yo b/rsyncd.conf.yo
 +the bf(exclude) directive for a way to hide the .rsyncsums files from the
 +user.
  
 +the bf(exclude) directive for a way to hide the .rsyncsums files from the
 +user.
  
- dit(bf(read only)) The "read only" option determines whether clients
+ dit(bf(read only)) This parameter determines whether clients
  will be able to upload files or not. If "read only" is true then any
  will be able to upload files or not. If "read only" is true then any