The patches for 3.3.0.
[rsync-patches.git] / link-by-hash.diff
index 45af67fe5e592455c9dc0dd4fc63e59b2f7d22c3..c3593a98aac18ea0b183627a376e05d137a59312 100644 (file)
@@ -12,7 +12,7 @@ To use this patch, run these commands for a successful build:
     ./configure
     make
 
-based-on: 4c0a4067df2516ce50e12a7d3ae572275fa9fc0b
+based-on: 6c8ca91c731b7bf2b081694bda85b7dadc2b7aff
 diff --git a/Makefile.in b/Makefile.in
 --- a/Makefile.in
 +++ b/Makefile.in
@@ -36,43 +36,43 @@ diff --git a/checksum.c b/checksum.c
 +extern char link_by_hash_extra_sum[MAX_DIGEST_LEN];
  extern const char *checksum_choice;
  
- struct name_num_obj valid_checksums = {
-@@ -444,7 +446,7 @@ static union {
-       MD4_CTX m4;
- #endif
      md5_context m5;
--} ctx;
-+} ctx, ctx2;
+ #define NNI_BUILTIN (1<<0)
+@@ -539,7 +541,7 @@ void file_checksum(const char *fname, const STRUCT_STAT *st_p, char *sum)
+ }
static int32 sumresidue;
+-static md_context ctx_md;
++static md_context ctx_md, ctx2_md;
  #ifdef SUPPORT_XXHASH
  static XXH64_state_t* xxh64_state;
  #endif
-@@ -483,6 +485,8 @@ void sum_init(int csum_type, int seed)
+@@ -597,6 +599,8 @@ int sum_init(struct name_num_item *nni, int seed)
  #endif
          case CSUM_MD5:
-               md5_begin(&ctx.m5);
+               md5_begin(&ctx_md);
 +              if (link_by_hash_dir)
-+                      md5_begin(&ctx2.m5);
++                      md5_begin(&ctx2_md);
                break;
          case CSUM_MD4:
- #ifdef USE_OPENSSL
-@@ -533,6 +537,8 @@ void sum_update(const char *p, int32 len)
+               mdfour_begin(&ctx_md);
+@@ -643,6 +647,8 @@ void sum_update(const char *p, int32 len)
  #endif
          case CSUM_MD5:
-               md5_update(&ctx.m5, (uchar *)p, len);
+               md5_update(&ctx_md, (uchar *)p, len);
 +              if (link_by_hash_dir)
-+                      md5_update(&ctx2.m5, (uchar *)p, len);
++                      md5_update(&ctx2_md, (uchar *)p, len);
                break;
          case CSUM_MD4:
- #ifdef USE_OPENSSL
-@@ -598,6 +604,8 @@ int sum_end(char *sum)
+         case CSUM_MD4_OLD:
+@@ -709,6 +715,8 @@ void sum_end(char *sum)
  #endif
          case CSUM_MD5:
-               md5_result(&ctx.m5, (uchar *)sum);
+               md5_result(&ctx_md, (uchar *)sum);
 +              if (link_by_hash_dir)
-+                      md5_result(&ctx2.m5, (uchar *)link_by_hash_extra_sum);
++                      md5_result(&ctx2_md, (uchar *)link_by_hash_extra_sum);
                break;
          case CSUM_MD4:
- #ifdef USE_OPENSSL
+         case CSUM_MD4_OLD:
 diff --git a/clientserver.c b/clientserver.c
 --- a/clientserver.c
 +++ b/clientserver.c
@@ -84,7 +84,7 @@ diff --git a/clientserver.c b/clientserver.c
  extern char *logfile_format;
  extern char *files_from;
  extern char *tmpdir;
-@@ -725,6 +726,9 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char
+@@ -736,6 +737,9 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char
                return -1;
        }
  
@@ -213,7 +213,7 @@ diff --git a/options.c b/options.c
  char *config_file = NULL;
  char *shell_cmd = NULL;
  char *logfile_name = NULL;
