diff options
author | dds <dds@FreeBSD.org> | 2005-10-04 14:58:58 +0000 |
---|---|---|
committer | dds <dds@FreeBSD.org> | 2005-10-04 14:58:58 +0000 |
commit | c066055957e1588955fe5f38460fb13c800e433b (patch) | |
tree | 82685873578b707cf6eb13849ba4c48bb438c702 /sys | |
parent | 71fe27e3b4164e796087695b0b97508a6c2da3c8 (diff) | |
download | FreeBSD-src-c066055957e1588955fe5f38460fb13c800e433b.zip FreeBSD-src-c066055957e1588955fe5f38460fb13c800e433b.tar.gz |
Update the vnode's access time after an mmap operation on it.
Before this change a copy operation with cp(1) would not update the
file access times.
According to the POSIX mmap(2) documentation: the st_atime field
of the mapped file may be marked for update at any time between the
mmap() call and the corresponding munmap() call. The initial read
or write reference to a mapped region shall cause the file's st_atime
field to be marked for update if it has not already been marked for
update.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/vm/vm_mmap.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index 7c9e56d..ab3349e 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -1164,6 +1164,18 @@ vm_mmap_vnode(struct thread *td, vm_size_t objsize, } *objp = obj; *flagsp = flags; + + /* Update access time. */ + if ((vp->v_mount->mnt_flag & MNT_NOATIME) == 0) { + struct vattr vattr; + struct timespec ts; + + VATTR_NULL(&vattr); + vfs_timestamp(&ts); + vattr.va_atime = ts; + (void)VOP_SETATTR(vp, &vattr, td->td_ucred, td); + + } done: vput(vp); VFS_UNLOCK_GIANT(vfslocked); |