Skip site navigation (1)Skip section navigation (2)
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?= <ache@nagual.ru>
To:        FreeBSD-current <current@freebsd.org>, Bruce Evans <bde@zeta.org.au>
Cc:        jdp@freebsd.org
Subject:   Activate nanoseconds in struct stat: please review!
Message-ID:  <Pine.BSF.3.95.961227124938.1292A-100000@nagual.ru>

next in thread | raw e-mail | index | archive | help
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
<ache@null.net>
http://www.nagual.ru/~ache/




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.95.961227124938.1292A-100000>