The patches for 3.1.1pre1.
[rsync-patches.git] / crtimes.diff
index af7ffef0add1af16854a8d9201106719818e8661..78f93f2b617a915fdedacf515c40690e70a8c07d 100644 (file)
@@ -5,13 +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
-@@ -45,6 +45,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;
@@ -19,7 +21,7 @@ diff --git a/compat.c b/compat.c
  extern int preserve_fileflags;
  extern int preserve_acls;
  extern int preserve_xattrs;
-@@ -63,7 +64,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. */
@@ -28,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 */
-@@ -139,6 +140,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;
@@ -40,15 +42,15 @@ diff --git a/compat.c b/compat.c
 diff --git a/flist.c b/flist.c
 --- a/flist.c
 +++ b/flist.c
-@@ -56,6 +56,7 @@ extern int preserve_fileflags;
- extern int uid_ndx;
- extern int gid_ndx;
+@@ -54,6 +54,7 @@ extern int preserve_fileflags;
+ extern int delete_during;
+ extern int missing_args;
  extern int eol_nulls;
 +extern int crtimes_ndx;
  extern int relative_paths;
  extern int implied_dirs;
- extern int file_extra_cnt;
-@@ -394,7 +395,7 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
+ extern int ignore_perishable;
+@@ -398,7 +399,7 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
  #endif
                            int ndx, int first_ndx)
  {
@@ -57,10 +59,10 @@ diff --git a/flist.c b/flist.c
        static mode_t mode;
  #ifdef SUPPORT_FILEFLAGS
        static uint32 fileflags;
-@@ -479,6 +480,13 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
-               xflags |= XMIT_SAME_TIME;
-       else
+@@ -509,6 +510,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;
 +      if (crtimes_ndx) {
 +              time_t file_crtime = f_crtime(file);
 +              if (file_crtime == modtime)
@@ -70,38 +72,29 @@ diff --git a/flist.c b/flist.c
 +      }
  
  #ifdef SUPPORT_HARD_LINKS
-       if (tmp_dev != 0) {
-@@ -548,6 +556,8 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
-               else
-                       write_int(f, modtime);
+       if (tmp_dev != -1) {
+@@ -593,6 +601,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));
 +      if (crtimes_ndx && !(xflags & XMIT_CRTIME_EQ_MTIME))
 +              write_varlong(f, crtime, 4);
        if (!(xflags & XMIT_SAME_MODE))
                write_int(f, to_wire_mode(mode));
  #ifdef SUPPORT_FILEFLAGS
-@@ -638,7 +648,7 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
- static struct file_struct *recv_file_entry(struct file_list *flist,
                                         int xflags, int f)
+@@ -686,7 +696,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)
  {
 -      static int64 modtime;
 +      static int64 modtime, crtime;
        static mode_t mode;
  #ifdef SUPPORT_FILEFLAGS
        static uint32 fileflags;
-@@ -744,6 +754,8 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
-                               uid = F_OWNER(first);
-                       if (preserve_gid)
-                               gid = F_GROUP(first);
-+                      if (crtimes_ndx)
-+                              crtime = f_crtime(first);
-                       if ((preserve_devices && IS_DEVICE(mode))
-                        || (preserve_specials && IS_SPECIAL(mode))) {
-                               uint32 *devp = F_RDEV_P(first);
-@@ -773,6 +785,19 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
-               } else
-                       modtime = read_int(f);
-       }
+@@ -835,6 +845,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;
 +      if (crtimes_ndx) {
 +              if (!(xflags & XMIT_CRTIME_EQ_MTIME)) {
 +                      crtime = read_varlong(f, 4);
@@ -118,7 +111,7 @@ diff --git a/flist.c b/flist.c
        if (!(xflags & XMIT_SAME_MODE))
                mode = from_wire_mode(read_int(f));
  
-@@ -932,6 +957,8 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
+@@ -1005,6 +1028,8 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
                F_GROUP(file) = gid;
                file->flags |= gid_flags;
        }
@@ -127,10 +120,10 @@ diff --git a/flist.c b/flist.c
        if (unsort_ndx)
                F_NDX(file) = flist->used + flist->ndx_start;
  
-@@ -1308,6 +1335,8 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
-               F_OWNER(file) = st.st_uid;
-       if (gid_ndx) /* Check gid_ndx instead of preserve_gid for del support */
+@@ -1406,6 +1431,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;
 +      if (crtimes_ndx)
 +              f_crtime_set(file, get_create_time(fname));
  
@@ -139,15 +132,7 @@ diff --git a/flist.c b/flist.c
 diff --git a/generator.c b/generator.c
 --- a/generator.c
 +++ b/generator.c
-@@ -21,6 +21,7 @@
-  */
- #include "rsync.h"
-+#include "ifuncs.h"
- extern int verbose;
- extern int dry_run;
-@@ -40,6 +41,7 @@ extern int preserve_xattrs;
+@@ -40,6 +40,7 @@ extern int preserve_xattrs;
  extern int preserve_links;
  extern int preserve_devices;
  extern int preserve_specials;
@@ -155,21 +140,42 @@ diff --git a/generator.c b/generator.c
  extern int preserve_hard_links;
  extern int preserve_executability;
  extern int preserve_fileflags;
-@@ -620,6 +622,13 @@ int unchanged_attrs(const char *fname, struct file_struct *file, stat_x *sxp)
-       if (gid_ndx && !(file->flags & FLAG_SKIP_GROUP) && sxp->st.st_gid != (gid_t)F_GROUP(file))
-               return 0;
+@@ -380,8 +381,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
-       if (preserve_acls && !S_ISLNK(file->mode)) {
-               if (!ACL_READY(*sxp))
-@@ -663,6 +672,12 @@ void itemize(const char *fnamecmp, struct file_struct *file, int ndx, int statre
+       return cmp_time(sxp->st.st_mtime, file->modtime);
+ }
+@@ -439,7 +447,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
+@@ -459,7 +467,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;
+@@ -502,6 +510,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))
                        iflags |= ITEM_REPORT_TIME;
