From 43634bc5ba08f97710f14d6856e92444a4801a98 Mon Sep 17 00:00:00 2001 From: nathanw Date: Wed, 24 Apr 2002 21:41:22 +0000 Subject: [PATCH] Since kinfo_proc2 has many values that are 64-bit, ps needs to know that they're 64-bit, and grab them out of memory appropriately. Otherwise, big-endian systems get the wrong end of the 64-bit value and lose. Keywords affected: inblk, majflt, minflt, msgrcv, msgsnd, nivcsw, nsigs, nswap, nvcsw, and oublk. --- bin/ps/keyword.c | 24 ++++++++++++------------ bin/ps/print.c | 19 +++++++++++++++++-- bin/ps/ps.h | 4 ++-- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/bin/ps/keyword.c b/bin/ps/keyword.c index c4fd02aff3e8..d790908c8848 100644 --- a/bin/ps/keyword.c +++ b/bin/ps/keyword.c @@ -1,4 +1,4 @@ -/* $NetBSD: keyword.c,v 1.26 2001/01/08 13:20:29 itojun Exp $ */ +/* $NetBSD: keyword.c,v 1.27 2002/04/24 21:41:22 nathanw Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)keyword.c 8.5 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: keyword.c,v 1.26 2001/01/08 13:20:29 itojun Exp $"); +__RCSID("$NetBSD: keyword.c,v 1.27 2002/04/24 21:41:22 nathanw Exp $"); #endif #endif /* not lint */ @@ -97,7 +97,7 @@ VAR var[] = { {"flags", "", "f"}, {"holdcnt", "HOLDCNT", NULL, 0, pvar, 0, POFF(p_holdcnt), INT, "d"}, {"ignored", "", "sigignore"}, - {"inblk", "INBLK", NULL, 0, pvar, 0, POFF(p_uru_inblock), ULONG, "d"}, + {"inblk", "INBLK", NULL, 0, pvar, 0, POFF(p_uru_inblock), UINT64, "ldd"}, {"inblock", "", "inblk"}, {"jobc", "JOBC", NULL, 0, pvar, 0, POFF(p_jobc), SHORT, "d"}, {"ktrace", "KTRACE", NULL, 0, pvar, 0, POFF(p_traceflag), INT, "x"}, @@ -107,20 +107,20 @@ VAR var[] = { {"login", "LOGIN", NULL, LJUST, logname}, {"logname", "", "login"}, {"lstart", "STARTED", NULL, LJUST, lstarted}, - {"majflt", "MAJFLT", NULL, 0, pvar, 0, POFF(p_uru_majflt), ULONG, "d"}, - {"minflt", "MINFLT", NULL, 0, pvar, 0, POFF(p_uru_minflt), ULONG, "d"}, - {"msgrcv", "MSGRCV", NULL, 0, pvar, 0, POFF(p_uru_msgrcv), ULONG, "d"}, - {"msgsnd", "MSGSND", NULL, 0, pvar, 0, POFF(p_uru_msgsnd), ULONG, "d"}, + {"majflt", "MAJFLT", NULL, 0, pvar, 0, POFF(p_uru_majflt), UINT64, "ldd"}, + {"minflt", "MINFLT", NULL, 0, pvar, 0, POFF(p_uru_minflt), UINT64, "ldd"}, + {"msgrcv", "MSGRCV", NULL, 0, pvar, 0, POFF(p_uru_msgrcv), UINT64, "ldd"}, + {"msgsnd", "MSGSND", NULL, 0, pvar, 0, POFF(p_uru_msgsnd), UINT64, "ldd"}, {"ni", "", "nice"}, {"nice", "NI", NULL, 0, pnice}, - {"nivcsw", "NIVCSW", NULL, 0, pvar, 0, POFF(p_uru_nivcsw), ULONG, "d"}, + {"nivcsw", "NIVCSW", NULL, 0, pvar, 0, POFF(p_uru_nivcsw), UINT64, "ldd"}, {"nsignals", "", "nsigs"}, - {"nsigs", "NSIGS", NULL, 0, pvar, 0, POFF(p_uru_nsignals), ULONG, "d"}, - {"nswap", "NSWAP", NULL, 0, pvar, 0, POFF(p_uru_nswap), ULONG, "d"}, - {"nvcsw", "NVCSW", NULL, 0, pvar, 0, POFF(p_uru_nvcsw), ULONG, "d"}, + {"nsigs", "NSIGS", NULL, 0, pvar, 0, POFF(p_uru_nsignals), UINT64, "ldd"}, + {"nswap", "NSWAP", NULL, 0, pvar, 0, POFF(p_uru_nswap), UINT64, "ldd"}, + {"nvcsw", "NVCSW", NULL, 0, pvar, 0, POFF(p_uru_nvcsw), UINT64, "ldd"}, /* XXX */ {"nwchan", "WCHAN", NULL, 0, pvar, 0, POFF(p_wchan), KPTR, "llx"}, - {"oublk", "OUBLK", NULL, 0, pvar, 0, POFF(p_uru_oublock), ULONG, "d"}, + {"oublk", "OUBLK", NULL, 0, pvar, 0, POFF(p_uru_oublock), UINT64, "ldd"}, {"oublock", "", "oublk"}, /* XXX */ {"p_ru", "P_RU", NULL, 0, pvar, 0, POFF(p_ru), KPTR, "llx"}, diff --git a/bin/ps/print.c b/bin/ps/print.c index dbbe13f22215..0e10906e202f 100644 --- a/bin/ps/print.c +++ b/bin/ps/print.c @@ -1,4 +1,4 @@ -/* $NetBSD: print.c,v 1.71 2002/02/21 19:31:03 martin Exp $ */ +/* $NetBSD: print.c,v 1.72 2002/04/24 21:41:22 nathanw Exp $ */ /* * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -74,7 +74,7 @@ #if 0 static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; #else -__RCSID("$NetBSD: print.c,v 1.71 2002/02/21 19:31:03 martin Exp $"); +__RCSID("$NetBSD: print.c,v 1.72 2002/04/24 21:41:22 nathanw Exp $"); #endif #endif /* not lint */ @@ -961,6 +961,15 @@ printval(bp, v, mode) uval &= 0xffffff; vok = VPTR; break; + case INT64: + val = (long long)GET(int64_t); + vok = VSIGN; + break; + case UINT64: + uval = (unsigned long long)CHK_INF127(GET(u_int64_t)); + vok = VUNSIGN; + break; + default: /* nothing... */; } @@ -1081,6 +1090,12 @@ printval(bp, v, mode) (void)asprintf(&obuf, ofmt, width, &buf[i]); } break; + case INT64: + (void)printf(ofmt, width, (long long)GET(int64_t)); + return; + case UINT64: + (void)printf(ofmt, width, (unsigned long long)CHK_INF127(GET(u_int64_t))); + return; default: errx(1, "unknown type %d", v->type); } diff --git a/bin/ps/ps.h b/bin/ps/ps.h index 5aff60ea5759..79d25c7ffb92 100644 --- a/bin/ps/ps.h +++ b/bin/ps/ps.h @@ -1,4 +1,4 @@ -/* $NetBSD: ps.h,v 1.17 2000/06/07 04:58:02 simonb Exp $ */ +/* $NetBSD: ps.h,v 1.18 2002/04/24 21:41:22 nathanw Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -42,7 +42,7 @@ enum type { CHAR, UCHAR, SHORT, USHORT, INT, UINT, LONG, ULONG, KPTR, KPTR24, - INT32, UINT32, SIGLIST + INT32, UINT32, SIGLIST, INT64, UINT64 }; /* Variables. */