directory atime not preserved by --open-noatime

xolodho xolodho at gmail.com
Mon Feb 7 00:44:32 UTC 2022


Hi.

(using version v3.2.3 on Linux, this might be Linux specific)

I recently noticed that rsync's --open-noatime option does not preserve
directory access times (atime) of the source directories (so they get all
modified), even though it does preserve atime of files within those directories,
the result is rather inconsistent. rsync's manpage says that --open-noatime
preserves files' atime and says nothing about directories so I don't consider
this a bug strictly speaking, however it would be nice if --open-noatime
preserved directories' atime too, at least (in Linux) it seems to be
implementable in theory.

I assume the current behavior is caused by opening directories via opendir(),
which unlike Linux open() does not permit supplying the O_NOATIME flag (nor any
flag at all). however, open() not only can be used for normal files, but also
for directories, even with O_NOATIME. in practice, instead of using opendir(),
one can use the open() + fdopendir() combo, afterwards readdir() can be used on
the DIR pointer as usual. this flag has some extra ownership restrictions (e.g.
from the open (2) linux manpage: "The effective UID of the process matches the
owner UID of the file"), this could trigger an EPERM error which wouldn't happen
if the flag weren't used (while opening a not-owned dir). I don't know how
reasonable it might be to have this implemented in rsync...

xol



More information about the rsync mailing list