@@ -182,65 +188,58 @@ diff --git a/generator.c b/generator.c
  #if !defined HAVE_LCHMOD && !defined HAVE_SETATTRLIST
                if (S_ISLNK(file->mode)) {
                        ;
-@@ -1223,6 +1238,7 @@ static int try_dests_non(struct file_struct *file, char *fname, int ndx,
+@@ -1118,6 +1132,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];
 +      time_t crtime = crtimes_ndx ? f_crtime(f) : 0;
-       double len;
+       int64 len;
+       int colwidth = human_readable ? 14 : 11;
  
-       if (!F_IS_ACTIVE(f)) {
-@@ -1237,14 +1253,16 @@ static void list_file_entry(struct file_struct *f)
+@@ -1133,10 +1148,12 @@ static void list_file_entry(struct file_struct *f)
  
  #ifdef SUPPORT_LINKS
        if (preserve_links && S_ISLNK(f->mode)) {
--              rprintf(FINFO, "%s %11.0f %s %s -> %s\n",
-+              rprintf(FINFO, "%s %11.0f %s %s %s -> %s\n",
-                       permbuf, len, timestring(f->modtime),
+-              rprintf(FINFO, "%s %*s %s %s -> %s\n",
++              rprintf(FINFO, "%s %*s %s%s%s %s -> %s\n",
+                       permbuf, colwidth, human_num(len),
+-                      timestring(f->modtime), f_name(f, NULL),
+-                      F_SYMLINK(f));
++                      timestring(f->modtime),
++                      crtimes_ndx ? " " : "",
 +                      crtimes_ndx ? timestring(crtime) : "",
-                       f_name(f, NULL), F_SYMLINK(f));
++                      f_name(f, NULL), F_SYMLINK(f));
        } else
  #endif
-       {
--              rprintf(FINFO, "%s %11.0f %s %s\n",
-+              rprintf(FINFO, "%s %11.0f %s %s %s\n",
-                       permbuf, len, timestring(f->modtime),
-+                      crtimes_ndx ? timestring(crtime) : "",
+       if (missing_args == 2 && f->mode == 0) {
+@@ -1144,9 +1161,12 @@ static void list_file_entry(struct file_struct *f)
+                       colwidth + 31, "*missing",
                        f_name(f, NULL));
+       } else {
+-              rprintf(FINFO, "%s %*s %s %s\n",
++              rprintf(FINFO, "%s %*s %s%s%s %s\n",
+                       permbuf, colwidth, human_num(len),
+-                      timestring(f->modtime), f_name(f, NULL));
++                      timestring(f->modtime),
++                      crtimes_ndx ? " " : "",
++                      crtimes_ndx ? timestring(crtime) : "",
++                      f_name(f, NULL));
        }
  }
-@@ -1336,6 +1354,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1238,6 +1258,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                        return;
                }
        }
 +      sx.crtime = 0;
  
- #ifdef SUPPORT_ACLS
-       sx.acc_acl = sx.def_acl = NULL;
-diff --git a/hlink.c b/hlink.c
---- a/hlink.c
-+++ b/hlink.c
-@@ -366,6 +366,7 @@ int hard_link_check(struct file_struct *file, int ndx, const char *fname,
-               char cmpbuf[MAXPATHLEN];
-               stat_x alt_sx;
-               int j = 0;
-+              alt_sx.crtime = 0;
- #ifdef SUPPORT_ACLS
-               alt_sx.acc_acl = alt_sx.def_acl = NULL;
- #endif
-@@ -494,6 +495,7 @@ void finish_hard_link(struct file_struct *file, const char *fname, int fin_ndx,
-       } else
-               our_name = fname;
-+      prev_sx.crtime = 0;
- #ifdef SUPPORT_ACLS
-       prev_sx.acc_acl = prev_sx.def_acl = NULL;
- #endif
+       if (dry_run > 1 || (dry_missing_dir && is_below(file, dry_missing_dir))) {
+               int i;
 diff --git a/ifuncs.h b/ifuncs.h
 --- a/ifuncs.h
 +++ b/ifuncs.h
-@@ -67,6 +67,28 @@ d_name(struct dirent *di)
- #endif
+@@ -43,6 +43,28 @@ free_xbuf(xbuf *xb)
+       memset(xb, 0, sizeof (xbuf));
  }
  
 +static inline time_t
@@ -266,12 +265,12 @@ diff --git a/ifuncs.h b/ifuncs.h
 +}
 +
  static inline int
isDigit(const char *ptr)
to_wire_mode(mode_t mode)
  {
 diff --git a/log.c b/log.c
 --- a/log.c
 +++ b/log.c
-@@ -663,7 +663,8 @@ static void log_formatted(enum logcode code, const char *format, const char *op,
+@@ -723,7 +723,8 @@ static void log_formatted(enum logcode code, const char *format, const char *op,
                        c[8] = !(iflags & ITEM_REPORT_FFLAGS) ? '.' : 'f';
                        c[9] = !(iflags & ITEM_REPORT_ACL) ? '.' : 'a';
                        c[10] = !(iflags & ITEM_REPORT_XATTR) ? '.' : 'x';
@@ -292,16 +291,16 @@ diff --git a/options.c b/options.c
  int update_only = 0;
  int cvs_exclude = 0;
  int dry_run = 0;
-@@ -362,6 +363,7 @@ void usage(enum logcode F)
+@@ -716,6 +717,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");
-   rprintf(F," -O, --omit-dir-times        omit directories from --times\n");
 +  rprintf(F," -N, --crtimes               preserve create times (newness)\n");
+   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");
- #ifdef SUPPORT_XATTRS
-   rprintf(F,"     --fake-super            store/recover privileged attrs using xattrs\n");
-@@ -508,6 +510,9 @@ static struct poptOption long_options[] = {
-   {"times",           't', POPT_ARG_VAL,    &preserve_times, 2, 0, 0 },
+@@ -883,6 +885,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 },
 +  {"crtimes",         'N', POPT_ARG_VAL,    &preserve_crtimes, 1, 0, 0 },
@@ -310,7 +309,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 },
-@@ -1799,6 +1804,8 @@ void server_options(char **args, int *argc_p)
+@@ -2445,6 +2450,8 @@ void server_options(char **args, int *argc_p)
                argstr[x++] = 'D';
        if (preserve_times)
                argstr[x++] = 't';
@@ -322,15 +321,17 @@ diff --git a/options.c b/options.c
 diff --git a/rsync.c b/rsync.c
 --- a/rsync.c
 +++ b/rsync.c
-@@ -428,6 +428,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
-                               full_fname(fname));
-                       return 0;
-               }
-+              sx2.crtime = 0;
- #ifdef SUPPORT_ACLS
-               sx2.acc_acl = sx2.def_acl = NULL;
- #endif
-@@ -475,6 +476,14 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
+@@ -581,6 +581,9 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
+        || (!(preserve_times & PRESERVE_DIR_TIMES) && S_ISDIR(sxp->st.st_mode))
+        || (!(preserve_times & PRESERVE_LINK_TIMES) && S_ISLNK(sxp->st.st_mode)))
+               flags |= ATTRS_SKIP_MTIME;
++      /* Don't set the creation date on the root folder of an HFS+ volume. */
++      if (sxp->st.st_ino == 2 && S_ISDIR(sxp->st.st_mode))
++              flags |= ATTRS_SKIP_CRTIME;
+       if (!(flags & ATTRS_SKIP_MTIME)
+           && cmp_time(sxp->st.st_mtime, file->modtime) != 0) {
+               int ret = set_modtime(fname, file->modtime, F_MOD_NSEC(file), sxp->st.st_mode, ST_FLAGS(sxp->st));
+@@ -594,6 +597,14 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
                else
                        file->flags |= FLAG_TIME_FAILED;
        }
@@ -343,9 +344,9 @@ diff --git a/rsync.c b/rsync.c
 +                      updated = 1;
 +      }
  
