Subject: patch to give pstat(8) a -k flag.
To: None <current-users@NetBSD.ORG>
From: matthew green <mrg@mame.mu.OZ.AU>
List: current-users
Date: 01/09/1995 23:05:02
someone (i forget who now) want this.  i've also send-pr'ed it.

.mrg.

Index: pstat.8
===================================================================
RCS file: /local/cvs/src/usr.sbin/pstat/pstat.8,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 pstat.8
*** 1.1.1.1	1995/01/09 11:21:06
--- pstat.8	1995/01/09 11:50:38
***************
*** 40,46 ****
  .Nd display system data structures
  .Sh SYNOPSIS
  .Nm pstat
! .Op Fl Tfnstv
  .Op Fl M Ar core
  .Op Fl N Ar system
  .Sh DESCRIPTION
--- 40,46 ----
  .Nd display system data structures
  .Sh SYNOPSIS
  .Nm pstat
! .Op Fl Tfnstvk
  .Op Fl M Ar core
  .Op Fl N Ar system
  .Sh DESCRIPTION
***************
*** 60,66 ****
  The
  .Fl n
  option specifies that devices should be printed out by major/minor
! number rather than by name.
  .Pp
  Options are
  .Bl -tag -width indent
--- 60,68 ----
  The
  .Fl n
  option specifies that devices should be printed out by major/minor
! number rather than by name.  The
! .Fl k
! option specifies that swap sizes should be printed out in 1K blocks.
  .Pp
  Options are
  .Bl -tag -width indent
Index: pstat.c
===================================================================
RCS file: /local/cvs/src/usr.sbin/pstat/pstat.c,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 pstat.c
*** 1.1.1.1	1995/01/09 11:21:07
--- pstat.c	1995/01/09 11:59:12
***************
*** 164,169 ****
--- 164,170 ----
  };
  
  int	usenumflag;
+ int	kflag;
  int	totalflag;
  char	*nlistf	= NULL;
  char	*memf	= NULL;
***************
*** 219,225 ****
  	char buf[_POSIX2_LINE_MAX];
  
  	fileflag = swapflag = ttyflag = vnodeflag = 0;
! 	while ((ch = getopt(argc, argv, "TM:N:finstv")) != EOF)
  		switch (ch) {
  		case 'f':
  			fileflag = 1;
--- 220,226 ----
  	char buf[_POSIX2_LINE_MAX];
  
  	fileflag = swapflag = ttyflag = vnodeflag = 0;
! 	while ((ch = getopt(argc, argv, "TM:N:finstvk")) != EOF)
  		switch (ch) {
  		case 'f':
  			fileflag = 1;
***************
*** 242,247 ****
--- 243,251 ----
  		case 't':
  			ttyflag = 1;
  			break;
+ 		case 'k':
+ 			kflag = 1;
+ 			break;
  		case 'v':
  		case 'i':		/* Backward compatibility. */
  			vnodeflag = 1;
***************
*** 249,254 ****
--- 253,262 ----
  		default:
  			usage();
  		}
+ 	/* -k makes no sense without -s */
+ 	if (kflag && !swapflag)
+ 		usage();
+ 
  	argc -= optind;
  	argv += optind;
  
***************
*** 1090,1096 ****
  		}
  	}
  
! 	header = getbsize(&hlen, &blocksize);
  	if (!totalflag)
  		(void)printf("%-11s %*s %8s %8s %8s  %s\n",
  		    "Device", hlen, header,
--- 1100,1111 ----
  		}
  	}
  
! 	if (kflag) {
! 		header = "1K-blocks";
! 		blocksize = 1024;
! 		hlen = strlen(header);
! 	} else
! 		header = getbsize(&hlen, &blocksize);
  	if (!totalflag)
  		(void)printf("%-11s %*s %8s %8s %8s  %s\n",
  		    "Device", hlen, header,
***************
*** 1149,1154 ****
  usage()
  {
  	(void)fprintf(stderr,
! 	    "usage: pstat [-Tfnstv] [-M core] [-N system]\n");
  	exit(1);
  }
--- 1164,1169 ----
  usage()
  {
  	(void)fprintf(stderr,
! 	    "usage: pstat [-Tfnstvk] [-M core] [-N system]\n");
  	exit(1);
  }