[Midnightbsd-cvs] src: usr.bin/systat: merge

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sat Nov 22 13:41:32 EST 2008


Log Message:
-----------
merge

Modified Files:
--------------
    src/usr.bin/systat:
        Makefile (r1.1.1.1 -> r1.2)
        cmdtab.c (r1.1.1.1 -> r1.2)
        convtbl.c (r1.1.1.1 -> r1.2)
        convtbl.h (r1.1.1.2 -> r1.2)
        icmp.c (r1.1.1.1 -> r1.2)
        icmp6.c (r1.1.1.1 -> r1.2)
        ifcmds.c (r1.1.1.1 -> r1.2)
        ifstat.c (r1.1.1.1 -> r1.2)
        iostat.c (r1.1.1.1 -> r1.2)
        ip.c (r1.1.1.1 -> r1.2)
        ip6.c (r1.1.1.1 -> r1.2)
        main.c (r1.1.1.1 -> r1.2)
        mbufs.c (r1.1.1.1 -> r1.2)
        netstat.c (r1.1.1.1 -> r1.2)
        pigs.c (r1.1.1.1 -> r1.2)
        swap.c (r1.1.1.1 -> r1.2)
        systat.1 (r1.2 -> r1.3)
        systat.h (r1.1.1.1 -> r1.2)
        tcp.c (r1.1.1.1 -> r1.2)
        vmstat.c (r1.2 -> r1.3)

-------------- next part --------------
Index: systat.1
===================================================================
RCS file: /home/cvs/src/usr.bin/systat/systat.1,v
retrieving revision 1.2
retrieving revision 1.3
diff -L usr.bin/systat/systat.1 -L usr.bin/systat/systat.1 -u -r1.2 -r1.3
--- usr.bin/systat/systat.1
+++ usr.bin/systat/systat.1
@@ -30,14 +30,14 @@
 .\" SUCH DAMAGE.
 .\"
 .\"	@(#)systat.1	8.2 (Berkeley) 12/30/93
-.\" $FreeBSD: src/usr.bin/systat/systat.1,v 1.44.2.2 2006/03/21 20:49:50 jmg Exp $
+.\" $FreeBSD: src/usr.bin/systat/systat.1,v 1.53 2006/10/12 10:54:34 ru Exp $
 .\"
-.Dd September 9, 1997
+.Dd October 12, 2006
 .Dt SYSTAT 1
 .Os
 .Sh NAME
 .Nm systat
-.Nd display system statistics on a crt
+.Nd display system statistics
 .Sh SYNOPSIS
 .Nm
 .Op Fl display
@@ -301,14 +301,14 @@
 active processes, that is processes that have run in the previous
 twenty seconds.
 The second row reports on memory usage of all processes.
-The first column reports on the number of physical pages
+The first column reports on the number of kilobytes in physical pages
 claimed by processes.
-The second column reports the number of physical pages that
+The second column reports the number of kilobytes in physical pages that
 are devoted to read only text pages.
 The third and fourth columns report the same two figures for
-virtual pages, that is the number of pages that would be
+virtual pages, that is the number of kilobytes in pages that would be
 needed if all processes had all of their pages.
-Finally the last column shows the number of physical pages
+Finally the last column shows the number of kilobytes in physical pages
 on the free list.
 .Pp
 Below the memory display is a list of the
@@ -333,6 +333,13 @@
 the number and percentage of the translations that were
 handled by the per process name translation cache.
 .Pp
