Fix alignment issue on 64-bit. Solution from Steve Ortiz.
[rsync/rsync-patches.git] / link-by-hash.diff
index 32d0521..53fff8f 100644 (file)
@@ -12,8 +12,8 @@ To use this patch, run these commands for a successful build:
     ./configure
     make
 
+based-on: a01e3b490eb36ccf9e704840e1b6683dab867550
 diff --git a/Makefile.in b/Makefile.in
-index feacb90..b27b1e7 100644
 --- a/Makefile.in
 +++ b/Makefile.in
 @@ -37,7 +37,7 @@ OBJS1=flist.o rsync.o generator.o receiver.o cleanup.o sender.o exclude.o \
@@ -26,10 +26,9 @@ index feacb90..b27b1e7 100644
  popt_OBJS=popt/findme.o  popt/popt.o  popt/poptconfig.o \
        popt/popthelp.o popt/poptparse.o
 diff --git a/flist.c b/flist.c
-index 09b4fc5..570bcee 100644
 --- a/flist.c
 +++ b/flist.c
-@@ -73,6 +73,7 @@ extern int sender_keeps_checksum;
+@@ -74,6 +74,7 @@ extern int sender_keeps_checksum;
  extern int unsort_ndx;
  extern struct stats stats;
  extern char *filesfrom_host;
@@ -37,7 +36,7 @@ index 09b4fc5..570bcee 100644
  extern char *usermap, *groupmap;
  
  extern char curr_dir[MAXPATHLEN];
-@@ -881,7 +882,7 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
+@@ -910,7 +911,7 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
                extra_len += EXTRA_LEN;
  #endif
  
@@ -48,7 +47,6 @@ index 09b4fc5..570bcee 100644
  #if SIZEOF_INT64 >= 8
 diff --git a/hashlink.c b/hashlink.c
 new file mode 100644
-index 0000000..15e2a73
 --- /dev/null
 +++ b/hashlink.c
 @@ -0,0 +1,339 @@
@@ -392,7 +390,6 @@ index 0000000..15e2a73
 +}
 +#endif
 diff --git a/options.c b/options.c
-index e7c6c61..73b1aa4 100644
 --- a/options.c
 +++ b/options.c
 @@ -158,6 +158,7 @@ char *backup_suffix = NULL;
@@ -403,7 +400,7 @@ index e7c6c61..73b1aa4 100644
  char *config_file = NULL;
  char *shell_cmd = NULL;
  char *logfile_name = NULL;
-@@ -745,6 +746,7 @@ void usage(enum logcode F)
+@@ -746,6 +747,7 @@ void usage(enum logcode F)
    rprintf(F,"     --compare-dest=DIR      also compare destination files relative to DIR\n");
    rprintf(F,"     --copy-dest=DIR         ... and include copies of unchanged files\n");
    rprintf(F,"     --link-dest=DIR         hardlink to files in DIR when unchanged\n");
@@ -412,15 +409,15 @@ index e7c6c61..73b1aa4 100644
    rprintf(F,"     --compress-level=NUM    explicitly set compression level\n");
    rprintf(F,"     --skip-compress=LIST    skip compressing files with a suffix in LIST\n");
 @@ -798,7 +800,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,
-       OPT_NO_D, OPT_APPEND, OPT_NO_ICONV, OPT_INFO, OPT_DEBUG,
--      OPT_USERMAP, OPT_GROUPMAP, OPT_CHOWN,
-+      OPT_USERMAP, OPT_GROUPMAP, OPT_CHOWN, OPT_LINK_BY_HASH,
+-      OPT_NO_D, OPT_APPEND, OPT_NO_ICONV, OPT_INFO, OPT_DEBUG,
++      OPT_NO_D, OPT_APPEND, OPT_NO_ICONV, OPT_INFO, OPT_DEBUG, OPT_LINK_BY_HASH,
+       OPT_USERMAP, OPT_GROUPMAP, OPT_CHOWN, OPT_BWLIMIT,
        OPT_SERVER, OPT_REFUSED_BASE = 9000};
  
- static struct poptOption long_options[] = {
-@@ -937,6 +939,7 @@ static struct poptOption long_options[] = {
+@@ -938,6 +940,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 },
@@ -428,7 +425,7 @@ index e7c6c61..73b1aa4 100644
    {"fuzzy",           'y', POPT_ARG_VAL,    &fuzzy_basis, 1, 0, 0 },
    {"no-fuzzy",         0,  POPT_ARG_VAL,    &fuzzy_basis, 0, 0, 0 },
    {"no-y",             0,  POPT_ARG_VAL,    &fuzzy_basis, 0, 0, 0 },
-@@ -1742,6 +1745,21 @@ int parse_arguments(int *argc_p, const char ***argv_p)
+@@ -1764,6 +1767,21 @@ int parse_arguments(int *argc_p, const char ***argv_p)
                        return 0;
  #endif
  
@@ -450,7 +447,7 @@ index e7c6c61..73b1aa4 100644
                default:
                        /* A large opt value means that set_refuse_options()
                         * turned this option off. */
-@@ -2584,6 +2602,11 @@ void server_options(char **args, int *argc_p)
+@@ -2636,6 +2654,11 @@ void server_options(char **args, int *argc_p)
        } else if (inplace)
                args[ac++] = "--inplace";
  
