howard@erix.UUCP (Howard Gayle) (02/04/88)
The manual entry for stat(2) has this to say about the st_atime field: "Time when file data was last read or modified. Changed by the following system calls: mknod(2), utimes(2), read(2), and write(2)." In fact, write does not change the access time. For example, here's a fragment from rwip() [lines 195-210 of sys_inode.c]: if (rw == UIO_READ) { if (n + on == bsize || uio->uio_offset == ip->i_size) bp->b_flags |= B_AGE; brelse(bp); } else { if ((ip->i_mode&IFMT) == IFDIR) bwrite(bp); else if (n + on == bsize) { bp->b_flags |= B_AGE; bawrite(bp); } else bdwrite(bp); ip->i_flag |= IUPD|ICHG; <<<<<<<< if (u.u_ruid != 0) ip->i_mode &= ~(ISUID|ISGID); } The marked line shows where the modification (IUPD) and change (ICHG) flags, but not the access flag (IACC), are set by a write. Is the bug in the documentation or the kernel? I use access times to search for files that I haven't used in a long time and that are thus candidates for compression, archiving, or removal. I imagine this is the typical use for access times. But what about a file that is frequently written but never read, such as a log file? Does the log file contain vital information in case something goes wrong, or is it just useless statistics? My colleagues and I believe that the kernel does the right thing and that the documentation should be changed. The access time now tells the last time the file was read; this potentially useful information would be lost if the kernel behaved the way the documentation says. When looking for unused files it is always possible to use the maximum of the access and modification times, if that is what is desired. TN/ETX/TX/UMG Howard Gayle Email: howard@erix.ericsson.se.UUCP Telefonaktiebolaget L M Ericsson Phone: +46 8 719 55 65 Ericsson Telecom Telex: 14910 ERIC S S-126 25 Stockholm FAX : +46 8 719 95 98 Sweden
guy@gorodish.Sun.COM (Guy Harris) (02/06/88)
> Is the bug in the documentation or the kernel?
Almost certainly in the documentation. S5R1, S5R3.2, 4.[23]BSD, and a
non-vanilla V7 whose source happens to be lying around all set the modified
time but *not* the accessed time on a "write".
Guy Harris
{ihnp4, decvax, seismo, decwrl, ...}!sun!guy
guy@sun.com