Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Jul 2001 16:43:17 -0700
From:      David Greenman <dg@root.com>
To:        "David E. Cross" <crossd@cs.rpi.edu>
Cc:        Ronald G Minnich <rminnich@lanl.gov>, freebsd-hackers@FreeBSD.ORG
Subject:   Re: exec() doesn't update access time
Message-ID:  <20010725164317.G14981@nexus.root.com>
In-Reply-To: <20010725142519.D14981@nexus.root.com>; from dg@root.com on Wed, Jul 25, 2001 at 02:25:19PM -0700
References:  <rminnich@lanl.gov> <200107252013.QAA00335@cs.rpi.edu> <20010725142519.D14981@nexus.root.com>

next in thread | previous in thread | raw e-mail | index | archive | help
>>Hmm... would it be as easy as
>>VOP_GETATTR();
>>.
>>.
>>.
>>VOP_SETATTR();
>>
>>within the exec() code?
>>
>>Certainly this would be an 'easy' fix (and I can work up diffs for review),
>>but is it the 'correct' fix?
>
>   No, it's not the correct fix. You shouldn't need to do the GETATTR first,
>and doing a SETATTR will cause a synchronous update of the atime, which is
>not what you want. This also doesn't fix that standard case of open/mmap() not
>updating the access time, which is the real problem, not execve.
>   Guessing, I think the correct fix is probably to set the IN_ACCESS flag in
>ufs_open() [and similarly with other filesystems where this makes sense] if
>the filesystem is not mounted with the noatime flag. However, I'm not sure
>of the symantics of the access time in the relavent standards, and I seem
>to recall Bruce saying that it was incorrect to indicate an access on just
>an open(), but I may be mistaken.

   Here is a patch that I just wrote that should implement the above. Please
test and report results (good or bad). :-)

-DG

David Greenman
Co-founder, The FreeBSD Project - http://www.freebsd.org
President, TeraSolutions, Inc. - http://www.terasolutions.com
Pave the road of life with opportunities.

Index: ufs_vnops.c
===================================================================
RCS file: /home/ncvs/src/sys/ufs/ufs/ufs_vnops.c,v
retrieving revision 1.131.2.3
diff -c -r1.131.2.3 ufs_vnops.c
*** ufs_vnops.c	2001/02/26 04:23:21	1.131.2.3
--- ufs_vnops.c	2001/07/25 23:52:38
***************
*** 249,255 ****
  /*
   * Open called.
   *
!  * Nothing to do.
   */
  /* ARGSUSED */
  int
--- 249,255 ----
  /*
   * Open called.
   *
!  * Update last accessed time.
   */
  /* ARGSUSED */
  int
***************
*** 261,273 ****
  		struct proc *a_p;
  	} */ *ap;
  {
  
  	/*
  	 * Files marked append-only must be opened for appending.
  	 */
! 	if ((VTOI(ap->a_vp)->i_flags & APPEND) &&
  	    (ap->a_mode & (FWRITE | O_APPEND)) == FWRITE)
  		return (EPERM);
  	return (0);
  }
  
--- 261,280 ----
  		struct proc *a_p;
  	} */ *ap;
  {
+ 	struct inode *ip;
  
+ 	ip = VTOI(ap->a_vp);
  	/*
  	 * Files marked append-only must be opened for appending.
  	 */
! 	if ((ip->i_flags & APPEND) &&
  	    (ap->a_mode & (FWRITE | O_APPEND)) == FWRITE)
  		return (EPERM);
+ 	/*
+ 	 * Update file access time.
+ 	 */
+ 	if ((ap->a_vp->v_mount->mnt_flag & MNT_NOATIME) == 0)
+ 		ip->i_flag |= IN_ACCESS;
  	return (0);
  }
  

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010725164317.G14981>