Path: utzoo!mnetor!uunet!mcvax!enea!erix!howard From: howard@erix.UUCP (Howard Gayle) Newsgroups: comp.bugs.4bsd Subject: stat(2) man entry & kernel inconsistent Message-ID: <1559@erix.UUCP> Date: 4 Feb 88 07:37:06 GMT Organization: Ericsson Telecom, Stockholm, Sweden Lines: 50 Keywords: access time Summary: write(2) doesn't change a file's access time 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