[6508] in Athena Bugs

home help back first fref pref prev next nref lref last post

iostat changes

daemon@ATHENA.MIT.EDU (daemon@ATHENA.MIT.EDU)
Sat Dec 1 23:58:01 1990

To: bugs@ATHENA.MIT.EDU
Date: Sat, 01 Dec 90 23:57:48 EST
From: John Carr <jfc@ATHENA.MIT.EDU>


See also changes.72 798 and 473.

These changes to the RT iostat.c give a source file that compiles and
runs on RT and VAX (so iostat can be moved to /source/bsd-4.3/common).
The following bugs are fixed:

	transfer rates could be negative

	some errors messages were printed to stdout

	/**/ contcatenation was used when not needed

	an extra variable and label existed

*** /source/bsd-4.3/vax/usr.bin/iostat/iostat.c	Fri Apr 26 00:27:25 1985
--- iostat.c	Sat Dec  1 23:52:17 1990
***************
*** 46,51 ****
--- 46,55 ----
  	{ "_ubdinit" },
  #define X_UBDINIT	13
  #endif
+ #ifdef ibm032
+ #define X_MBDINIT	12
+ 	{ "_ioccdinit" },
+ #endif
  	{ 0 },
  };
  
***************
*** 56,74 ****
  int	ndrives = 0;
  #ifdef vax
  char	*defdrives[] = { "hp0", "hp1", "hp2",  0 };
- #else
- char	*defdrives[] = { 0 };
  #endif
  
  struct {
  	int	dk_busy;
! 	long	cp_time[CPUSTATES];
! 	long	*dk_time;
! 	long	*dk_wds;
! 	long	*dk_seek;
! 	long	*dk_xfer;
! 	long	tk_nin;
! 	long	tk_nout;
  } s, s1;
  
  int	mf;
--- 60,79 ----
  int	ndrives = 0;
  #ifdef vax
  char	*defdrives[] = { "hp0", "hp1", "hp2",  0 };
  #endif
+ #ifdef ibm032
+ char	*defdrives[] = { "hd0", "hd1", "hd2",  0 };
+ #endif
  
  struct {
  	int	dk_busy;
! 	unsigned long	cp_time[CPUSTATES];
! 	unsigned long	*dk_time;
! 	unsigned long	*dk_wds;
! 	unsigned long	*dk_seek;
! 	unsigned long	*dk_xfer;
! 	unsigned long	tk_nin;
! 	unsigned long	tk_nout;
  } s, s1;
  
  int	mf;
***************
*** 77,82 ****
--- 82,90 ----
  double	etime;
  int	tohdr = 1;
  int	printhdr();
+ #ifdef ibm032
+ int	debug;
+ #endif
  
  main(argc, argv)
  	char *argv[];
***************
*** 84,114 ****
  	extern char *ctime();
  	register  i;
  	int iter, ndrives;
- 	double f1, f2;
  	long t;
! 	char *arg, **cp, name[6], buf[BUFSIZ];
  
  	nlist("/vmunix", nl);
  	if(nl[X_DK_BUSY].n_type == 0) {
! 		printf("dk_busy not found in /vmunix namelist\n");
  		exit(1);
  	}
  	mf = open("/dev/kmem", 0);
  	if(mf < 0) {
! 		printf("cannot open /dev/kmem\n");
  		exit(1);
  	}
  	iter = 0;
  	for (argc--, argv++; argc > 0 && argv[0][0] == '-'; argc--, argv++)
  		;
! 	if (nl[DK_NDRIVE].n_value == 0) {
! 		printf("dk_ndrive undefined in system\n");
  		exit(1);
  	}
  	lseek(mf, nl[X_DK_NDRIVE].n_value, L_SET);
  	read(mf, &dk_ndrive, sizeof (dk_ndrive));
  	if (dk_ndrive <= 0) {
! 		printf("dk_ndrive %d\n", dk_ndrive);
  		exit(1);
  	}
  	dr_select = (int *)calloc(dk_ndrive, sizeof (int));
--- 92,121 ----
  	extern char *ctime();
  	register  i;
  	int iter, ndrives;
  	long t;
! 	char *arg, **cp, buf[BUFSIZ];
  
  	nlist("/vmunix", nl);
  	if(nl[X_DK_BUSY].n_type == 0) {
! 		fprintf(stderr, "dk_busy not found in /vmunix namelist\n");
  		exit(1);
  	}
  	mf = open("/dev/kmem", 0);
  	if(mf < 0) {
! 		perror("cannot open /dev/kmem");
  		exit(1);
  	}
  	iter = 0;
  	for (argc--, argv++; argc > 0 && argv[0][0] == '-'; argc--, argv++)
  		;
