This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
What operations set st_amode on a directory?
- From: Tom Brown <sa212+glibc at cyconix dot com>
- To: libc-help <libc-help at sourceware dot org>
- Date: Thu, 22 Oct 2009 23:42:28 +0100
- Subject: What operations set st_amode on a directory?
Is there any specific information on this? My problem is that I have a
lister program that reads and/or sets the access timestamp, and it works
differently on different distributions when operating on a directory.
I've only tried it on Centos 4.4 (2.6.9, glibc 2.3.4) and Fedora 8
(2.6.23, glibc-2.7).
My program uses 'scandir' to step through the contents of a directory,
and 'lstat' to get st_atime for each entry in the directory (excluding
'.' and '..'). It then uses 'lstat' to get st_atime for the directory
itself.
On Centos 4.4, 'scandir' on a directory's contents changes st_atime for
that directory. On F8, it doesn't (although there do seem to be some
circumstances where it can; I haven't got to the bottom of this).
A simpler test is to get st_atime for a directory name, then 'ls' that
directory, and then get st_atime again. For Centos 4.4, the access time
changes to the date at which the 'ls' was carried out; for F8, it
doesn't change.
If this is unspecified or has changed, can someone suggest a way to get
the attributes of a directory tree without changing those attributes? I
can work around this by reading a directory's attributes before
examining the contents of the directory, and then restoring the
attributes afterwards, but this isn't ideal.
Thanks -
Tom