Subject: bin/34205: vmstat(1) on sparc64 complains "time makes no sense; namelist must be wrong."
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <nakayama@NetBSD.org>
List: netbsd-bugs
Date: 08/15/2006 05:40:00
>Number: 34205
>Category: bin
>Synopsis: vmstat(1) on sparc64 complains "time makes no sense; namelist must be wrong."
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Aug 15 05:40:00 +0000 2006
>Originator: Takeshi Nakayama
>Release: NetBSD 4.0_BETA
>Organization:
>Environment:
System: NetBSD eos 4.0_BETA NetBSD 4.0_BETA (EOS) #0: Tue Aug 15 08:35:41 JST 2006 takeshi@eos:/work/netbsd-4/src/sys/arch/sparc64/compile/EOS sparc64
Architecture: sparc64
Machine: sparc64
>Description:
Kernel variable "time_second" is time_t (which is int on sparc64),
and "tv_sec in struct timeval" is long.
These size are incompatible on LP64 environment, so vmstat gets
bogus value from kernel.
>How-To-Repeat:
Run vmstat(1) on sparc64.
>Fix:
--- usr.bin/vmstat/vmstat.c.orig 2006-07-21 14:26:53.000000000 +0900
+++ usr.bin/vmstat/vmstat.c 2006-08-13 08:59:12.000000000 +0900
@@ -541,11 +541,12 @@
{
static struct timeval boottime;
struct timeval now;
- time_t uptime;
+ time_t nowsec, uptime;
if (boottime.tv_sec == 0)
kread(namelist, X_BOOTTIME, &boottime, sizeof(boottime));
- if (kreadc(namelist, X_TIME_SECOND, &now.tv_sec, sizeof(now))) {
+ if (kreadc(namelist, X_TIME_SECOND, &nowsec, sizeof(nowsec))) {
+ now.tv_sec = nowsec;
now.tv_usec = 0;
} else {
kread(namelist, X_TIME, &now, sizeof(now));