Patch to make rsync preserve access times

Martin Pool mbp at
Sat Sep 1 10:59:42 EST 2001

First of all, I agree that this would be a good feature.  It has been
discussed before and for various reasons never merged, but we can
certainly look again.

In fact, there are two related features

 (a) Don't update the atime on source files as they're read, which is
     what people normally ask for.

 (b) Propagate atimes from source to destination.

This patch seems to implement (b) but not (a).  

To some extent this is not so useful, since otherwise the atimes will
be updated on the first run and it will only work the first time you
replicate.  This goes against the goal of rsync to be idempotent on
repeated transfers.

Leaving that aside, the big problem is that trying to preserve access
times on Unix is inherently flaky.  There is no way to open a file
without touching its atime.  You might see this as a security feature,
though not a very good one.

The way GNU tar works around this, if I understand correctly, is to
remember the original atime, and then go back and reset it after
reading.  But there's a bad race here: some other program might also
be accessing it, and so the time ought to be updated.  And of course
this also touches the ctime, which is perhaps not a good tradeoff.  I
don't think there's any good solution possible in userspace.

Arguably Unix/Linux ought to add an open mode O_NOATIME, just as there
is a mount option.  If Linux had that we could certainly use it.
There are still some tricky cases.

At the moment I think unless there is a reliable and consistent way to
do this we should hold off.


More information about the rsync mailing list