The latest patches.
[rsync.git/patches.git] / checksum-updating.diff
index 71c7c45d84843270a0d413798f5eaf8434d8818f..2b85f4e10218aa60a544a2245831c1bf08a4a236 100644 (file)
@@ -29,7 +29,7 @@ diff --git a/flist.c b/flist.c
  extern int am_root;
  extern int am_server;
  extern int am_daemon;
-@@ -109,6 +110,9 @@ extern iconv_t ic_send, ic_recv;
+@@ -112,6 +113,9 @@ extern iconv_t ic_send, ic_recv;
  
  #define PTR_SIZE (sizeof (struct file_struct *))
  
@@ -39,7 +39,7 @@ diff --git a/flist.c b/flist.c
  int io_error;
  int flist_csum_len;
  dev_t filesystem_dev; /* used to implement -x */
-@@ -151,8 +155,13 @@ static char empty_sum[MAX_DIGEST_LEN];
+@@ -154,8 +158,13 @@ static char empty_sum[MAX_DIGEST_LEN];
  static int flist_count_offset; /* for --delete --progress */
  static int show_filelist_progress;
  
@@ -52,8 +52,8 @@ diff --git a/flist.c b/flist.c
 +      int checksum_updates;
  } *csum_cache = NULL;
  
- static void flist_sort_and_clean(struct file_list *flist, int flags);
-@@ -348,7 +357,79 @@ static void flist_done_allocating(struct file_list *flist)
+ static struct file_list *flist_new(int flags, const char *msg);
+@@ -351,7 +360,79 @@ static void flist_done_allocating(struct file_list *flist)
                flist->pool_boundary = ptr;
  }
  
@@ -109,7 +109,7 @@ diff --git a/flist.c b/flist.c
 +              const char *alt_sum = file->basename + strlen(file->basename) + 1;
 +              if (whole_dir && !(file->flags & FLAG_SUM_KEEP))
 +                      continue;
-+              if (checksum_type == 5)
++              if (file_sum_nni->num == CSUM_MD5)
 +                      fprintf(out_fp, "%s ", alt_sum);
 +              if (file->flags & FLAG_SUM_MISSING) {
 +                      do {
@@ -120,7 +120,7 @@ diff --git a/flist.c b/flist.c
 +                              fprintf(out_fp, "%02x", (int)CVAL(cp, 0));
 +                      } while (++cp != end);
 +              }
