From owner-freebsd-current Fri Dec 27 02:13:15 1996 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id CAA13177 for current-outgoing; Fri, 27 Dec 1996 02:13:15 -0800 (PST) Received: from sequent.kiae.su (sequent.kiae.su [193.125.152.6]) by freefall.freebsd.org (8.8.4/8.8.4) with SMTP id CAA13172; Fri, 27 Dec 1996 02:13:07 -0800 (PST) Received: by sequent.kiae.su id AA14985 (5.65.kiae-2 ); Fri, 27 Dec 1996 12:55:51 +0300 Received: by sequent.KIAE.su (UUMAIL/2.0); Fri, 27 Dec 96 12:55:49 +0300 Received: from localhost (nagual.ru [127.0.0.1]) by nagual.ru (8.8.4/8.8.4) with SMTP id MAA01301; Fri, 27 Dec 1996 12:54:21 +0300 (MSK) Date: Fri, 27 Dec 1996 12:54:20 +0300 (MSK) From: =?KOI8-R?Q?=E1=CE=C4=D2=C5=CA_=FE=C5=D2=CE=CF=D7=2C_Andrey_Chernov?= To: FreeBSD-current , Bruce Evans Cc: jdp@freebsd.org Subject: Activate nanoseconds in struct stat: please review! Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-current@freebsd.org X-Loop: FreeBSD.org Precedence: bulk The problem is that st->st_*timespec.tv_nsec is always zero, this patch fix it. *** ufs/ufs/inode.h.orig Fri Sep 20 01:39:32 1996 --- ufs/ufs/inode.h Fri Dec 27 12:31:54 1996 *************** *** 147,169 **** /* * XXX this is too long to be a macro, and isn't used in any time-critical ! * place; in fact it is only used in ufs_vnops.c so it shouldn't be in a ! * header file. */ #define ITIMES(ip, t1, t2) { \ - long tv_sec = time.tv_sec; \ if ((ip)->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE)) { \ (ip)->i_flag |= IN_MODIFIED; \ ! if ((ip)->i_flag & IN_ACCESS) \ ! (ip)->i_atime.tv_sec \ ! = ((t1) == &time ? tv_sec : (t1)->tv_sec); \ if ((ip)->i_flag & IN_UPDATE) { \ ! (ip)->i_mtime.tv_sec \ ! = ((t2) == &time ? tv_sec : (t2)->tv_sec); \ (ip)->i_modrev++; \ } \ if ((ip)->i_flag & IN_CHANGE) \ ! (ip)->i_ctime.tv_sec = tv_sec; \ (ip)->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_UPDATE); \ } \ } --- 147,172 ---- /* * XXX this is too long to be a macro, and isn't used in any time-critical ! * place. */ #define ITIMES(ip, t1, t2) { \ if ((ip)->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE)) { \ + struct timeval *tv, now; \ + int s = splclock(); \ + now = time; \ + splx(s); \ (ip)->i_flag |= IN_MODIFIED; \ ! if ((ip)->i_flag & IN_ACCESS) { \ ! tv = ((t1) == &time) ? &now : (t1); \ ! TIMEVAL_TO_TIMESPEC(tv, &((ip)->i_atime)); \ ! } \ if ((ip)->i_flag & IN_UPDATE) { \ ! tv = ((t2) == &time) ? &now : (t2); \ ! TIMEVAL_TO_TIMESPEC(tv, &((ip)->i_mtime)); \ (ip)->i_modrev++; \ } \ if ((ip)->i_flag & IN_CHANGE) \ ! TIMEVAL_TO_TIMESPEC(&now, &((ip)->i_ctime)); \ (ip)->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_UPDATE); \ } \ } *** ufs/ffs/ffs_inode.c.orig Thu Nov 7 02:55:57 1996 --- ufs/ffs/ffs_inode.c Fri Dec 27 12:38:30 1996 *************** *** 90,96 **** struct buf *bp; struct inode *ip; int error; - time_t tv_sec; ip = VTOI(ap->a_vp); if (ap->a_vp->v_mount->mnt_flag & MNT_RDONLY) { --- 90,95 ---- *************** *** 109,130 **** * same copy of `time'. This is not as good. Some callers forget * to make a copy; others make a copy too early (before the i/o * has completed)... - * - * XXX there should be a function or macro for reading the time - * (e.g., some machines may require splclock()). */ ! tv_sec = time.tv_sec; ! if (ip->i_flag & IN_ACCESS) ! ip->i_atime.tv_sec = ! (ap->a_access == &time ? tv_sec : ap->a_access->tv_sec); ! if (ip->i_flag & IN_UPDATE) { ! ip->i_mtime.tv_sec = ! (ap->a_modify == &time ? tv_sec : ap->a_modify->tv_sec); ! ip->i_modrev++; ! } ! if (ip->i_flag & IN_CHANGE) ! ip->i_ctime.tv_sec = tv_sec; ! ip->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE); fs = ip->i_fs; /* * Ensure that uid and gid are correct. This is a temporary --- 108,116 ---- * same copy of `time'. This is not as good. Some callers forget * to make a copy; others make a copy too early (before the i/o * has completed)... */ ! ITIMES(ip, ap->a_access, ap->a_modify); ! ip->i_flag &= ~IN_MODIFIED; fs = ip->i_fs; /* * Ensure that uid and gid are correct. This is a temporary -- Andrey A. Chernov http://www.nagual.ru/~ache/