-       change_uid = am_root && uid_ndx && sxp->st.st_uid != (uid_t)F_OWNER(file);
-       change_gid = gid_ndx && !(file->flags & FLAG_SKIP_GROUP)
-@@ -622,7 +631,7 @@ int finish_transfer(const char *fname, const char *fnametmp,
+ #ifdef SUPPORT_ACLS
+       /* It's OK to call set_acl() now, even for a dir, as the generator
+@@ -710,7 +721,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
@@ -353,8 +354,8 @@ diff --git a/rsync.c b/rsync.c
 +                     | (ok_to_set_time ? 0 : ATTRS_SKIP_MTIME | ATTRS_SKIP_CRTIME));
  
        /* move tmp file over real file */
-       if (verbose > 2)
-@@ -653,7 +662,7 @@ int finish_transfer(const char *fname, const char *fnametmp,
+       if (DEBUG_GTE(RECV, 1))
+@@ -739,7 +750,7 @@ int finish_transfer(const char *fname, const char *fnametmp,
  
    do_set_file_attrs:
        set_file_attrs(fnametmp, file, NULL, fnamecmp,
@@ -366,15 +367,17 @@ diff --git a/rsync.c b/rsync.c
 diff --git a/rsync.h b/rsync.h
 --- a/rsync.h
 +++ b/rsync.h
-@@ -60,6 +60,7 @@
- #define XMIT_RDEV_MINOR_8_pre30 (1<<11)       /* protocols 28 - 29  */
- #define XMIT_GROUP_NAME_FOLLOWS (1<<11) /* protocols 30 - now */
+@@ -62,7 +62,8 @@
  #define XMIT_HLINK_FIRST (1<<12)      /* protocols 30 - now (HLINKED files only) */
-+#define XMIT_CRTIME_EQ_MTIME (1<<13)  /* protocols ?? - now */
- #define XMIT_SAME_FLAGS (1<<14)               /* protocols ?? - now */
+ #define XMIT_IO_ERROR_ENDLIST (1<<12) /* protocols 31*- now (w/XMIT_EXTENDED_FLAGS) (also protocol 30 w/'f' compat flag) */
+ #define XMIT_MOD_NSEC (1<<13)         /* protocols 31 - now */
+-#define XMIT_SAME_FLAGS (1<<14)               /* protocols ?? - now */
++#define XMIT_CRTIME_EQ_MTIME (1<<14)  /* protocols ?? - now */
++#define XMIT_SAME_FLAGS (1<<15)               /* protocols ?? - now */
  
  /* These flags are used in the live flist data. */
-@@ -156,6 +157,7 @@
+@@ -167,6 +168,7 @@
  #define ATTRS_REPORT          (1<<0)
  #define ATTRS_SKIP_MTIME      (1<<1)
  #define ATTRS_DELAY_IMMUTABLE (1<<2)
@@ -382,7 +385,7 @@ diff --git a/rsync.h b/rsync.h
  
  #define FULL_FLUSH    1
  #define NORMAL_FLUSH  0
-@@ -172,7 +174,7 @@
+@@ -183,7 +185,7 @@
  #define FNAMECMP_FUZZY                0x83
  
  /* For use by the itemize_changes code */
@@ -391,7 +394,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 */
-@@ -657,6 +659,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;
@@ -399,7 +402,7 @@ diff --git a/rsync.h b/rsync.h
  extern int fileflags_ndx;
  extern int acls_ndx;
  extern int xattrs_ndx;
-@@ -664,6 +667,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)
@@ -407,7 +410,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)
-@@ -931,6 +935,7 @@ typedef struct {
+@@ -1021,6 +1025,7 @@ typedef struct {
  
  typedef struct {
      STRUCT_STAT st;
@@ -418,25 +421,25 @@ diff --git a/rsync.h b/rsync.h
 diff --git a/rsync.yo b/rsync.yo
 --- a/rsync.yo
 +++ b/rsync.yo
-@@ -350,6 +350,7 @@ to the detailed description below for a complete description.  verb(
+@@ -370,6 +370,7 @@ to the detailed description below for a complete description.  verb(
+      --specials              preserve special files
   -D                          same as --devices --specials
   -t, --times                 preserve modification times
-  -O, --omit-dir-times        omit directories from --times
 + -N, --crtimes               preserve create times (newness)
+  -O, --omit-dir-times        omit directories from --times
+  -J, --omit-link-times       omit symlinks from --times
       --super                 receiver attempts super-user activities
-      --fake-super            store/recover privileged attrs using xattrs
-  -S, --sparse                handle sparse files efficiently
-@@ -1028,6 +1029,9 @@ 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).
- This option is inferred if you use bf(--backup) without bf(--backup-dir).
+@@ -1190,6 +1191,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)).
  
 +dit(bf(-N, --crtimes)) This tells rsync to set the create times (newness) of
 +the destination files to the same value as the source files.
 +
- dit(bf(--super)) This tells the receiving side to attempt super-user
- activities even if the receiving rsync wasn't run by the super-user.  These
- activities include: preserving users via the bf(--owner) option, preserving
-@@ -1692,7 +1696,7 @@ with older versions of rsync, but that also turns on the output of other
+ 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).
+@@ -2065,7 +2069,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
@@ -445,7 +448,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.
-@@ -1751,6 +1755,8 @@ quote(itemization(
+@@ -2124,6 +2128,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.
@@ -457,23 +460,24 @@ diff --git a/rsync.yo b/rsync.yo
 diff --git a/syscall.c b/syscall.c
 --- a/syscall.c
 +++ b/syscall.c
-@@ -37,6 +37,11 @@ extern int force_change;
+@@ -42,6 +42,13 @@ extern int force_change;
  extern int preserve_perms;
  extern int preserve_executability;
  
++#pragma pack(push, 4)
 +struct create_time {
-+      unsigned long length;
++      uint32 length;
 +      struct timespec crtime;
 +};
++#pragma pack(pop)
 +
  #define RETURN_ERROR_IF(x,e) \
        do { \
                if (x) { \
-@@ -394,3 +399,33 @@ OFF_T do_lseek(int fd, OFF_T offset, int whence)
-       return lseek(fd, offset, whence);
+@@ -460,6 +467,36 @@ OFF_T do_lseek(int fd, OFF_T offset, int whence)
  #endif
  }
-+
 +time_t get_create_time(const char *path)
 +{
 +      static struct create_time attrBuf;
@@ -503,6 +507,10 @@ diff --git a/syscall.c b/syscall.c
 +      attrList.commonattr = ATTR_CMN_CRTIME;
 +      return setattrlist(path, &attrList, &ts, sizeof ts, FSOPT_NOFOLLOW);
 +}
++
+ #ifdef HAVE_UTIMENSAT
+ int do_utimensat(const char *fname, time_t modtime, uint32 mod_nsec)
+ {
 diff --git a/testsuite/crtimes.test b/testsuite/crtimes.test
 new file mode 100644
 --- /dev/null
@@ -535,7 +543,7 @@ new file mode 100644
 diff --git a/testsuite/rsync.fns b/testsuite/rsync.fns
 --- a/testsuite/rsync.fns
 +++ b/testsuite/rsync.fns
-@@ -24,9 +24,9 @@ todir="$tmpdir/to"
+@@ -23,9 +23,9 @@ todir="$tmpdir/to"
  chkdir="$tmpdir/chk"
  
  # For itemized output:
@@ -545,13 +553,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
-@@ -107,6 +107,8 @@ static int stat_xattr(const char *fname, STRUCT_STAT *fst)
+@@ -109,6 +109,8 @@ static int stat_xattr(const char *fname, STRUCT_STAT *fst)
  
  #endif
  
@@ -560,25 +568,32 @@ diff --git a/tls.c b/tls.c
  static void failed(char const *what, char const *where)
  {
        fprintf(stderr, PROGRAM ": %s %s: %s\n",
-@@ -114,16 +116,36 @@ static void failed(char const *what, char const *where)
+@@ -116,16 +118,44 @@ static void failed(char const *what, char const *where)
        exit(1);
  }
  
-+static void storetime(char *dest, time_t t, size_t destsize)
++static void storetime(char *dest, size_t destsize, time_t t, int nsecs)
 +{
 +      if (t) {
++              int len;
 +              struct tm *mt = gmtime(&t);
 +
-+              snprintf(dest, destsize,
-+                      "%04d-%02d-%02d %02d:%02d:%02d ",
++              len = snprintf(dest, destsize,
++                      "%04d-%02d-%02d %02d:%02d:%02d",
 +                      (int)mt->tm_year + 1900,
 +                      (int)mt->tm_mon + 1,
 +                      (int)mt->tm_mday,
 +                      (int)mt->tm_hour,
 +                      (int)mt->tm_min,
 +                      (int)mt->tm_sec);
-+      } else
-+              strlcpy(dest, "                    ", destsize);
++              if (nsecs >= 0 && len >= 0)
++                      snprintf(dest + len, destsize - len, ".%09d", nsecs);
++      } else {
++              int has_nsecs = nsecs >= 0 ? 1 : 0;
++              int len = MIN(19 + 9*has_nsecs, (int)destsize - 1);
++              memset(dest, ' ', len);
++              dest[len] = '\0';
++      }
 +}
 +
  static void list_file(const char *fname)
@@ -591,6 +606,7 @@ diff --git a/tls.c b/tls.c
 +      char mtimebuf[50];
 +      char crtimebuf[50];
        char linkbuf[4096];
++      int nsecs;
  
        if (do_lstat(fname, &buf) < 0)
                failed("stat", fname);
@@ -599,14 +615,16 @@ diff --git a/tls.c b/tls.c
  #ifdef SUPPORT_XATTRS
        if (am_root < 0)
                stat_xattr(fname, &buf);
-@@ -158,19 +180,11 @@ static void list_file(const char *fname)
+@@ -159,30 +189,17 @@ static void list_file(const char *fname)
+       }
  
        permstring(permbuf, buf.st_mode);
+-
 -      if (buf.st_mtime) {
+-              int len;
 -              mt = gmtime(&buf.st_mtime);
 -
--              snprintf(datebuf, sizeof datebuf,
+-              len = snprintf(datebuf, sizeof datebuf,
 -                      "%04d-%02d-%02d %02d:%02d:%02d",
 -                      (int)mt->tm_year + 1900,
 -                      (int)mt->tm_mon + 1,
@@ -614,20 +632,33 @@ diff --git a/tls.c b/tls.c
 -                      (int)mt->tm_hour,
 -                      (int)mt->tm_min,
 -                      (int)mt->tm_sec);
--      } else
--              strlcpy(datebuf, "                   ", sizeof datebuf);
-+      storetime(mtimebuf, buf.st_mtime, sizeof mtimebuf);
+ #ifdef ST_MTIME_NSEC
+-              if (nsec_times) {
+-                      snprintf(datebuf + len, sizeof datebuf - len,
+-                              ".%09d", (int)buf.ST_MTIME_NSEC);
+-              }
++      if (nsec_times)
++              nsecs = (int)buf.ST_MTIME_NSEC;
++      else
+ #endif
+-      } else {
+-              int len = MIN(19 + 9*nsec_times, (int)sizeof datebuf - 1);
+-              memset(datebuf, ' ', len);
+-              datebuf[len] = '\0';
+-      }
++              nsecs = -1;
++      storetime(mtimebuf, sizeof mtimebuf, buf.st_mtime, nsecs);
 +      if (display_crtimes)
-+              storetime(crtimebuf, crtime, sizeof crtimebuf);
++              storetime(crtimebuf, sizeof crtimebuf, crtime, -1);
 +      else
 +              crtimebuf[0] = '\0';
  
        /* TODO: Perhaps escape special characters in fname? */
  
-@@ -181,13 +195,14 @@ static void list_file(const char *fname)
+@@ -193,13 +210,14 @@ static void list_file(const char *fname)
                    (long)minor(buf.st_rdev));
-       } else /* NB: use double for size since it might not fit in a long. */
-               printf("%12.0f", (double)buf.st_size);
+       } else
+               printf("%15s", do_big_num(buf.st_size, 1, NULL));
 -      printf(" %6ld.%-6ld %6ld %s %s%s\n",
 +      printf(" %6ld.%-6ld %6ld %s%s%s%s\n",
               (long)buf.st_uid, (long)buf.st_gid, (long)buf.st_nlink,
@@ -641,7 +672,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
-@@ -203,6 +218,7 @@ static void tls_usage(int ret)
+@@ -218,6 +236,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");