+To the right of the name translations display are lines showing
+the number of dirty buffers in the buffer cache (`dtbuf'),
+desired maximum size of vnode cache (`desvn'),
+number of vnodes actually allocated (`numvn'),
+and
+number of allocated vnodes that are free (`frevn').
+.Pp
 At the bottom left is the disk usage display.
 It reports the number of
 kilobytes per transaction, transactions per second, megabytes
@@ -363,33 +370,43 @@
 number of pages transferred per second over the last refresh interval.
 .Pp
 Below the paging statistics is a column of lines regarding the virtual
-memory system which list the average number of
+memory system.
+The first few lines describe,
+in units (except as noted below)
+of pages per second averaged over the sampling interval,
 pages copied on write (`cow'),
 pages zero filled on demand (`zfod'),
-pages optimize zero filled on demand (`ozfod'),
-slow (on-the-fly) zero fills percentage (`%slo-z'),
-pages wired down (`wire'),
-active pages (`act'),
-inactive pages (`inact'),
-pages on the buffer cache queue (`cache'),
-number of free pages (`free'),
+pages optimally zero filled on demand (`ozfod'),
+the ratio of the (average) ozfod / zfod as a percentage (`%ozfod'),
 pages freed by the page daemon (`daefr'),
 pages freed by exiting processes (`prcfr'),
+total pages freed (`totfr'),
 pages reactivated from the free list (`react'),
-times the page daemon was awakened (`pdwak'),
+the average number of
+times per second that the page daemon was awakened (`pdwak'),
 pages analyzed by the page daemon (`pdpgs'),
 and
-intransit blocking page faults (`intrn')
-per second over the refresh interval.
-.Pp
-At the bottom of this column are lines showing the
-amount of memory, in kilobytes, used for the buffer cache (`buf'),
-the number of dirty buffers in the buffer cache (`dirtybuf'),
-desired maximum size of vnode cache (`desiredvnodes') (mostly unused,
-except to size the name cache),
-number of vnodes actually allocated (`numvnodes'),
+in-transit blocking page faults (`intrn').
+Note that the units are special for `%ozfod' and `pdwak'.
+The next few lines describe,
+as amounts of memory in kilobytes,
+pages wired down (`wire'),
+active pages (`act'),
+inactive pages (`inact'),
+pages on the cache queue (`cache'),
 and
-number of allocated vnodes that are free (`freevnodes').
+free pages (`free').
+Note that the values displayed are the current transient ones;
+they are not averages.
+.Pp
+At the bottom of this column is a line showing the
+amount of virtual memory, in kilobytes, mapped into the buffer cache (`buf').
+This statistic is not useful.
+It exists only as a placeholder for the corresponding useful statistic
+(the amount of real memory used to cache disks).
+The most important component of the latter (the amount of real memory
+used by the vm system to cache disks) is not available,
+but can be guessed from the `inact' amount under some system loads.
 .Pp
 Running down the right hand side of the display is a breakdown
 of the interrupts being handled by the system.
@@ -411,8 +428,6 @@
 command is given.
 .It Cm time
 Display statistics averaged over the refresh interval (the default).
-.It Cm want_fd
-Toggle the display of fd devices in the disk usage display.
 .It Cm zero
 Reset running statistics to zero.
 .El
Index: icmp6.c
===================================================================
RCS file: /home/cvs/src/usr.bin/systat/icmp6.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/systat/icmp6.c -L usr.bin/systat/icmp6.c -u -r1.1.1.1 -r1.2
--- usr.bin/systat/icmp6.c
+++ usr.bin/systat/icmp6.c
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 
-__FBSDID("$FreeBSD: src/usr.bin/systat/icmp6.c,v 1.1 2003/08/01 20:28:20 dwmalone Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/systat/icmp6.c,v 1.3 2006/04/30 04:47:23 bde Exp $");
 
 #ifdef lint
 static char sccsid[] = "@(#)mbufs.c	8.1 (Berkeley) 6/6/93";
@@ -64,25 +64,25 @@
 /*-
 --0         1         2         3         4         5         6         7
 --0123456789012345678901234567890123456789012345678901234567890123456789012345
-01          ICMPv6 Input                       ICMPv6 Output
-02999999999 total messages           999999999 total messages
-03999999999 with bad code            999999999 errors generated
-04999999999 with bad length          999999999 suppressed - original too short
-05999999999 with bad checksum        999999999 suppressed - original was ICMP
-06999999999 with insufficient data   999999999 responses sent
-07
-08          Input Histogram                    Output Histogram
-09999999999 echo response            999999999 echo response
-10999999999 echo request             999999999 echo request
-11999999999 destination unreachable  999999999 destination unreachable
-12999999999 redirect                 999999999 redirect
-13999999999 time-to-live exceeded    999999999 time-to-line exceeded
-14999999999 parameter problem        999999999 parameter problem
-15999999999 neighbor solicitation    999999999 neighbor solicitation
-16999999999 neighbor advertisment    999999999 neighbor advertisment
-17999999999 router advertisement     999999999 router solicitation
+00          ICMPv6 Input                       ICMPv6 Output
+01999999999 total messages           999999999 total messages
+02999999999 with bad code            999999999 errors generated
+03999999999 with bad length          999999999 suppressed - original too short
+04999999999 with bad checksum        999999999 suppressed - original was ICMP
+05999999999 with insufficient data   999999999 responses sent
+06
+07          Input Histogram                    Output Histogram
+08999999999 echo response            999999999 echo response
+09999999999 echo request             999999999 echo request
+10999999999 destination unreachable  999999999 destination unreachable
+11999999999 redirect                 999999999 redirect
+12999999999 time-to-live exceeded    999999999 time-to-line exceeded
+13999999999 parameter problem        999999999 parameter problem
+14999999999 neighbor solicitation    999999999 neighbor solicitation
+15999999999 neighbor advertisment    999999999 neighbor advertisment
+16999999999 router advertisement     999999999 router solicitation
+17
 18
-19
 --0123456789012345678901234567890123456789012345678901234567890123456789012345
 --0         1         2         3         4         5         6         7
 */
@@ -90,7 +90,7 @@
 WINDOW *
 openicmp6(void)
 {
-	return (subwin(stdscr, LINES-5-1, 0, 5, 0));
+	return (subwin(stdscr, LINES-3-1, 0, MAINWIN_ROW, 0));
 }
 
 void
@@ -110,24 +110,24 @@
 	wmove(wnd, 0, 0); wclrtoeol(wnd);
 #define L(row, str) mvwprintw(wnd, row, 10, str)
 #define R(row, str) mvwprintw(wnd, row, 45, str);
-	L(1, "ICMPv6 Input");		R(1, "ICMPv6 Output");
-	L(2, "total messages");		R(2, "total messages");
-	L(3, "with bad code");		R(3, "errors generated");
-	L(4, "with bad length");	R(4, "suppressed - original too short");
-	L(5, "with bad checksum");	R(5, "suppressed - original was ICMP");
-	L(6, "with insufficient data");	R(6, "responses sent");
+	L(0, "ICMPv6 Input");		R(0, "ICMPv6 Output");
+	L(1, "total messages");		R(1, "total messages");
+	L(2, "with bad code");		R(2, "errors generated");
+	L(3, "with bad length");	R(3, "suppressed - original too short");
+	L(4, "with bad checksum");	R(4, "suppressed - original was ICMP");
+	L(5, "with insufficient data");	R(5, "responses sent");
 
-	L(8, "Input Histogram");	R(8, "Output Histogram");
+	L(7, "Input Histogram");	R(7, "Output Histogram");
 #define B(row, str) L(row, str); R(row, str)
-	B(9, "echo response");
-	B(10, "echo request");
-	B(11, "destination unreachable");
-	B(12, "redirect");
-	B(13, "time-to-live exceeded");
-	B(14, "parameter problem");
-	B(15, "neighbor solicitation");
-	B(16, "neighbor advertisment");
-	L(17, "router advertisement");	R(17, "router solicitation");
+	B(8, "echo response");
+	B(9, "echo request");
+	B(10, "destination unreachable");
+	B(11, "redirect");
+	B(12, "time-to-live exceeded");
+	B(13, "parameter problem");
+	B(14, "neighbor solicitation");
+	B(15, "neighbor advertisment");
+	L(16, "router advertisement");	R(16, "router solicitation");
 #undef L
 #undef R
 #undef B
@@ -171,7 +171,7 @@
 	}
 #undef DO
 }
-	
+
 void
 showicmp6(void)
 {
@@ -185,34 +185,34 @@
 		totalin += stats.icp6s_inhist[i];
 		totalout += stats.icp6s_outhist[i];
 	}
-	totalin += stats.icp6s_badcode + stats.icp6s_badlen + 
+	totalin += stats.icp6s_badcode + stats.icp6s_badlen +
 		stats.icp6s_checksum + stats.icp6s_tooshort;
-	mvwprintw(wnd, 2, 0, "%9lu", totalin);
-	mvwprintw(wnd, 2, 35, "%9lu", totalout);
+	mvwprintw(wnd, 1, 0, "%9lu", totalin);
+	mvwprintw(wnd, 1, 35, "%9lu", totalout);
 
 #define DO(stat, row, col) \
 	mvwprintw(wnd, row, col, "%9lu", stats.stat)
 
-	DO(icp6s_badcode, 3, 0);
-	DO(icp6s_badlen, 4, 0);
-	DO(icp6s_checksum, 5, 0);
-	DO(icp6s_tooshort, 6, 0);
-	DO(icp6s_error, 3, 35);
-	DO(icp6s_tooshort, 4, 35);
-	DO(icp6s_canterror, 5, 35);
-	DO(icp6s_reflect, 6, 35);
+	DO(icp6s_badcode, 2, 0);
+	DO(icp6s_badlen, 3, 0);
+	DO(icp6s_checksum, 4, 0);
+	DO(icp6s_tooshort, 5, 0);
+	DO(icp6s_error, 2, 35);
+	DO(icp6s_tooshort, 3, 35);
+	DO(icp6s_canterror, 4, 35);
+	DO(icp6s_reflect, 5, 35);
 #define DO2(type, row) DO(icp6s_inhist[type], row, 0); DO(icp6s_outhist[type], \
 							 row, 35)
-	DO2(ICMP6_ECHO_REPLY, 9);
-	DO2(ICMP6_ECHO_REQUEST, 10);
-	DO2(ICMP6_DST_UNREACH, 11);
-	DO2(ND_REDIRECT, 12);
-	DO2(ICMP6_TIME_EXCEEDED, 13);
-	DO2(ICMP6_PARAM_PROB, 14);
-	DO2(ND_NEIGHBOR_SOLICIT, 15);
-	DO2(ND_NEIGHBOR_ADVERT, 16);
-	DO(icp6s_inhist[ND_ROUTER_SOLICIT], 17, 0);
-	DO(icp6s_outhist[ND_ROUTER_ADVERT], 17, 35);
+	DO2(ICMP6_ECHO_REPLY, 8);
+	DO2(ICMP6_ECHO_REQUEST, 9);
+	DO2(ICMP6_DST_UNREACH, 10);
+	DO2(ND_REDIRECT, 11);
+	DO2(ICMP6_TIME_EXCEEDED, 12);
+	DO2(ICMP6_PARAM_PROB, 13);
+	DO2(ND_NEIGHBOR_SOLICIT, 14);
+	DO2(ND_NEIGHBOR_ADVERT, 15);
+	DO(icp6s_inhist[ND_ROUTER_SOLICIT], 16, 0);
+	DO(icp6s_outhist[ND_ROUTER_ADVERT], 16, 35);
 #undef DO
 #undef DO2
 }
Index: convtbl.h
===================================================================
RCS file: /home/cvs/src/usr.bin/systat/convtbl.h,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -L usr.bin/systat/convtbl.h -L usr.bin/systat/convtbl.h -u -r1.1.1.2 -r1.2
--- usr.bin/systat/convtbl.h
+++ usr.bin/systat/convtbl.h
@@ -25,108 +25,35 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/usr.bin/systat/convtbl.h,v 1.2 2004/03/09 11:57:27 dwmalone Exp $
+ * $FreeBSD: src/usr.bin/systat/convtbl.h,v 1.8 2006/11/27 16:33:44 yar Exp $
  */
 
 #ifndef _CONVTBL_H_
 #define _CONVTBL_H_
 
 #include <sys/types.h>
+#include <stdint.h>
 
-#define BITS	(1)
-#define BYTES	(1)
-#define KILO	(1024)
-#define	MEGA	(KILO * 1024)
-#define GIGA	(MEGA * 1024)
-
-#define SC_BYTE		(0)
-#define SC_KILOBYTE	(1)
-#define SC_MEGABYTE	(2)
-#define SC_GIGABYTE	(3)
-#define SC_BIT		(4)
-#define	SC_KILOBIT	(5)
-#define	SC_MEGABIT	(6)
-#define SC_GIGABIT	(7)
-#define SC_AUTO		(8)
-
-#define BIT	(8)
-#define BYTE	(1)
-
-struct convtbl {
-	u_int	 mul;
-	u_int	 scale;
-	const char	*str;
-};
-
-extern	struct convtbl convtbl[];
-
-extern	double 	 convert(const u_long, const u_int);
-extern	const char	*get_string(const u_long, const u_int);
-
-#endif		/* ! _CONVTBL_H_ */
 /*
- * Copyright (c) 2003, Trent Nelson, <trent at arpa.com>.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $Id$
+ * Keep the order in the enum.
  */
-
-#ifndef _CONVTBL_H_
-#define _CONVTBL_H_
-
-#include <sys/types.h>
-
-#define BITS	(1)
-#define BYTES	(1)
-#define KILO	(1024)
-#define	MEGA	(KILO * 1024)
-#define GIGA	(MEGA * 1024)
-
-#define SC_BYTE		(0)
-#define SC_KILOBYTE	(1)
-#define SC_MEGABYTE	(2)
-#define SC_GIGABYTE	(3)
-#define SC_BIT		(4)
-#define	SC_KILOBIT	(5)
-#define	SC_MEGABIT	(6)
-#define SC_GIGABIT	(7)
-#define SC_AUTO		(8)
-
-#define BIT	(8)
-#define BYTE	(1)
-
-struct convtbl {
-	u_int	 mul;
-	u_int	 scale;
-	char	*str;
+enum scale {
+	SC_BYTE,
+	SC_KILOBYTE,
+	SC_MEGABYTE,
+	SC_GIGABYTE,
+	SC_TERABYTE,
+	SC_BIT,
+	SC_KILOBIT,
+	SC_MEGABIT,
+	SC_GIGABIT,
+	SC_TERABIT,
+	SC_AUTO		/* KEEP THIS LAST */
 };
 
-extern	struct convtbl convtbl[];
-
-extern	double 	 convert(const u_long, const u_int);
-extern	char	*get_string(const u_long, const u_int);
+extern	double		 convert(const uintmax_t, const int);
+extern	const char	*get_helplist(void);
+extern	int		 get_scale(const char *);
+extern	const char	*get_string(const uintmax_t, const int);
 
 #endif		/* ! _CONVTBL_H_ */
Index: ip.c
===================================================================
RCS file: /home/cvs/src/usr.bin/systat/ip.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/systat/ip.c -L usr.bin/systat/ip.c -u -r1.1.1.1 -r1.2
--- usr.bin/systat/ip.c
+++ usr.bin/systat/ip.c
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 
-__FBSDID("$FreeBSD: src/usr.bin/systat/ip.c,v 1.5 2001/12/12 00:13:37 markm Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/systat/ip.c,v 1.7 2006/04/30 04:47:23 bde Exp $");
 
 #ifdef lint
 static const char sccsid[] = "@(#)mbufs.c	8.1 (Berkeley) 6/6/93";
@@ -73,25 +73,25 @@
 /*-
 --0         1         2         3         4         5         6         7
 --0123456789012345678901234567890123456789012345678901234567890123456789012345
-01          IP Input                           IP Output
-02999999999 total packets received   999999999 total packets sent
-03999999999 - with bad checksums     999999999 - generated locally
-04999999999 - too short for header   999999999 - output drops
-05999999999 - too short for data     999999999 output fragments generated
-06999999999 - with invalid hlen      999999999 - fragmentation failed
-07999999999 - with invalid length    999999999 destinations unreachable
-08999999999 - with invalid version   999999999 packets output via raw IP
-09999999999 - jumbograms
-10999999999 total fragments received           UDP Statistics
-11999999999 - fragments dropped      999999999 total input packets
-12999999999 - fragments timed out    999999999 - too short for header
-13999999999 - packets reassembled ok 999999999 - invalid checksum
-14999999999 packets forwarded        999999999 - no checksum
-15999999999 - unreachable dests      999999999 - invalid length
-16999999999 - redirects generated    999999999 - no socket for dest port
-17999999999 option errors            999999999 - no socket for broadcast
-18999999999 unwanted multicasts      999999999 - socket buffer full
-19999999999 delivered to upper layer 999999999 total output packets
+00          IP Input                           IP Output
+01999999999 total packets received   999999999 total packets sent
+02999999999 - with bad checksums     999999999 - generated locally
+03999999999 - too short for header   999999999 - output drops
+04999999999 - too short for data     999999999 output fragments generated
+05999999999 - with invalid hlen      999999999 - fragmentation failed
+06999999999 - with invalid length    999999999 destinations unreachable
+07999999999 - with invalid version   999999999 packets output via raw IP
+08999999999 - jumbograms
+09999999999 total fragments received           UDP Statistics
+10999999999 - fragments dropped      999999999 total input packets
+11999999999 - fragments timed out    999999999 - too short for header
+12999999999 - packets reassembled ok 999999999 - invalid checksum
+13999999999 packets forwarded        999999999 - no checksum
+14999999999 - unreachable dests      999999999 - invalid length
+15999999999 - redirects generated    999999999 - no socket for dest port
+16999999999 option errors            999999999 - no socket for broadcast
+17999999999 unwanted multicasts      999999999 - socket buffer full
+18999999999 delivered to upper layer 999999999 total output packets
 --0123456789012345678901234567890123456789012345678901234567890123456789012345
 --0         1         2         3         4         5         6         7
 */
@@ -99,7 +99,7 @@
 WINDOW *
 openip(void)
 {
-	return (subwin(stdscr, LINES-4-1, 0, 4, 0));
+	return (subwin(stdscr, LINES-3-1, 0, MAINWIN_ROW, 0));
 }
 
 void
@@ -119,25 +119,25 @@
 	wmove(wnd, 0, 0); wclrtoeol(wnd);
 #define L(row, str) mvwprintw(wnd, row, 10, str)
 #define R(row, str) mvwprintw(wnd, row, 45, str);
-	L(1, "IP Input");			R(1, "IP Output");
-	L(2, "total packets received");		R(2, "total packets sent");
-	L(3, "- with bad checksums");		R(3, "- generated locally");
-	L(4, "- too short for header");		R(4, "- output drops");
-	L(5, "- too short for data");	R(5, "output fragments generated");
-	L(6, "- with invalid hlen");	R(6, "- fragmentation failed");
-	L(7, "- with invalid length");	R(7, "destinations unreachable");
-	L(8, "- with invalid version");	R(8, "packets output via raw IP");
-	L(9, "- jumbograms");
-	L(10, "total fragments received");	R(10, "UDP Statistics");
-	L(11, "- fragments dropped");	R(11, "total input packets");
-	L(12, "- fragments timed out");	R(12, "- too short for header");
-	L(13, "- packets reassembled ok");	R(13, "- invalid checksum");
-	L(14, "packets forwarded");	R(14, "- no checksum");
-	L(15, "- unreachable dests");	R(15, "- invalid length");
-	L(16, "- redirects generated");	R(16, "- no socket for dest port");
-	L(17, "option errors");		R(17, "- no socket for broadcast");
-	L(18, "unwanted multicasts");	R(18, "- socket buffer full");
-	L(19, "delivered to upper layer");	R(19, "total output packets");
+	L(0, "IP Input");		R(0, "IP Output");
+	L(1, "total packets received");	R(1, "total packets sent");
+	L(2, "- with bad checksums");	R(2, "- generated locally");
+	L(3, "- too short for header");	R(3, "- output drops");
+	L(4, "- too short for data");	R(4, "output fragments generated");
+	L(5, "- with invalid hlen");	R(5, "- fragmentation failed");
+	L(6, "- with invalid length");	R(6, "destinations unreachable");
+	L(7, "- with invalid version");	R(7, "packets output via raw IP");
+	L(8, "- jumbograms");
+	L(9, "total fragments received");	R(9, "UDP Statistics");
+	L(10, "- fragments dropped");	R(10, "total input packets");
+	L(11, "- fragments timed out");	R(11, "- too short for header");
+	L(12, "- packets reassembled ok");	R(12, "- invalid checksum");
+	L(13, "packets forwarded");	R(13, "- no checksum");
+	L(14, "- unreachable dests");	R(14, "- invalid length");
+	L(15, "- redirects generated");	R(15, "- no socket for dest port");
+	L(16, "option errors");		R(16, "- no socket for broadcast");
+	L(17, "unwanted multicasts");	R(17, "- socket buffer full");
+	L(18, "delivered to upper layer");	R(18, "total output packets");
 #undef L
 #undef R
 }
@@ -201,7 +201,7 @@
 	DO(u.udps_opackets);
 #undef DO
 }
-	
+
 void
 showip(void)
 {
@@ -214,40 +214,40 @@
 #define DO(stat, row, col) \
 	mvwprintw(wnd, row, col, "%9lu", stats.stat)
 
-	DO(i.ips_total, 2, 0);
-	mvwprintw(wnd, 2, 35, "%9lu", totalout);
-	DO(i.ips_badsum, 3, 0);
-	DO(i.ips_localout, 3, 35);
-	DO(i.ips_tooshort, 4, 0);
-	DO(i.ips_odropped, 4, 35);
-	DO(i.ips_toosmall, 5, 0);
-	DO(i.ips_ofragments, 5, 35);
-	DO(i.ips_badhlen, 6, 0);
-	DO(i.ips_cantfrag, 6, 35);
-	DO(i.ips_badlen, 7, 0);
-	DO(i.ips_noroute, 7, 35);
-	DO(i.ips_badvers, 8, 0);
-	DO(i.ips_rawout, 8, 35);
-	DO(i.ips_toolong, 9, 0);
-	DO(i.ips_fragments, 10, 0);
-	DO(i.ips_fragdropped, 11, 0);
-	DO(u.udps_ipackets, 11, 35);
-	DO(i.ips_fragtimeout, 12, 0);
-	DO(u.udps_hdrops, 12, 35);
-	DO(i.ips_reassembled, 13, 0);
-	DO(u.udps_badsum, 13, 35);
-	DO(i.ips_forward, 14, 0);
-	DO(u.udps_nosum, 14, 35);
-	DO(i.ips_cantforward, 15, 0);
-	DO(u.udps_badlen, 15, 35);
-	DO(i.ips_redirectsent, 16, 0);
-	DO(u.udps_noport, 16, 35);
-	DO(i.ips_badoptions, 17, 0);
-	DO(u.udps_noportbcast, 17, 35);
-	DO(i.ips_notmember, 18, 0);
-	DO(u.udps_fullsock, 18, 35);
-	DO(i.ips_delivered, 19, 0);
-	DO(u.udps_opackets, 19, 35);
+	DO(i.ips_total, 1, 0);
+	mvwprintw(wnd, 1, 35, "%9lu", totalout);
+	DO(i.ips_badsum, 2, 0);
+	DO(i.ips_localout, 2, 35);
+	DO(i.ips_tooshort, 3, 0);
+	DO(i.ips_odropped, 3, 35);
+	DO(i.ips_toosmall, 4, 0);
+	DO(i.ips_ofragments, 4, 35);
+	DO(i.ips_badhlen, 5, 0);
+	DO(i.ips_cantfrag, 5, 35);
+	DO(i.ips_badlen, 6, 0);
+	DO(i.ips_noroute, 6, 35);
+	DO(i.ips_badvers, 7, 0);
+	DO(i.ips_rawout, 7, 35);
+	DO(i.ips_toolong, 8, 0);
+	DO(i.ips_fragments, 9, 0);
+	DO(i.ips_fragdropped, 10, 0);
+	DO(u.udps_ipackets, 10, 35);
+	DO(i.ips_fragtimeout, 11, 0);
+	DO(u.udps_hdrops, 11, 35);
+	DO(i.ips_reassembled, 12, 0);
+	DO(u.udps_badsum, 12, 35);
+	DO(i.ips_forward, 13, 0);
+	DO(u.udps_nosum, 13, 35);
+	DO(i.ips_cantforward, 14, 0);
+	DO(u.udps_badlen, 14, 35);
+	DO(i.ips_redirectsent, 15, 0);
+	DO(u.udps_noport, 15, 35);
+	DO(i.ips_badoptions, 16, 0);
+	DO(u.udps_noportbcast, 16, 35);
+	DO(i.ips_notmember, 17, 0);
+	DO(u.udps_fullsock, 17, 35);
+	DO(i.ips_delivered, 18, 0);
+	DO(u.udps_opackets, 18, 35);
 #undef DO
 }
 
Index: pigs.c
===================================================================
RCS file: /home/cvs/src/usr.bin/systat/pigs.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/systat/pigs.c -L usr.bin/systat/pigs.c -u -r1.1.1.1 -r1.2
--- usr.bin/systat/pigs.c
+++ usr.bin/systat/pigs.c
@@ -38,7 +38,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/systat/pigs.c,v 1.20 2005/05/02 10:50:10 delphij Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/systat/pigs.c,v 1.24 2007/09/17 05:27:19 jeff Exp $");
 
 /*
  * Pigs display from Bill Reeves at Lucasfilm
@@ -66,14 +66,13 @@
 	struct kinfo_proc *pt_kp;
 } *pt;
 
-static long stime[CPUSTATES];
 static int    fscale;
 static double  lccpu;
 
 WINDOW *
 openpigs()
 {
-	return (subwin(stdscr, LINES-5-1, 0, 5, 0));
+	return (subwin(stdscr, LINES-3-1, 0, MAINWIN_ROW, 0));
 }
 
 void
@@ -92,45 +91,27 @@
 showpigs()
 {
 	register int i, j, y, k;
-	float total;
-	int factor;
 	const char *uname, *pname;
 	char pidname[30];
 
 	if (pt == NULL)
 		return;
-	/* Accumulate the percent of cpu per user. */
-	total = 0.0;
-	for (i = 0; i <= nproc; i++) {
-		/* Accumulate the percentage. */
-		total += pt[i].pt_pctcpu;
-	}
-
-	if (total < 1.0)
- 		total = 1.0;
-	factor = 50.0/total;
 
-        qsort(pt, nproc + 1, sizeof (struct p_times), compar);
+	qsort(pt, nproc, sizeof (struct p_times), compar);
 	y = 1;
-	i = nproc + 1;
+	i = nproc;
 	if (i > wnd->_maxy-1)
 		i = wnd->_maxy-1;
 	for (k = 0; i > 0 && pt[k].pt_pctcpu > 0.01; i--, y++, k++) {
-		if (pt[k].pt_kp == NULL) {
-			uname = "";
-			pname = "<idle>";
-		}
-		else {
-			uname = user_from_uid(pt[k].pt_kp->ki_uid, 0);
-			pname = pt[k].pt_kp->ki_comm;
-		}
+		uname = user_from_uid(pt[k].pt_kp->ki_uid, 0);
+		pname = pt[k].pt_kp->ki_comm;
 		wmove(wnd, y, 0);
 		wclrtoeol(wnd);
 		mvwaddstr(wnd, y, 0, uname);
 		snprintf(pidname, sizeof(pidname), "%10.10s", pname);
 		mvwaddstr(wnd, y, 9, pidname);
 		wmove(wnd, y, 20);
-		for (j = pt[k].pt_pctcpu*factor + 0.5; j > 0; j--)
+		for (j = pt[k].pt_pctcpu * 50 + 0.5; j > 0; j--)
 			waddch(wnd, 'X');
 	}
 	wmove(wnd, y, 0); wclrtobot(wnd);
@@ -143,13 +124,6 @@
 	size_t len;
 	int err;
 
-	len = sizeof(stime);
-	err = sysctlbyname("kern.cp_time", &stime, &len, NULL, 0);
-	if (err || len != sizeof(stime)) {
-		perror("kern.cp_time");
-		return (0);
-	}
-
 	len = sizeof(ccpu);
 	err = sysctlbyname("kern.ccpu", &ccpu, &len, NULL, 0);
 	if (err || len != sizeof(ccpu)) {
@@ -176,11 +150,7 @@
 	float ftime;
 	float *pctp;
 	struct kinfo_proc *kpp;
-	long c_time[CPUSTATES];
-	double t;
 	static int lastnproc = 0;
-	size_t len;
-	int err;
 
 	if ((kpp = kvm_getprocs(kd, KERN_PROC_ALL, 0, &nproc)) == NULL) {
 		error("%s", kvm_geterr(kd));
@@ -191,7 +161,7 @@
 	if (nproc > lastnproc) {
 		free(pt);
 		if ((pt =
-		    malloc((nproc + 1) * sizeof(struct p_times))) == NULL) {
+		    malloc(nproc * sizeof(struct p_times))) == NULL) {
 			error("Out of memory");
 			die(0);
 		}
@@ -204,30 +174,12 @@
 		pt[i].pt_kp = &kpp[i];
 		pctp = &pt[i].pt_pctcpu;
 		ftime = kpp[i].ki_swtime;
-		if (ftime == 0 || (kpp[i].ki_sflag & PS_INMEM) == 0)
+		if (ftime == 0 || (kpp[i].ki_flag & P_INMEM) == 0)
 			*pctp = 0;
 		else
 			*pctp = ((double) kpp[i].ki_pctcpu /
 					fscale) / (1.0 - exp(ftime * lccpu));
 	}
-	/*
-	 * and for the imaginary "idle" process
-	 */
-	len = sizeof(c_time);
-	err = sysctlbyname("kern.cp_time", &c_time, &len, NULL, 0);
-	if (err || len != sizeof(c_time)) {
-		perror("kern.cp_time");
-		return;
-	}
-	t = 0;
-	for (i = 0; i < CPUSTATES; i++)
-		t += c_time[i] - stime[i];
-	if (t == 0.0)
-		t = 1.0;
-	pt[nproc].pt_kp = NULL;
-	pt[nproc].pt_pctcpu = (c_time[CP_IDLE] - stime[CP_IDLE]) / t;
-	for (i = 0; i < CPUSTATES; i++)
-		stime[i] = c_time[i];
 }
 
 void
@@ -236,7 +188,7 @@
 	wmove(wnd, 0, 0);
 	wclrtoeol(wnd);
 	mvwaddstr(wnd, 0, 20,
-	    "/0   /10  /20  /30  /40  /50  /60  /70  /80  /90  /100");
+	    "/0%  /10  /20  /30  /40  /50  /60  /70  /80  /90  /100");
 }
 
 int
Index: netstat.c
===================================================================
RCS file: /home/cvs/src/usr.bin/systat/netstat.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/systat/netstat.c -L usr.bin/systat/netstat.c -u -r1.1.1.1 -r1.2
--- usr.bin/systat/netstat.c
+++ usr.bin/systat/netstat.c
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 
-__FBSDID("$FreeBSD: src/usr.bin/systat/netstat.c,v 1.23 2005/02/19 16:54:26 ume Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/systat/netstat.c,v 1.28 2006/11/27 17:34:40 yar Exp $");
 
 #ifdef lint
 static const char sccsid[] = "@(#)netstat.c	8.1 (Berkeley) 6/6/93";
@@ -97,7 +97,7 @@
 {
 	sethostent(1);
 	setnetent(1);
-	return (subwin(stdscr, LINES-5-1, 0, 5, 0));
+	return (subwin(stdscr, LINES-3-1, 0, MAINWIN_ROW, 0));
 }
 
 struct netinfo {
@@ -143,15 +143,17 @@
 
 static const char *miblist[] = {
 	"net.inet.tcp.pcblist",
-	"net.inet.udp.pcblist" 
+	"net.inet.udp.pcblist"
 };
 
+static char tcb[] = "tcb", udb[] = "udb";
+
 struct nlist namelist[] = {
 #define	X_TCB	0
-	{ "tcb" },
+	{ .n_name = tcb },
 #define	X_UDB	1
-	{ "udb" },
-	{ "" },
+	{ .n_name = udb },
+	{ .n_name = NULL },
 };
 
 int
@@ -250,8 +252,8 @@
 	struct xinpgen *inpg;
 	char *cur, *end;
 	struct inpcb *inpcb;
-	struct xinpcb *xip;
-	struct xtcpcb *xtp;
+	struct xinpcb *xip = NULL;
+	struct xtcpcb *xtp = NULL;
 	int plen;
 	size_t lsz;
 
@@ -274,9 +276,9 @@
 			error("sysctl(%s...) failed", miblist[idx]);
 			continue;
 		}
-		/* 
+		/*
 		 * We currently do no require a consistent pcb list.
-		 * Try to be robust in case of struct size changes 
+		 * Try to be robust in case of struct size changes
 		 */
 		cur = ((char *)inpg) + inpg->xig_len;
 		/* There is also a trailing struct xinpgen */
@@ -322,7 +324,7 @@
 			if (nports && !checkport(inpcb))
 				continue;
 			if (idx == 0)	/* TCP */
-				enter_sysctl(inpcb, &xtp->xt_socket, 
+				enter_sysctl(inpcb, &xtp->xt_socket,
 				    xtp->xt_tp.t_state, "tcp");
 			else		/* UDP */
 				enter_sysctl(inpcb, &xip->xi_socket, 0, "udp");
@@ -471,7 +473,8 @@
 shownetstat()
 {
 	struct netinfo *p, *q;
-	char proto[6], *family = "";
+	char proto[6];
+	const char *family = "";
 
 	/*
 	 * First, delete any connections that have gone
@@ -574,10 +577,10 @@
 	if (!nflag && port)
 		sp = getservbyport(port, proto);
 	if (sp || port == 0)
-		snprintf(cp, sizeof(line) - (cp - line), "%.8s", 
+		snprintf(cp, sizeof(line) - (cp - line), "%.8s",
 		    sp ? sp->s_name : "*");
 	else
-		snprintf(cp, sizeof(line) - (cp - line), "%d", 
+		snprintf(cp, sizeof(line) - (cp - line), "%d",
 		    ntohs((u_short)port));
 	/* pad to full column to clear any garbage */
 	cp = index(line, '\0');
Index: main.c
===================================================================
RCS file: /home/cvs/src/usr.bin/systat/main.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/systat/main.c -L usr.bin/systat/main.c -u -r1.1.1.1 -r1.2
--- usr.bin/systat/main.c
+++ usr.bin/systat/main.c
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 
-__FBSDID("$FreeBSD: src/usr.bin/systat/main.c,v 1.18 2004/03/09 11:57:28 dwmalone Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/systat/main.c,v 1.20 2006/04/30 04:47:23 bde Exp $");
 
 #ifdef lint
 static const char sccsid[] = "@(#)main.c	8.1 (Berkeley) 6/6/93";
@@ -109,11 +109,11 @@
 	}
 	kd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf);
 	if (kd != NULL) {
-		/* 
+		/*
 		 * Try to actually read something, we may be in a jail, and
 		 * have /dev/null opened as /dev/mem.
 		 */
-		if (kvm_nlist(kd, namelist) != 0 || namelist[0].n_value == 0 || 
+		if (kvm_nlist(kd, namelist) != 0 || namelist[0].n_value == 0 ||
 		    kvm_read(kd, namelist[0].n_value, &dummy, sizeof(dummy)) !=
 		    sizeof(dummy)) {
 			kvm_close(kd);
@@ -121,7 +121,7 @@
 		}
 	}
 	if (kd == NULL) {
-		/* 
+		/*
 		 * Maybe we are lacking permissions? Retry, this time with bogus
 		 * devices. We can now use sysctl only.
 		 */
@@ -150,7 +150,7 @@
 		warnx("couldn't initialize display");
 		die(0);
 	}
-	wload = newwin(1, 0, 3, 20);
+	wload = newwin(1, 0, 1, 20);
 	if (wload == NULL) {
 		warnx("couldn't set up load average window");
 		die(0);
@@ -183,9 +183,9 @@
 labels()
 {
 	if (curcmd->c_flags & CF_LOADAV) {
-		mvaddstr(2, 20,
+		mvaddstr(0, 20,
 		    "/0   /1   /2   /3   /4   /5   /6   /7   /8   /9   /10");
-		mvaddstr(3, 5, "Load Average");
+		mvaddstr(1, 5, "Load Average");
 	}
 	(*curcmd->c_label)();
 #ifdef notdef
Index: icmp.c
===================================================================
RCS file: /home/cvs/src/usr.bin/systat/icmp.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/systat/icmp.c -L usr.bin/systat/icmp.c -u -r1.1.1.1 -r1.2
--- usr.bin/systat/icmp.c
+++ usr.bin/systat/icmp.c
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 
-__FBSDID("$FreeBSD: src/usr.bin/systat/icmp.c,v 1.3 2001/12/12 00:13:37 markm Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/systat/icmp.c,v 1.5 2006/04/30 04:47:23 bde Exp $");
 
 #ifdef lint
 static char sccsid[] = "@(#)mbufs.c	8.1 (Berkeley) 6/6/93";
@@ -66,25 +66,25 @@
 /*-
 --0         1         2         3         4         5         6         7
 --0123456789012345678901234567890123456789012345678901234567890123456789012345
-01          ICMP Input                         ICMP Output
-02999999999 total messages           999999999 total messages
-03999999999 with bad code            999999999 errors generated
-04999999999 with bad length          999999999 suppressed - original too short
-05999999999 with bad checksum        999999999 suppressed - original was ICMP
-06999999999 with insufficient data   999999999 responses sent
-07                                   999999999 suppressed - multicast echo
-08                                   999999999 suppressed - multicast tstamp
-09
-10          Input Histogram                    Output Histogram
-11999999999 echo response            999999999 echo response
-12999999999 echo request             999999999 echo request
-13999999999 destination unreachable  999999999 destination unreachable
-14999999999 redirect                 999999999 redirect
-15999999999 time-to-live exceeded    999999999 time-to-line exceeded
-16999999999 parameter problem        999999999 parameter problem
-17999999999 router advertisement     999999999 router solicitation
+00          ICMP Input                         ICMP Output
+01999999999 total messages           999999999 total messages
+02999999999 with bad code            999999999 errors generated
+03999999999 with bad length          999999999 suppressed - original too short
+04999999999 with bad checksum        999999999 suppressed - original was ICMP
+05999999999 with insufficient data   999999999 responses sent
+06                                   999999999 suppressed - multicast echo
+07                                   999999999 suppressed - multicast tstamp
+08
+09          Input Histogram                    Output Histogram
+10999999999 echo response            999999999 echo response
+11999999999 echo request             999999999 echo request
+12999999999 destination unreachable  999999999 destination unreachable
+13999999999 redirect                 999999999 redirect
+14999999999 time-to-live exceeded    999999999 time-to-line exceeded
+15999999999 parameter problem        999999999 parameter problem
+16999999999 router advertisement     999999999 router solicitation
+17
 18
-19
 --0123456789012345678901234567890123456789012345678901234567890123456789012345
 --0         1         2         3         4         5         6         7
 */
@@ -92,7 +92,7 @@
 WINDOW *
 openicmp(void)
 {
-	return (subwin(stdscr, LINES-5-1, 0, 5, 0));
+	return (subwin(stdscr, LINES-3-1, 0, MAINWIN_ROW, 0));
 }
 
 void
@@ -112,23 +112,23 @@
 	wmove(wnd, 0, 0); wclrtoeol(wnd);
 #define L(row, str) mvwprintw(wnd, row, 10, str)
 #define R(row, str) mvwprintw(wnd, row, 45, str);
-	L(1, "ICMP Input");		R(1, "ICMP Output");
-	L(2, "total messages");		R(2, "total messages");
-	L(3, "with bad code");		R(3, "errors generated");
-	L(4, "with bad length");	R(4, "suppressed - original too short");
-	L(5, "with bad checksum");	R(5, "suppressed - original was ICMP");
-	L(6, "with insufficient data");	R(6, "responses sent");
-	;				R(7, "suppressed - multicast echo");
-	;				R(8, "suppressed - multicast tstamp");
-	L(10, "Input Histogram");	R(10, "Output Histogram");
+	L(0, "ICMP Input");		R(0, "ICMP Output");
+	L(1, "total messages");		R(1, "total messages");
+	L(2, "with bad code");		R(2, "errors generated");
+	L(3, "with bad length");	R(3, "suppressed - original too short");
+	L(4, "with bad checksum");	R(4, "suppressed - original was ICMP");
+	L(5, "with insufficient data");	R(5, "responses sent");
+					R(6, "suppressed - multicast echo");
+					R(7, "suppressed - multicast tstamp");
+	L(9, "Input Histogram");	R(9, "Output Histogram");
 #define B(row, str) L(row, str); R(row, str)
-	B(11, "echo response");
-	B(12, "echo request");
-	B(13, "destination unreachable");
-	B(14, "redirect");
-	B(15, "time-to-live exceeded");
-	B(16, "parameter problem");
-	L(17, "router advertisement");	R(17, "router solicitation");
+	B(10, "echo response");
+	B(11, "echo request");
+	B(12, "destination unreachable");
+	B(13, "redirect");
+	B(14, "time-to-live exceeded");
+	B(15, "parameter problem");
+	L(16, "router advertisement");	R(16, "router solicitation");
 #undef L
 #undef R
 #undef B
@@ -174,7 +174,7 @@
 	DO(icps_bmcasttstamp);
 #undef DO
 }
-	
+
 void
 showicmp(void)
 {
@@ -188,34 +188,34 @@
 		totalin += stats.icps_inhist[i];
 		totalout += stats.icps_outhist[i];
 	}
-	totalin += stats.icps_badcode + stats.icps_badlen + 
+	totalin += stats.icps_badcode + stats.icps_badlen +
 		stats.icps_checksum + stats.icps_tooshort;
-	mvwprintw(wnd, 2, 0, "%9lu", totalin);
-	mvwprintw(wnd, 2, 35, "%9lu", totalout);
+	mvwprintw(wnd, 1, 0, "%9lu", totalin);
+	mvwprintw(wnd, 1, 35, "%9lu", totalout);
 
 #define DO(stat, row, col) \
 	mvwprintw(wnd, row, col, "%9lu", stats.stat)
 
-	DO(icps_badcode, 3, 0);
-	DO(icps_badlen, 4, 0);
-	DO(icps_checksum, 5, 0);
-	DO(icps_tooshort, 6, 0);
-	DO(icps_error, 3, 35);
-	DO(icps_oldshort, 4, 35);
-	DO(icps_oldicmp, 5, 35);
-	DO(icps_reflect, 6, 35);
-	DO(icps_bmcastecho, 7, 35);
-	DO(icps_bmcasttstamp, 8, 35);
+	DO(icps_badcode, 2, 0);
+	DO(icps_badlen, 3, 0);
+	DO(icps_checksum, 4, 0);
+	DO(icps_tooshort, 5, 0);
+	DO(icps_error, 2, 35);
+	DO(icps_oldshort, 3, 35);
+	DO(icps_oldicmp, 4, 35);
+	DO(icps_reflect, 5, 35);
+	DO(icps_bmcastecho, 6, 35);
+	DO(icps_bmcasttstamp, 7, 35);
 #define DO2(type, row) DO(icps_inhist[type], row, 0); DO(icps_outhist[type], \
 							 row, 35)
-	DO2(ICMP_ECHOREPLY, 11);
-	DO2(ICMP_ECHO, 12);
-	DO2(ICMP_UNREACH, 13);
-	DO2(ICMP_REDIRECT, 14);
-	DO2(ICMP_TIMXCEED, 15);
-	DO2(ICMP_PARAMPROB, 16);
-	DO(icps_inhist[ICMP_ROUTERADVERT], 17, 0);
-	DO(icps_outhist[ICMP_ROUTERSOLICIT], 17, 35);
+	DO2(ICMP_ECHOREPLY, 10);
+	DO2(ICMP_ECHO, 11);
+	DO2(ICMP_UNREACH, 12);
+	DO2(ICMP_REDIRECT, 13);
+	DO2(ICMP_TIMXCEED, 14);
+	DO2(ICMP_PARAMPROB, 15);
+	DO(icps_inhist[ICMP_ROUTERADVERT], 16, 0);
+	DO(icps_outhist[ICMP_ROUTERSOLICIT], 16, 35);
 #undef DO
 #undef DO2
 }
Index: systat.h
===================================================================
RCS file: /home/cvs/src/usr.bin/systat/systat.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/systat/systat.h -L usr.bin/systat/systat.h -u -r1.1.1.1 -r1.2
--- usr.bin/systat/systat.h
+++ usr.bin/systat/systat.h
@@ -31,7 +31,7 @@
  * SUCH DAMAGE.
  *
  *	From: @(#)systat.h	8.1 (Berkeley) 6/6/93
- * $FreeBSD: src/usr.bin/systat/systat.h,v 1.6 2001/12/12 00:13:37 markm Exp $
+ * $FreeBSD: src/usr.bin/systat/systat.h,v 1.8 2006/04/30 04:47:23 bde Exp $
  */
 
 #include <curses.h>
@@ -49,12 +49,12 @@
 	char	c_flags;		/* see below */
 };
 
-/* 
+/*
  * If we are started with privileges, use a kmem interface for netstat handling,
  * otherwise use sysctl.
  * In case of many open sockets, the sysctl handling might become slow.
  */
-extern int use_kvm; 
+extern int use_kvm;
 
 #define	CF_INIT		0x1		/* been initialized */
 #define	CF_LOADAV	0x2		/* display w/ load average */
@@ -62,6 +62,8 @@
 #define	TCP	0x1
 #define	UDP	0x2
 
+#define	MAINWIN_ROW	3		/* top row for the main/lower window */
+
 #define GETSYSCTL(name, var) getsysctl(name, &(var), sizeof(var))
 #define KREAD(addr, buf, len)  kvm_ckread((addr), (buf), (len))
 #define NVAL(indx)  namelist[(indx)].n_value
Index: tcp.c
===================================================================
RCS file: /home/cvs/src/usr.bin/systat/tcp.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/systat/tcp.c -L usr.bin/systat/tcp.c -u -r1.1.1.1 -r1.2
--- usr.bin/systat/tcp.c
+++ usr.bin/systat/tcp.c
@@ -41,7 +41,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/systat/tcp.c,v 1.9 2004/02/25 13:26:53 bde Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/systat/tcp.c,v 1.14 2007/06/15 18:12:58 jhb Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -70,26 +70,27 @@
 /*-
 --0         1         2         3         4         5         6         7
 --0123456789012345678901234567890123456789012345678901234567890123456789012345
-01          TCP Connections                    TCP Packets
-02999999999 connections initiated    999999999 total packets sent
-03999999999 connections accepted     999999999 - data
-04999999999 connections established  999999999 - data (retransmit)
-05999999999 connections dropped      999999999 - ack-only
-06999999999 - in embryonic state     999999999 - window probes
-07999999999 - on retransmit timeout  999999999 - window updates
-08999999999 - by keepalive           999999999 - urgent data only
-09999999999 - from listen queue      999999999 - control
-10                                   999999999 - resends by PMTU discovery
-11          TCP Timers               999999999 total packets received
-12999999999 potential rtt updates    999999999 - in sequence
-13999999999 - successful             999999999 - completely duplicate
-14999999999 delayed acks sent        999999999 - with some duplicate data
-15999999999 retransmit timeouts      999999999 - out-of-order
-16999999999 persist timeouts         999999999 - duplicate acks
-17999999999 keepalive probes         999999999 - acks
-18999999999 - timeouts               999999999 - window probes
-19                                   999999999 - window updates
-20                                   999999999 - bad checksum
+00             TCP Connections                       TCP Packets
+01999999999999 connections initiated    999999999999 total packets sent
+02999999999999 connections accepted     999999999999 - data
+03999999999999 connections established  999999999999 - data (retransmit by dupack)
+04999999999999 connections dropped      999999999999 - data (retransmit by sack)
+05999999999999 - in embryonic state     999999999999 - ack-only
+06999999999999 - on retransmit timeout  999999999999 - window probes
+07999999999999 - by keepalive           999999999999 - window updates
+08999999999999 - from listen queue      999999999999 - urgent data only
+09                                      999999999999 - control
+10                                      999999999999 - resends by PMTU discovery
+11             TCP Timers               999999999999 total packets received
+12999999999999 potential rtt updates    999999999999 - in sequence
+13999999999999 - successful             999999999999 - completely duplicate
+14999999999999 delayed acks sent        999999999999 - with some duplicate data
+15999999999999 retransmit timeouts      999999999999 - out-of-order
+16999999999999 persist timeouts         999999999999 - duplicate acks
+17999999999999 keepalive probes         999999999999 - acks
+18999999999999 - timeouts               999999999999 - window probes
+19                                      999999999999 - window updates
+20                                      999999999999 - bad checksum
 --0123456789012345678901234567890123456789012345678901234567890123456789012345
 --0         1         2         3         4         5         6         7
 */
@@ -97,8 +98,7 @@
 WINDOW *
 opentcp(void)
 {
-
-	return (stdscr);
+	return (subwin(stdscr, LINES-3-1, 0, MAINWIN_ROW, 0));
 }
 
 void
@@ -109,34 +109,36 @@
 		return;
 	wclear(w);
 	wrefresh(w);
+	delwin(w);
 }
 
 void
 labeltcp(void)
 {
 	wmove(wnd, 0, 0); wclrtoeol(wnd);
-#define L(row, str) mvwprintw(wnd, row, 10, str)
-#define R(row, str) mvwprintw(wnd, row, 45, str);
-	L(1, "TCP Connections");		R(1, "TCP Packets");
-	L(2, "connections initiated");		R(2, "total packets sent");
-	L(3, "connections accepted");		R(3, "- data");
-	L(4, "connections established");	R(4, "- data (retransmit)");
-	L(5, "connections dropped");		R(5, "- ack-only");
-	L(6, "- in embryonic state");		R(6, "- window probes");
-	L(7, "- on retransmit timeout");	R(7, "- window updates");
-	L(8, "- by keepalive");			R(8, "- urgent data only");
-	L(9, "- from listen queue");		R(9, "- control");
-	R(10, "- resends by PMTU discovery");
-	L(11, "TCP Timers");		R(11, "total packets received");
+#define L(row, str) mvwprintw(wnd, row, 13, str)
+#define R(row, str) mvwprintw(wnd, row, 51, str);
+	L(0, "TCP Connections");		R(0, "TCP Packets");
+	L(1, "connections initiated");		R(1, "total packets sent");
+	L(2, "connections accepted");		R(2, "- data");
+	L(3, "connections established");	R(3, "- data (retransmit by dupack)");
+	L(4, "connections dropped");		R(4, "- data (retransmit by sack)");
+	L(5, "- in embryonic state");		R(5, "- ack-only");
+	L(6, "- on retransmit timeout");	R(6, "- window probes");
+	L(7, "- by keepalive");			R(7, "- window updates");
+	L(8, "- from listen queue");		R(8, "- urgent data only");
+						R(9, "- control");
+						R(10, "- resends by PMTU discovery");
+	L(11, "TCP Timers");			R(11, "total packets received");
 	L(12, "potential rtt updates");		R(12, "- in sequence");
-	L(13, "- successful");		R(13, "- completely duplicate");
-	L(14, "delayed acks sent");	R(14, "- with some duplicate data");
-	L(15, "retransmit timeouts");	R(15, "- out-of-order");
-	L(16, "persist timeouts");	R(16, "- duplicate acks");
-	L(17, "keepalive probes");	R(17, "- acks");
-	L(18, "- timeouts");		R(18, "- window probes");
-	R(19, "- window updates");
-	R(20, "- bad checksum");
+	L(13, "- successful");			R(13, "- completely duplicate");
+	L(14, "delayed acks sent");		R(14, "- with some duplicate data");
+	L(15, "retransmit timeouts");		R(15, "- out-of-order");
+	L(16, "persist timeouts");		R(16, "- duplicate acks");
+	L(17, "keepalive probes");		R(17, "- acks");
+	L(18, "- timeouts");			R(18, "- window probes");
+						R(19, "- window updates");
+						R(20, "- bad checksum");
 #undef L
 #undef R
 }
@@ -183,7 +185,7 @@
 	DO(tcps_sndpack);
 	DO(tcps_sndbyte);
 	DO(tcps_sndrexmitpack);
-	DO(tcps_sndrexmitbyte);
+	DO(tcps_sack_rexmits);
 	DO(tcps_sndacks);
 	DO(tcps_sndprobe);
 	DO(tcps_sndurg);
@@ -227,7 +229,7 @@
 	DO(tcps_listendrop);
 #undef DO
 }
-	
+
 void
 showtcp(void)
 {
@@ -237,19 +239,20 @@
 	domode(&stats);
 
 #define DO(stat, row, col) \
-	mvwprintw(wnd, row, col, "%9lu", stats.stat)
+	mvwprintw(wnd, row, col, "%12lu", stats.stat)
 #define	L(row, stat) DO(stat, row, 0)
-#define	R(row, stat) DO(stat, row, 35)
-	L(2, tcps_connattempt);		R(2, tcps_sndtotal);
-	L(3, tcps_accepts);		R(3, tcps_sndpack);
-	L(4, tcps_connects);		R(4, tcps_sndrexmitpack);
-	L(5, tcps_drops);		R(5, tcps_sndacks);
-	L(6, tcps_conndrops);		R(6, tcps_sndprobe);
-	L(7, tcps_timeoutdrop);		R(7, tcps_sndwinup);
-	L(8, tcps_keepdrops);		R(8, tcps_sndurg);
-	L(9, tcps_listendrop);		R(9, tcps_sndctrl);
-	R(10, tcps_mturesent);
-	R(11, tcps_rcvtotal);
+#define	R(row, stat) DO(stat, row, 38)
+	L(1, tcps_connattempt);		R(1, tcps_sndtotal);
+	L(2, tcps_accepts);		R(2, tcps_sndpack);
+	L(3, tcps_connects);		R(3, tcps_sndrexmitpack);
+	L(4, tcps_drops);		R(4, tcps_sack_rexmits);
+	L(5, tcps_conndrops);		R(5, tcps_sndacks);
+	L(6, tcps_timeoutdrop);		R(6, tcps_sndprobe);
+	L(7, tcps_keepdrops);		R(7, tcps_sndwinup);
+	L(8, tcps_listendrop);		R(8, tcps_sndurg);
+					R(9, tcps_sndctrl);
+					R(10, tcps_mturesent);
+					R(11, tcps_rcvtotal);
 	L(12, tcps_segstimed);		R(12, tcps_rcvpack);
 	L(13, tcps_rttupdated);		R(13, tcps_rcvduppack);
 	L(14, tcps_delack);		R(14, tcps_rcvpartduppack);
@@ -257,8 +260,8 @@
 	L(16, tcps_persisttimeo);	R(16, tcps_rcvdupack);
 	L(17, tcps_keepprobe);		R(17, tcps_rcvackpack);
 	L(18, tcps_keeptimeo);		R(18, tcps_rcvwinprobe);
-	R(19, tcps_rcvwinupd);
-	R(20, tcps_rcvbadsum);
+					R(19, tcps_rcvwinupd);
+					R(20, tcps_rcvbadsum);
 #undef DO
 #undef L
 #undef R
Index: Makefile
===================================================================
RCS file: /home/cvs/src/usr.bin/systat/Makefile,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/systat/Makefile -L usr.bin/systat/Makefile -u -r1.1.1.1 -r1.2
--- usr.bin/systat/Makefile
+++ usr.bin/systat/Makefile
@@ -1,12 +1,19 @@
 #	@(#)Makefile	8.1 (Berkeley) 6/6/93
-# $FreeBSD: src/usr.bin/systat/Makefile,v 1.15 2004/02/04 10:20:43 ru Exp $
+# $FreeBSD: src/usr.bin/systat/Makefile,v 1.18 2006/11/27 21:30:38 yar Exp $
+
+.include <bsd.own.mk>
 
 PROG=	systat
 SRCS=	cmds.c cmdtab.c devs.c fetch.c iostat.c keyboard.c main.c \
-	mbufs.c netcmds.c netstat.c pigs.c swap.c icmp.c icmp6.c \
-	mode.c ip.c ip6.c tcp.c \
+	mbufs.c netcmds.c netstat.c pigs.c swap.c icmp.c \
+	mode.c ip.c tcp.c \
 	vmstat.c convtbl.c ifcmds.c ifstat.c
-CFLAGS+=-DINET6
+
+.if ${MK_INET6_SUPPORT} != "no"
+SRCS+=	icmp6.c ip6.c
+CFLAGS+= -DINET6
+.endif
+
 DPADD=	${LIBCURSES} ${LIBM} ${LIBDEVSTAT} ${LIBKVM}
 LDADD=	-lcurses -lm -ldevstat -lkvm
 
Index: ifcmds.c
===================================================================
RCS file: /home/cvs/src/usr.bin/systat/ifcmds.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/systat/ifcmds.c -L usr.bin/systat/ifcmds.c -u -r1.1.1.1 -r1.2
--- usr.bin/systat/ifcmds.c
+++ usr.bin/systat/ifcmds.c
@@ -25,72 +25,29 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/usr.bin/systat/ifcmds.c,v 1.2 2004/03/09 11:57:27 dwmalone Exp $
+ * $FreeBSD: src/usr.bin/systat/ifcmds.c,v 1.6 2006/11/27 16:14:32 yar Exp $
  */
 
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/sysctl.h>
-#include <sys/time.h>
-#include <sys/queue.h>
-#include <net/if.h>
-#include <net/if_mib.h>
-#include <net/if_types.h>	/* For IFT_ETHER */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <float.h>
-#include <err.h>
-
 #include "systat.h"
 #include "extern.h"
-#include "mode.h"
 #include "convtbl.h"
 
-int	curscale = SC_AUTO;
-
-static	int selectscale(const char *);
+int curscale = SC_AUTO;
 
 int
 ifcmd(const char *cmd, const char *args)
 {
+	int scale;
+
 	if (prefix(cmd, "scale")) {
-		if (*args != '\0' && selectscale(args) != -1)
-			;
+		if ((scale = get_scale(args)) != -1)
+			curscale = scale;
 		else {
 			move(CMDLINE, 0);
 			clrtoeol();
-			addstr("what scale? kbit, kbyte, mbit, mbyte, " \
-			       "gbit, gbyte, auto");
+			addstr("what scale? ");
+			addstr(get_helplist());
 		} 
 	}
-	return 1;
-}
-
-static int
-selectscale(const char *args)
-{
-	int	retval = 0;
-
-#define streq(a,b)	(strcmp(a,b) == 0)
-	if (streq(args, "default") || streq(args, "auto"))
-		curscale = SC_AUTO;
-	else if (streq(args, "kbit"))
-		curscale = SC_KILOBIT;
-	else if (streq(args, "kbyte"))
-		curscale = SC_KILOBYTE;
-	else if (streq(args, "mbit"))
-		curscale = SC_MEGABIT;
-	else if (streq(args, "mbyte"))
-		curscale = SC_MEGABYTE;
-	else if (streq(args, "gbit"))
-		curscale = SC_GIGABIT;
-	else if (streq(args, "gbyte"))
-		curscale = SC_GIGABYTE;
-	else
-		retval = -1;
-
-	return retval;
+	return (1);
 }
Index: ip6.c
===================================================================
RCS file: /home/cvs/src/usr.bin/systat/ip6.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/systat/ip6.c -L usr.bin/systat/ip6.c -u -r1.1.1.1 -r1.2
--- usr.bin/systat/ip6.c
+++ usr.bin/systat/ip6.c
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 
-__FBSDID("$FreeBSD: src/usr.bin/systat/ip6.c,v 1.1 2003/08/01 20:28:20 dwmalone Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/systat/ip6.c,v 1.3 2006/04/30 04:47:23 bde Exp $");
 
 #ifdef lint
 static const char sccsid[] = "@(#)mbufs.c	8.1 (Berkeley) 6/6/93";
@@ -67,25 +67,26 @@
 /*-
 --0         1         2         3         4         5         6         7
 --0123456789012345678901234567890123456789012345678901234567890123456789012345
-01        IPv6 Input                         IPv6 Output
-029999999 total packets received   999999999 total packets sent
-039999999 - too short for header   999999999 - generated locally
-049999999 - too short for data     999999999 - output drops
-059999999 - with invalid version   999999999 output fragments generated
-069999999 total fragments received 999999999 - fragmentation failed
-079999999 - fragments dropped      999999999 destinations unreachable
-089999999 - fragments timed out    999999999 packets output via raw IP
-099999999 - fragments overflown              Input next-header histogram
-109999999 - packets reassembled ok 999999999  - destination options
-119999999 packets forwarded        999999999  - hop-by-hop options
-129999999 - unreachable dests      999999999  - IPv4
-139999999 - redirects generated    999999999  - TCP
-149999999 option errors            999999999  - UDP
-159999999 unwanted multicasts      999999999  - IPv6
-169999999 delivered to upper layer 999999999  - routing header
-17                                 999999999  - fragmentation header
-189999999 bad scope packets        999999999  - ICMP6
-199999999 address selection failed 999999999  - none
+00        IPv6 Input                         IPv6 Output
+019999999 total packets received   999999999 total packets sent
+029999999 - too short for header   999999999 - generated locally
+039999999 - too short for data     999999999 - output drops
+049999999 - with invalid version   999999999 output fragments generated
+059999999 total fragments received 999999999 - fragmentation failed
+069999999 - fragments dropped      999999999 destinations unreachable
+079999999 - fragments timed out    999999999 packets output via raw IP
+089999999 - fragments overflown
+099999999 - packets reassembled ok           Input next-header histogram
+109999999 packets forwarded        999999999  - destination options
+119999999 - unreachable dests      999999999  - hop-by-hop options
+129999999 - redirects generated    999999999  - IPv4
+139999999 option errors            999999999  - TCP
+149999999 unwanted multicasts      999999999  - UDP
+159999999 delivered to upper layer 999999999  - IPv6
+169999999 bad scope packets        999999999  - routing header
+179999999 address selection failed 999999999  - fragmentation header
+18                                 999999999  - ICMP6
+19                                 999999999  - none
 --0123456789012345678901234567890123456789012345678901234567890123456789012345
 --0         1         2         3         4         5         6         7
 */
@@ -93,7 +94,7 @@
 WINDOW *
 openip6(void)
 {
-	return (subwin(stdscr, LINES-4-1, 0, 4, 0));
+	return (subwin(stdscr, LINES-3-1, 0, MAINWIN_ROW, 0));
 }
 
 void
@@ -113,25 +114,26 @@
 	wmove(wnd, 0, 0); wclrtoeol(wnd);
 #define L(row, str) mvwprintw(wnd, row, 10, str)
 #define R(row, str) mvwprintw(wnd, row, 45, str);
-	L(1, "IPv6 Input");		R(1, "IPv6 Output");
-	L(2, "total packets received");	R(2, "total packets sent");
-	L(3, "- too short for header");	R(3, "- generated locally");
-	L(4, "- too short for data");	R(4, "- output drops");
-	L(5, "- with invalid version");	R(5, "output fragments generated");
-	L(6, "total fragments received"); R(6, "- fragmentation failed");
-	L(7, "- fragments dropped");	R(7, "destinations unreachable");
-	L(8, "- fragments timed out");	R(8, "packets output via raw IP");
-	L(9, "- fragments overflown");	R(9, "Input next-header histogram");
-	L(10, "- packets reassembled ok"); R(10, " - destination options");
-	L(11, "packets forwarded");	R(11, " - hop-by-hop options");
-	L(12, "- unreachable dests");	R(12, " - IPv4");
-	L(13, "- redirects generated");	R(13, " - TCP");
-	L(14, "option errors");		R(14, " - UDP");
-	L(15, "unwanted multicasts");	R(15, " - IPv6");
-	L(16, "delivered to upper layer"); R(16, " - routing header");
-					R(17, " - fragmentation header");
-	L(18, "bad scope packets");	R(18, " - ICMP6");
-	L(19, "address selection failed"); R(19, " - none");
+	L(0, "IPv6 Input");		R(0, "IPv6 Output");
+	L(1, "total packets received");	R(1, "total packets sent");
+	L(2, "- too short for header");	R(2, "- generated locally");
+	L(3, "- too short for data");	R(3, "- output drops");
+	L(4, "- with invalid version");	R(4, "output fragments generated");
+	L(5, "total fragments received"); R(5, "- fragmentation failed");
+	L(6, "- fragments dropped");	R(6, "destinations unreachable");
+	L(7, "- fragments timed out");	R(7, "packets output via raw IP");
+	L(8, "- fragments overflown");
+	L(9, "- packets reassembled ok"); R(9, "Input next-header histogram");
+	L(10, "packets forwarded");	R(10, " - destination options");
+	L(11, "- unreachable dests");	R(11, " - hop-by-hop options");
+	L(12, "- redirects generated");	R(12, " - IPv4");
+	L(13, "option errors");		R(13, " - TCP");
+	L(14, "unwanted multicasts");	R(14, " - UDP");
+	L(15, "delivered to upper layer"); R(15, " - IPv6");
+	L(16, "bad scope packets");	R(16, " - routing header");
+	L(17, "address selection failed"); R(17, " - fragmentation header");
+					R(18, " - ICMP6");
+					R(19, " - none");
 #undef L
 #undef R
 }
@@ -186,7 +188,7 @@
 	DO(ip6s_sources_none);
 #undef DO
 }
-	
+
 void
 showip6(void)
 {
@@ -199,40 +201,40 @@
 #define DO(stat, row, col) \
 	mvwprintw(wnd, row, col, "%9lu", stats.stat)
 
-	DO(ip6s_total, 2, 0);
-	mvwprintw(wnd, 2, 35, "%9lu", totalout);
-	DO(ip6s_localout, 3, 35);
-	DO(ip6s_tooshort, 3, 0);
-	DO(ip6s_odropped, 4, 35);
-	DO(ip6s_toosmall, 4, 0);
-	DO(ip6s_ofragments, 5, 35);
-	DO(ip6s_badvers, 5, 0);
-	DO(ip6s_cantfrag, 6, 35);
-	DO(ip6s_fragments, 6, 0);
-	DO(ip6s_noroute, 7, 35);
-	DO(ip6s_fragdropped, 7, 0);
-	DO(ip6s_rawout, 8, 35);
-	DO(ip6s_fragtimeout, 8, 0);
-	DO(ip6s_fragoverflow, 9, 0);
+	DO(ip6s_total, 1, 0);
+	mvwprintw(wnd, 1, 35, "%9lu", totalout);
+	DO(ip6s_tooshort, 2, 0);
+	DO(ip6s_localout, 2, 35);
+	DO(ip6s_toosmall, 3, 0);
+	DO(ip6s_odropped, 3, 35);
+	DO(ip6s_badvers, 4, 0);
+	DO(ip6s_ofragments, 4, 35);
+	DO(ip6s_fragments, 5, 0);
+	DO(ip6s_cantfrag, 5, 35);
+	DO(ip6s_fragdropped, 6, 0);
+	DO(ip6s_noroute, 6, 35);
+	DO(ip6s_fragtimeout, 7, 0);
+	DO(ip6s_rawout, 7, 35);
+	DO(ip6s_fragoverflow, 8, 0);
+	DO(ip6s_reassembled, 9, 0);
+	DO(ip6s_forward, 10, 0);
 	DO(ip6s_nxthist[IPPROTO_DSTOPTS], 10, 35);
-	DO(ip6s_reassembled, 10, 0);
+	DO(ip6s_cantforward, 11, 0);
 	DO(ip6s_nxthist[IPPROTO_HOPOPTS], 11, 35);
-	DO(ip6s_forward, 11, 0);
+	DO(ip6s_redirectsent, 12, 0);
 	DO(ip6s_nxthist[IPPROTO_IPV4], 12, 35);
-	DO(ip6s_cantforward, 12, 0);
+	DO(ip6s_badoptions, 13, 0);
 	DO(ip6s_nxthist[IPPROTO_TCP], 13, 35);
-	DO(ip6s_redirectsent, 13, 0);
+	DO(ip6s_notmember, 14, 0);
 	DO(ip6s_nxthist[IPPROTO_UDP], 14, 35);
-	DO(ip6s_badoptions, 14, 0);
+	DO(ip6s_delivered, 15, 0);
 	DO(ip6s_nxthist[IPPROTO_IPV6], 15, 35);
-	DO(ip6s_notmember, 15, 0);
+	DO(ip6s_badscope, 16, 0);
 	DO(ip6s_nxthist[IPPROTO_ROUTING], 16, 35);
-	DO(ip6s_delivered, 16, 0);
+	DO(ip6s_sources_none, 17, 0);
 	DO(ip6s_nxthist[IPPROTO_FRAGMENT], 17, 35);
 	DO(ip6s_nxthist[IPPROTO_ICMPV6], 18, 35);
-	DO(ip6s_badscope, 18, 0);
 	DO(ip6s_nxthist[IPPROTO_NONE], 19, 35);
-	DO(ip6s_sources_none, 19, 0);
 #undef DO
 }
 
Index: mbufs.c
===================================================================
RCS file: /home/cvs/src/usr.bin/systat/mbufs.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/systat/mbufs.c -L usr.bin/systat/mbufs.c -u -r1.1.1.1 -r1.2
--- usr.bin/systat/mbufs.c
+++ usr.bin/systat/mbufs.c
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 
-__FBSDID("$FreeBSD: src/usr.bin/systat/mbufs.c,v 1.18 2005/04/09 14:31:41 stefanf Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/systat/mbufs.c,v 1.20 2006/07/24 01:49:24 rwatson Exp $");
 
 #ifdef lint
 static const char sccsid[] = "@(#)mbufs.c	8.1 (Berkeley) 6/6/93";
@@ -63,7 +63,6 @@
 	{ MT_DATA, 	"data"},
 	{ MT_HEADER,	"headers"},
 	{ MT_SONAME,	"socknames"},
-	{ MT_FTABLE,	"frags"},
 	{ MT_CONTROL,	"control"},
 	{ MT_OOBDATA,	"oobdata"}
 };
@@ -72,7 +71,7 @@
 WINDOW *
 openmbufs()
 {
-	return (subwin(stdscr, LINES-5-1, 0, 5, 0));
+	return (subwin(stdscr, LINES-3-1, 0, MAINWIN_ROW, 0));
 }
 
 void
Index: ifstat.c
===================================================================
RCS file: /home/cvs/src/usr.bin/systat/ifstat.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/systat/ifstat.c -L usr.bin/systat/ifstat.c -u -r1.1.1.1 -r1.2
--- usr.bin/systat/ifstat.c
+++ usr.bin/systat/ifstat.c
@@ -25,34 +25,28 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/usr.bin/systat/ifstat.c,v 1.2 2004/03/09 11:57:27 dwmalone Exp $
+ * $FreeBSD: src/usr.bin/systat/ifstat.c,v 1.6.4.1 2008/01/26 22:13:30 delphij Exp $
  */
 
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/sysctl.h>
-#include <sys/time.h>
-#include <sys/queue.h>
 #include <net/if.h>
 #include <net/if_mib.h>
-#include <net/if_types.h>	/* For IFT_ETHER */
 
-#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
-#include <float.h>
 #include <err.h>
+#include <errno.h>
 
 #include "systat.h"
 #include "extern.h"
-#include "mode.h"
 #include "convtbl.h"
 
                                 /* Column numbers */
 
 #define C1	0		/*  0-19 */
-#define C2	20		/* 20-39 */ 
+#define C2	20		/* 20-39 */
 #define C3	40		/* 40-59 */
 #define C4	60		/* 60-80 */
 #define C5	80		/* Used for label positioning. */
@@ -65,7 +59,7 @@
 static const int col5 = C5;
 
 
-SLIST_HEAD(, if_stat)		curlist;	
+SLIST_HEAD(, if_stat)		curlist;
 SLIST_HEAD(, if_stat_disp)	displist;
 
 struct if_stat {
@@ -85,7 +79,7 @@
 
 extern	 u_int curscale;
 
-static	 void  right_align_string(const struct if_stat *);
+static	 void  right_align_string(struct if_stat *);
 static	 void  getifmibdata(const int, struct ifmibdata *);
 static	 void  sort_interface_list(void);
 static	 u_int getifnum(void);
@@ -96,13 +90,13 @@
 	err((n), (s));							\
 } while (0)
 
-#define STARTING_ROW	(8)
-#define ROW_SPACING	(3)
-
-#define TOPLINE 5
+#define TOPLINE 3
 #define TOPLABEL \
 "      Interface           Traffic               Peak                Total"
 
+#define STARTING_ROW	(TOPLINE + 1)
+#define ROW_SPACING	(3)
+
 #define CLEAR_LINE(y, x)	do {					\
 	wmove(wnd, y, x);						\
 	wclrtoeol(wnd);							\
@@ -153,7 +147,7 @@
 WINDOW *
 openifstat(void)
 {
-	return (subwin(stdscr, LINES-1-5, 0, 5, 0));
+	return (subwin(stdscr, LINES-3-1, 0, MAINWIN_ROW, 0));
 }
 
 void
@@ -204,7 +198,7 @@
 	return;
 }
 
-int 
+int
 initifstat(void)
 {
 	struct   if_stat *p = NULL;
@@ -217,16 +211,15 @@
 	SLIST_INIT(&curlist);
 
 	for (i = 0; i < n; i++) {
-		p = (struct if_stat *)malloc(sizeof(struct if_stat));
+		p = (struct if_stat *)calloc(1, sizeof(struct if_stat));
 		if (p == NULL)
 			IFSTAT_ERR(1, "out of memory");
-		memset((void *)p, 0, sizeof(struct if_stat));
 		SLIST_INSERT_HEAD(&curlist, p, link);
 		p->if_row = i+1;
 		getifmibdata(p->if_row, &p->if_mib);
 		right_align_string(p);
 
-		/* 
+		/*
 		 * Initially, we only display interfaces that have
 		 * received some traffic.
 		 */
@@ -249,11 +242,11 @@
 	u_int	we_need_to_sort_interface_list = 0;
 
 	SLIST_FOREACH(ifp, &curlist, link) {
-		/* 
+		/*
 		 * Grab a copy of the old input/output values before we
 		 * call getifmibdata().
 		 */
-		old_inb = ifp->if_mib.ifmd_data.ifi_ibytes;		
+		old_inb = ifp->if_mib.ifmd_data.ifi_ibytes;
 		old_outb = ifp->if_mib.ifmd_data.ifi_obytes;
 		ifp->tv_lastchanged = ifp->if_mib.ifmd_data.ifi_lastchange;
 
@@ -269,7 +262,7 @@
 		if (new_inb > 0 && old_inb == 0) {
 			ifp->display = 1;
 			we_need_to_sort_interface_list++;
-		} 
+		}
 
 		/*
 		 * The rest is pretty trivial.  Calculate the new values
@@ -308,12 +301,12 @@
 	return;
 }
 
-/* 
+/*
  * We want to right justify our interface names against the first column
  * (first sixteen or so characters), so we need to do some alignment.
  */
 static void
-right_align_string(const struct if_stat *ifp)
+right_align_string(struct if_stat *ifp)
 {
 	int	 str_len = 0, pad_len = 0;
 	char	*newstr = NULL, *ptr = NULL;
@@ -325,7 +318,7 @@
 		str_len = strlen(ifp->if_mib.ifmd_name)+1;
 		pad_len = IF_NAMESIZE-(str_len);
 
-		newstr = (char *)ifp->if_name;
+		newstr = ifp->if_name;
 		ptr = newstr + pad_len;
 		(void)memset((void *)newstr, (int)' ', IF_NAMESIZE);
 		(void)strncpy(ptr, (const char *)&ifp->if_mib.ifmd_name,
@@ -348,7 +341,7 @@
 sort_interface_list(void)
 {
 	struct	if_stat	*ifp = NULL;
-	u_int	y = 0;	
+	u_int	y = 0;
 
 	y = STARTING_ROW;
 	SLIST_FOREACH(ifp, &curlist, link) {
@@ -378,7 +371,7 @@
 	return data;
 }
 
-static void 
+static void
 getifmibdata(int row, struct ifmibdata *data)
 {
 	size_t	datalen = 0;
@@ -391,8 +384,8 @@
 	datalen = sizeof(*data);
 	name[4] = row;
 
-	if (sysctl(name, 6, (void *)data, (size_t *)&datalen, (void *)NULL,
-	    (size_t)0) != 0)
+	if ((sysctl(name, 6, (void *)data, (size_t *)&datalen, (void *)NULL,
+	    (size_t)0) != 0) && (errno != ENOENT))
 		IFSTAT_ERR(2, "sysctl error getting interface data");
 }
 
Index: iostat.c
===================================================================
RCS file: /home/cvs/src/usr.bin/systat/iostat.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/systat/iostat.c -L usr.bin/systat/iostat.c -u -r1.1.1.1 -r1.2
--- usr.bin/systat/iostat.c
+++ usr.bin/systat/iostat.c
@@ -60,7 +60,7 @@
 
 #include <sys/cdefs.h>
 
-__FBSDID("$FreeBSD: src/usr.bin/systat/iostat.c,v 1.21 2003/11/01 02:06:02 tjr Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/systat/iostat.c,v 1.24 2006/11/27 20:19:05 yar Exp $");
 
 #ifdef lint
 static const char sccsid[] = "@(#)iostat.c	8.1 (Berkeley) 6/6/93";
@@ -97,7 +97,7 @@
 WINDOW *
 openiostat()
 {
-	return (subwin(stdscr, LINES-1-5, 0, 5, 0));
+	return (subwin(stdscr, LINES-3-1, 0, MAINWIN_ROW, 0));
 }
 
 void
@@ -121,7 +121,7 @@
 	last.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo));
 	bzero(cur.dinfo, sizeof(struct devinfo));
 	bzero(last.dinfo, sizeof(struct devinfo));
-	
+
 	/*
 	 * This value for maxshowdevs (100) is bogus.  I'm not sure exactly
 	 * how to calculate it, though.
@@ -149,7 +149,7 @@
 	cur.dinfo = tmp_dinfo;
 
 	last.snap_time = cur.snap_time;
-         
+
 	/*
 	 * Here what we want to do is refresh our device stats.
 	 * getdevs() returns 1 when the device list has changed.
@@ -182,7 +182,7 @@
 	row = 0;
 	wmove(wnd, row, 0); wclrtobot(wnd);
 	mvwaddstr(wnd, row++, INSET,
-	    "/0   /10  /20  /30  /40  /50  /60  /70  /80  /90  /100");
+	    "/0%  /10  /20  /30  /40  /50  /60  /70  /80  /90  /100");
 	mvwaddstr(wnd, row++, 0, "cpu  user|");
 	mvwaddstr(wnd, row++, 0, "     nice|");
 	mvwaddstr(wnd, row++, 0, "   system|");
@@ -244,7 +244,7 @@
 	char tmpstr[10];
 
 	mvwaddstr(wnd, row++, INSET,
-	    "/0   /10  /20  /30  /40  /50  /60  /70  /80  /90  /100");
+	    "/0%  /10  /20  /30  /40  /50  /60  /70  /80  /90  /100");
 	linesperregion = 2 + kbpt;
 	for (i = 0; i < num_devices; i++)
 		if (dev_select[i].selected) {
@@ -252,7 +252,7 @@
 				break;
 			sprintf(tmpstr, "%s%d", dev_select[i].device_name,
 				dev_select[i].unit_number);
-			mvwprintw(wnd, row++, 0, "%-5.5s MB/s|", 
+			mvwprintw(wnd, row++, 0, "%-5.5s MB/s|",
 				  tmpstr);
 			mvwaddstr(wnd, row++, 0, "      tps|");
 			if (kbpt)
@@ -319,7 +319,7 @@
 	long double kb_per_transfer, mb_per_second;
 	long double busy_seconds;
 	int di;
-	
+
 	di = dev_select[dn].position;
 
 	busy_seconds = cur.snap_time - last.snap_time;
Index: swap.c
===================================================================
RCS file: /home/cvs/src/usr.bin/systat/swap.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/systat/swap.c -L usr.bin/systat/swap.c -u -r1.1.1.1 -r1.2
--- usr.bin/systat/swap.c
+++ usr.bin/systat/swap.c
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 
-__FBSDID("$FreeBSD: src/usr.bin/systat/swap.c,v 1.21 2002/12/30 18:14:43 mike Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/systat/swap.c,v 1.35 2006/12/23 22:39:38 yar Exp $");
 
 #ifdef lint
 static const char sccsid[] = "@(#)swap.c	8.3 (Berkeley) 4/29/95";
@@ -60,13 +60,17 @@
 
 kvm_t	*kd;
 
+static char *header;
 static long blocksize;
+static int dlen, odlen;
 static int hlen;
+static int ulen, oulen;
+static int pagesize;
 
 WINDOW *
 openswap()
 {
-	return (subwin(stdscr, LINES-5-1, 0, 5, 0));
+	return (subwin(stdscr, LINES-3-1, 0, MAINWIN_ROW, 0));
 }
 
 void
@@ -86,113 +90,134 @@
  * Kevin Lahey <kml at rokkaku.atl.ga.us>.
  */
 
+#define NSWAP	16
+
+static struct kvm_swap kvmsw[NSWAP];
+static int kvnsw, okvnsw;
+
+static void calclens(void);
+
+#define CONVERT(v)	((int)((int64_t)(v) * pagesize / blocksize))
+
+static void
+calclens()
+{
+	int i, n;
+	int len;
+
+	dlen = sizeof("Disk");
+	for (i = 0; i < kvnsw; ++i) {
+		len = strlen(kvmsw[i].ksw_devname);
+		if (dlen < len)
+			dlen = len;
+	}
+
+	ulen = sizeof("Used");
+	for (n = CONVERT(kvmsw[kvnsw].ksw_used), len = 2; n /= 10; ++len);
+	if (ulen < len)
+		ulen = len;
+}
+
 int
 initswap()
 {
-	char msgbuf[BUFSIZ];
 	static int once = 0;
-	struct kvm_swap dummy;
 
 	if (once)
 		return (1);
 
-	if (kvm_getswapinfo(kd, &dummy, 1, 0) < 0) {
-		snprintf(msgbuf, sizeof(msgbuf), "systat: kvm_getswapinfo failed");
-		error("%s", msgbuf);
+	header = getbsize(&hlen, &blocksize);
+	pagesize = getpagesize();
+
+	if ((kvnsw = kvm_getswapinfo(kd, kvmsw, NSWAP, 0)) < 0) {
+		error("systat: kvm_getswapinfo failed");
 		return (0);
 	}
+	okvnsw = kvnsw;
+
+	calclens();
+	odlen = dlen;
+	oulen = ulen;
 
 	once = 1;
 	return (1);
 }
 
-static struct kvm_swap	kvmsw[16];
-static int kvnsw;
-
 void
 fetchswap()
 {
-	kvnsw = kvm_getswapinfo(kd, kvmsw, 16, 0);
+
+	okvnsw = kvnsw;
+	if ((kvnsw = kvm_getswapinfo(kd, kvmsw, NSWAP, 0)) < 0) {
+		error("systat: kvm_getswapinfo failed");
+		return;
+	}
+
+	odlen = dlen;
+	oulen = ulen;
+	calclens();
 }
 
 void
 labelswap()
 {
-	char *header;
-	int row, i;
+	const char *name;
+	int i;
 
 	fetchswap();
 
-	row = 0;
-	wmove(wnd, row, 0); wclrtobot(wnd);
-	header = getbsize(&hlen, &blocksize);
-	mvwprintw(wnd, row++, 0, "%-5s%*s%9s %55s",
-	    "Disk", hlen, header, "Used",
-	    "/0%  /10% /20% /30% /40% /50% /60% /70% /80% /90% /100");
+	werase(wnd);
 
-	for (i = 0; i < kvnsw; ++i) {
-		mvwprintw(wnd, i + 1, 0, "%-5s", kvmsw[i].ksw_devname);
+	mvwprintw(wnd, 0, 0, "%*s%*s%*s %s",
+	    -dlen, "Disk", hlen, header, ulen, "Used",
+	    "/0%  /10  /20  /30  /40  /50  /60  /70  /80  /90  /100");
+
+	for (i = 0; i <= kvnsw; ++i) {
+		if (i == kvnsw) {
+			if (kvnsw == 1)
+				break;
+			name = "Total";
+		} else
+			name = kvmsw[i].ksw_devname;
+		mvwprintw(wnd, i + 1, 0, "%*s", -dlen, name);
 	}
 }
 
 void
 showswap()
 {
+	int count;
 	int i;
-	int pagesize = getpagesize();
 
-#define CONVERT(v)      ((int)((quad_t)(v) * pagesize / blocksize))
+	if (kvnsw != okvnsw || dlen != odlen || ulen != oulen)
+		labelswap();
 
 	for (i = 0; i <= kvnsw; ++i) {
-		int lcol = 5;
-		int count;
-
 		if (i == kvnsw) {
 			if (kvnsw == 1)
 				break;
-			mvwprintw(
-			    wnd,
-			    i + 1,
-			    lcol,
-			    "%-5s",
-			    "Total"
-			);
-			lcol += 5;
 		}
+
 		if (kvmsw[i].ksw_total == 0) {
 			mvwprintw(
 			    wnd,
 			    i + 1,
-			    lcol + 5,
+			    dlen + hlen + ulen + 1,
 			    "(swap not configured)"
 			);
 			continue;
 		}
 
-		mvwprintw(
-		    wnd, 
-		    i + 1, 
-		    lcol,
-		    "%*d",
-		    hlen, 
-		    CONVERT(kvmsw[i].ksw_total)
-		);
-		lcol += hlen;
-
-		mvwprintw(
-		    wnd,
-		    i + 1,
-		    lcol, 
-		    "%9d  ",
-		    CONVERT(kvmsw[i].ksw_used)
-		);
+		wmove(wnd, i + 1, dlen);
 
-		count = (int)((double)kvmsw[i].ksw_used * 49.999 /
-		    (double)kvmsw[i].ksw_total);
+		wprintw(wnd, "%*d", hlen, CONVERT(kvmsw[i].ksw_total));
+		wprintw(wnd, "%*d", ulen, CONVERT(kvmsw[i].ksw_used));
 
-		while (count >= 0) {
+		count = 50.0 * kvmsw[i].ksw_used / kvmsw[i].ksw_total + 1;
+
+		waddch(wnd, ' ');
+		while (count--)
 			waddch(wnd, 'X');
-			--count;
-		}
+		wclrtoeol(wnd);
 	}
 }
Index: vmstat.c
===================================================================
RCS file: /home/cvs/src/usr.bin/systat/vmstat.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -L usr.bin/systat/vmstat.c -L usr.bin/systat/vmstat.c -u -r1.2 -r1.3
--- usr.bin/systat/vmstat.c
+++ usr.bin/systat/vmstat.c
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 
-__FBSDID("$FreeBSD: src/usr.bin/systat/vmstat.c,v 1.60.2.1 2006/03/21 20:49:50 jmg Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/systat/vmstat.c,v 1.83 2006/11/28 12:46:02 ru Exp $");
 
 #ifdef lint
 static const char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 1/12/94";
@@ -149,7 +149,6 @@
 static	long *intrloc;
 static	char **intrname;
 static	int nextintsrow;
-static  int extended_vm_stats;
 
 struct	utmp utmp;
 
@@ -179,25 +178,27 @@
 /*
  * These constants define where the major pieces are laid out
  */
-#define STATROW		 0	/* uses 1 row and 68 cols */
-#define STATCOL		 2
-#define MEMROW		 2	/* uses 4 rows and 31 cols */
+#define STATROW		 0	/* uses 1 row and 67 cols */
+#define STATCOL		 0
+#define MEMROW		 2	/* uses 4 rows and 45 cols */
 #define MEMCOL		 0
-#define PAGEROW		 2	/* uses 4 rows and 26 cols */
-#define PAGECOL		46
-#define INTSROW		 6	/* uses all rows to bottom and 17 cols */
-#define INTSCOL		61
-#define PROCSROW	 7	/* uses 2 rows and 20 cols */
+#define PAGEROW		 2	/* uses 4 rows and 30 cols */
+#define PAGECOL		47
+#define INTSROW		 6	/* uses all rows to bottom and 16 cols */
+#define INTSCOL		64
+#define PROCSROW	 6	/* uses 3 rows and 19 cols */
 #define PROCSCOL	 0
-#define GENSTATROW	 7	/* uses 2 rows and 30 cols */
-#define GENSTATCOL	20
-#define VMSTATROW	 6	/* uses 17 rows and 12 cols */
-#define VMSTATCOL	48
-#define GRAPHROW	10	/* uses 3 rows and 51 cols */
+#define GENSTATROW	 7	/* uses 2 rows and 29 cols */
+#define GENSTATCOL	21
+#define VMSTATROW	 7	/* uses 17 rows and 12-14 cols */
+#define VMSTATCOL	49	/* actually 50-51 for some fields */
+#define GRAPHROW	10	/* uses 3 rows and 49-51 cols */
 #define GRAPHCOL	 0
-#define NAMEIROW	14	/* uses 3 rows and 38 cols */
+#define VNSTATROW	13	/* uses 4 rows and 13 columns */
+#define VNSTATCOL	35
+#define NAMEIROW	14	/* uses 3 rows and 32 cols */
 #define NAMEICOL	 0
-#define DISKROW		18	/* uses 5 rows and 50 cols (for 9 drives) */
+#define DISKROW		18	/* uses 5 rows and 47 cols (for 7 drives) */
 #define DISKCOL		 0
 
 #define	DRIVESPACE	 7	/* max # for space */
@@ -207,7 +208,7 @@
 int
 initkre()
 {
-	char *intrnamebuf, *cp;
+	char *cp, *cp1, *cp2, *intrnamebuf, *nextcp;
 	int i;
 	size_t sz;
 
@@ -249,8 +250,39 @@
 			return(0);
 		}
 		for (cp = intrnamebuf, i = 0; i < nintr; i++) {
+			nextcp = cp + strlen(cp) + 1;
+
+			/* Discard trailing spaces. */
+			for (cp1 = nextcp - 1; cp1 > cp && *(cp1 - 1) == ' '; )
+				*--cp1 = '\0';
+
+			/* Convert "irqN: name" to "name irqN". */
+			if (strncmp(cp, "irq", 3) == 0) {
+				cp1 = cp + 3;
+				while (isdigit((u_char)*cp1))
+					cp1++;
+				if (cp1 != cp && *cp1 == ':' &&
+				    *(cp1 + 1) == ' ') {
+					*cp1 = '\0';
+					cp1 = cp1 + 2;
+					cp2 = strdup(cp);
+					bcopy(cp1, cp, strlen(cp1) + 1);
+					strcat(cp, " ");
+					strcat(cp, cp2);
+					free(cp2);
+				}
+			}
+
+			/*
+			 * Convert "name irqN" to "name N" if the former is
+			 * longer than the field width.
+			 */
+			if ((cp1 = strstr(cp, "irq")) != NULL &&
+			    strlen(cp) > 10)
+				bcopy(cp1 + 3, cp1, strlen(cp1 + 3) + 1);
+
 			intrname[i] = cp;
-			cp += strlen(cp) + 1;
+			cp = nextcp;
 		}
 		nextintsrow = INTSROW + 2;
 		allocinfo(&s);
@@ -286,7 +318,7 @@
 	int i, j;
 
 	clear();
-	mvprintw(STATROW, STATCOL + 4, "users    Load");
+	mvprintw(STATROW, STATCOL + 6, "users    Load");
 	mvprintw(MEMROW, MEMCOL, "Mem:KB    REAL            VIRTUAL");
 	mvprintw(MEMROW + 1, MEMCOL, "        Tot   Share      Tot    Share");
 	mvprintw(MEMROW + 2, MEMCOL, "Act");
@@ -294,49 +326,55 @@
 
 	mvprintw(MEMROW + 1, MEMCOL + 41, "Free");
 
-	mvprintw(PAGEROW, PAGECOL,     "        VN PAGER  SWAP PAGER ");
-	mvprintw(PAGEROW + 1, PAGECOL, "        in  out     in  out ");
+	mvprintw(PAGEROW, PAGECOL,     "         VN PAGER   SWAP PAGER");
+	mvprintw(PAGEROW + 1, PAGECOL, "         in   out     in   out");
 	mvprintw(PAGEROW + 2, PAGECOL, "count");
 	mvprintw(PAGEROW + 3, PAGECOL, "pages");
 
-	mvprintw(INTSROW, INTSCOL + 3, " Interrupts");
-	mvprintw(INTSROW + 1, INTSCOL + 9, "total");
+	mvprintw(INTSROW, INTSCOL + 1, "Interrupts");
+	mvprintw(INTSROW + 1, INTSCOL + 6, "total");
 
-	mvprintw(VMSTATROW + 1, VMSTATCOL + 10, "cow");
-	mvprintw(VMSTATROW + 2, VMSTATCOL + 10, "wire");
-	mvprintw(VMSTATROW + 3, VMSTATCOL + 10, "act");
-	mvprintw(VMSTATROW + 4, VMSTATCOL + 10, "inact");
-	mvprintw(VMSTATROW + 5, VMSTATCOL + 10, "cache");
-	mvprintw(VMSTATROW + 6, VMSTATCOL + 10, "free");
-	mvprintw(VMSTATROW + 7, VMSTATCOL + 10, "daefr");
-	mvprintw(VMSTATROW + 8, VMSTATCOL + 10, "prcfr");
-	mvprintw(VMSTATROW + 9, VMSTATCOL + 10, "react");
-	mvprintw(VMSTATROW + 10, VMSTATCOL + 10, "pdwake");
-	mvprintw(VMSTATROW + 11, VMSTATCOL + 10, "pdpgs");
-	mvprintw(VMSTATROW + 12, VMSTATCOL + 10, "intrn");
-	mvprintw(VMSTATROW + 13, VMSTATCOL + 10, "buf");
-	mvprintw(VMSTATROW + 14, VMSTATCOL + 10, "dirtybuf");
-
-	mvprintw(VMSTATROW + 15, VMSTATCOL + 10, "desiredvnodes");
-	mvprintw(VMSTATROW + 16, VMSTATCOL + 10, "numvnodes");
-	mvprintw(VMSTATROW + 17, VMSTATCOL + 10, "freevnodes");
+	mvprintw(VMSTATROW, VMSTATCOL + 9, "cow");
+	mvprintw(VMSTATROW + 1, VMSTATCOL + 9, "zfod");
+	mvprintw(VMSTATROW + 2, VMSTATCOL + 9, "ozfod");
+	mvprintw(VMSTATROW + 3, VMSTATCOL + 9 - 1, "%%ozfod");
+	mvprintw(VMSTATROW + 4, VMSTATCOL + 9, "daefr");
+	mvprintw(VMSTATROW + 5, VMSTATCOL + 9, "prcfr");
+	mvprintw(VMSTATROW + 6, VMSTATCOL + 9, "totfr");
+	mvprintw(VMSTATROW + 7, VMSTATCOL + 9, "react");
+	mvprintw(VMSTATROW + 8, VMSTATCOL + 9, "pdwak");
+	mvprintw(VMSTATROW + 9, VMSTATCOL + 9, "pdpgs");
+	mvprintw(VMSTATROW + 10, VMSTATCOL + 9, "intrn");
+	mvprintw(VMSTATROW + 11, VMSTATCOL + 9, "wire");
+	mvprintw(VMSTATROW + 12, VMSTATCOL + 9, "act");
+	mvprintw(VMSTATROW + 13, VMSTATCOL + 9, "inact");
+	mvprintw(VMSTATROW + 14, VMSTATCOL + 9, "cache");
+	mvprintw(VMSTATROW + 15, VMSTATCOL + 9, "free");
+	if (LINES - 1 > VMSTATROW + 16)
+		mvprintw(VMSTATROW + 16, VMSTATCOL + 9, "buf");
 
-	mvprintw(GENSTATROW, GENSTATCOL, "  Csw  Trp  Sys  Int  Sof  Flt");
+	mvprintw(GENSTATROW, GENSTATCOL, " Csw  Trp  Sys  Int  Sof  Flt");
 
 	mvprintw(GRAPHROW, GRAPHCOL,
 		"  . %%Sys    . %%Intr   . %%User   . %%Nice   . %%Idle");
-	mvprintw(PROCSROW, PROCSCOL, "Proc:r  p  d  s  w");
+	mvprintw(PROCSROW, PROCSCOL, "Proc:");
+	mvprintw(PROCSROW + 1, PROCSCOL, "  r   p   d   s   w");
 	mvprintw(GRAPHROW + 1, GRAPHCOL,
 		"|    |    |    |    |    |    |    |    |    |    |");
 
-	mvprintw(NAMEIROW, NAMEICOL, "Namei         Name-cache    Dir-cache");
+	mvprintw(VNSTATROW, VNSTATCOL + 8, "dtbuf");
+	mvprintw(VNSTATROW + 1, VNSTATCOL + 8, "desvn");
+	mvprintw(VNSTATROW + 2, VNSTATCOL + 8, "numvn");
+	mvprintw(VNSTATROW + 3, VNSTATCOL + 8, "frevn");
+
+	mvprintw(NAMEIROW, NAMEICOL, "Namei     Name-cache   Dir-cache");
 	mvprintw(NAMEIROW + 1, NAMEICOL,
-		"    Calls     hits    %%     hits    %%");
+		"   Calls    hits   %%    hits   %%");
 	mvprintw(DISKROW, DISKCOL, "Disks");
 	mvprintw(DISKROW + 1, DISKCOL, "KB/t");
 	mvprintw(DISKROW + 2, DISKCOL, "tps");
 	mvprintw(DISKROW + 3, DISKCOL, "MB/s");
-	mvprintw(DISKROW + 4, DISKCOL, "%% busy");
+	mvprintw(DISKROW + 4, DISKCOL, "%%busy");
 	/*
 	 * For now, we don't support a fourth disk statistic.  So there's
 	 * no point in providing a label for it.  If someone can think of a
@@ -354,24 +392,10 @@
 			j++;
 		}
 
-	if (j <= 4) {
-		/*
-		 * room for extended VM stats
-		 */
-		mvprintw(VMSTATROW + 11, VMSTATCOL - 6, "zfod");
-		mvprintw(VMSTATROW + 12, VMSTATCOL - 6, "ozfod");
-		mvprintw(VMSTATROW + 13, VMSTATCOL - 6, "%%slo-z");
-		mvprintw(VMSTATROW + 14, VMSTATCOL - 6, "tfree");
-		extended_vm_stats = 1;
-	} else {
-		extended_vm_stats = 0;
-		mvprintw(VMSTATROW + 0, VMSTATCOL + 10, "zfod");
-	}
-
 	for (i = 0; i < nintr; i++) {
 		if (intrloc[i] == 0)
 			continue;
-		mvprintw(intrloc[i], INTSCOL + 9, "%-10.10s", intrname[i]);
+		mvprintw(intrloc[i], INTSCOL + 6, "%-10.10s", intrname[i]);
 	}
 }
 
@@ -381,8 +405,10 @@
 #define Z(fld)	{t = s.nchstats.fld; s.nchstats.fld -= s1.nchstats.fld; \
 	if(state == TIME) s1.nchstats.fld = t;}
 #define PUTRATE(fld, l, c, w) \
+do { \
 	Y(fld); \
-	putint((int)((float)s.fld/etime + 0.5), l, c, w)
+	putint((int)((float)s.fld/etime + 0.5), l, c, w); \
+} while (0)
 #define MAXFAIL 5
 
 static	char cpuchar[CPUSTATES] = { '=' , '+', '>', '-', ' ' };
@@ -394,9 +420,8 @@
 {
 	float f1, f2;
 	int psiz, inttotal;
-	int i, j, k, l, lc;
+	int i, l, lc;
 	static int failcnt = 0;
-	char intrbuffer[10];
 
 	etime = 0;
 	for(i = 0; i < CPUSTATES; i++) {
@@ -428,22 +453,15 @@
 			if (nextintsrow == LINES)
 				continue;
 			intrloc[i] = nextintsrow++;
-			k = 0;
-			for (j = 0; j < (int)sizeof(intrbuffer); j++) {
-				if (strncmp(&intrname[i][j], "irq", 3) == 0)
-					j += 3;
-				intrbuffer[k++] = intrname[i][j];
-			}
-			intrbuffer[k] = '\0';
-			mvprintw(intrloc[i], INTSCOL + 9, "%-10.10s",
-				intrbuffer);
+			mvprintw(intrloc[i], INTSCOL + 6, "%-10.10s",
+				intrname[i]);
 		}
 		X(intrcnt);
 		l = (int)((float)s.intrcnt[i]/etime + 0.5);
 		inttotal += l;
-		putint(l, intrloc[i], INTSCOL + 2, 6);
+		putint(l, intrloc[i], INTSCOL, 5);
 	}
-	putint(inttotal, INTSROW + 1, INTSCOL + 2, 6);
+	putint(inttotal, INTSROW + 1, INTSCOL, 5);
 	Z(ncs_goodhits); Z(ncs_badhits); Z(ncs_miss);
 	Z(ncs_long); Z(ncs_pass2); Z(ncs_2passes); Z(ncs_neghits);
 	s.nchcount = nchtotal.ncs_goodhits + nchtotal.ncs_badhits +
@@ -458,8 +476,6 @@
 		f1 = cputime(i);
 		f2 += f1;
 		l = (int) ((f2 + 1.0) / 2.0) - psiz;
-		if (f1 > 99.9)
-			f1 = 99.9;	/* no room to display 100.0 */
 		putfloat(f1, GRAPHROW, GRAPHCOL + 10 * lc, 4, 1, 0);
 		move(GRAPHROW + 2, psiz);
 		psiz += l;
@@ -467,84 +483,61 @@
 			addch(cpuchar[lc]);
 	}
 
-	putint(ucount(), STATROW, STATCOL, 3);
-	putfloat(avenrun[0], STATROW, STATCOL + 17, 6, 2, 0);
-	putfloat(avenrun[1], STATROW, STATCOL + 23, 6, 2, 0);
-	putfloat(avenrun[2], STATROW, STATCOL + 29, 6, 2, 0);
-	mvaddstr(STATROW, STATCOL + 53, buf);
+	putint(ucount(), STATROW, STATCOL, 5);
+	putfloat(avenrun[0], STATROW, STATCOL + 20, 5, 2, 0);
+	putfloat(avenrun[1], STATROW, STATCOL + 26, 5, 2, 0);
+	putfloat(avenrun[2], STATROW, STATCOL + 32, 5, 2, 0);
+	mvaddstr(STATROW, STATCOL + 55, buf);
 #define pgtokb(pg)	((pg) * (s.v_page_size / 1024))
-	putint(pgtokb(total.t_arm), MEMROW + 2, MEMCOL + 3, 8);
-	putint(pgtokb(total.t_armshr), MEMROW + 2, MEMCOL + 11, 8);
-	putint(pgtokb(total.t_avm), MEMROW + 2, MEMCOL + 19, 9);
-	putint(pgtokb(total.t_avmshr), MEMROW + 2, MEMCOL + 28, 9);
-	putint(pgtokb(total.t_rm), MEMROW + 3, MEMCOL + 3, 8);
-	putint(pgtokb(total.t_rmshr), MEMROW + 3, MEMCOL + 11, 8);
-	putint(pgtokb(total.t_vm), MEMROW + 3, MEMCOL + 19, 9);
-	putint(pgtokb(total.t_vmshr), MEMROW + 3, MEMCOL + 28, 9);
-	putint(pgtokb(total.t_free), MEMROW + 2, MEMCOL + 37, 8);
-	putint(total.t_rq - 1, PROCSROW + 1, PROCSCOL + 3, 3);
-	putint(total.t_pw, PROCSROW + 1, PROCSCOL + 6, 3);
-	putint(total.t_dw, PROCSROW + 1, PROCSCOL + 9, 3);
-	putint(total.t_sl, PROCSROW + 1, PROCSCOL + 12, 3);
-	putint(total.t_sw, PROCSROW + 1, PROCSCOL + 15, 3);
-	if (extended_vm_stats == 0) {
-		PUTRATE(v_zfod, VMSTATROW + 0, VMSTATCOL + 4, 5);
-	}
-	PUTRATE(v_cow_faults, VMSTATROW + 1, VMSTATCOL + 3, 6);
-	putint(pgtokb(s.v_wire_count), VMSTATROW + 2, VMSTATCOL, 9);
-	putint(pgtokb(s.v_active_count), VMSTATROW + 3, VMSTATCOL, 9);
-	putint(pgtokb(s.v_inactive_count), VMSTATROW + 4, VMSTATCOL, 9);
-	putint(pgtokb(s.v_cache_count), VMSTATROW + 5, VMSTATCOL, 9);
-	putint(pgtokb(s.v_free_count), VMSTATROW + 6, VMSTATCOL, 9);
-	PUTRATE(v_dfree, VMSTATROW + 7, VMSTATCOL, 9);
-	PUTRATE(v_pfree, VMSTATROW + 8, VMSTATCOL, 9);
-	PUTRATE(v_reactivated, VMSTATROW + 9, VMSTATCOL, 9);
-	PUTRATE(v_pdwakeups, VMSTATROW + 10, VMSTATCOL, 9);
-	PUTRATE(v_pdpages, VMSTATROW + 11, VMSTATCOL, 9);
-	PUTRATE(v_intrans, VMSTATROW + 12, VMSTATCOL, 9);
-
-	if (extended_vm_stats) {
-	    PUTRATE(v_zfod, VMSTATROW + 11, VMSTATCOL - 16, 9);
-	    PUTRATE(v_ozfod, VMSTATROW + 12, VMSTATCOL - 16, 9);
-	    putint(
-		((s.v_ozfod < s.v_zfod) ?
-		    s.v_ozfod * 100 / s.v_zfod : 
-		    0
-		),
-		VMSTATROW + 13, 
-		VMSTATCOL - 16,
-		9
-	    );
-	    PUTRATE(v_tfree, VMSTATROW + 14, VMSTATCOL - 16, 9);
-	}
-
-	putint(s.bufspace/1024, VMSTATROW + 13, VMSTATCOL, 9);
-	putint(s.numdirtybuffers, VMSTATROW + 14, VMSTATCOL, 9);
-	putint(s.desiredvnodes, VMSTATROW + 15, VMSTATCOL, 9);
-	putint(s.numvnodes, VMSTATROW + 16, VMSTATCOL, 9);
-	putint(s.freevnodes, VMSTATROW + 17, VMSTATCOL, 9);
-	PUTRATE(v_vnodein, PAGEROW + 2, PAGECOL + 5, 5);
-	PUTRATE(v_vnodeout, PAGEROW + 2, PAGECOL + 10, 5);
-	PUTRATE(v_swapin, PAGEROW + 2, PAGECOL + 17, 5);
-	PUTRATE(v_swapout, PAGEROW + 2, PAGECOL + 22, 5);
-	PUTRATE(v_vnodepgsin, PAGEROW + 3, PAGECOL + 5, 5);
-	PUTRATE(v_vnodepgsout, PAGEROW + 3, PAGECOL + 10, 5);
-	PUTRATE(v_swappgsin, PAGEROW + 3, PAGECOL + 17, 5);
-	PUTRATE(v_swappgsout, PAGEROW + 3, PAGECOL + 22, 5);
-	PUTRATE(v_swtch, GENSTATROW + 1, GENSTATCOL, 5);
-	PUTRATE(v_trap, GENSTATROW + 1, GENSTATCOL + 5, 5);
-	PUTRATE(v_syscall, GENSTATROW + 1, GENSTATCOL + 10, 5);
-	PUTRATE(v_intr, GENSTATROW + 1, GENSTATCOL + 15, 5);
-	PUTRATE(v_soft, GENSTATROW + 1, GENSTATCOL + 20, 5);
-	PUTRATE(v_vm_faults, GENSTATROW + 1, GENSTATCOL + 25, 5);
-	mvprintw(DISKROW, DISKCOL + 5, "                              ");
+	putint(pgtokb(total.t_arm), MEMROW + 2, MEMCOL + 4, 7);
+	putint(pgtokb(total.t_armshr), MEMROW + 2, MEMCOL + 12, 7);
+	putint(pgtokb(total.t_avm), MEMROW + 2, MEMCOL + 20, 8);
+	putint(pgtokb(total.t_avmshr), MEMROW + 2, MEMCOL + 29, 8);
+	putint(pgtokb(total.t_rm), MEMROW + 3, MEMCOL + 4, 7);
+	putint(pgtokb(total.t_rmshr), MEMROW + 3, MEMCOL + 12, 7);
+	putint(pgtokb(total.t_vm), MEMROW + 3, MEMCOL + 20, 8);
+	putint(pgtokb(total.t_vmshr), MEMROW + 3, MEMCOL + 29, 8);
+	putint(pgtokb(total.t_free), MEMROW + 2, MEMCOL + 38, 7);
+	putint(total.t_rq - 1, PROCSROW + 2, PROCSCOL, 3);
+	putint(total.t_pw, PROCSROW + 2, PROCSCOL + 4, 3);
+	putint(total.t_dw, PROCSROW + 2, PROCSCOL + 8, 3);
+	putint(total.t_sl, PROCSROW + 2, PROCSCOL + 12, 3);
+	putint(total.t_sw, PROCSROW + 2, PROCSCOL + 16, 3);
+	PUTRATE(v_cow_faults, VMSTATROW, VMSTATCOL + 2, 8 - 2);
+	PUTRATE(v_zfod, VMSTATROW + 1, VMSTATCOL + 2, 8 - 2);
+	PUTRATE(v_ozfod, VMSTATROW + 2, VMSTATCOL, 8);
+	putint(s.v_zfod != 0 ? (int)(s.v_ozfod * 100.0 / s.v_zfod) : 0,
+	    VMSTATROW + 3, VMSTATCOL + 1, 8 - 1);
+	PUTRATE(v_dfree, VMSTATROW + 4, VMSTATCOL + 2, 8 - 2);
+	PUTRATE(v_pfree, VMSTATROW + 5, VMSTATCOL + 2, 8 - 2);
+	PUTRATE(v_tfree, VMSTATROW + 6, VMSTATCOL, 8);
+	PUTRATE(v_reactivated, VMSTATROW + 7, VMSTATCOL, 8);
+	PUTRATE(v_pdwakeups, VMSTATROW + 8, VMSTATCOL, 8);
+	PUTRATE(v_pdpages, VMSTATROW + 9, VMSTATCOL, 8);
+	PUTRATE(v_intrans, VMSTATROW + 10, VMSTATCOL, 8);
+	putint(pgtokb(s.v_wire_count), VMSTATROW + 11, VMSTATCOL, 8);
+	putint(pgtokb(s.v_active_count), VMSTATROW + 12, VMSTATCOL, 8);
+	putint(pgtokb(s.v_inactive_count), VMSTATROW + 13, VMSTATCOL, 8);
+	putint(pgtokb(s.v_cache_count), VMSTATROW + 14, VMSTATCOL, 8);
+	putint(pgtokb(s.v_free_count), VMSTATROW + 15, VMSTATCOL, 8);
+	if (LINES - 1 > VMSTATROW + 16)
+		putint(s.bufspace / 1024, VMSTATROW + 16, VMSTATCOL, 8);
+	PUTRATE(v_vnodein, PAGEROW + 2, PAGECOL + 6, 5);
+	PUTRATE(v_vnodeout, PAGEROW + 2, PAGECOL + 12, 5);
+	PUTRATE(v_swapin, PAGEROW + 2, PAGECOL + 19, 5);
+	PUTRATE(v_swapout, PAGEROW + 2, PAGECOL + 25, 5);
+	PUTRATE(v_vnodepgsin, PAGEROW + 3, PAGECOL + 6, 5);
+	PUTRATE(v_vnodepgsout, PAGEROW + 3, PAGECOL + 12, 5);
+	PUTRATE(v_swappgsin, PAGEROW + 3, PAGECOL + 19, 5);
+	PUTRATE(v_swappgsout, PAGEROW + 3, PAGECOL + 25, 5);
+	PUTRATE(v_swtch, GENSTATROW + 1, GENSTATCOL, 4);
+	PUTRATE(v_trap, GENSTATROW + 1, GENSTATCOL + 5, 4);
+	PUTRATE(v_syscall, GENSTATROW + 1, GENSTATCOL + 10, 4);
+	PUTRATE(v_intr, GENSTATROW + 1, GENSTATCOL + 15, 4);
+	PUTRATE(v_soft, GENSTATROW + 1, GENSTATCOL + 20, 4);
+	PUTRATE(v_vm_faults, GENSTATROW + 1, GENSTATCOL + 25, 4);
 	for (i = 0, lc = 0; i < num_devices && lc < MAXDRIVES; i++)
 		if (dev_select[i].selected) {
-			char tmpstr[80];
-			sprintf(tmpstr, "%s%d", dev_select[i].device_name,
-				dev_select[i].unit_number);
-			mvprintw(DISKROW, DISKCOL + 5 + 6 * lc,
-				" %5.5s", tmpstr);
 			switch(state) {
 			case TIME:
 				dinfo(i, ++lc, &cur, &last);
@@ -557,16 +550,20 @@
 				break;
 			}
 		}
-	putint(s.nchcount, NAMEIROW + 2, NAMEICOL, 9);
+	putint(s.numdirtybuffers, VNSTATROW, VNSTATCOL, 7);
+	putint(s.desiredvnodes, VNSTATROW + 1, VNSTATCOL, 7);
+	putint(s.numvnodes, VNSTATROW + 2, VNSTATCOL, 7);
+	putint(s.freevnodes, VNSTATROW + 3, VNSTATCOL, 7);
+	putint(s.nchcount, NAMEIROW + 2, NAMEICOL, 8);
 	putint((nchtotal.ncs_goodhits + nchtotal.ncs_neghits),
-	   NAMEIROW + 2, NAMEICOL + 9, 9);
+	   NAMEIROW + 2, NAMEICOL + 9, 7);
 #define nz(x)	((x) ? (x) : 1)
 	putfloat((nchtotal.ncs_goodhits+nchtotal.ncs_neghits) *
 	   100.0 / nz(s.nchcount),
-	   NAMEIROW + 2, NAMEICOL + 19, 4, 0, 1);
-	putint(nchtotal.ncs_pass2, NAMEIROW + 2, NAMEICOL + 23, 9);
+	   NAMEIROW + 2, NAMEICOL + 17, 3, 0, 1);
+	putint(nchtotal.ncs_pass2, NAMEIROW + 2, NAMEICOL + 21, 7);
 	putfloat(nchtotal.ncs_pass2 * 100.0 / nz(s.nchcount),
-	   NAMEIROW + 2, NAMEICOL + 33, 4, 0, 1);
+	   NAMEIROW + 2, NAMEICOL + 29, 3, 0, 1);
 #undef nz
 }
 
@@ -669,19 +666,30 @@
 putint(n, l, lc, w)
 	int n, l, lc, w;
 {
+	int snr;
 	char b[128];
 
 	move(l, lc);
+#ifdef DEBUG
+		while (w-- > 0)
+			addch('*');
+		return;
+#endif
 	if (n == 0) {
 		while (w-- > 0)
 			addch(' ');
 		return;
 	}
-	snprintf(b, sizeof(b), "%*d", w, n);
-	if ((int)strlen(b) > w)
-		snprintf(b, sizeof(b), "%*dk", w - 1, n / 1000);
-	if ((int)strlen(b) > w)
-		snprintf(b, sizeof(b), "%*dM", w - 1, n / 1000000);
+	snr = snprintf(b, sizeof(b), "%*d", w, n);
+	if (snr != w)
+		snr = snprintf(b, sizeof(b), "%*dk", w - 1, n / 1000);
+	if (snr != w)
+		snr = snprintf(b, sizeof(b), "%*dM", w - 1, n / 1000000);
+	if (snr != w) {
+		while (w-- > 0)
+			addch('*');
+		return;
+	}
 	addstr(b);
 }
 
@@ -690,18 +698,24 @@
 	double f;
 	int l, lc, w, d, nz;
 {
+	int snr;
 	char b[128];
 
 	move(l, lc);
+#ifdef DEBUG
+		while (--w >= 0)
+			addch('*');
+		return;
+#endif
 	if (nz && f == 0.0) {
 		while (--w >= 0)
 			addch(' ');
 		return;
 	}
-	snprintf(b, sizeof(b), "%*.*f", w, d, f);
-	if ((int)strlen(b) > w)
-		snprintf(b, sizeof(b), "%*.0f", w, f);
-	if ((int)strlen(b) > w) {
+	snr = snprintf(b, sizeof(b), "%*.*f", w, d, f);
+	if (snr != w)
+		snr = snprintf(b, sizeof(b), "%*.0f", w, f);
+	if (snr != w) {
 		while (--w >= 0)
 			addch('*');
 		return;
@@ -714,18 +728,24 @@
 	long double f;
 	int l, lc, w, d, nz;
 {
+	int snr;
 	char b[128];
 
 	move(l, lc);
+#ifdef DEBUG
+		while (--w >= 0)
+			addch('*');
+		return;
+#endif
 	if (nz && f == 0.0) {
 		while (--w >= 0)
 			addch(' ');
 		return;
 	}
-	sprintf(b, "%*.*Lf", w, d, f);
-	if ((int)strlen(b) > w)
-		sprintf(b, "%*.0Lf", w, f);
-	if ((int)strlen(b) > w) {
+	snr = snprintf(b, sizeof(b), "%*.*Lf", w, d, f);
+	if (snr != w)
+		snr = snprintf(b, sizeof(b), "%*.0Lf", w, f);
+	if (snr != w) {
 		while (--w >= 0)
 			addch('*');
 		return;
Index: cmdtab.c
===================================================================
RCS file: /home/cvs/src/usr.bin/systat/cmdtab.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/systat/cmdtab.c -L usr.bin/systat/cmdtab.c -u -r1.1.1.1 -r1.2
--- usr.bin/systat/cmdtab.c
+++ usr.bin/systat/cmdtab.c
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 
-__FBSDID("$FreeBSD: src/usr.bin/systat/cmdtab.c,v 1.9 2003/08/01 20:28:20 dwmalone Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/systat/cmdtab.c,v 1.10 2006/04/30 04:26:46 bde Exp $");
 
 #ifdef lint
 static const char sccsid[] = "@(#)cmdtab.c	8.1 (Berkeley) 6/6/93";
@@ -78,7 +78,7 @@
 #endif
 	{ "tcp",	showtcp,	fetchtcp,	labeltcp,
 	  inittcp,	opentcp,	closetcp,	cmdmode,
-	  resettcp,	0 },
+	  resettcp,	CF_LOADAV },
 	{ "ifstat",	showifstat,	fetchifstat,	labelifstat,
 	  initifstat,	openifstat,	closeifstat,	cmdifstat,
 	  0,		CF_LOADAV },
Index: convtbl.c
===================================================================
RCS file: /home/cvs/src/usr.bin/systat/convtbl.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/systat/convtbl.c -L usr.bin/systat/convtbl.c -u -r1.1.1.1 -r1.2
--- usr.bin/systat/convtbl.c
+++ usr.bin/systat/convtbl.c
@@ -25,41 +25,61 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/usr.bin/systat/convtbl.c,v 1.3 2004/07/04 16:11:03 stefanf Exp $
+ * $FreeBSD: src/usr.bin/systat/convtbl.c,v 1.12 2007/01/18 09:24:08 ru Exp $
  */
 
 #include <sys/types.h>
-#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
 #include "convtbl.h"
 
-struct	convtbl convtbl[] = {
-	/* mul, scale, str */
-	{ BYTE, BYTES, "bytes" },	/* SC_BYTE	(0) */
-	{ BYTE, KILO, "KB" },		/* SC_KILOBYTE	(1) */
-	{ BYTE, MEGA, "MB" },		/* SC_MEGABYTE	(2) */
-	{ BYTE, GIGA, "GB" },		/* SC_GIGABYTE	(3) */
-
-	{ BIT, BITS, "b" },		/* SC_BITS	(4) */
-	{ BIT, KILO, "Kb" },		/* SC_KILOBITS	(5) */
-	{ BIT, MEGA, "Mb" },		/* SC_MEGABITS	(6) */
-	{ BIT, GIGA, "Gb" },		/* SC_GIGABITS	(7) */
+#define BIT		(8)
+#define BITS		(1)
+#define KILOBIT		(1000LL)
+#define MEGABIT		(KILOBIT * 1000)
+#define GIGABIT		(MEGABIT * 1000)
+#define TERABIT		(GIGABIT * 1000)
+
+#define BYTE		(1)
+#define BYTES		(1)
+#define KILOBYTE	(1024LL)
+#define MEGABYTE	(KILOBYTE * 1024)
+#define GIGABYTE	(MEGABYTE * 1024)
+#define TERABYTE	(GIGABYTE * 1024)
+
+struct convtbl {
+	uintmax_t	 mul;
+	uintmax_t	 scale;
+	const char	*str;
+	const char	*name;
+};
 
-	{ 0, 0, "" }			/* SC_AUTO	(8) */
+static struct convtbl convtbl[] = {
+	/* mul, scale, str, name */
+	[SC_BYTE] =	{ BYTE, BYTES, "B", "byte" },
+	[SC_KILOBYTE] =	{ BYTE, KILOBYTE, "KB", "kbyte" },
+	[SC_MEGABYTE] =	{ BYTE, MEGABYTE, "MB", "mbyte" },
+	[SC_GIGABYTE] =	{ BYTE, GIGABYTE, "GB", "gbyte" },
+	[SC_TERABYTE] =	{ BYTE, TERABYTE, "TB", "tbyte" },
+
+	[SC_BIT] =	{ BIT, BITS, "b", "bit" },
+	[SC_KILOBIT] =	{ BIT, KILOBIT, "Kb", "kbit" },
+	[SC_MEGABIT] =	{ BIT, MEGABIT, "Mb", "mbit" },
+	[SC_GIGABIT] =	{ BIT, GIGABIT, "Gb", "gbit" },
+	[SC_TERABIT] =	{ BIT, TERABIT, "Tb", "tbit" },
 
+	[SC_AUTO] =	{ 0, 0, "", "auto" }
 };
 
-
-static __inline
+static
 struct convtbl *
-get_tbl_ptr(const u_long size, const u_int scale)
+get_tbl_ptr(const uintmax_t size, const int scale)
 {
-	struct	convtbl *tbl_ptr = NULL;
-	u_long	tmp = 0;
-	u_int	idx = scale;
+	uintmax_t	 tmp;
+	int		 idx;
 
 	/* If our index is out of range, default to auto-scaling. */
-	if (idx > SC_AUTO)
-		idx = SC_AUTO;
+	idx = scale < SC_AUTO ? scale : SC_AUTO;
 
 	if (idx == SC_AUTO)
 		/*
@@ -69,30 +89,62 @@
 		 * index as the array index into the conversion table.
 		 */
 		for (tmp = size, idx = SC_KILOBYTE;
-		     tmp >= MEGA && idx <= SC_GIGABYTE;
+		     tmp >= MEGABYTE && idx < SC_BIT - 1;
 		     tmp >>= 10, idx++);
 
-	tbl_ptr = &convtbl[idx];
-	return tbl_ptr;
+	return (&convtbl[idx]);
 }
 
 double
-convert(const u_long size, const u_int scale)
+convert(const uintmax_t size, const int scale)
 {
-	struct	convtbl	*tp = NULL;
+	struct convtbl	*tp;
 
 	tp = get_tbl_ptr(size, scale);
-
 	return ((double)size * tp->mul / tp->scale);
 
 }
 
 const char *
-get_string(const u_long size, const u_int scale)
+get_string(const uintmax_t size, const int scale)
 {
-	struct	convtbl *tp = NULL;
+	struct convtbl	*tp;
 
 	tp = get_tbl_ptr(size, scale);
+	return (tp->str);
+}
+
+int
+get_scale(const char *name)
+{
+	int i;
+
+	for (i = 0; i <= SC_AUTO; i++)
+		if (strcmp(convtbl[i].name, name) == 0)
+			return (i);
+	return (-1);
+}
 
-	return tp->str;
+const char *
+get_helplist()
+{
+	int i;
+	size_t len;
+	static char *buf;
+
+	if (buf == NULL) {
+		len = 0;
+		for (i = 0; i <= SC_AUTO; i++)
+			len += strlen(convtbl[i].name) + 2;
+		if ((buf = malloc(len)) != NULL) {
+			buf[0] = '\0';
+			for (i = 0; i <= SC_AUTO; i++) {
+				strcat(buf, convtbl[i].name);
+				if (i < SC_AUTO)
+					strcat(buf, ", ");
+			}
+		} else
+			return ("");
+	}
+	return (buf);
 }


More information about the Midnightbsd-cvs mailing list