Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-6]: src/usr.bin/vmstat Pull up revision 1.105 (requested by nat...



details:   https://anonhg.NetBSD.org/src/rev/e730aa9b9da1
branches:  netbsd-1-6
changeset: 529762:e730aa9b9da1
user:      he <he%NetBSD.org@localhost>
date:      Thu Dec 12 22:12:09 2002 +0000

description:
Pull up revision 1.105 (requested by nathanw in ticket #999):
  In getuptime(), use kread() instead of time(3) to get the
  current time and boottime.  This makes rate calculations
  of crash dumps sensible.

diffstat:

 usr.bin/vmstat/vmstat.c |  15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diffs (48 lines):

diff -r e72c059da6d8 -r e730aa9b9da1 usr.bin/vmstat/vmstat.c
--- a/usr.bin/vmstat/vmstat.c   Thu Dec 12 22:08:30 2002 +0000
+++ b/usr.bin/vmstat/vmstat.c   Thu Dec 12 22:12:09 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.100.2.1 2002/06/30 05:47:55 lukem Exp $ */
+/* $NetBSD: vmstat.c,v 1.100.2.2 2002/12/12 22:12:09 he Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001 The NetBSD Foundation, Inc.
@@ -81,7 +81,7 @@
 #if 0
 static char sccsid[] = "@(#)vmstat.c   8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.100.2.1 2002/06/30 05:47:55 lukem Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.100.2.2 2002/12/12 22:12:09 he Exp $");
 #endif
 #endif /* not lint */
 
@@ -168,7 +168,9 @@
        { "_pool_head" },
 #define        X_UVMEXP        12
        { "_uvmexp" },
-#define        X_END           13
+#define        X_TIME          13
+       { "_time" },
+#define        X_END           14
 #if defined(pc532)
 #define        X_IVT           (X_END)
        { "_ivt" },
@@ -512,14 +514,15 @@
 long
 getuptime(void)
 {
-       static time_t now;
        static struct timeval boottime;
+       struct timeval now, diff;
        time_t uptime;
 
        if (boottime.tv_sec == 0)
                kread(X_BOOTTIME, &boottime, sizeof(boottime));
-       (void)time(&now);
-       uptime = now - boottime.tv_sec;
+       kread(X_TIME, &now, sizeof(now));
+       timersub(&now, &boottime, &diff);
+       uptime = diff.tv_sec;
        if (uptime <= 0 || uptime > 60*60*24*365*10)
                errx(1, "time makes no sense; namelist must be wrong.");
        return (uptime);



Home | Main Index | Thread Index | Old Index