- Changed the name of the option to --atimes to more closely match
[rsync/rsync-patches.git] / atimes.diff
1 After applying this patch and running configure, you MUST run this
2 command before "make":
3
4     make proto
5
6
7 --- orig/batch.c        2005-04-09 18:00:28
8 +++ batch.c     2004-07-03 20:15:41
9 @@ -208,6 +208,8 @@ void show_flist(int index, struct file_s
10                 rprintf(FINFO, "flist->flags=%#x\n", fptr[i]->flags);
11                 rprintf(FINFO, "flist->modtime=%#lx\n",
12                         (long unsigned) fptr[i]->modtime);
13 +               rprintf(FINFO, "flist->atime=%#lx\n",
14 +                       (long unsigned) fptr[i]->atime);
15                 rprintf(FINFO, "flist->length=%.0f\n",
16                         (double) fptr[i]->length);
17                 rprintf(FINFO, "flist->mode=%#o\n", (int) fptr[i]->mode);
18 --- orig/flist.c        2005-07-27 23:31:12
19 +++ flist.c     2005-07-28 00:16:34
20 @@ -50,6 +50,7 @@ extern int preserve_perms;
21  extern int preserve_devices;
22  extern int preserve_uid;
23  extern int preserve_gid;
24 +extern int preserve_atimes;
25  extern int relative_paths;
26  extern int implied_dirs;
27  extern int copy_links;
28 @@ -141,16 +142,18 @@ static void list_file_entry(struct file_
29  
30  #ifdef SUPPORT_LINKS
31         if (preserve_links && S_ISLNK(f->mode)) {
32 -               rprintf(FINFO, "%s %11.0f %s %s -> %s\n",
33 +               rprintf(FINFO, "%s %11.0f %s %s %s -> %s\n",
34                         perms,
35                         (double)f->length, timestring(f->modtime),
36 +                       timestring(f->atime),
37                         safe_fname(f_name(f)), safe_fname(f->u.link));
38         } else
39  #endif
40         {
41 -               rprintf(FINFO, "%s %11.0f %s %s\n",
42 +               rprintf(FINFO, "%s %11.0f %s %s %s\n",
43                         perms,
44                         (double)f->length, timestring(f->modtime),
45 +                       timestring(f->atime),
46                         safe_fname(f_name(f)));
47         }
48  }
49 @@ -314,6 +317,7 @@ void send_file_entry(struct file_struct 
50  {
51         unsigned short flags;
52         static time_t modtime;
53 +       static time_t atime;
54         static mode_t mode;
55         static int64 dev;
56         static dev_t rdev;
57 @@ -329,7 +333,7 @@ void send_file_entry(struct file_struct 
58  
59         if (!file) {
60                 write_byte(f, 0);
61 -               modtime = 0, mode = 0;
62 +               modtime = 0, atime = 0, mode = 0;
63                 dev = 0, rdev = makedev(0, 0);
64                 rdev_major = 0;
65                 uid = 0, gid = 0;
66 @@ -378,6 +382,12 @@ void send_file_entry(struct file_struct 
67                 flags |= XMIT_SAME_TIME;
68         else
69                 modtime = file->modtime;
70 +       if (preserve_atimes && !S_ISDIR(mode)) {
71 +               if (file->atime == atime)
72 +                       flags |= XMIT_SAME_ATIME;
73 +               else
74 +                       atime = file->atime;
75 +       }
76  
77  #ifdef SUPPORT_HARD_LINKS
78         if (file->link_u.idev) {
79 @@ -433,6 +443,8 @@ void send_file_entry(struct file_struct 
80                 write_int(f, modtime);
81         if (!(flags & XMIT_SAME_MODE))
82                 write_int(f, to_wire_mode(mode));
83 +       if (preserve_atimes && !S_ISDIR(mode) && !(flags & XMIT_SAME_ATIME))
84 +               write_int(f, atime);
85         if (preserve_uid && !(flags & XMIT_SAME_UID)) {
86                 if (!numeric_ids)
87                         add_uid(uid);
88 @@ -506,6 +518,7 @@ static struct file_struct *receive_file_
89                                               unsigned short flags, int f)
90  {
91         static time_t modtime;
92 +       static time_t atime;
93         static mode_t mode;
94         static int64 dev;
95         static dev_t rdev;
96 @@ -524,7 +537,7 @@ static struct file_struct *receive_file_
97         struct file_struct *file;
98  
99         if (!flist) {
100 -               modtime = 0, mode = 0;
101 +               modtime = 0, atime = 0, mode = 0;
102                 dev = 0, rdev = makedev(0, 0);
103                 rdev_major = 0;
104                 uid = 0, gid = 0;
105 @@ -580,6 +593,8 @@ static struct file_struct *receive_file_
106                 modtime = (time_t)read_int(f);
107         if (!(flags & XMIT_SAME_MODE))
108                 mode = from_wire_mode(read_int(f));
109 +       if (preserve_atimes && !S_ISDIR(mode) && !(flags & XMIT_SAME_ATIME))
110 +               atime = (time_t)read_int(f);
111  
112         if (preserve_uid && !(flags & XMIT_SAME_UID))
113                 uid = (uid_t)read_int(f);
114 @@ -630,6 +645,7 @@ static struct file_struct *receive_file_
115  
116         file->flags = 0;
117         file->modtime = modtime;
118 +       file->atime = atime;
119         file->length = file_length;
120         file->mode = mode;
121         file->uid = uid;
122 @@ -882,6 +898,7 @@ skip_filters:
123  
124         file->flags = flags;
125         file->modtime = st.st_mtime;
126 +       file->atime = st.st_atime;
127         file->length = st.st_size;
128         file->mode = st.st_mode;
129         file->uid = st.st_uid;
130 --- orig/generator.c    2005-07-27 23:31:12
131 +++ generator.c 2005-07-28 00:14:43
132 @@ -44,6 +44,7 @@ extern int preserve_uid;
133  extern int preserve_gid;
134  extern int preserve_times;
135  extern int omit_dir_times;
136 +extern int preserve_atimes;
137  extern int delete_before;
138  extern int delete_during;
139  extern int delete_after;
140 @@ -323,9 +324,21 @@ void itemize(struct file_struct *file, i
141                             : S_ISDIR(file->mode) ? !omit_dir_times
142                             : !S_ISLNK(file->mode);
143  
144 +                       if (iflags & (ITEM_TRANSFER|ITEM_LOCAL_CHANGE) && !keep_time
145 +                            && (!(iflags & ITEM_XNAME_FOLLOWS) || *xname)) {
146 +                               iflags |= ITEM_REPORT_TIME;
147 +                               if (!preserve_atimes && !S_ISDIR(file->mode))
148 +                                       iflags |= ITEM_REPORT_ATIME;
149 +                       } else {
150 +                               if (keep_time && cmp_time(file->modtime, st->st_mtime) != 0)
151 +                                       iflags |= ITEM_REPORT_TIME;
152 +                               if (preserve_atimes && !S_ISDIR(file->mode)
153 +                                && cmp_time(file->atime, st->st_atime) != 0)
154 +                                       iflags |= ITEM_REPORT_ATIME;
155 +                       }
156                         if ((iflags & (ITEM_TRANSFER|ITEM_LOCAL_CHANGE) && !keep_time
157                              && (!(iflags & ITEM_XNAME_FOLLOWS) || *xname))
158 -                           || (keep_time && cmp_modtime(file->modtime, st->st_mtime) != 0))
159 +                           || (keep_time && cmp_time(file->modtime, st->st_mtime) != 0))
160                                 iflags |= ITEM_REPORT_TIME;
161                         if (preserve_perms
162                          && (file->mode & CHMOD_BITS) != (st->st_mode & CHMOD_BITS))
163 @@ -377,7 +390,7 @@ static int unchanged_file(char *fn, stru
164         if (ignore_times)
165                 return 0;
166  
167 -       return cmp_modtime(st->st_mtime, file->modtime) == 0;
168 +       return cmp_time(st->st_mtime, file->modtime) == 0;
169  }
170  
171  
172 @@ -530,7 +543,7 @@ static int find_fuzzy(struct file_struct
173                 name = fp->basename;
174  
175                 if (fp->length == file->length
176 -                   && cmp_modtime(fp->modtime, file->modtime) == 0) {
177 +                   && cmp_time(fp->modtime, file->modtime) == 0) {
178                         if (verbose > 4) {
179                                 rprintf(FINFO,
180                                         "fuzzy size/modtime match for %s\n",
181 @@ -851,7 +864,7 @@ static void recv_generator(char *fname, 
182         }
183  
184         if (update_only && statret == 0
185 -           && cmp_modtime(st.st_mtime, file->modtime) > 0) {
186 +           && cmp_time(st.st_mtime, file->modtime) > 0) {
187                 if (verbose > 1)
188                         rprintf(FINFO, "%s is newer\n", safe_fname(fname));
189                 return;
190 --- orig/log.c  2005-06-10 21:33:28
191 +++ log.c       2005-07-28 00:22:30
192 @@ -38,6 +38,7 @@ extern int module_id;
193  extern int msg_fd_out;
194  extern int protocol_version;
195  extern int preserve_times;
196 +extern int preserve_atimes;
197  extern int log_format_has_o_or_i;
198  extern int daemon_log_format_has_o_or_i;
199  extern char *auth_user;
200 @@ -501,11 +502,14 @@ static void log_formatted(enum logcode c
201                         n[4] = !(iflags & ITEM_REPORT_TIME) ? '.'
202                              : !preserve_times || IS_DEVICE(file->mode)
203                                                || S_ISLNK(file->mode) ? 'T' : 't';
204 -                       n[5] = !(iflags & ITEM_REPORT_PERMS) ? '.' : 'p';
205 -                       n[6] = !(iflags & ITEM_REPORT_OWNER) ? '.' : 'o';
206 -                       n[7] = !(iflags & ITEM_REPORT_GROUP) ? '.' : 'g';
207 -                       n[8] = !(iflags & ITEM_REPORT_XATTRS) ? '.' : 'a';
208 -                       n[9] = '\0';
209 +                       n[5] = !(iflags & ITEM_REPORT_ATIME) ? '.'
210 +                            : !preserve_atimes || IS_DEVICE(file->mode)
211 +                                               || S_ISLNK(file->mode) ? 'A' : 'a';
212 +                       n[6] = !(iflags & ITEM_REPORT_PERMS) ? '.' : 'p';
213 +                       n[7] = !(iflags & ITEM_REPORT_OWNER) ? '.' : 'o';
214 +                       n[8] = !(iflags & ITEM_REPORT_GROUP) ? '.' : 'g';
215 +                       n[9] = !(iflags & ITEM_REPORT_XATTRS) ? '.' : 'a';
216 +                       n[10] = '\0';
217  
218                         if (iflags & (ITEM_IS_NEW|ITEM_MISSING_DATA)) {
219                                 char ch = iflags & ITEM_IS_NEW ? '+' : '?';
220 --- orig/options.c      2005-07-27 23:31:12
221 +++ options.c   2005-07-28 01:00:24
222 @@ -49,6 +49,7 @@ int preserve_uid = 0;
223  int preserve_gid = 0;
224  int preserve_times = 0;
225  int omit_dir_times = 0;
226 +int preserve_atimes = 0;
227  int update_only = 0;
228  int cvs_exclude = 0;
229  int dry_run = 0;
230 @@ -285,8 +286,9 @@ void usage(enum logcode F)
231    rprintf(F," -o, --owner                 preserve owner (root only)\n");
232    rprintf(F," -g, --group                 preserve group\n");
233    rprintf(F," -D, --devices               preserve devices (root only)\n");
234 -  rprintf(F," -t, --times                 preserve times\n");
235 -  rprintf(F," -O, --omit-dir-times        omit directories when preserving times\n");
236 +  rprintf(F," -t, --times                 preserve modify times\n");
237 +  rprintf(F," -O, --omit-dir-times        omit directories when preserving modify times\n");
238 +  rprintf(F," -A, --atimes                preserve access times\n");
239    rprintf(F," -S, --sparse                handle sparse files efficiently\n");
240    rprintf(F," -n, --dry-run               show what would have been transferred\n");
241    rprintf(F," -W, --whole-file            copy files whole (without rsync algorithm)\n");
242 @@ -413,6 +415,7 @@ static struct poptOption long_options[] 
243    {"devices",         'D', POPT_ARG_NONE,   &preserve_devices, 0, 0, 0 },
244    {"times",           't', POPT_ARG_NONE,   &preserve_times, 0, 0, 0 },
245    {"omit-dir-times",  'O', POPT_ARG_VAL,    &omit_dir_times, 2, 0, 0 },
246 +  {"atimes",          'A', POPT_ARG_NONE,   &preserve_atimes, 0, 0, 0 },
247    {"checksum",        'c', POPT_ARG_NONE,   &always_checksum, 0, 0, 0 },
248    {"verbose",         'v', POPT_ARG_NONE,   0, 'v', 0, 0 },
249    {"quiet",           'q', POPT_ARG_NONE,   0, 'q', 0, 0 },
250 @@ -1292,6 +1295,8 @@ void server_options(char **args,int *arg
251                 argstr[x++] = 'D';
252         if (preserve_times)
253                 argstr[x++] = 't';
254 +       if (preserve_atimes)
255 +               argstr[x++] = 'A';
256         if (omit_dir_times == 2 && am_sender)
257                 argstr[x++] = 'O';
258         if (preserve_perms)
259 --- orig/rsync.c        2005-07-27 23:31:12
260 +++ rsync.c     2005-07-28 00:17:37
261 @@ -27,6 +27,7 @@ extern int dry_run;
262  extern int daemon_log_format_has_i;
263  extern int preserve_times;
264  extern int omit_dir_times;
265 +extern int preserve_atimes;
266  extern int am_root;
267  extern int am_server;
268  extern int am_sender;
269 @@ -56,6 +57,7 @@ int set_perms(char *fname,struct file_st
270         int updated = 0;
271         STRUCT_STAT st2;
272         int change_uid, change_gid;
273 +       time_t atime, mtime;
274  
275         if (!st) {
276                 if (dry_run)
277 @@ -70,16 +72,29 @@ int set_perms(char *fname,struct file_st
278  
279         if (!preserve_times || (S_ISDIR(st->st_mode) && omit_dir_times))
280                 flags |= PERMS_SKIP_MTIME;
281 +       if (!preserve_atimes || S_ISDIR(st->st_mode))
282 +               flags |= PERMS_SKIP_ATIME;
283         if (!(flags & PERMS_SKIP_MTIME)
284 -           && cmp_modtime(st->st_mtime, file->modtime) != 0) {
285 -               int ret = set_modtime(fname, file->modtime, st->st_mode);
286 +           && cmp_time(st->st_mtime, file->modtime) != 0) {
287 +               mtime = file->modtime;
288 +               updated = 1;
289 +       } else
290 +               mtime = st->st_mtime;
291 +       if (!(flags & PERMS_SKIP_ATIME)
292 +           && cmp_time(st->st_atime, file->atime) != 0) {
293 +               atime = file->atime;
294 +               updated = 1;
295 +       } else
296 +               atime = st->st_atime;
297 +       if (updated) {
298 +               int ret = set_times(fname, mtime, atime, st->st_mode);
299                 if (ret < 0) {
300                         rsyserr(FERROR, errno, "failed to set times on %s",
301                                 full_fname(fname));
302                         return 0;
303                 }
304 -               if (ret == 0) /* ret == 1 if symlink could not be set */
305 -                       updated = 1;
306 +               if (ret > 0) /* ret == 1 if symlink could not be set */
307 +                       updated = 0;
308         }
309  
310         change_uid = am_root && preserve_uid && st->st_uid != file->uid;
311 --- orig/rsync.h        2005-05-03 17:11:01
312 +++ rsync.h     2005-07-28 00:04:51
313 @@ -54,6 +54,7 @@
314  #define XMIT_HAS_IDEV_DATA (1<<9)
315  #define XMIT_SAME_DEV (1<<10)
316  #define XMIT_RDEV_MINOR_IS_SMALL (1<<11)
317 +#define XMIT_SAME_ATIME (1<<12)
318  
319  /* These flags are used in the live flist data. */
320  
321 @@ -118,6 +119,7 @@
322  
323  #define PERMS_REPORT           (1<<0)
324  #define PERMS_SKIP_MTIME       (1<<1)
325 +#define PERMS_SKIP_ATIME       (1<<2)
326  
327  #define FULL_FLUSH     1
328  #define NORMAL_FLUSH   0
329 @@ -139,6 +141,7 @@
330  #define DEL_TERSE              (1<<3)
331  
332  /* For use by the itemize_changes code */
333 +#define ITEM_REPORT_ATIME (1<<0)
334  #define ITEM_REPORT_CHECKSUM (1<<1)
335  #define ITEM_REPORT_SIZE (1<<2)
336  #define ITEM_REPORT_TIME (1<<3)
337 @@ -509,6 +512,7 @@ struct file_struct {
338                 struct hlink *links;
339         } link_u;
340         time_t modtime;
341 +       time_t atime;
342         uid_t uid;
343         gid_t gid;
344         mode_t mode;
345 --- orig/rsync.yo       2005-07-07 23:11:09
346 +++ rsync.yo    2005-07-28 01:04:09
347 @@ -309,8 +309,9 @@ to the detailed description below for a 
348   -o, --owner                 preserve owner (root only)
349   -g, --group                 preserve group
350   -D, --devices               preserve devices (root only)
351 - -t, --times                 preserve times
352 + -t, --times                 preserve modify times
353   -O, --omit-dir-times        omit directories when preserving times
354 + -A, --atimes                preserve access times
355   -S, --sparse                handle sparse files efficiently
356   -n, --dry-run               show what would have been transferred
357   -W, --whole-file            copy files whole (without rsync algorithm)
358 @@ -648,6 +649,12 @@ it is preserving modification times (see
359  the directories on the receiving side, it is a good idea to use bf(-O).
360  This option is inferred if you use bf(--backup) without bf(--backup-dir).
361  
362 +dit(bf(-A, --atimes)) This tells rsync to set the access times of the
363 +destination files to the same value as the source files.  Note that the
364 +reading of the source file may update the atime of the source files, so
365 +repeated rsync runs with --atimes may be needed if you want to force the
366 +access-time values to be 100% identical on the two systems.
367 +
368  dit(bf(-n, --dry-run)) This tells rsync to not do any file transfers,
369  instead it will just report the actions it would have taken.
370  
371 @@ -1055,7 +1062,7 @@ changes that are being made to each file
372  This is exactly the same as specifying bf(--log-format='%i %n%L').
373  
374  The "%i" escape has a cryptic output that is 9 letters long.  The general
375 -format is like the string bf(UXcstpoga)), where bf(U) is replaced by the
376 +format is like the string bf(UXcstapogx)), where bf(U) is replaced by the
377  kind of update being done, bf(X) is replaced by the file-type, and the
378  other letters represent attributes that may be output if they are being
379  modified.
380 @@ -1094,17 +1101,22 @@ quote(itemize(
381    by the file transfer.
382    it() A bf(t) means the modification time is different and is being updated
383    to the sender's value (requires bf(--times)).  An alternate value of bf(T)
384 -  means that the time will be set to the transfer time, which happens
385 +  means that the modify time will be set to the transfer time, which happens
386    anytime a symlink is transferred, or when a file or device is transferred
387    without bf(--times).
388 +  it() A bf(a) means the access time is different and is being updated to
389 +  the sender's value (requires bf(--atimes)).  An alternate value of bf(A)
390 +  means that the access time  will be set to the transfer time, which happens
391 +  anytime a symlink is transferred, or when a file or device is transferred
392 +  without bf(--atimes).
393    it() A bf(p) means the permissions are different and are being updated to
394    the sender's value (requires bf(--perms)).
395    it() An bf(o) means the owner is different and is being updated to the
396    sender's value (requires bf(--owner) and root privileges).
397    it() A bf(g) means the group is different and is being updated to the
398    sender's value (requires bf(--group) and the authority to set the group).
399 -  it() The bf(a) is reserved for a future enhanced version that supports
400 -  extended file attributes, such as ACLs.
401 +  it() The bf(x) is reserved for a future enhanced version that supports
402 +  extended file attributes.
403  ))
404  
405  One other output is possible:  when deleting files, the "%i" will output
406 --- orig/testsuite/atimes.test  2004-06-30 00:06:23
407 +++ testsuite/atimes.test       2004-06-30 00:06:23
408 @@ -0,0 +1,19 @@
409 +#! /bin/sh
410 +
411 +# Test rsync copying atimes
412 +
413 +. "$suitedir/rsync.fns"
414 +
415 +set -x
416 +
417 +mkdir "$fromdir"
418 +
419 +touch "$fromdir/foo"
420 +touch -a -t 200102031717.42 "$fromdir/foo"
421 +
422 +TLS_ARGS=--atime
423 +
424 +checkit "$RSYNC -rtAgvvv \"$fromdir/\" \"$todir/\"" "$fromdir" "$todir"
425 +
426 +# The script would have aborted on error, so getting here means we've won.
427 +exit 0
428 --- orig/testsuite/itemize.test 2005-07-07 20:35:48
429 +++ testsuite/itemize.test      2005-07-28 00:29:54
430 @@ -44,14 +44,14 @@ ln "$fromdir/foo/config1" "$fromdir/foo/
431  $RSYNC -iplr "$fromdir/" "$todir/" \
432      | tee "$outfile"
433  cat <<EOT >"$chkfile"
434 -cd+++++++ bar/
435 -cd+++++++ bar/baz/
436 ->f+++++++ bar/baz/rsync
437 -cd+++++++ foo/
438 ->f+++++++ foo/config1
439 ->f+++++++ foo/config2
440 ->f+++++++ foo/extra
441 -cL+++++++ foo/sym -> ../bar/baz/rsync
442 +cd++++++++ bar/
443 +cd++++++++ bar/baz/
444 +>f++++++++ bar/baz/rsync
445 +cd++++++++ foo/
446 +>f++++++++ foo/config1
447 +>f++++++++ foo/config2
448 +>f++++++++ foo/extra
449 +cL++++++++ foo/sym -> ../bar/baz/rsync
450  EOT
451  diff $diffopt "$chkfile" "$outfile" || test_fail "test 1 failed"
452  
453 @@ -63,10 +63,10 @@ chmod 601 "$fromdir/foo/config2"
454  $RSYNC -iplrH "$fromdir/" "$todir/" \
455      | tee "$outfile"
456  cat <<EOT >"$chkfile"
457 ->f..T.... bar/baz/rsync
458 ->f..T.... foo/config1
459 ->f.sTp... foo/config2
460 -hf..T.... foo/extra => foo/config1
461 +>f..TA.... bar/baz/rsync
462 +>f..TA.... foo/config1
463 +>f.sTAp... foo/config2
464 +hf..TA.... foo/extra => foo/config1
465  EOT
466  diff $diffopt "$chkfile" "$outfile" || test_fail "test 2 failed"
467  
468 @@ -83,11 +83,11 @@ chmod 777 "$todir/bar/baz/rsync"
469  $RSYNC -iplrtc "$fromdir/" "$todir/" \
470      | tee "$outfile"
471  cat <<EOT >"$chkfile"
472 -.f..tp... bar/baz/rsync
473 -.d..t.... foo/
474 -.f..t.... foo/config1
475 ->fcstp... foo/config2
476 -cL..T.... foo/sym -> ../bar/baz/rsync
477 +.f..t.p... bar/baz/rsync
478 +.d..t..... foo/
479 +.f..t..... foo/config1
480 +>fcst.p... foo/config2
481 +cL..TA.... foo/sym -> ../bar/baz/rsync
482  EOT
483  diff $diffopt "$chkfile" "$outfile" || test_fail "test 3 failed"
484  
485 @@ -112,15 +112,15 @@ $RSYNC -ivvplrtH "$fromdir/" "$todir/" \
486      | tee "$outfile"
487  filter_outfile
488  cat <<EOT >"$chkfile"
489 -.d        ./
490 -.d        bar/
491 -.d        bar/baz/
492 -.f...p... bar/baz/rsync
493 -.d        foo/
494 -.f        foo/config1
495 ->f..t.... foo/config2
496 -hf        foo/extra
497 -.L        foo/sym -> ../bar/baz/rsync
498 +.d         ./
499 +.d         bar/
500 +.d         bar/baz/
501 +.f....p... bar/baz/rsync
502 +.d         foo/
503 +.f         foo/config1
504 +>f..t..... foo/config2
505 +hf         foo/extra
506 +.L         foo/sym -> ../bar/baz/rsync
507  EOT
508  diff $diffopt "$chkfile" "$outfile" || test_fail "test 5 failed"
509  
510 @@ -139,8 +139,8 @@ touch "$todir/foo/config2"
511  $RSYNC -iplrtH "$fromdir/" "$todir/" \
512      | tee "$outfile"
513  cat <<EOT >"$chkfile"
514 -.f...p... foo/config1
515 ->f..t.... foo/config2
516 +.f....p... foo/config1
517 +>f..t..... foo/config2
518  EOT
519  diff $diffopt "$chkfile" "$outfile" || test_fail "test 7 failed"
520  
521 @@ -149,15 +149,15 @@ $RSYNC -ivvplrtH --copy-dest="$lddir" "$
522      | tee "$outfile"
523  filter_outfile
524  cat <<EOT >"$chkfile"
525 -.d..t.... ./
526 -cd+++++++ bar/
527 -cd+++++++ bar/baz/
528 -cf....... bar/baz/rsync
529 -cd+++++++ foo/
530 -cf....... foo/config1
531 -cf....... foo/config2
532 -hf+++++++ foo/extra => foo/config1
533 -cL+++++++ foo/sym -> ../bar/baz/rsync
534 +.d..t..... ./
535 +cd++++++++ bar/
536 +cd++++++++ bar/baz/
537 +cf........ bar/baz/rsync
538 +cd++++++++ foo/
539 +cf........ foo/config1
540 +cf........ foo/config2
541 +hf++++++++ foo/extra => foo/config1
542 +cL++++++++ foo/sym -> ../bar/baz/rsync
543  EOT
544  diff $diffopt "$chkfile" "$outfile" || test_fail "test 8 failed"
545  
546 @@ -165,12 +165,12 @@ rm -rf "$todir"
547  $RSYNC -iplrtH --link-dest="$lddir" "$fromdir/" "$todir/" \
548      | tee "$outfile"
549  cat <<EOT >"$chkfile"
550 -.d..t.... ./
551 -cd+++++++ bar/
552 -cd+++++++ bar/baz/
553 -cd+++++++ foo/
554 -hf+++++++ foo/extra => foo/config1
555 -cL+++++++ foo/sym -> ../bar/baz/rsync
556 +.d..t..... ./
557 +cd++++++++ bar/
558 +cd++++++++ bar/baz/
559 +cd++++++++ foo/
560 +hf++++++++ foo/extra => foo/config1
561 +cL++++++++ foo/sym -> ../bar/baz/rsync
562  EOT
563  diff $diffopt "$chkfile" "$outfile" || test_fail "test 9 failed"
564  
565 --- orig/testsuite/rsync.fns    2005-06-10 21:33:28
566 +++ testsuite/rsync.fns 2005-07-28 00:41:20
567 @@ -50,7 +50,7 @@ printmsg() {
568  
569  
570  rsync_ls_lR() {
571 -    find "$@" -print | sort | sed 's/ /\\ /g' | xargs "$TOOLDIR/tls"
572 +    find "$@" -print | sort | sed 's/ /\\ /g' | xargs "$TOOLDIR/tls" $TLS_ARGS
573  }
574  
575  rsync_getgroups() { 
576 @@ -158,6 +158,10 @@ checkit() {
577      # We can just write everything to stdout/stderr, because the
578      # wrapper hides it unless there is a problem.
579  
580 +    if test x$TLS_ARGS = x--atime; then
581 +       ( cd "$2" && rsync_ls_lR . ) > "$tmpdir/ls-from"
582 +    fi
583 +
584      echo "Running: \"$1\""  
585      eval "$1" 
586      status=$?
587 @@ -165,10 +169,13 @@ checkit() {
588         failed="YES";
589      fi
590  
591 +    if test x$TLS_ARGS != x--atime; then
592 +       ( cd "$2" && rsync_ls_lR . ) > "$tmpdir/ls-from"
593 +    fi
594 +
595      echo "-------------"
596      echo "check how the directory listings compare with diff:"
597      echo ""
598 -    ( cd "$2" && rsync_ls_lR . ) > "$tmpdir/ls-from"
599      ( cd "$3" && rsync_ls_lR . ) > "$tmpdir/ls-to"
600      diff $diffopt "$tmpdir/ls-from" "$tmpdir/ls-to" || failed=YES
601  
602 --- orig/tls.c  2005-01-19 19:30:29
603 +++ tls.c       2005-03-23 17:49:48
604 @@ -39,6 +39,7 @@
605  
606  
607  #include "rsync.h"
608 +#include "popt.h"
609  
610  #define PROGRAM "tls"
611  
612 @@ -48,6 +49,7 @@ int read_only = 1;
613  int list_only = 0;
614  int preserve_perms = 0;
615  
616 +static int display_atime = 0;
617  
618  static void failed(char const *what, char const *where)
619  {
620 @@ -56,14 +58,29 @@ static void failed(char const *what, cha
621         exit(1);
622  }
623  
624 +static void storetime(char *dest, time_t t)
625 +{
626 +       if (t) {
627 +               struct tm *mt = gmtime(&t);
628  
629 +               sprintf(dest, "%04d-%02d-%02d %02d:%02d:%02d ",
630 +                       mt->tm_year + 1900,
631 +                       mt->tm_mon + 1,
632 +                       mt->tm_mday,
633 +                       mt->tm_hour,
634 +                       mt->tm_min,
635 +                       mt->tm_sec);
636 +       } else {
637 +               strcpy(dest, "                    ");
638 +       }
639 +}      
640  
641  static void list_file(const char *fname)
642  {
643         STRUCT_STAT buf;
644         char permbuf[PERMSTRING_SIZE];
645 -       struct tm *mt;
646 -       char datebuf[50];
647 +       char mtimebuf[50];
648 +       char atimebuf[50];
649         char linkbuf[4096];
650  
651         if (do_lstat(fname, &buf) < 0)
652 @@ -96,19 +113,8 @@ static void list_file(const char *fname)
653  
654         permstring(permbuf, buf.st_mode);
655  
656 -       if (buf.st_mtime) {
657 -               mt = gmtime(&buf.st_mtime);
658 -
659 -               sprintf(datebuf, "%04d-%02d-%02d %02d:%02d:%02d",
660 -                       mt->tm_year + 1900,
661 -                       mt->tm_mon + 1,
662 -                       mt->tm_mday,
663 -                       mt->tm_hour,
664 -                       mt->tm_min,
665 -                       mt->tm_sec);
666 -       } else {
667 -               strcpy(datebuf, "                   ");
668 -       }
669 +       storetime(mtimebuf, buf.st_mtime);
670 +       storetime(atimebuf, buf.st_atime);
671  
672         /* TODO: Perhaps escape special characters in fname? */
673  
674 @@ -119,24 +125,55 @@ static void list_file(const char *fname)
675                     (long)minor(buf.st_rdev));
676         } else /* NB: use double for size since it might not fit in a long. */
677                 printf("%12.0f", (double)buf.st_size);
678 -       printf(" %6ld.%-6ld %6ld %s %s%s\n",
679 +       printf(" %6ld.%-6ld %6ld %s%s%s%s\n",
680                (long)buf.st_uid, (long)buf.st_gid, (long)buf.st_nlink,
681 -              datebuf, fname, linkbuf);
682 +              mtimebuf, display_atime && !S_ISDIR(buf.st_mode) ? atimebuf : "",
683 +              fname, linkbuf);
684  }
685  
686 +static struct poptOption long_options[] = {
687 +  /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
688 +  {"atime",           'u', POPT_ARG_NONE,   &display_atime, 0,   0, 0},
689 +  {"help",            'h', POPT_ARG_NONE,   0,              'h', 0, 0},
690 +  {0,0,0,0,0,0,0}
691 +};
692 +
693 +static void tls_usage(int ret)
694 +{
695 +       fprintf(stderr, "usage: " PROGRAM " [--atime | -u] DIR ...\n"
696 +           "Trivial file listing program for portably checking rsync\n");
697 +       exit(ret);
698 +}
699  
700  int
701  main(int argc, char *argv[])
702  {
703 -       if (argc < 2) {
704 -               fprintf(stderr, "usage: " PROGRAM " DIR ...\n"
705 -                       "Trivial file listing program for portably checking rsync\n");
706 -               return 1;
707 +       poptContext pc;
708 +       const char **extra_args;
709 +       int opt;
710 +
711 +       pc = poptGetContext(PROGRAM, argc, (const char **)argv,
712 +                           long_options, 0);
713 +       while ((opt = poptGetNextOpt(pc)) != -1) {
714 +               switch (opt) {
715 +               case 'h':
716 +                       tls_usage(0);
717 +               default:
718 +                       fprintf(stderr,
719 +                               "%s: %s\n",
720 +                               poptBadOption(pc, POPT_BADOPTION_NOALIAS),
721 +                               poptStrerror(opt));
722 +                       tls_usage(1);
723 +               }
724         }
725  
726 -       for (argv++; *argv; argv++) {
727 -               list_file(*argv);
728 -       }
729 +       extra_args = poptGetArgs(pc);
730 +       if (*extra_args == NULL)
731 +               tls_usage(1);
732 +
733 +       for (; *extra_args; extra_args++)
734 +               list_file(*extra_args);
735 +       poptFreeContext(pc);
736  
737         return 0;
738  }
739 --- orig/util.c 2005-07-27 23:31:12
740 +++ util.c      2005-07-27 23:37:27
741 @@ -128,7 +128,7 @@ void overflow_exit(char *str)
742  
743  
744  
745 -int set_modtime(char *fname, time_t modtime, mode_t mode)
746 +int set_times(char *fname, time_t modtime, time_t atime, mode_t mode)
747  {
748  #if !defined HAVE_LUTIMES || !defined HAVE_UTIMES
749         if (S_ISLNK(mode))
750 @@ -136,9 +136,13 @@ int set_modtime(char *fname, time_t modt
751  #endif
752  
753         if (verbose > 2) {
754 -               rprintf(FINFO, "set modtime of %s to (%ld) %s",
755 +               char mtimebuf[200];
756 +
757 +               strlcpy(mtimebuf, timestring(modtime), sizeof mtimebuf);
758 +               rprintf(FINFO,
759 +                       "set modtime, atime of %s to (%ld) %s, (%ld) %s\n",
760                         safe_fname(fname), (long)modtime,
761 -                       asctime(localtime(&modtime)));
762 +                       mtimebuf, (long)atime, timestring(atime));
763         }
764  
765         if (dry_run)
766 @@ -147,7 +151,7 @@ int set_modtime(char *fname, time_t modt
767         {
768  #ifdef HAVE_UTIMES
769                 struct timeval t[2];
770 -               t[0].tv_sec = time(NULL);
771 +               t[0].tv_sec = atime;
772                 t[0].tv_usec = 0;
773                 t[1].tv_sec = modtime;
774                 t[1].tv_usec = 0;
775 @@ -158,12 +162,12 @@ int set_modtime(char *fname, time_t modt
776                 return utimes(fname, t);
777  #elif defined HAVE_UTIMBUF
778                 struct utimbuf tbuf;
779 -               tbuf.actime = time(NULL);
780 +               tbuf.actime = atime;
781                 tbuf.modtime = modtime;
782                 return utime(fname,&tbuf);
783  #elif defined HAVE_UTIME
784                 time_t t[2];
785 -               t[0] = time(NULL);
786 +               t[0] = atime;
787                 t[1] = modtime;
788                 return utime(fname,t);
789  #else
790 @@ -1167,8 +1171,8 @@ int msleep(int t)
791  
792  
793  /**
794 - * Determine if two file modification times are equivalent (either
795 - * exact or in the modification timestamp window established by
796 + * Determine if two file  times are equivalent (either
797 + * exact or in the timestamp window established by
798   * --modify-window).
799   *
800   * @retval 0 if the times should be treated as the same
801 @@ -1177,7 +1181,7 @@ int msleep(int t)
802   *
803   * @retval -1 if the 2nd is later
804   **/
805 -int cmp_modtime(time_t file1, time_t file2)
806 +int cmp_time(time_t file1, time_t file2)
807  {
808         if (file2 > file1) {
809                 if (file2 - file1 <= modify_window)