<sigh> I missed that there were a couple other diffs in my tree that were
necessary for building with that change to <sys/sysctl.h>: ps was using
the removed defines for EMULNAMELEN and WMESGLEN.
(This could actually be commited without the other diff: the existing code
is wrong, mixing the old defines with the new structure; it's only by
coincidence that the values line up, so it works everywhere.)
Also, (1) the code tests an array member, which is always true, and (2)
struct kinfo_proc2's p_wmesg is guaranteed to be NUL terminated; that lets
the wchan() function be simplified.
Philip Guenther
Index: bin/ps/keyword.c
===================================================================
RCS file: /cvs/src/bin/ps/keyword.c,v
retrieving revision 1.30
diff -u -p -r1.30 keyword.c
--- bin/ps/keyword.c 14 Feb 2010 00:17:14 -0000 1.30
+++ bin/ps/keyword.c 24 Oct 2010 09:16:26 -0000
@@ -90,7 +90,7 @@ VAR var[] = {
{"cpuid", "CPUID", NULL, 0, pvar, 8, 0, POFF(p_cpuid), UINT64, "lld"},
{"cputime", "", "time"},
{"dsiz", "DSIZ", NULL, 0, dsize, 4},
- {"emul", "EMUL", NULL, LJUST, emulname, EMULNAMELEN},
+ {"emul", "EMUL", NULL, LJUST, emulname, KI_EMULNAMELEN - 1},
{"etime", "", "start"},
{"f", "F", NULL, 0, pvar, 7, 0, POFF(p_flag), INT32, "x"},
{"flags", "", "f"},
@@ -171,7 +171,7 @@ VAR var[] = {
{"usrpri", "", "upr"},
{"vsize", "", "vsz"},
{"vsz", "VSZ", NULL, 0, vsize, 5},
- {"wchan", "WCHAN", NULL, LJUST, wchan, 7},
+ {"wchan", "WCHAN", NULL, LJUST, wchan, KI_WMESGLEN - 1},
{"xstat", "XSTAT", NULL, 0, pvar, 4, 0, POFF(p_xstat), UINT16, "x"},
{""},
};
Index: bin/ps/print.c
===================================================================
RCS file: /cvs/src/bin/ps/print.c,v
retrieving revision 1.46
diff -u -p -r1.46 print.c
--- bin/ps/print.c 14 Feb 2010 00:17:14 -0000 1.46
+++ bin/ps/print.c 24 Oct 2010 09:16:26 -0000
@@ -432,16 +432,7 @@ wchan(const struct kinfo_proc2 *kp, VARE
v = ve->var;
if (kp->p_wchan) {
- int n;
-
- if (kp->p_wmesg) {
- n = min(v->width, WMESGLEN);
- (void)printf("%-*.*s", n, n, kp->p_wmesg);
- if (v->width > n)
- (void)printf("%*s", v->width - n, "");
- } else
- (void)printf("%-*lx", v->width,
- (long)kp->p_wchan &~ KERNBASE);
+ (void)printf("%-*s", (int)v->width, kp->p_wmesg);
} else
(void)printf("%-*s", v->width, "-");
}