Fix hfs_receiver_check() on a relative path.
[rsync-patches.git] / crtimes.diff
index cb789a54af3aa3fdad65f14f4613ae0f0357572b..7fa197165c6fc233986aefe192b9f474599fafe8 100644 (file)
@@ -5,14 +5,15 @@ To use this patch, run these commands for a successful build:
 
     patch -p1 <patches/fileflags.diff
     patch -p1 <patches/crtimes.diff
-    ./configure                      (optional if already run)
+    ./prepare-source
+    ./configure
     make
 
 based-on: patch/master/fileflags
 diff --git a/compat.c b/compat.c
 --- a/compat.c
 +++ b/compat.c
-@@ -46,6 +46,7 @@ extern int force_change;
+@@ -47,6 +47,7 @@ extern int force_change;
  extern int protect_args;
  extern int preserve_uid;
  extern int preserve_gid;
@@ -20,7 +21,7 @@ diff --git a/compat.c b/compat.c
  extern int preserve_fileflags;
  extern int preserve_acls;
  extern int preserve_xattrs;
-@@ -64,7 +65,7 @@ extern char *iconv_opt;
+@@ -65,7 +66,7 @@ extern char *iconv_opt;
  #endif
  
  /* These index values are for the file-list's extra-attribute array. */
@@ -29,7 +30,7 @@ diff --git a/compat.c b/compat.c
  
  int receiver_symlink_times = 0; /* receiver can set the time on a symlink */
  int sender_symlink_iconv = 0; /* sender should convert symlink content */
-@@ -141,6 +142,8 @@ void setup_protocol(int f_out,int f_in)
+@@ -142,6 +143,8 @@ void setup_protocol(int f_out,int f_in)
                uid_ndx = ++file_extra_cnt;
        if (preserve_gid)
                gid_ndx = ++file_extra_cnt;
@@ -49,7 +50,7 @@ diff --git a/flist.c b/flist.c
  extern int relative_paths;
  extern int implied_dirs;
  extern int ignore_perishable;
-@@ -405,7 +406,7 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
+@@ -397,7 +398,7 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
  #endif
                            int ndx, int first_ndx)
  {
@@ -58,7 +59,7 @@ diff --git a/flist.c b/flist.c
        static mode_t mode;
  #ifdef SUPPORT_FILEFLAGS
        static uint32 fileflags;
-@@ -516,6 +517,13 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
+@@ -508,6 +509,13 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
                modtime = file->modtime;
        if (NSEC_BUMP(file) && protocol_version >= 31)
                xflags |= XMIT_MOD_NSEC;
@@ -72,7 +73,7 @@ diff --git a/flist.c b/flist.c
  
  #ifdef SUPPORT_HARD_LINKS
        if (tmp_dev != -1) {
-@@ -600,6 +608,8 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
+@@ -592,6 +600,8 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
        }
        if (xflags & XMIT_MOD_NSEC)
                write_varint(f, F_MOD_NSEC(file));
@@ -81,7 +82,7 @@ diff --git a/flist.c b/flist.c
        if (!(xflags & XMIT_SAME_MODE))
                write_int(f, to_wire_mode(mode));
  #ifdef SUPPORT_FILEFLAGS
-@@ -693,7 +703,7 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
+@@ -685,7 +695,7 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
  
  static struct file_struct *recv_file_entry(int f, struct file_list *flist, int xflags)
  {
@@ -90,7 +91,7 @@ diff --git a/flist.c b/flist.c
        static mode_t mode;
  #ifdef SUPPORT_FILEFLAGS
        static uint32 fileflags;
-@@ -838,6 +848,19 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
+@@ -834,6 +844,19 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
                modtime_nsec = read_varint(f);
        else
                modtime_nsec = 0;
@@ -110,7 +111,7 @@ diff --git a/flist.c b/flist.c
        if (!(xflags & XMIT_SAME_MODE))
                mode = from_wire_mode(read_int(f));
  
-@@ -1008,6 +1031,8 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
+@@ -1004,6 +1027,8 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
                F_GROUP(file) = gid;
                file->flags |= gid_flags;
        }
@@ -119,7 +120,7 @@ diff --git a/flist.c b/flist.c
        if (unsort_ndx)
                F_NDX(file) = flist->used + flist->ndx_start;
  
-@@ -1409,6 +1434,8 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1405,6 +1430,8 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
                F_GROUP(file) = st.st_gid;
        if (am_generator && st.st_uid == our_uid)
                file->flags |= FLAG_OWNED_BY_US;
@@ -139,20 +140,41 @@ diff --git a/generator.c b/generator.c
  extern int preserve_hard_links;
  extern int preserve_executability;
  extern int preserve_fileflags;
-@@ -406,6 +407,13 @@ static inline int ownership_differs(struct file_struct *file, stat_x *sxp)
-       return 0;
+@@ -379,8 +380,15 @@ static void do_delete_pass(void)
+               rprintf(FINFO, "                    \r");
  }
  
