Fix some WARNS6 regression that crept up in the last days.
[dragonfly.git] / bin / ps / print.c
index a74508a..d5e582c 100644 (file)
@@ -32,7 +32,7 @@
  *
  * @(#)print.c 8.6 (Berkeley) 4/16/94
  * $FreeBSD: src/bin/ps/print.c,v 1.36.2.4 2002/11/30 13:00:14 tjr Exp $
- * $DragonFly: src/bin/ps/print.c,v 1.31 2007/02/18 16:15:23 corecode Exp $
+ * $DragonFly: src/bin/ps/print.c,v 1.34 2008/11/10 14:56:33 swildner Exp $
  */
 
 #include <sys/param.h>
@@ -51,6 +51,7 @@
 #include <locale.h>
 #include <math.h>
 #include <nlist.h>
+#include <pwd.h>
 #include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -182,12 +183,16 @@ state(const KINFO *k, const struct varent *vent)
        case SACTIVE:
                switch (KI_LWP(k, stat)) {
                case LSSLEEP:
-                       if (KI_LWP(k, flags) & LWP_SINTR)       /* interruptable (long) */
+                       if (KI_LWP(k, flags) & LWP_SINTR) {
+                               /* interruptable wait short/long */
                                *cp = KI_LWP(k, slptime) >= MAXSLP ? 'I' : 'S';
+                       }
                        else if (KI_LWP(k, tdflags) & TDF_SINTR)
-                               *cp = 'S';
+                               *cp = 'S';      /* interruptable lwkt wait */
+                       else if (KI_PROC(k, paddr))
+                               *cp = 'D';      /* uninterruptable wait */
                        else
-                               *cp = 'D';
+                               *cp = 'B';      /* uninterruptable lwkt wait */
                        break;
 
                case LSRUN:
@@ -384,15 +389,12 @@ lstarted(const KINFO *k, const struct varent *vent)
 void
 wchan(const KINFO *k, const struct varent *vent)
 {
-       if (KI_LWP(k, wchan)) {
-               if (*KI_LWP(k, wmesg) != '\0')
-                       printf("%-*.*s", vent->width, vent->width,
-                              KI_LWP(k, wmesg));
-               else
-                       printf("%-*lx", vent->width,
-                              (long)KI_LWP(k, wchan));
-       } else
+       if (*KI_LWP(k, wmesg)) {
+               printf("%-*.*s", vent->width, vent->width,
+                      KI_LWP(k, wmesg));
+       } else {
                printf("%-*s", vent->width, "-");
+       }
 }
 
 #ifndef pgtok
@@ -402,7 +404,7 @@ wchan(const KINFO *k, const struct varent *vent)
 void
 vsize(const KINFO *k, const struct varent *vent)
 {
-       printf("%*d", vent->width, (KI_PROC(k, vm_map_size)/1024));
+       printf("%*ju", vent->width, (uintmax_t)(KI_PROC(k, vm_map_size)/1024));
 }
 
 void