-+              if (checksum_type != 5)
++              if (file_sum_nni->num < CSUM_MD5)
 +                      fprintf(out_fp, " %s", alt_sum);
 +              fprintf(out_fp, " %10.0f %10.0f %10lu %10lu %s\n",
 +                      (double)F_LENGTH(file), (double)file->modtime,
@@ -204,7 +204,7 @@ diff --git a/flist.c b/flist.c
 @@ -458,7 +554,7 @@ static void read_checksums(int slot, struct file_list *flist, const char *dirnam
        while (fgets(line, sizeof line, fp)) {
                cp = line;
-               if (checksum_type == 5) {
+               if (file_sum_nni->num == CSUM_MD5) {
 -                      char *alt_sum = cp;
 +                      alt_sum = cp;
                        if (*cp == '=')
@@ -236,7 +236,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;
 +                      alt_sum = cp;
                        if (*cp == '=')
@@ -285,7 +285,7 @@ diff --git a/flist.c b/flist.c
 +              if (!(out_fp = fopen(fbuf, "a")))
 +                      return;
 +
-+              if (checksum_type == 5) {
++              if (file_sum_nni->num == CSUM_MD5) {
 +                      for (j = 0; j < flist_csum_len; j++)
 +                              fputs("==", out_fp);
 +                      fputc(' ', out_fp);
@@ -293,7 +293,7 @@ diff --git a/flist.c b/flist.c
 +              do {
 +                      fprintf(out_fp, "%02x", (int)CVAL(cp, 0));
 +              } while (++cp != end);
-+              if (checksum_type != 5) {
++              if (file_sum_nni->num < CSUM_MD5) {
 +                      fputc(' ', out_fp);
 +                      for (j = 0; j < flist_csum_len; j++)
 +                              fputs("==", out_fp);
@@ -390,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
-@@ -1509,6 +1720,8 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1583,6 +1794,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++;
@@ -399,7 +399,7 @@ diff --git a/flist.c b/flist.c
                return NULL;
        }
  
-@@ -1555,13 +1768,13 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1629,13 +1842,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)
@@ -415,7 +415,7 @@ diff --git a/flist.c b/flist.c
                }
        }
        basename_len = strlen(basename) + 1; /* count the '\0' */
-@@ -1671,7 +1884,7 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1759,7 +1972,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)
@@ -424,7 +424,7 @@ diff --git a/flist.c b/flist.c
                else
                        file_checksum(thisname, &st, tmp_sum);
                if (sender_keeps_checksum)
-@@ -2064,6 +2277,9 @@ static void send_directory(int f, struct file_list *flist, char *fbuf, int len,
+@@ -2151,6 +2364,9 @@ static void send_directory(int f, struct file_list *flist, char *fbuf, int len,
  
        closedir(d);
  
@@ -434,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". */
-@@ -2733,6 +2949,9 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
+@@ -2816,6 +3032,9 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
                        rprintf(FINFO, "[%s] flist_eof=1\n", who_am_i());
        }
  
@@ -447,24 +447,24 @@ diff --git a/flist.c b/flist.c
 diff --git a/generator.c b/generator.c
 --- a/generator.c
 +++ b/generator.c
-@@ -111,6 +111,7 @@ static int dir_tweaking;
+@@ -113,6 +113,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;
  
- enum nonregtype {
-@@ -591,7 +592,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)
--                      get_cached_checksum(slot, fn, file, st, sum);
-+                      get_cached_checksum(slot, fn, file, -1, st, sum);
-               else
-                       file_checksum(fn, st, sum);
-               return memcmp(sum, F_SUM(file), flist_csum_len) == 0;
-@@ -1335,7 +1336,8 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+ /* Forward declarations. */
+@@ -627,7 +628,7 @@ int quick_check_ok(enum filetype ftype, const char *fn, struct file_struct *file
+               if (always_checksum > 0) {
+                       char sum[MAX_DIGEST_LEN];
+                       if (checksum_files && slot >= 0)
+-                              get_cached_checksum(slot, fn, file, st, sum);
++                              get_cached_checksum(slot, fn, file, -1, st, sum);
+                       else
+                               file_checksum(fn, st, sum);
+                       return memcmp(sum, F_SUM(file), flist_csum_len) == 0;
+@@ -1359,7 +1360,8 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                                }
                        }
                        if (checksum_files) {
@@ -474,7 +474,7 @@ diff --git a/generator.c b/generator.c
                        }
                        need_new_dirscan = 0;
                }
-@@ -1506,6 +1508,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1547,6 +1549,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                        else
                                change_local_filter_dir(fname, strlen(fname), F_DEPTH(file));
                }
@@ -482,7 +482,7 @@ diff --git a/generator.c b/generator.c
                prior_dir_file = file;
                goto cleanup;
        }
-@@ -1781,6 +1784,8 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1819,6 +1822,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 | maybe_ATTRS_ACCURATE_TIME);
@@ -491,7 +491,7 @@ diff --git a/generator.c b/generator.c
                if (itemizing)
                        itemize(fnamecmp, file, ndx, statret, &sx, 0, 0, NULL);
  #ifdef SUPPORT_HARD_LINKS
-@@ -2279,6 +2284,7 @@ void generate_files(int f_out, const char *local_name)
+@@ -2311,6 +2316,7 @@ void generate_files(int f_out, const char *local_name)
                                } else
                                        change_local_filter_dir(fbuf, strlen(fbuf), F_DEPTH(fp));
                        }
@@ -499,7 +499,7 @@ 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];
-@@ -2373,6 +2379,9 @@ void generate_files(int f_out, const char *local_name)
+@@ -2405,6 +2411,9 @@ void generate_files(int f_out, const char *local_name)
                        wait_for_receiver();
        }
  
@@ -512,15 +512,15 @@ diff --git a/generator.c b/generator.c
 diff --git a/io.c b/io.c
 --- a/io.c
 +++ b/io.c
-@@ -54,6 +54,7 @@ extern int read_batch;
+@@ -55,6 +55,7 @@ extern int read_batch;
  extern int compat_flags;
  extern int protect_args;
  extern int checksum_seed;
 +extern int checksum_files;
+ extern int daemon_connection;
  extern int protocol_version;
  extern int remove_source_files;
- extern int preserve_hard_links;
-@@ -1056,6 +1057,9 @@ static void got_flist_entry_status(enum festatus status, int ndx)
+@@ -1117,6 +1118,9 @@ static void got_flist_entry_status(enum festatus status, int ndx)
                                if (inc_recurse)
                                        flist->in_progress++;
                        }
@@ -533,7 +533,7 @@ diff --git a/io.c b/io.c
 diff --git a/loadparm.c b/loadparm.c
 --- a/loadparm.c
 +++ b/loadparm.c
