We now remove any extraneous xattr values from a file that isn't
[rsync/rsync-patches.git] / atimes.diff
index 2802037..0a7beb2 100644 (file)
@@ -6,17 +6,28 @@ To use this patch, run these commands for a successful build:
     make
 
 
+--- old/compat.c
++++ new/compat.c
+@@ -56,6 +56,8 @@ void setup_protocol(int f_out,int f_in)
+               preserve_uid = ++file_extra_cnt;
+       if (preserve_gid)
+               preserve_gid = ++file_extra_cnt;
++      if (preserve_atimes)
++              preserve_atimes = ++file_extra_cnt;
+       if (remote_protocol == 0) {
+               if (!read_batch)
 --- old/flist.c
 +++ new/flist.c
-@@ -46,6 +46,7 @@ extern int preserve_devices;
+@@ -48,6 +48,7 @@ extern int preserve_devices;
  extern int preserve_specials;
  extern int preserve_uid;
  extern int preserve_gid;
 +extern int preserve_atimes;
  extern int relative_paths;
  extern int implied_dirs;
- extern int flist_extra_cnt;
-@@ -134,6 +135,7 @@ void show_flist_stats(void)
+ extern int file_extra_cnt;
+@@ -143,6 +144,7 @@ void show_flist_stats(void)
  static void list_file_entry(struct file_struct *f)
  {
        char permbuf[PERMSTRING_SIZE];
@@ -24,7 +35,7 @@ To use this patch, run these commands for a successful build:
        double len;
  
        if (!F_IS_ACTIVE(f)) {
-@@ -146,14 +148,16 @@ static void list_file_entry(struct file_
+@@ -155,14 +157,16 @@ static void list_file_entry(struct file_
  
  #ifdef SUPPORT_LINKS
        if (preserve_links && S_ISLNK(f->mode)) {
@@ -43,24 +54,15 @@ To use this patch, run these commands for a successful build:
                        f_name(f, NULL));
        }
  }
-@@ -311,6 +315,7 @@ static void send_file_entry(struct file_
+@@ -346,6 +350,7 @@ int push_flist_dir(const char *dir, int 
+ static void send_file_entry(int f, struct file_struct *file, int ndx)
  {
-       unsigned short flags;
        static time_t modtime;
 +      static time_t atime;
        static mode_t mode;
        static int64 dev;
        static dev_t rdev;
-@@ -326,7 +331,7 @@ static void send_file_entry(struct file_
-       if (!file) {
-               write_byte(f, 0);
--              modtime = 0, mode = 0;
-+              modtime = 0, atime = 0, mode = 0;
-               dev = 0, rdev = MAKEDEV(0, 0);
-               rdev_major = 0;
-               uid = 0, gid = 0;
-@@ -376,6 +381,13 @@ static void send_file_entry(struct file_
+@@ -413,6 +418,13 @@ static void send_file_entry(int f, struc
                flags |= XMIT_SAME_TIME;
        else
                modtime = file->modtime;
@@ -73,35 +75,26 @@ To use this patch, run these commands for a successful build:
 +      }
  
  #ifdef SUPPORT_HARD_LINKS
-       if (tmp_idev.dev != 0) {
-@@ -428,6 +440,8 @@ static void send_file_entry(struct file_
+       if (tmp_dev != 0) {
+@@ -480,6 +492,8 @@ static void send_file_entry(int f, struc
                write_int(f, modtime);
        if (!(flags & XMIT_SAME_MODE))
                write_int(f, to_wire_mode(mode));
 +      if (preserve_atimes && !S_ISDIR(mode) && !(flags & XMIT_SAME_ATIME))
 +              write_int(f, atime);
        if (preserve_uid && !(flags & XMIT_SAME_UID)) {
-               if (!numeric_ids)
-                       add_uid(uid);
-@@ -494,7 +508,7 @@ static void send_file_entry(struct file_
+               write_int(f, uid);
+               if (flags & XMIT_USER_NAME_FOLLOWS) {
+@@ -553,7 +567,7 @@ static void send_file_entry(int f, struc
  static struct file_struct *recv_file_entry(struct file_list *flist,
-                                          unsigned short flags, int f)
+                                          int flags, int f)
  {
 -      static time_t modtime;
 +      static time_t modtime, atime;
        static mode_t mode;
        static int64 dev;
        static dev_t rdev;
-@@ -514,7 +528,7 @@ static struct file_struct *recv_file_ent
-       struct file_struct *file;
-       if (!flist) {
--              modtime = 0, mode = 0;
-+              modtime = 0, atime = 0, mode = 0;
-               dev = 0, rdev = MAKEDEV(0, 0);
-               rdev_major = 0;
-               uid = 0, gid = 0;
-@@ -570,6 +584,8 @@ static struct file_struct *recv_file_ent
+@@ -650,6 +664,8 @@ static struct file_struct *recv_file_ent
                modtime = (time_t)read_int(f);
        if (!(flags & XMIT_SAME_MODE))
                mode = from_wire_mode(read_int(f));
@@ -110,27 +103,27 @@ To use this patch, run these commands for a successful build:
  
        if (chmod_modes && !S_ISLNK(mode))
                mode = tweak_mode(mode, chmod_modes);
-@@ -654,6 +670,8 @@ static struct file_struct *recv_file_ent
-               F_UID(file) = uid;
+@@ -758,6 +774,8 @@ static struct file_struct *recv_file_ent
+               F_OWNER(file) = uid;
        if (preserve_gid)
-               F_GID(file) = gid;
+               F_GROUP(file) = gid;
 +      if (preserve_atimes)
 +              F_ATIME(file) = atime;
  
-       if (dirname_len) {
-               file->dirname = lastdir = bp;
-@@ -930,6 +948,8 @@ struct file_struct *make_file(const char
-               F_UID(file) = st.st_uid;
+       if (basename != thisname) {
+               file->dirname = lastdir;
+@@ -1055,6 +1073,8 @@ struct file_struct *make_file(const char
+               F_OWNER(file) = st.st_uid;
        if (preserve_gid)
-               F_GID(file) = st.st_gid;
+               F_GROUP(file) = st.st_gid;
 +      if (preserve_atimes)
 +              F_ATIME(file) = st.st_atime;
  
-       if (dirname_len) {
-               file->dirname = lastdir = bp;
+       if (basename != thisname)
+               file->dirname = lastdir;
 --- old/generator.c
 +++ new/generator.c
-@@ -43,6 +43,7 @@ extern int preserve_perms;
+@@ -44,6 +44,7 @@ extern int preserve_perms;
  extern int preserve_uid;
  extern int preserve_gid;
  extern int preserve_times;
@@ -138,25 +131,25 @@ To use this patch, run these commands for a successful build:
  extern int omit_dir_times;
  extern int delete_mode;
  extern int delete_before;
-@@ -475,6 +476,9 @@ void itemize(struct file_struct *file, i
+@@ -539,6 +540,9 @@ void itemize(struct file_struct *file, i
                  && (!(iflags & ITEM_XNAME_FOLLOWS) || *xname))
                 || (keep_time && cmp_time(file->modtime, st->st_mtime) != 0))
                        iflags |= ITEM_REPORT_TIME;
 +              if (preserve_atimes && !S_ISDIR(file->mode) && !S_ISLNK(file->mode)
 +               && cmp_time(F_ATIME(file), st->st_atime) != 0)
 +                      iflags |= ITEM_REPORT_ATIME;
-               if ((file->mode & CHMOD_BITS) != (st->st_mode & CHMOD_BITS))
+               if (!BITS_EQUAL(st->st_mode, file->mode, CHMOD_BITS))
                        iflags |= ITEM_REPORT_PERMS;
                if (preserve_uid && am_root && F_UID(file) != st->st_uid)
-@@ -785,6 +789,8 @@ static int try_dests_reg(struct file_str
-                       if (hard_link_one(file, ndx, fname, 0, stp,
-                                         cmpbuf, 1, i, code) < 0)
+@@ -849,6 +853,8 @@ static int try_dests_reg(struct file_str
+               if (link_dest) {
+                       if (!hard_link_one(file, fname, cmpbuf, 1))
                                goto try_a_copy;
 +                      if (preserve_atimes)
 +                              set_file_attrs(fname, file, stp, 0);
                        if (preserve_hard_links && F_IS_HLINKED(file))
-                               hard_link_cluster(file, ndx, itemizing, code, j);
-               } else
+                               finish_hard_link(file, fname, stp, itemizing, code, j);
+                       if (itemizing && (verbose > 1 || stdout_format_has_i > 1)) {
 --- old/log.c
 +++ new/log.c
 @@ -37,6 +37,7 @@ extern int msg_fd_out;
@@ -209,16 +202,7 @@ To use this patch, run these commands for a successful build:
    {"omit-dir-times",  'O', POPT_ARG_VAL,    &omit_dir_times, 2, 0, 0 },
    {"modify-window",    0,  POPT_ARG_INT,    &modify_window, OPT_MODIFY_WINDOW, 0, 0 },
    {"super",            0,  POPT_ARG_VAL,    &am_root, 2, 0, 0 },
-@@ -1223,6 +1228,8 @@ int parse_arguments(int *argc, const cha
-               preserve_uid = ++flist_extra_cnt;
-       if (preserve_gid)
-               preserve_gid = ++flist_extra_cnt;
-+      if (preserve_atimes)
-+              preserve_atimes = ++flist_extra_cnt;
-       *argv = poptGetArgs(pc);
-       *argc = count_args(*argv);
-@@ -1542,6 +1549,8 @@ void server_options(char **args,int *arg
+@@ -1552,6 +1557,8 @@ void server_options(char **args,int *arg
                argstr[x++] = 'D';
        if (preserve_times)
                argstr[x++] = 't';
@@ -237,7 +221,7 @@ To use this patch, run these commands for a successful build:
  extern int preserve_times;
  extern int omit_dir_times;
  extern int am_root;
-@@ -182,6 +183,7 @@ int set_file_attrs(char *fname, struct f
+@@ -232,6 +233,7 @@ int set_file_attrs(char *fname, struct f
        int updated = 0;
        STRUCT_STAT st2;
        int change_uid, change_gid;
@@ -245,7 +229,7 @@ To use this patch, run these commands for a successful build:
        mode_t new_mode = file->mode;
  
        if (!st) {
-@@ -201,18 +203,36 @@ int set_file_attrs(char *fname, struct f
+@@ -251,18 +253,36 @@ int set_file_attrs(char *fname, struct f
                }
        }
  
@@ -287,15 +271,15 @@ To use this patch, run these commands for a successful build:
        change_uid = am_root && preserve_uid && st->st_uid != F_UID(file);
 --- old/rsync.h
 +++ new/rsync.h
-@@ -54,6 +54,7 @@
- #define XMIT_HAS_IDEV_DATA (1<<9)
- #define XMIT_SAME_DEV (1<<10)
+@@ -57,6 +57,7 @@
  #define XMIT_RDEV_MINOR_IS_SMALL (1<<11)
-+#define XMIT_SAME_ATIME (1<<12)
+ #define XMIT_USER_NAME_FOLLOWS (1<<12)        /* protocols >= 30 */
+ #define XMIT_GROUP_NAME_FOLLOWS (1<<13) /* protocols >= 30 */
++#define XMIT_SAME_ATIME (1<<14)               /* protocols >= 30 */
  
  /* These flags are used in the live flist data. */
  
-@@ -121,6 +122,7 @@
+@@ -135,6 +136,7 @@
  
  #define ATTRS_REPORT          (1<<0)
  #define ATTRS_SKIP_MTIME      (1<<1)
@@ -303,22 +287,22 @@ To use this patch, run these commands for a successful build:
  
  #define FULL_FLUSH    1
  #define NORMAL_FLUSH  0
-@@ -511,6 +513,7 @@ struct file_struct {
-       union flist_extras {
-               uid_t uid;           /* The user ID number */
-               uid_t gid;           /* The group ID number or GID_NONE */
-+              time_t utime;        /* A unix-time value */
-               struct idev *idev;   /* The hard-link info during matching */
-               struct hlist *hlist; /* The hard-link info after matching */
-               uint32 unum;         /* An unsigned number */
-@@ -551,6 +554,7 @@ extern int preserve_gid;
+@@ -565,6 +567,7 @@ struct file_struct {
+ extern int file_extra_cnt;
+ extern int preserve_uid;
+ extern int preserve_gid;
++extern int preserve_atimes;
+ #define FILE_STRUCT_LEN (offsetof(struct file_struct, basename))
+ #define EXTRA_LEN (sizeof (union file_extras))
+@@ -597,6 +600,7 @@ extern int preserve_gid;
  /* When the associated option is on, all entries will have these present: */
- #define F_UID(f) REQ_EXTRA(f, preserve_uid)->uid
- #define F_GID(f) REQ_EXTRA(f, preserve_gid)->gid
-+#define F_ATIME(f) REQ_EXTRA(f, preserve_atimes)->utime
+ #define F_OWNER(f) REQ_EXTRA(f, preserve_uid)->unum
+ #define F_GROUP(f) REQ_EXTRA(f, preserve_gid)->unum
++#define F_ATIME(f) REQ_EXTRA(f, preserve_atimes)->unum
  
- /* These are per-entry optional and mutally exclusive: */
- #define F_IDEV(f)  OPT_EXTRA(f, LEN64_BUMP(f))->idev
+ /* These items are per-entry optional and mutally exclusive: */
+ #define F_HL_GNUM(f) OPT_EXTRA(f, LEN64_BUMP(f))->num
 --- old/rsync.yo
 +++ new/rsync.yo
 @@ -328,8 +328,9 @@ to the detailed description below for a 
@@ -378,13 +362,13 @@ To use this patch, run these commands for a successful build:
  One other output is possible:  when deleting files, the "%i" will output
 --- old/sender.c
 +++ new/sender.c
-@@ -41,6 +41,7 @@ extern int do_progress;
+@@ -42,6 +42,7 @@ extern int do_progress;
  extern int inplace;
  extern int batch_fd;
  extern int write_batch;
 +extern unsigned int file_struct_len;
  extern struct stats stats;
- extern struct file_list *the_file_list;
+ extern struct file_list *cur_flist, *first_flist;
  extern char *stdout_format;
 --- old/testsuite/atimes.test
 +++ new/testsuite/atimes.test
@@ -539,7 +523,7 @@ To use this patch, run these commands for a successful build:
 +
 +static void tls_usage(int ret)
 +{
-+      fprintf(stderr, "usage: " PROGRAM " [--atime | -u] DIR ...\n"
++      fprintf(stderr, "usage: " PROGRAM " [--atime | -u] FILE ...\n"
 +          "Trivial file listing program for portably checking rsync\n");
 +      exit(ret);
  }
@@ -548,7 +532,7 @@ To use this patch, run these commands for a successful build:
  main(int argc, char *argv[])
  {
 -      if (argc < 2) {
--              fprintf(stderr, "usage: " PROGRAM " DIR ...\n"
+-              fprintf(stderr, "usage: " PROGRAM " FILE ...\n"
 -                      "Trivial file listing program for portably checking rsync\n");
 -              return 1;
 -      }