[356] | 1 | /* |
---|
| 2 | * Stand alone function to read the disk info. |
---|
| 3 | * Sets up global arrays dr_name and dr_unit as declared below. |
---|
| 4 | * This function requires 'int kmem' to be set to the open descriptor |
---|
| 5 | * for /dev/kmem. The array 'namelist' should be initailized, with |
---|
| 6 | * the proper X_MBDINIT all set. |
---|
| 7 | */ |
---|
[2] | 8 | |
---|
[356] | 9 | #include "mon.h" |
---|
| 10 | /* these files should be included somehow |
---|
| 11 | #include <stdio.h> |
---|
| 12 | #include <sys/param.h> |
---|
| 13 | #include <sys/vm.h> |
---|
| 14 | #include <sys/dk.h> |
---|
| 15 | #include <nlist.h> |
---|
| 16 | */ |
---|
| 17 | #include <sys/buf.h> |
---|
| 18 | #ifdef vax |
---|
| 19 | #include <vaxuba/ubavar.h> |
---|
| 20 | #include <vaxmba/mbavar.h> |
---|
| 21 | #endif |
---|
| 22 | #ifdef sun |
---|
| 23 | #include <sundev/mbvar.h> |
---|
| 24 | #endif |
---|
| 25 | #ifdef ibm032 |
---|
| 26 | #include <caio/ioccvar.h> |
---|
| 27 | #endif |
---|
[2] | 28 | |
---|
[356] | 29 | extern char dr_name[DK_NDRIVE][10]; |
---|
| 30 | extern char dr_unit[DK_NDRIVE]; |
---|
| 31 | extern int kmem; |
---|
| 32 | extern struct nlist namelist[] ; |
---|
| 33 | |
---|
| 34 | |
---|
| 35 | /* Where kmem is the open file descriptor describing /dev/kmem */ |
---|
| 36 | #define steal(where, var) lseek(kmem, where, 0); read(kmem, &var, sizeof var); |
---|
| 37 | |
---|
[2] | 38 | /* |
---|
[356] | 39 | * Read the drive names out of kmem. |
---|
[2] | 40 | */ |
---|
[356] | 41 | #ifdef vax |
---|
| 42 | read_names() |
---|
| 43 | { |
---|
| 44 | struct mba_device mdev; |
---|
| 45 | register struct mba_device *mp; |
---|
| 46 | struct mba_driver mdrv; |
---|
| 47 | short two_char; |
---|
| 48 | char *cp = (char *) &two_char; |
---|
| 49 | struct uba_device udev, *up; |
---|
| 50 | struct uba_driver udrv; |
---|
[2] | 51 | |
---|
[356] | 52 | mp = (struct mba_device *) namelist[X_MBDINIT].n_value; |
---|
| 53 | up = (struct uba_device *) namelist[X_UBDINIT].n_value; |
---|
| 54 | if (up == 0) { |
---|
| 55 | fprintf(stderr, "vmstat: Disk init info not in namelist\n"); |
---|
| 56 | exit(1); |
---|
| 57 | } |
---|
| 58 | if (mp) for (;;) { |
---|
| 59 | steal(mp++, mdev); |
---|
| 60 | if (mdev.mi_driver == 0) |
---|
| 61 | break; |
---|
| 62 | if (mdev.mi_dk < 0 || mdev.mi_alive == 0) |
---|
| 63 | continue; |
---|
| 64 | steal(mdev.mi_driver, mdrv); |
---|
| 65 | steal(mdrv.md_dname, two_char); |
---|
| 66 | sprintf(dr_name[mdev.mi_dk], "%c%c", cp[0], cp[1]); |
---|
| 67 | dr_unit[mdev.mi_dk] = mdev.mi_unit; |
---|
| 68 | } |
---|
| 69 | for (;;) { |
---|
| 70 | steal(up++, udev); |
---|
| 71 | if (udev.ui_driver == 0) |
---|
| 72 | break; |
---|
| 73 | if (udev.ui_dk < 0 || udev.ui_alive == 0) |
---|
| 74 | continue; |
---|
| 75 | steal(udev.ui_driver, udrv); |
---|
| 76 | steal(udrv.ud_dname, two_char); |
---|
| 77 | sprintf(dr_name[udev.ui_dk], "%c%c", cp[0], cp[1]); |
---|
| 78 | dr_unit[udev.ui_dk] = udev.ui_unit; |
---|
| 79 | } |
---|
| 80 | } |
---|
| 81 | #endif |
---|
[2] | 82 | |
---|
[356] | 83 | #ifdef sun |
---|
[2] | 84 | read_names() |
---|
| 85 | { |
---|
[356] | 86 | struct iocc_device mdev; |
---|
| 87 | register struct iocc_device *mp; |
---|
| 88 | struct iocc_driver mdrv; |
---|
| 89 | short two_char; |
---|
| 90 | char *cp = (char *) &two_char; |
---|
[2] | 91 | |
---|
[356] | 92 | mp = (struct iocc_device *) namelist[X_MBDINIT].n_value; |
---|
| 93 | if (mp == 0) { |
---|
| 94 | fprintf(stderr, "iostat: Disk init info not in namelist\n"); |
---|
| 95 | exit(1); |
---|
| 96 | } |
---|
| 97 | for (;;) { |
---|
| 98 | steal(mp++, mdev); |
---|
| 99 | if (mdev.md_driver == 0) |
---|
| 100 | break; |
---|
| 101 | if (mdev.md_dk < 0 || mdev.md_alive == 0) |
---|
| 102 | continue; |
---|
| 103 | steal(mdev.md_driver, mdrv); |
---|
| 104 | steal(mdrv.mdr_dname, two_char); |
---|
| 105 | sprintf(dr_name[mdev.md_dk], "%c%c%d", cp[0], cp[1]); |
---|
| 106 | dr_unit[mdev.md_dk] = mdev.md_unit; |
---|
| 107 | } |
---|
[2] | 108 | } |
---|
[356] | 109 | #endif |
---|
| 110 | |
---|
| 111 | #ifdef ibm032 |
---|
| 112 | read_names() |
---|
| 113 | { |
---|
| 114 | struct iocc_device iod; |
---|
| 115 | register struct iocc_device *mp; |
---|
| 116 | struct iocc_driver mdrv; |
---|
| 117 | union { |
---|
| 118 | short two_short; |
---|
| 119 | char two_char[2]; |
---|
| 120 | } two; |
---|
| 121 | char *cp = two.two_char; |
---|
| 122 | |
---|
| 123 | mp = (struct iocc_device *) namelist[X_MBDINIT].n_value; |
---|
| 124 | if (mp == 0) { |
---|
| 125 | fprintf(stderr, "iostat: Disk init info not in namelist\n"); |
---|
| 126 | exit(1); |
---|
| 127 | } |
---|
| 128 | for (;;) { |
---|
| 129 | steal(mp++, iod); |
---|
| 130 | if (iod.iod_driver == 0) |
---|
| 131 | break; |
---|
| 132 | /* if (debug) |
---|
| 133 | printf("dk=%d alive=%d ctlr=%d\n",iod.iod_dk, |
---|
| 134 | iod.iod_alive,iod.iod_ctlr); |
---|
| 135 | */ |
---|
| 136 | if (iod.iod_dk < 0 || iod.iod_alive == 0) |
---|
| 137 | continue; |
---|
| 138 | if (iod.iod_ctlr < 0) |
---|
| 139 | continue; |
---|
| 140 | steal(iod.iod_driver, mdrv); |
---|
| 141 | steal(mdrv.idr_dname, two.two_short); |
---|
| 142 | sprintf(dr_name[iod.iod_dk], "%c%c%d", cp[0], cp[1], |
---|
| 143 | dr_unit[iod.iod_dk] = iod.iod_unit); |
---|
| 144 | } |
---|
| 145 | } |
---|
| 146 | #endif |
---|