-@@ -402,6 +402,10 @@ static struct enum_list enum_csum_modes[] = {
+@@ -166,6 +166,10 @@ static struct enum_list enum_checksum_files[] = {
        { CSF_IGNORE_FILES, "none" },
        { CSF_LAX_MODE, "lax" },
        { CSF_STRICT_MODE, "strict" },
@@ -547,7 +547,7 @@ diff --git a/loadparm.c b/loadparm.c
 diff --git a/options.c b/options.c
 --- a/options.c
 +++ b/options.c
-@@ -1725,7 +1725,15 @@ int parse_arguments(int *argc_p, const char ***argv_p)
+@@ -1750,7 +1750,15 @@ int parse_arguments(int *argc_p, const char ***argv_p)
  
                case OPT_SUMFILES:
                        arg = poptGetOptArg(pc);
@@ -567,7 +567,7 @@ diff --git a/options.c b/options.c
 diff --git a/receiver.c b/receiver.c
 --- a/receiver.c
 +++ b/receiver.c
-@@ -50,6 +50,7 @@ extern int sparse_files;
+@@ -51,6 +51,7 @@ extern int sparse_files;
  extern int preallocate_files;
  extern int keep_partial;
  extern int checksum_seed;
@@ -575,28 +575,30 @@ diff --git a/receiver.c b/receiver.c
  extern int whole_file;
  extern int inplace;
  extern int inplace_partial;
-@@ -433,7 +434,7 @@ static void handle_delayed_updates(char *local_name)
+@@ -440,7 +441,8 @@ static void handle_delayed_updates(char *local_name)
                                        "rename failed for %s (from %s)",
                                        full_fname(fname), partialptr);
                        } else {
--                              if (remove_source_files
+-                              if (remove_source_files || (preserve_hard_links && F_IS_HLINKED(file)))
 +                              if (remove_source_files || checksum_files & CSF_UPDATE
-                                || (preserve_hard_links && F_IS_HLINKED(file)))
-                                       send_msg_int(MSG_SUCCESS, ndx);
++                               || (preserve_hard_links && F_IS_HLINKED(file)))
+                                       send_msg_success(fname, ndx);
                                handle_partial_dir(partialptr, PDIR_DELETE);
-@@ -906,7 +907,7 @@ int recv_files(int f_in, int f_out, char *local_name)
+                       }
+@@ -926,7 +928,8 @@ int recv_files(int f_in, int f_out, char *local_name)
                case 2:
                        break;
                case 1:
--                      if (remove_source_files || inc_recurse
+-                      if (remove_source_files || inc_recurse || (preserve_hard_links && F_IS_HLINKED(file)))
 +                      if (remove_source_files || inc_recurse || checksum_files & CSF_UPDATE
-                        || (preserve_hard_links && F_IS_HLINKED(file)))
-                               send_msg_int(MSG_SUCCESS, ndx);
++                       || (preserve_hard_links && F_IS_HLINKED(file)))
+                               send_msg_success(fname, ndx);
                        break;
+               case 0: {
 diff --git a/rsync.1.md b/rsync.1.md
 --- a/rsync.1.md
 +++ b/rsync.1.md
-@@ -702,9 +702,13 @@ your home directory (remove the '=' for that).
+@@ -803,9 +803,13 @@ expand it.
  
      The MODE value is either "lax", for relaxed checking (which compares size
      and mtime), "strict" (which also compares ctime and inode), or "none" to
@@ -606,17 +608,17 @@ diff --git a/rsync.1.md b/rsync.1.md
 +    ignore any .rsyncsums files ("none" is the default).
 +    If you want rsync to create and/or update these files, specify a prefixed
 +    plus ("+lax" or "+strict").  Adding a second prefixed '+' causes the
-+    checksum-file updates to happen even when the transfer is in `--dry-run`
++    checksum-file updates to happen even when the transfer is in [`--dry-run`](#opt)
 +    mode ("++lax" or "++strict").  There is also a perl script in the support
 +    directory named "rsyncsums" that can be used to update the .rsyncsums
 +    files.
  
-     This option has no effect unless `--checksum`, `-c` was also specified.  It
-     also only affects the current side of the transfer, so if you want the
+     This option has no effect unless [`--checksum`](#opt) (`-c`) was also
+     specified.  It also only affects the current side of the transfer, so if
 diff --git a/rsync.h b/rsync.h
 --- a/rsync.h
 +++ b/rsync.h
-@@ -1042,6 +1042,8 @@ typedef struct {
+@@ -1123,6 +1123,8 @@ typedef struct {
  
  #define CSF_ENABLE (1<<1)
  #define CSF_LAX (1<<2)
@@ -628,11 +630,11 @@ 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
-@@ -409,13 +409,15 @@ the values of parameters.  See the GLOBAL PARAMETERS section for more details.
+@@ -450,13 +450,15 @@ the values of parameters.  See the GLOBAL PARAMETERS section for more details.
      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 `--checksum` option.  The value can be set to either "lax",
--    "strict", or "none" -- see the client's `--sumfiles` option for what these
+-    "strict", or "none".  See the client's `--sumfiles` option for what these
 -    choices do.
 +    "strict", "+lax", "+strict", "++lax", "++strict", or +"none".  See the
 +    client's `--sumfiles` option for what these choices do.