From 7e5137f3727919acc04d8fad75ad60fdffe6308d Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 10 Sep 2003 00:45:22 +0000 Subject: [PATCH] Make vnode times on /kern/boottime be the boot time, not "now". Handy because ls(1) helpfully converts the time to human-readable format when printing, and because shell tools like "test -nt" and "find -newer" can be used against it. "Inspired" by a discussion about removing lockfiles older than the last reboot, and Al Crooks' handy observation that a close approximation can be found with /var/run/dmesg.boot While here, notice that a lot of the kernfs structures and naming changed suddenly, and though it seems a clear improvement, there was no mention in commit logs. --- sys/miscfs/kernfs/kernfs_vnops.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sys/miscfs/kernfs/kernfs_vnops.c b/sys/miscfs/kernfs/kernfs_vnops.c index 75ec01dda5ef..f7955348f080 100644 --- a/sys/miscfs/kernfs/kernfs_vnops.c +++ b/sys/miscfs/kernfs/kernfs_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: kernfs_vnops.c,v 1.91 2003/09/08 10:54:14 itojun Exp $ */ +/* $NetBSD: kernfs_vnops.c,v 1.92 2003/09/10 00:45:22 dan Exp $ */ /* * Copyright (c) 1992, 1993 @@ -39,7 +39,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.91 2003/09/08 10:54:14 itojun Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.92 2003/09/10 00:45:22 dan Exp $"); #ifdef _KERNEL_OPT #include "opt_ipsec.h" @@ -650,11 +650,17 @@ kernfs_getattr(v) vap->va_size = 0; vap->va_blocksize = DEV_BSIZE; /* - * Make all times be current TOD. Avoid microtime(9), it's slow. + * Make all times be current TOD, except for the "boottime" node. + * Avoid microtime(9), it's slow. * We don't guard the read from time(9) with splclock(9) since we * don't actually need to be THAT sure the access is atomic. */ - TIMEVAL_TO_TIMESPEC(&time, &vap->va_ctime); + if (kfs->kfs_kt->kt_namlen == 8 && + !memcmp(kfs->kfs_kt->kt_name, "boottime", 8)) { + TIMEVAL_TO_TIMESPEC(&boottime, &vap->va_ctime); + } else { + TIMEVAL_TO_TIMESPEC(&time, &vap->va_ctime); + } vap->va_atime = vap->va_mtime = vap->va_ctime; vap->va_gen = 0; vap->va_flags = 0;