@@ -463,10 +460,9 @@ index e7c6c61..73b1aa4 100644
                if (filesfrom_host) {
                        args[ac++] = "--files-from";
 diff --git a/receiver.c b/receiver.c
-index 4325e30..2709d5e 100644
 --- a/receiver.c
 +++ b/receiver.c
-@@ -164,11 +164,13 @@ int open_tmpfile(char *fnametmp, const char *fname, struct file_struct *file)
+@@ -196,11 +196,13 @@ int open_tmpfile(char *fnametmp, const char *fname, struct file_struct *file)
  }
  
  static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
@@ -481,7 +477,7 @@ index 4325e30..2709d5e 100644
        int32 len;
        OFF_T offset = 0;
        OFF_T offset2;
-@@ -188,6 +190,9 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
+@@ -220,6 +222,9 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
        } else
                mapbuf = NULL;
  
@@ -491,7 +487,7 @@ index 4325e30..2709d5e 100644
        sum_init(checksum_seed);
  
        if (append_mode > 0) {
-@@ -232,6 +237,8 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
+@@ -264,6 +269,8 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
                        cleanup_got_literal = 1;
  
                        sum_update(data, i);
@@ -500,7 +496,7 @@ index 4325e30..2709d5e 100644
  
                        if (fd != -1 && write_file(fd,data,i) != i)
                                goto report_write_error;
-@@ -258,6 +265,8 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
+@@ -290,6 +297,8 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
  
                        see_token(map, len);
                        sum_update(map, len);
@@ -509,7 +505,7 @@ index 4325e30..2709d5e 100644
                }
  
                if (updating_basis_or_equiv) {
-@@ -305,6 +314,9 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
+@@ -337,6 +346,9 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
        if (sum_end(file_sum1) != checksum_len)
                overflow_exit("checksum_len"); /* Impossible... */
  
@@ -519,7 +515,7 @@ index 4325e30..2709d5e 100644
        if (mapbuf)
                unmap_file(mapbuf);
  
-@@ -319,7 +331,7 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
+@@ -351,7 +363,7 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
  
  static void discard_receive_data(int f_in, OFF_T length)
  {
@@ -528,28 +524,27 @@ index 4325e30..2709d5e 100644
  }
  
  static void handle_delayed_updates(char *local_name)
-@@ -744,7 +756,7 @@ int recv_files(int f_in, char *local_name)
+@@ -779,7 +791,7 @@ int recv_files(int f_in, int f_out, char *local_name)
  
                /* recv file data */
                recv_ok = receive_data(f_in, fnamecmp, fd1, st.st_size,
 -                                     fname, fd2, F_LENGTH(file));
 +                                     fname, fd2, F_LENGTH(file), F_SUM(file));
  
-               log_item(log_code, file, &initial_stats, iflags, NULL);
+               log_item(log_code, file, iflags, NULL);
  
 diff --git a/rsync.c b/rsync.c
-index 2c026a2..87f6d54 100644
 --- a/rsync.c
 +++ b/rsync.c
-@@ -48,6 +48,7 @@ extern int flist_eof;
- extern int msgs2stderr;
+@@ -49,6 +49,7 @@ extern int flist_eof;
+ extern int file_old_total;
  extern int keep_dirlinks;
  extern int make_backups;
 +extern char *link_by_hash_dir;
  extern struct file_list *cur_flist, *first_flist, *dir_flist;
  extern struct chmod_mode_struct *daemon_chmod_modes;
  #ifdef ICONV_OPTION
-@@ -575,8 +576,15 @@ int finish_transfer(const char *fname, const char *fnametmp,
+@@ -644,8 +645,15 @@ int finish_transfer(const char *fname, const char *fnametmp,
        /* move tmp file over real file */
        if (DEBUG_GTE(RECV, 1))
                rprintf(FINFO, "renaming %s to %s\n", fnametmp, fname);
@@ -568,10 +563,9 @@ index 2c026a2..87f6d54 100644
                rsyserr(FERROR_XFER, errno, "%s %s -> \"%s\"",
                        ret == -2 ? "copy" : "rename",
 diff --git a/rsync.h b/rsync.h
-index be7cf8a..d4e2aca 100644
 --- a/rsync.h
 +++ b/rsync.h
-@@ -853,6 +853,14 @@ struct stats {
+@@ -865,6 +865,14 @@ struct stats {
        int xferred_files;
  };
  
@@ -587,7 +581,6 @@ index be7cf8a..d4e2aca 100644
  
  struct flist_ndx_item {
 diff --git a/rsync.yo b/rsync.yo
-index 941f7a5..568b481 100644
 --- a/rsync.yo
 +++ b/rsync.yo
 @@ -400,6 +400,7 @@ to the detailed description below for a complete description.  verb(