From owner-freebsd-arch@FreeBSD.ORG Sat May 3 17:33:00 2003 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5FC8537B401; Sat, 3 May 2003 17:33:00 -0700 (PDT) Received: from beastie.mckusick.com (beastie.mckusick.com [209.31.233.184]) by mx1.FreeBSD.org (Postfix) with ESMTP id D7AF743F85; Sat, 3 May 2003 17:32:59 -0700 (PDT) (envelope-from mckusick@beastie.mckusick.com) Received: from beastie.mckusick.com (localhost [127.0.0.1]) by beastie.mckusick.com (8.12.8/8.12.3) with ESMTP id h440WvTh015707; Sat, 3 May 2003 17:32:58 -0700 (PDT) (envelope-from mckusick@beastie.mckusick.com) Message-Id: <200305040032.h440WvTh015707@beastie.mckusick.com> To: Bruce Evans , Jens Schweikhardt X-URL: http://WWW.McKusick.COM/ Date: Sat, 03 May 2003 17:32:57 -0700 From: Kirk McKusick cc: arch@FreeBSD.org cc: Brian Buhrow Subject: Access times on executables (kern/25777) X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Kirk McKusick List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 May 2003 00:33:00 -0000 I was asked to review kern/25777 which points out that FreeBSD at some point stopped updating access times on files being executed which is counter to its earlier behavior and to POSIX. I propose that the fix below be put in to restore this behavior. Those concerned with the overhead of the updates can use the "noatimes" mount option to disable it. Comments? Kirk McKusick =-=-=-=-= Index: sys/kern_exec.c =================================================================== RCS file: /usr/ncvs/src/sys/kern/kern_exec.c,v retrieving revision 1.218 diff -c -r1.218 kern_exec.c *** kern_exec.c 1 Apr 2003 01:26:20 -0000 1.218 --- kern_exec.c 4 May 2003 00:26:00 -0000 *************** *** 598,603 **** --- 598,618 ---- exec_setregs(td, imgp->entry_addr, (u_long)(uintptr_t)stack_base, imgp->ps_strings); + /* + * At this point, it counts as an access. + * Ensure that atime gets updated if needed. + */ + if (!(textvp->v_mount->mnt_flag & MNT_NOATIME)) { + struct vattr vattr; + + VATTR_NULL(&vattr); + vfs_timestamp(&vattr.va_atime); + VOP_LEASE(textvp, td, p->p_ucred, LEASE_WRITE); + vn_lock(textvp, LK_EXCLUSIVE | LK_RETRY, td); + (void) VOP_SETATTR(textvp, &vattr, p->p_ucred, td); + VOP_UNLOCK(textvp, 0, td); + } + done1: /* * Free any resources malloc'd earlier that we didn't use.