_IO_file_underflow_mmap read call for atime

Roland McGrath roland@frob.com
Wed Jul 31 15:16:00 GMT 2002


> The problem is timing.  mmap affects atime, yes, but at the time the 
> mmap happens.  The I/O stream rules require that atime is modified at 
> the time of the first read operation.

The spec gives wide latitude in how mmap can behave.  It allows st_atime to
be updated at any time between mmap and munmap.  But it only requires that
it be updated by the time of the first successful access to a mapped area.

If we assume that the mmap implementations we are using in fact also meet
the stricter criterion of updating st_atime on each read fault, then it is
safe to just use mmap and st_atime will meet the POSIX stdio rules.  I
haven't experimented on Linux, but this is certainly how mmap behaves on
GNU/Hurd.



More information about the Libc-hacker mailing list