Subject: bin/718: add -k flag to pstat(8)
To: None <gnats-admin@NetBSD.ORG>
From: None <mrg@mame.mu.OZ.AU>
List: netbsd-bugs
Date: 01/09/1995 09:35:05
>Number:         718
>Category:       bin
>Synopsis:       add -k flag to pstat(8)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Jan  9 09:35:03 1995
>Originator:     matthew green
>Organization:
bozotic softwar foundation
>Release:        n/a
>Environment:
	
System: NetBSD splode.mame.mu.OZ.AU 1.0A NetBSD 1.0A (_splode_) #119: Mon Jan 9 22:07:39 EST 1995 mrg@splode.mame.mu.OZ.AU:/splode/build/src/sys/arch/sparc/compile/_splode_ sparc


>Description:

	pstat doesn't have a -k flag to show swap sizes in 1k block,
	which is unlike other commands that show disk sizes (df, du).

>How-To-Repeat:
>Fix:

	this patch impliments a -k flag.

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);
  }
>Audit-Trail:
>Unformatted: