The patches for 3.1.1pre1.
[rsync-patches.git] / atimes.diff
index 83fee4424fab40314504febc3076daada4f0b05e..f43d0ec26afd10125716fb6eccc0a242145c361f 100644 (file)
@@ -4,7 +4,7 @@ To use this patch, run these commands for a successful build:
     ./configure                      (optional if already run)
     make
 
-based-on: 05fce6582a9192c58b2107153ec00056fd120d14
+based-on: 8946cfc6f8018e30740ee1db4cc2e2008e4f7e7e
 diff --git a/compat.c b/compat.c
 --- a/compat.c
 +++ b/compat.c
@@ -134,7 +134,7 @@ diff --git a/generator.c b/generator.c
  #if !defined HAVE_LCHMOD && !defined HAVE_SETATTRLIST
                if (S_ISLNK(file->mode)) {
                        ;
-@@ -907,6 +910,8 @@ static int try_dests_reg(struct file_struct *file, char *fname, int ndx,
+@@ -905,6 +908,8 @@ static int try_dests_reg(struct file_struct *file, char *fname, int ndx,
                if (link_dest) {
                        if (!hard_link_one(file, fname, cmpbuf, 1))
                                goto try_a_copy;
@@ -143,7 +143,7 @@ diff --git a/generator.c b/generator.c
                        if (preserve_hard_links && F_IS_HLINKED(file))
                                finish_hard_link(file, fname, ndx, &sxp->st, itemizing, code, j);
                        if (!maybe_ATTRS_REPORT && (INFO_GTE(NAME, 2) || stdout_format_has_i > 1)) {
-@@ -1109,6 +1114,7 @@ static int try_dests_non(struct file_struct *file, char *fname, int ndx,
+@@ -1107,6 +1112,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];
@@ -151,36 +151,38 @@ diff --git a/generator.c b/generator.c
        int64 len;
        int colwidth = human_readable ? 14 : 11;
  
-@@ -1124,10 +1130,11 @@ static void list_file_entry(struct file_struct *f)
+@@ -1122,10 +1128,12 @@ static void list_file_entry(struct file_struct *f)
  
  #ifdef SUPPORT_LINKS
        if (preserve_links && S_ISLNK(f->mode)) {
 -              rprintf(FINFO, "%s %*s %s %s -> %s\n",
-+              rprintf(FINFO, "%s %*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),
++                      atimes_ndx ? " " : "",
 +                      atimes_ndx ? timestring(atime) : "",
 +                      f_name(f, NULL), F_SYMLINK(f));
        } else
  #endif
        if (missing_args == 2 && f->mode == 0) {
-@@ -1135,9 +1142,11 @@ static void list_file_entry(struct file_struct *f)
+@@ -1133,9 +1141,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\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),
++                      atimes_ndx ? " " : "",
 +                      atimes_ndx ? timestring(atime) : "",
 +                      f_name(f, NULL));
        }
  }
  
-@@ -2034,7 +2043,7 @@ static void touch_up_dirs(struct file_list *flist, int ndx)
+@@ -2036,7 +2047,7 @@ static void touch_up_dirs(struct file_list *flist, int ndx)
                        STRUCT_STAT st;
                        if (link_stat(fname, &st, 0) == 0
                         && cmp_time(st.st_mtime, file->modtime) != 0)
@@ -283,7 +285,7 @@ diff --git a/rsync.c b/rsync.c
        mode_t new_mode = file->mode;
        int inherit;
  
-@@ -496,22 +497,40 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
+@@ -543,22 +544,40 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
                set_xattr(fname, file, fnamecmp, sxp);
  #endif
  
@@ -327,7 +329,7 @@ diff --git a/rsync.c b/rsync.c
 +              }
        }
  
-       change_uid = am_root && uid_ndx && sxp->st.st_uid != (uid_t)F_OWNER(file);
+ #ifdef SUPPORT_ACLS
 @@ -662,7 +681,7 @@ int finish_transfer(const char *fname, const char *fnametmp,
  
        /* Change permissions before putting the file into place. */
@@ -520,27 +522,47 @@ new file mode 100644
 +
 +# The script would have aborted on error, so getting here means we've won.
 +exit 0
+diff --git a/testsuite/daemon.test b/testsuite/daemon.test
+--- a/testsuite/daemon.test
++++ b/testsuite/daemon.test
+@@ -27,7 +27,7 @@ outfile="$scratchdir/rsync.out"
+ SSH="src/support/lsh.sh --no-cd"
+ FILE_REPL='s/^\([^d][^ ]*\) *\(..........[0-9]\) /\1 \2 /'
+ DIR_REPL='s/^\(d[^ ]*\)  *[0-9][.,0-9]* /\1         DIR /'
+-LS_REPL='s;[0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9];####/##/## ##:##:##;'
++LS_REPL='s;[0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9] ;####/##/## ##:##:## ;'
+ build_rsyncd_conf
 diff --git a/testsuite/rsync.fns b/testsuite/rsync.fns
 --- a/testsuite/rsync.fns
 +++ b/testsuite/rsync.fns
-@@ -219,6 +219,10 @@ checkit() {
+@@ -219,6 +219,14 @@ checkit() {
      # We can just write everything to stdout/stderr, because the
      # wrapper hides it unless there is a problem.
  
-+    if test x$TLS_ARGS = x--atimes; then
++    case "x$TLS_ARGS" in
++    *--atimes*)
 +      ( cd "$2" && rsync_ls_lR . ) > "$tmpdir/ls-from"
-+    fi
++      ;;
++    *)
++      ;;
++    esac
 +
      echo "Running: \"$1\""  
      eval "$1" 
      status=$?
-@@ -226,10 +230,13 @@ checkit() {
+@@ -226,10 +234,17 @@ checkit() {
        failed="$failed status=$status"
      fi
  
-+    if test x$TLS_ARGS != x--atimes; then
++    case "x$TLS_ARGS" in
++    *--atimes*)
++      ;;
++    *)
 +      ( cd "$2" && rsync_ls_lR . ) > "$tmpdir/ls-from"
-+    fi
++      ;;
++    esac
 +
      echo "-------------"
      echo "check how the directory listings compare with diff:"
@@ -561,7 +583,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",
-@@ -116,12 +118,37 @@ static void failed(char const *what, char const *where)
+@@ -116,13 +118,38 @@ static void failed(char const *what, char const *where)
        exit(1);
  }
  
@@ -579,14 +601,13 @@ diff --git a/tls.c b/tls.c
 +                      (int)mt->tm_hour,
 +                      (int)mt->tm_min,
 +                      (int)mt->tm_sec);
