Are file access times not properly maintained in Mac OS X?

Posted by Ether on Super User See other posts from Super User or by Ether
Published on 2009-12-30T19:52:55Z Indexed on 2010/03/18 16:41 UTC
Read the original article Hit count: 434

I'm trying to determine how file access times are maintained by default in Mac OS X, as I'm trying to diagnose some odd behaviour I'm seeing in a new MBP Unibody (running Snow Leopard, 10.6.2):

The symptoms (drilling down to the specific behaviour that seems to be causing the issue):

  • mutt is unable to switch to mailboxes which have recently received new mail
  • mail is delivered by procmail, which updates the mtime of the mbox folder it is updating, but does not alter the atime (this is how new mail detection works: by comparing atime to mtime)
  • however, both the mtime and atime of the mbox file is getting updated

Through testing, it does not appear that atimes can be set separately in the filesystem:

: [ether@tequila ~]$; touch test
: [ether@tequila ~]$; touch -m -t 200801010000 test2
: [ether@tequila ~]$; touch -a -t 200801010000 test3
: [ether@tequila ~]$; ls -l test*
-rw-------  1 ether  staff  0 Dec 30 11:42 test
-rw-------  1 ether  staff  0 Jan  1  2008 test2
-rw-------  1 ether  staff  0 Dec 30 11:43 test3
: [ether@tequila ~]$; ls -lu test*
-rw-------  1 ether  staff  0 Dec 30 11:42 test
-rw-------  1 ether  staff  0 Dec 30 11:43 test2
-rw-------  1 ether  staff  0 Dec 30 11:43 test3

The test2 file is created with an old mtime, and the atime is set to now (as it is a new file), which is correct. However, test3 is created with an old atime, but is not set properly on the file. To be sure this is not just behaviour seen with new files, let's modify an old file:

: [ether@tequila ~]$; touch -a -t 200801010000 test
: [ether@tequila ~]$; ls -l test
-rw-------  1 ether  staff  0 Dec 30 11:42 test
: [ether@tequila ~]$; ls -lu test
-rw-------  1 ether  staff  0 Dec 30 11:45 test

So it would seem that atimes cannot be set explicitly (it is always reset to "now" when either mtime or atime modifications are submitted).

Is this something inherent to the filesystem itself, is it something that can be changed, or am I totally crazy and looking in the wrong place?

PS. the output of mount is:

: [ether@tequila ~]$; mount
/dev/disk0s2 on / (hfs, local, journaled)
devfs on /dev (devfs, local, nobrowse)
map -hosts on /net (autofs, nosuid, automounted, nobrowse)
map auto_home on /home (autofs, automounted, nobrowse)

...and Disk Utility says that the drive is of type "Mac OS Extended (Journaled)".

© Super User or respective owner

Related posts about filesystems

Related posts about osx