+-static inline int time_differs(struct file_struct *file, stat_x *sxp)
++static inline int time_differs(struct file_struct *file, stat_x *sxp, const char *fname)
+ {
 +      if (crtimes_ndx) {
 +              if (sxp->crtime == 0)
 +                      sxp->crtime = get_create_time(fname);
 +              if (cmp_time(sxp->crtime, f_crtime(file)) != 0)
-+                      return 0;
++                      return 1;
 +      }
 +
- #ifdef SUPPORT_ACLS
- static inline int acls_differ(const char *fname, struct file_struct *file, stat_x *sxp)
+       return cmp_time(sxp->st.st_mtime, file->modtime);
+ }
+@@ -438,7 +446,7 @@ int unchanged_attrs(const char *fname, struct file_struct *file, stat_x *sxp)
  {
+       if (S_ISLNK(file->mode)) {
+ #ifdef CAN_SET_SYMLINK_TIMES
+-              if (preserve_times & PRESERVE_LINK_TIMES && time_differs(file, sxp))
++              if (preserve_times & PRESERVE_LINK_TIMES && time_differs(file, sxp, fname))
+                       return 0;
+ #endif
+ #ifdef CAN_CHMOD_SYMLINK
+@@ -458,7 +466,7 @@ int unchanged_attrs(const char *fname, struct file_struct *file, stat_x *sxp)
+                       return 0;
+ #endif
+       } else {
+-              if (preserve_times && time_differs(file, sxp))
++              if (preserve_times && time_differs(file, sxp, fname))
+                       return 0;
+               if (perms_differ(file, sxp))
+                       return 0;
 @@ -501,6 +509,12 @@ void itemize(const char *fnamecmp, struct file_struct *file, int ndx, int statre
                 : iflags & (ITEM_TRANSFER|ITEM_LOCAL_CHANGE) && !(iflags & ITEM_MATCHED)
                  && (!(iflags & ITEM_XNAME_FOLLOWS) || *xname))
@@ -166,7 +188,7 @@ diff --git a/generator.c b/generator.c
  #if !defined HAVE_LCHMOD && !defined HAVE_SETATTRLIST
                if (S_ISLNK(file->mode)) {
                        ;
-@@ -1074,6 +1088,7 @@ static int try_dests_non(struct file_struct *file, char *fname, int ndx,
+@@ -1076,6 +1090,7 @@ static int try_dests_non(struct file_struct *file, char *fname, int ndx,
  static void list_file_entry(struct file_struct *f)
  {
        char permbuf[PERMSTRING_SIZE];
@@ -174,7 +196,7 @@ diff --git a/generator.c b/generator.c
        int64 len;
        int colwidth = human_readable ? 14 : 11;
  
-@@ -1089,10 +1104,11 @@ static void list_file_entry(struct file_struct *f)
+@@ -1091,10 +1106,11 @@ static void list_file_entry(struct file_struct *f)
  
  #ifdef SUPPORT_LINKS
        if (preserve_links && S_ISLNK(f->mode)) {
@@ -189,7 +211,7 @@ diff --git a/generator.c b/generator.c
        } else
  #endif
        if (missing_args == 2 && f->mode == 0) {
-@@ -1100,9 +1116,11 @@ static void list_file_entry(struct file_struct *f)
+@@ -1102,9 +1118,11 @@ static void list_file_entry(struct file_struct *f)
                        colwidth + 31, "*missing",
                        f_name(f, NULL));
        } else {
@@ -203,7 +225,7 @@ diff --git a/generator.c b/generator.c
        }
  }
  
-@@ -1194,6 +1212,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1196,6 +1214,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                        return;
                }
        }
@@ -267,7 +289,7 @@ diff --git a/options.c b/options.c
  int update_only = 0;
  int cvs_exclude = 0;
  int dry_run = 0;
-@@ -708,6 +709,7 @@ void usage(enum logcode F)
+@@ -713,6 +714,7 @@ void usage(enum logcode F)
    rprintf(F,"     --specials              preserve special files\n");
    rprintf(F," -D                          same as --devices --specials\n");
    rprintf(F," -t, --times                 preserve modification times\n");
@@ -275,7 +297,7 @@ diff --git a/options.c b/options.c
    rprintf(F," -O, --omit-dir-times        omit directories from --times\n");
    rprintf(F," -J, --omit-link-times       omit symlinks from --times\n");
    rprintf(F,"     --super                 receiver attempts super-user activities\n");
-@@ -866,6 +868,9 @@ static struct poptOption long_options[] = {
+@@ -876,6 +878,9 @@ static struct poptOption long_options[] = {
    {"times",           't', POPT_ARG_VAL,    &preserve_times, 1, 0, 0 },
    {"no-times",         0,  POPT_ARG_VAL,    &preserve_times, 0, 0, 0 },
    {"no-t",             0,  POPT_ARG_VAL,    &preserve_times, 0, 0, 0 },
@@ -285,7 +307,7 @@ diff --git a/options.c b/options.c
    {"omit-dir-times",  'O', POPT_ARG_VAL,    &omit_dir_times, 1, 0, 0 },
    {"no-omit-dir-times",0,  POPT_ARG_VAL,    &omit_dir_times, 0, 0, 0 },
    {"no-O",             0,  POPT_ARG_VAL,    &omit_dir_times, 0, 0, 0 },
-@@ -2382,6 +2387,8 @@ void server_options(char **args, int *argc_p)
+@@ -2393,6 +2398,8 @@ void server_options(char **args, int *argc_p)
                argstr[x++] = 'D';
        if (preserve_times)
                argstr[x++] = 't';
@@ -322,7 +344,7 @@ diff --git a/rsync.c b/rsync.c
  
        change_uid = am_root && uid_ndx && sxp->st.st_uid != (uid_t)F_OWNER(file);
        change_gid = gid_ndx && !(file->flags & FLAG_SKIP_GROUP)
-@@ -688,7 +699,7 @@ int finish_transfer(const char *fname, const char *fnametmp,
+@@ -691,7 +702,7 @@ int finish_transfer(const char *fname, const char *fnametmp,
        /* Change permissions before putting the file into place. */
        set_file_attrs(fnametmp, file, NULL, fnamecmp,
                       ATTRS_DELAY_IMMUTABLE
@@ -331,7 +353,7 @@ diff --git a/rsync.c b/rsync.c
  
        /* move tmp file over real file */
        if (DEBUG_GTE(RECV, 1))
-@@ -717,7 +728,7 @@ int finish_transfer(const char *fname, const char *fnametmp,
+@@ -720,7 +731,7 @@ int finish_transfer(const char *fname, const char *fnametmp,
  
    do_set_file_attrs:
        set_file_attrs(fnametmp, file, NULL, fnamecmp,
@@ -370,7 +392,7 @@ diff --git a/rsync.h b/rsync.h
  #define ITEM_REPORT_CHANGE (1<<1)
  #define ITEM_REPORT_SIZE (1<<2)     /* regular files only */
  #define ITEM_REPORT_TIMEFAIL (1<<2) /* symlinks only */
-@@ -708,6 +710,7 @@ extern int file_extra_cnt;
+@@ -733,6 +735,7 @@ extern int file_extra_cnt;
  extern int inc_recurse;
  extern int uid_ndx;
  extern int gid_ndx;
@@ -378,7 +400,7 @@ diff --git a/rsync.h b/rsync.h
  extern int fileflags_ndx;
  extern int acls_ndx;
  extern int xattrs_ndx;
-@@ -715,6 +718,7 @@ extern int xattrs_ndx;
+@@ -740,6 +743,7 @@ extern int xattrs_ndx;
  #define FILE_STRUCT_LEN (offsetof(struct file_struct, basename))
  #define EXTRA_LEN (sizeof (union file_extras))
  #define PTR_EXTRA_CNT ((sizeof (char *) + EXTRA_LEN - 1) / EXTRA_LEN)
@@ -386,7 +408,7 @@ diff --git a/rsync.h b/rsync.h
  #define DEV_EXTRA_CNT 2
  #define DIRNODE_EXTRA_CNT 3
  #define SUM_EXTRA_CNT ((MAX_DIGEST_LEN + EXTRA_LEN - 1) / EXTRA_LEN)
-@@ -994,6 +998,7 @@ typedef struct {
+@@ -1019,6 +1023,7 @@ typedef struct {
  
  typedef struct {
      STRUCT_STAT st;
@@ -405,7 +427,7 @@ diff --git a/rsync.yo b/rsync.yo
   -O, --omit-dir-times        omit directories from --times
   -J, --omit-link-times       omit symlinks from --times
       --super                 receiver attempts super-user activities
-@@ -1152,6 +1153,9 @@ cause the next transfer to behave as if it used bf(-I), causing all files to be
+@@ -1154,6 +1155,9 @@ cause the next transfer to behave as if it used bf(-I), causing all files to be
  updated (though rsync's delta-transfer algorithm will make the update fairly efficient
  if the files haven't actually changed, you're much better off using bf(-t)).
  
@@ -415,7 +437,7 @@ diff --git a/rsync.yo b/rsync.yo
  dit(bf(-O, --omit-dir-times)) This tells rsync to omit directories when
  it is preserving modification times (see bf(--times)).  If NFS is sharing
  the directories on the receiving side, it is a good idea to use bf(-O).
-@@ -1983,7 +1987,7 @@ with older versions of rsync, but that also turns on the output of other
+@@ -2005,7 +2009,7 @@ with older versions of rsync, but that also turns on the output of other
  verbose messages).
  
  The "%i" escape has a cryptic output that is 11 letters long.  The general
@@ -424,7 +446,7 @@ diff --git a/rsync.yo b/rsync.yo
  type of update being done, bf(X) is replaced by the file-type, and the
  other letters represent attributes that may be output if they are being
  modified.
-@@ -2042,6 +2046,8 @@ quote(itemization(
+@@ -2064,6 +2068,8 @@ quote(itemization(
    it() The bf(f) means that the fileflags information changed.
    it() The bf(a) means that the ACL information changed.
    it() The bf(x) means that the extended attribute information changed.
@@ -436,12 +458,11 @@ diff --git a/rsync.yo b/rsync.yo
 diff --git a/syscall.c b/syscall.c
 --- a/syscall.c
 +++ b/syscall.c
-@@ -38,6 +38,14 @@ extern int force_change;
+@@ -42,6 +42,13 @@ extern int force_change;
  extern int preserve_perms;
  extern int preserve_executability;
  
-+#pragma pack(push)
-+#pragma pack(4)
++#pragma pack(push, 4)
 +struct create_time {
 +      uint32 length;
 +      struct timespec crtime;
@@ -451,7 +472,7 @@ diff --git a/syscall.c b/syscall.c
  #define RETURN_ERROR_IF(x,e) \
        do { \
                if (x) { \
-@@ -456,6 +464,36 @@ OFF_T do_lseek(int fd, OFF_T offset, int whence)
+@@ -460,6 +467,36 @@ OFF_T do_lseek(int fd, OFF_T offset, int whence)
  #endif
  }
  
@@ -530,13 +551,13 @@ diff --git a/testsuite/rsync.fns b/testsuite/rsync.fns
 +all_plus='++++++++++'
 +allspace='          '
 +dots='......' # trailing dots after changes
+ tab_ch='      ' # a single tab character
  
  # Berkley's nice.
- PATH="$PATH:/usr/ucb"
 diff --git a/tls.c b/tls.c
 --- a/tls.c
 +++ b/tls.c
-@@ -118,6 +118,8 @@ static int stat_xattr(const char *fname, STRUCT_STAT *fst)
+@@ -110,6 +110,8 @@ static int stat_xattr(const char *fname, STRUCT_STAT *fst)
  
  #endif
  
@@ -545,7 +566,7 @@ diff --git a/tls.c b/tls.c
  static void failed(char const *what, char const *where)
  {
        fprintf(stderr, PROGRAM ": %s %s: %s\n",
-@@ -125,16 +127,44 @@ static void failed(char const *what, char const *where)
+@@ -117,16 +119,44 @@ static void failed(char const *what, char const *where)
        exit(1);
  }
  
@@ -592,7 +613,7 @@ diff --git a/tls.c b/tls.c
  #ifdef SUPPORT_XATTRS
        if (am_root < 0)
                stat_xattr(fname, &buf);
-@@ -169,29 +199,11 @@ static void list_file(const char *fname)
+@@ -161,29 +191,11 @@ static void list_file(const char *fname)
  
        permstring(permbuf, buf.st_mode);
  
@@ -627,7 +648,7 @@ diff --git a/tls.c b/tls.c
  
        /* TODO: Perhaps escape special characters in fname? */
  
-@@ -202,13 +214,14 @@ static void list_file(const char *fname)
+@@ -194,13 +206,14 @@ static void list_file(const char *fname)
                    (long)minor(buf.st_rdev));
        } else
                printf("%15s", do_big_num(buf.st_size, 1, NULL));
@@ -644,7 +665,7 @@ diff --git a/tls.c b/tls.c
    {"link-times",      'l', POPT_ARG_NONE,   &link_times, 0, 0, 0 },
    {"link-owner",      'L', POPT_ARG_NONE,   &link_owner, 0, 0, 0 },
  #ifdef SUPPORT_XATTRS
-@@ -227,6 +240,7 @@ static void tls_usage(int ret)
+@@ -219,6 +232,7 @@ static void tls_usage(int ret)
    fprintf(F,"usage: " PROGRAM " [OPTIONS] FILE ...\n");
    fprintf(F,"Trivial file listing program for portably checking rsync\n");
    fprintf(F,"\nOptions:\n");