-+              if (nsecs >= 0) {
-+                      snprintf(datebuf + len, sizeof datebuf - len, ".%09d", nsecs);
-+              }
++              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*nsec_times, (int)sizeof datebuf - 1);
-+              memset(datebuf, ' ', len);
-+              datebuf[len] = '\0';
++              int len = MIN(19 + 9*has_nsecs, (int)destsize - 1);
++              memset(dest, ' ', len);
++              dest[len] = '\0';
 +      }
 +}
 +
@@ -599,8 +620,10 @@ diff --git a/tls.c b/tls.c
 +      char mtimebuf[50];
 +      char atimebuf[50];
        char linkbuf[4096];
++      int nsecs;
  
        if (do_lstat(fname, &buf) < 0)
+               failed("stat", fname);
 @@ -159,30 +186,17 @@ static void list_file(const char *fname)
        }
  
@@ -624,7 +647,7 @@ diff --git a/tls.c b/tls.c
 -                              ".%09d", (int)buf.ST_MTIME_NSEC);
 -              }
 +      if (nsec_times)
-+              nsecs = (int)buf.ST_MTIME_NSEC
++              nsecs = (int)buf.ST_MTIME_NSEC;
 +      else
  #endif
 -      } else {
@@ -669,7 +692,7 @@ diff --git a/tls.c b/tls.c
 diff --git a/util.c b/util.c
 --- a/util.c
 +++ b/util.c
-@@ -116,20 +116,24 @@ void print_child_argv(const char *prefix, char **cmd)
+@@ -117,20 +117,24 @@ void print_child_argv(const char *prefix, char **cmd)
  
  /* This returns 0 for success, 1 for a symlink if symlink time-setting
   * is not possible, or -1 for any other error. */
@@ -698,7 +721,7 @@ diff --git a/util.c b/util.c
                        break;
                if (errno != ENOSYS)
                        return -1;
-@@ -139,7 +143,7 @@ int set_modtime(const char *fname, time_t modtime, uint32 mod_nsec, mode_t mode)
+@@ -140,7 +144,7 @@ int set_modtime(const char *fname, time_t modtime, uint32 mod_nsec, mode_t mode)
  
  #ifdef HAVE_LUTIMES
  #include "case_N.h"
@@ -707,7 +730,7 @@ diff --git a/util.c b/util.c
                        break;
                if (errno != ENOSYS)
                        return -1;
-@@ -158,10 +162,10 @@ int set_modtime(const char *fname, time_t modtime, uint32 mod_nsec, mode_t mode)
+@@ -159,10 +163,10 @@ int set_modtime(const char *fname, time_t modtime, uint32 mod_nsec, mode_t mode)
  
  #include "case_N.h"
  #ifdef HAVE_UTIMES