-@@ -230,7 +231,7 @@ static const char *debug_verbosity[] = {
+@@ -231,7 +232,7 @@ static const char *debug_verbosity[] = {
        /*2*/ "BIND,CMD,CONNECT,DEL,DELTASUM,DUP,FILTER,FLIST,ICONV",
        /*3*/ "ACL,BACKUP,CONNECT2,DELTASUM2,DEL2,EXIT,FILTER2,FLIST2,FUZZY,GENR,OWN,RECV,SEND,TIME",
        /*4*/ "CMD2,DELTASUM3,DEL3,EXIT2,FLIST3,ICONV2,OWN2,PROTO,TIME2",
@@ -222,7 +222,7 @@ diff --git a/options.c b/options.c
  };
  
  #define MAX_VERBOSITY ((int)(sizeof debug_verbosity / sizeof debug_verbosity[0]) - 1)
-@@ -301,6 +302,7 @@ static struct output_struct debug_words[COUNT_DEBUG+1] = {
+@@ -302,6 +303,7 @@ static struct output_struct debug_words[COUNT_DEBUG+1] = {
        DEBUG_WORD(FUZZY, W_REC, "Debug fuzzy scoring (levels 1-2)"),
        DEBUG_WORD(GENR, W_REC, "Debug generator functions"),
        DEBUG_WORD(HASH, W_SND|W_REC, "Debug hashtable code"),
@@ -230,7 +230,7 @@ diff --git a/options.c b/options.c
        DEBUG_WORD(HLINK, W_SND|W_REC, "Debug hard-link actions (levels 1-3)"),
        DEBUG_WORD(ICONV, W_CLI|W_SRV, "Debug iconv character conversions (levels 1-2)"),
        DEBUG_WORD(IO, W_CLI|W_SRV, "Debug I/O routines (levels 1-4)"),
-@@ -581,7 +583,7 @@ enum {OPT_SERVER = 1000, OPT_DAEMON, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
+@@ -582,7 +584,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,
@@ -239,7 +239,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};
-@@ -742,6 +744,7 @@ static struct poptOption long_options[] = {
+@@ -743,6 +745,7 @@ static struct poptOption long_options[] = {
    {"compare-dest",     0,  POPT_ARG_STRING, 0, OPT_COMPARE_DEST, 0, 0 },
    {"copy-dest",        0,  POPT_ARG_STRING, 0, OPT_COPY_DEST, 0, 0 },
    {"link-dest",        0,  POPT_ARG_STRING, 0, OPT_LINK_DEST, 0, 0 },
@@ -247,7 +247,7 @@ diff --git a/options.c b/options.c
    {"fuzzy",           'y', POPT_ARG_NONE,   0, 'y', 0, 0 },
    {"no-fuzzy",         0,  POPT_ARG_VAL,    &fuzzy_basis, 0, 0, 0 },
    {"no-y",             0,  POPT_ARG_VAL,    &fuzzy_basis, 0, 0, 0 },
-@@ -987,6 +990,9 @@ static void set_refuse_options(void)
+@@ -990,6 +993,9 @@ static void set_refuse_options(void)
                ref = cp + 1;
        }
  
@@ -257,8 +257,8 @@ diff --git a/options.c b/options.c
        if (am_daemon) {
  #ifdef ICONV_OPTION
                if (!*lp_charset(module_id))
-@@ -1860,6 +1866,20 @@ int parse_arguments(int *argc_p, const char ***argv_p)
-                       return 0;
+@@ -1867,6 +1873,20 @@ int parse_arguments(int *argc_p, const char ***argv_p)
+                       goto cleanup;
  #endif
  
 +                case OPT_LINK_BY_HASH:
@@ -278,7 +278,7 @@ diff --git a/options.c b/options.c
                case OPT_STOP_AFTER: {
                        long val;
                        arg = poptGetOptArg(pc);
-@@ -2231,6 +2251,8 @@ int parse_arguments(int *argc_p, const char ***argv_p)
+@@ -2252,6 +2272,8 @@ int parse_arguments(int *argc_p, const char ***argv_p)
                        tmpdir = sanitize_path(NULL, tmpdir, NULL, 0, SP_DEFAULT);
                if (backup_dir)
                        backup_dir = sanitize_path(NULL, backup_dir, NULL, 0, SP_DEFAULT);
@@ -287,7 +287,7 @@ diff --git a/options.c b/options.c
        }
        if (daemon_filter_list.head && !am_sender) {
                filter_rule_list *elp = &daemon_filter_list;
-@@ -2915,6 +2937,12 @@ void server_options(char **args, int *argc_p)
+@@ -2941,6 +2963,12 @@ void server_options(char **args, int *argc_p)
                        args[ac++] = "--no-W";
        }
  
@@ -303,7 +303,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
-@@ -449,6 +449,7 @@ has its own detailed description later in this manpage.
+@@ -510,6 +510,7 @@ has its own detailed description later in this manpage.
  --compare-dest=DIR       also compare destination files relative to DIR
  --copy-dest=DIR          ... and include copies of unchanged files
  --link-dest=DIR          hardlink to files in DIR when unchanged
@@ -311,7 +311,7 @@ diff --git a/rsync.1.md b/rsync.1.md
  --compress, -z           compress file data during the transfer
  --compress-choice=STR    choose the compression algorithm (aka --zc)
  --compress-level=NUM     explicitly set compression level (aka --zl)
-@@ -2619,6 +2620,50 @@ expand it.
+@@ -2720,6 +2721,50 @@ expand it.
      this bug by avoiding the `-o` option (or using `--no-o`) when sending to an
      old rsync.
  
@@ -387,7 +387,7 @@ diff --git a/rsync.c b/rsync.c
 diff --git a/rsync.h b/rsync.h
 --- a/rsync.h
 +++ b/rsync.h
-@@ -1450,7 +1450,8 @@ extern short info_levels[], debug_levels[];
+@@ -1446,7 +1446,8 @@ extern short info_levels[], debug_levels[];
  #define DEBUG_FUZZY (DEBUG_FLIST+1)
  #define DEBUG_GENR (DEBUG_FUZZY+1)
  #define DEBUG_HASH (DEBUG_GENR+1)
@@ -400,7 +400,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
-@@ -356,6 +356,23 @@ the values of parameters.  See the GLOBAL PARAMETERS section for more details.
+@@ -388,6 +388,23 @@ in the values of parameters.  See that section for details.
      is 0, which means no limit.  A negative value disables the module.  See
      also the "[lock file](#)" parameter.