This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

atime preservation


Hello all,

A long time ago, someone added O_NOATIME in the glibc documentation: an option 
to open that would avoid changing the atime on read(). More recently, Linux 
2.6.8 implemented this option, and soon tar will support it as 
--preserve-atime=system.

However, O_NOATIME has some limitations, which should be addressed in a future 
version of glibc:

1) There's no way to tell if the kernel supports O_NOATIME or not, and support 
may vary by file or filesystem. It is pretty much impossible, for example, to 
do O_NOATIME on any NFS filesystem. Right now Linux just silently ignores the 
flag, but it would be best if EINVAL is documented as a possible open() 
errno.

2) There is no way to read directories or symlinks without changing atime. 
Through using the Linux open() and getdents() system calls, one can in fact 
read directories without touching their atime. But it would be best if there 
were a documented interface into opendir() to accomplish this end. Similarly, 
there needs to be a version of readlink() that won't touch the atime on the 
link.

To fix these, I propose the following changes. I'm happy to do the coding:
1) open() may return EINVAL if it is passed O_NOATIME and the file does not 
support that flag.
2) new system calls readlinkopt() and opendiropt(), which work like readlink() 
and opendir() but take an extra flag argument, the only flag (at present) 
being O_NOATIME. They set EINVAL if the file is not a symbolic link (for 
readlinkopt()) or does not support a passed flag.

Comments are very much appreciated.

Cheers,

--Ian Turner


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]