Index: lib/libc/sys/stat.2 =================================================================== RCS file: /home/dcvs/src/lib/libc/sys/stat.2,v retrieving revision 1.5 diff -u -r1.5 stat.2 --- lib/libc/sys/stat.2 1 May 2008 23:36:43 -0000 1.5 +++ lib/libc/sys/stat.2 21 May 2008 19:31:19 -0000 @@ -123,10 +123,12 @@ .It st_atime Time when file data last accessed. Changed by the +.Xr execve 2 , .Xr mknod 2 , -.Xr utimes 2 -and +.Xr mmap 2 , .Xr read 2 +and +.Xr utimes 2 system calls. .It st_mtime Time when file data last modified. Index: sys/kern/kern_exec.c =================================================================== RCS file: /home/dcvs/src/sys/kern/kern_exec.c,v retrieving revision 1.63 diff -u -r1.63 kern_exec.c --- sys/kern/kern_exec.c 6 Jan 2008 16:55:51 -0000 1.63 +++ sys/kern/kern_exec.c 21 May 2008 15:26:31 -0000 @@ -465,6 +465,9 @@ exec_setregs(imgp->entry_addr, (u_long)(uintptr_t)stack_base, imgp->ps_strings); + /* Set the access time on the vnode */ + vn_mark_atime(imgp->vp, td); + /* Free any previous argument cache */ if (p->p_args && --p->p_args->ar_ref == 0) FREE(p->p_args, M_PARGS); Index: sys/kern/vfs_subr.c =================================================================== RCS file: /home/dcvs/src/sys/kern/vfs_subr.c,v retrieving revision 1.114 diff -u -r1.114 vfs_subr.c --- sys/kern/vfs_subr.c 18 May 2008 05:54:25 -0000 1.114 +++ sys/kern/vfs_subr.c 21 May 2008 15:26:31 -0000 @@ -2114,3 +2114,17 @@ return(0); } +void +vn_mark_atime(struct vnode *vp, struct thread *td) +{ + struct vattr atimeattr; + struct proc *p = td->td_proc; + struct ucred *cred = p ? p->p_ucred : NOCRED; + + if ((vp->v_mount->mnt_flag & (MNT_NOATIME | MNT_RDONLY)) == 0) { + vattr_null(&atimeattr); + vfs_timestamp(&atimeattr.va_atime); + VOP_SETATTR(vp, &atimeattr, cred); + } +} + Index: sys/sys/vnode.h =================================================================== RCS file: /home/dcvs/src/sys/sys/vnode.h,v retrieving revision 1.80 diff -u -r1.80 vnode.h --- sys/sys/vnode.h 18 May 2008 21:47:05 -0000 1.80 +++ sys/sys/vnode.h 21 May 2008 15:26:31 -0000 @@ -520,6 +520,7 @@ int vn_stat (struct vnode *vp, struct stat *sb, struct ucred *cred); cdev_t vn_todev (struct vnode *vp); void vfs_timestamp (struct timespec *); +void vn_mark_atime(struct vnode *vp, struct thread *t); int vn_writechk (struct vnode *vp, struct nchandle *nch); int ncp_writechk(struct nchandle *nch); int vop_stdopen (struct vop_open_args *ap); Index: sys/vm/vm_mmap.c =================================================================== RCS file: /home/dcvs/src/sys/vm/vm_mmap.c,v retrieving revision 1.39 diff -u -r1.39 vm_mmap.c --- sys/vm/vm_mmap.c 30 Apr 2007 07:18:57 -0000 1.39 +++ sys/vm/vm_mmap.c 21 May 2008 15:26:31 -0000 @@ -983,6 +983,7 @@ boolean_t fitit; vm_object_t object; struct vnode *vp = NULL; + struct thread *td = curthread; struct proc *p; objtype_t type; int rv = KERN_SUCCESS; @@ -1064,6 +1065,9 @@ object = vm_pager_allocate(type, handle, objsize, prot, foff); if (object == NULL) return (type == OBJT_DEVICE ? EINVAL : ENOMEM); + /* Set the access time on the vnode */ + vn_mark_atime(handle, td); + docow = MAP_PREFAULT_PARTIAL; }