Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.unix.wizards Subject: Re: BSD vi/view resets inode ctime: why? Message-ID: <5718@mimsy.UUCP> Date: Mon, 9-Mar-87 12:23:14 EST Article-I.D.: mimsy.5718 Posted: Mon Mar 9 12:23:14 1987 Date-Received: Tue, 10-Mar-87 06:32:59 EST References: <4801@brl-adm.ARPA> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 45 In article <4801@brl-adm.ARPA> rex@erebus (Rex Sanders) writes: >Why does 4.2/4.3 BSD vi/view, exited without changing the file, update the >inode change time? (If you saw an earlier answer from me, ignore it. I was suffering from brain rot at the time. I think I cancelled it before it got far. This version is right. I think.) In /usr/src/ucb/ex_io.c, one finds a routine called iostats(). This routine is called just after reading or writing any file. It does this: (void) fsync(io); close(io); In /sys/sys/ufs_syscalls.c, we find fsync(): fp = getinode(uap->fd); if (fp == NULL) return; ip = (struct inode *)fp->f_data; ILOCK(ip); syncip(ip); IUNLOCK(ip); Note that there is no verification that the file is open for writing. (Perhaps this is by design.) In /sys/sys/ufs_inode.c, at the end of syncip(), there is this code: ip->i_flag |= ICHG; iupdat(ip, &time, &time, 1); which sets to `now' the inode change time (and, if the inode has been previously marked, the access and update times). One might argue that this is unnecessary: but I am uncertain. Again, this may be by design. By far the easiest fix is to change vi. In ex_io.c, find the two calls to iostats(), and add a `dosync' parameter, or move the fsync() call to just before the call from the file-writing code. Another possible fix, if it is deemed correct, would be to ensure that (fp->f_flag & FWRITE) != 0. Then vi's fsync() in the read case would silently fail. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) UUCP: seismo!mimsy!chris ARPA/CSNet: chris@mimsy.umd.edu