! 	if (nl[X_DK_NDRIVE].n_value == 0) {
! 		fprintf(stderr, "dk_ndrive undefined in system\n");
  		exit(1);
  	}
  	lseek(mf, nl[X_DK_NDRIVE].n_value, L_SET);
  	read(mf, &dk_ndrive, sizeof (dk_ndrive));
  	if (dk_ndrive <= 0) {
! 		fprintf(stderr, "dk_ndrive %d\n", dk_ndrive);
  		exit(1);
  	}
  	dr_select = (int *)calloc(dk_ndrive, sizeof (int));
***************
*** 115,126 ****
  	dr_name = (char **)calloc(dk_ndrive, sizeof (char *));
  	dk_mspw = (float *)calloc(dk_ndrive, sizeof (float));
  #define	allocate(e, t) \
!     s./**/e = (t *)calloc(dk_ndrive, sizeof (t)); \
!     s1./**/e = (t *)calloc(dk_ndrive, sizeof (t));
! 	allocate(dk_time, long);
! 	allocate(dk_wds, long);
! 	allocate(dk_seek, long);
! 	allocate(dk_xfer, long);
  	for (arg = buf, i = 0; i < dk_ndrive; i++) {
  		dr_name[i] = arg;
  		sprintf(dr_name[i], "dk%d", i);
--- 122,133 ----
  	dr_name = (char **)calloc(dk_ndrive, sizeof (char *));
  	dk_mspw = (float *)calloc(dk_ndrive, sizeof (float));
  #define	allocate(e, t) \
!     s.e = (t *)calloc(dk_ndrive, sizeof (t)); \
!     s1.e = (t *)calloc(dk_ndrive, sizeof (t));
! 	allocate(dk_time, unsigned long);
! 	allocate(dk_wds, unsigned long);
! 	allocate(dk_seek, unsigned long);
! 	allocate(dk_xfer, unsigned long);
  	for (arg = buf, i = 0; i < dk_ndrive; i++) {
  		dr_name[i] = arg;
  		sprintf(dr_name[i], "dk%d", i);
***************
*** 214,220 ****
  		stat1(i);
  	printf("\n");
  	fflush(stdout);
- contin:
  	if (--iter && argc > 0) {
  		sleep(atoi(argv[0]));
  		goto loop;
--- 221,226 ----
***************
*** 240,246 ****
  
  stats(dn)
  {
- 	register i;
  	double atime, words, xtime, itime;
  
  	if (dk_mspw[dn] == 0.0) {
--- 246,251 ----
***************
*** 319,324 ****
--- 324,366 ----
  		steal(udrv.ud_dname, two_char);
  		sprintf(dr_name[udev.ui_dk], "%c%c%d",
  		    cp[0], cp[1], udev.ui_unit);
+ 	}
+ }
+ #endif
+ 
+ #ifdef ibm032
+ #include <machineio/ioccvar.h>
+ read_names()
+ {
+ 	struct iocc_device iod;
+ 	register struct iocc_device *mp;
+ 	struct iocc_driver mdrv;
+ 	union {
+ 	short two_short;
+ 	char two_char[2];
+ 	} two;
+ 	char *cp =  two.two_char;
+ 
+ 	mp = (struct iocc_device *) nl[X_MBDINIT].n_value;
+ 	if (mp == 0) {
+ 		fprintf(stderr, "iostat: Disk init info not in namelist\n");
+ 		exit(1);
+ 	}
+ 	for (;;) {
+ 		steal(mp++, iod);
+ 		if (iod.iod_driver == 0)
+ 			break;
+ 		if (debug)
+ 			printf("dk=%d alive=%d ctlr=%d\n",iod.iod_dk,
+ 				iod.iod_alive,iod.iod_ctlr);
+ 		if (iod.iod_dk < 0 || iod.iod_alive == 0)
+ 			continue;
+ 		if (iod.iod_ctlr < 0)
+ 			continue;
+ 		steal(iod.iod_driver, mdrv);
+ 		steal(mdrv.idr_dname, two.two_short);
+ 		sprintf(dr_name[iod.iod_dk], "%c%c%d", cp[0], cp[1],
+ 			 iod.iod_unit);
  	}
  }
  #endif


home help back first fref pref prev next nref lref last post