# 2.11BSD#431 - /usr/src/ucb/PORT/systat/disks.c

##### Functions

    dkcmd             X
    dkinit            X
    dkselect          X
    read_names        X

##### Macros

    X_DK_MSPW         X
    X_DK_NDRIVE       X
    X_MBDINIT         X
    X_UBDINIT         X
    steal             X

       1: /*
       2:  * Copyright (c) 1980 Regents of the University of California.
       3:  * All rights reserved.  The Berkeley software License Agreement
       4:  * specifies the terms and conditions for redistribution.
       5:  */
       6:
       7: #ifndef lint
       8: static char sccsid[] = "@(#)disks.c	5.2 (Berkeley) 12/11/85";
       9: #endif not lint
      10:
      11: #include "systat.h"
      12: #include <sys/buf.h>
      13: #include <ctype.h>
      14:
      15: static struct nlist nlst[] = {
      16: #define X_DK_NDRIVE 0
      17:     { "_dk_ndrive" },
      18: #define X_DK_MSPW   1
      19:     { "_dk_mspw" },
      20: #ifdef vax
      21: #define X_MBDINIT   2
      22:     { "_mbdinit" },
      23: #define X_UBDINIT   3
      24:     { "_ubdinit" },
      25: #endif
      26: #ifdef sun
      27: #define X_MBDINIT   2
      28:     { "_mbdinit" },
      29: #endif
      30:     { "" },
      31: };
      32:
      33: dkinit()
      34: {
      35:     register int i;
      36:     register char *cp;
      37:     static int once = 0;
      38:     static char buf[1024];
      39:
      40:     if (once)
      41:         return(1);
      42:     nlist("/vmunix", nlst);
      43:     if (nlst[X_DK_NDRIVE].n_value == 0) {
      44:         error("dk_ndrive undefined in kernel");
      45:         return(0);
      46:     }
      47:     dk_ndrive = getw(nlst[X_DK_NDRIVE].n_value);
      48:     if (dk_ndrive <= 0) {
      49:         error("dk_ndrive=%d according to /vmunix", dk_ndrive);
      50:         return(0);
      51:     }
      52:     dk_mspw = (float *)calloc(dk_ndrive, sizeof (float));
      53:     lseek(kmem, nlst[X_DK_MSPW].n_value, L_SET);
      54:     read(kmem, dk_mspw, dk_ndrive * sizeof (float));
      55:     dr_name = (char **)calloc(dk_ndrive, sizeof (char *));
      56:     dk_select = (int *)calloc(dk_ndrive, sizeof (int));
      57:     for (cp = buf, i = 0; i < dk_ndrive; i++) {
      58:         dr_name[i] = cp;
      59:         sprintf(dr_name[i], "dk%d", i);
      60:         cp += strlen(dr_name[i]) + 1;
      61:         if (dk_mspw[i] != 0.0)
      62:             dk_select[i] = 1;
      63:     }
      64:     if (! read_names()) {
      65:         free(dr_name);
      66:         free(dk_select);
      67:         free(dk_mspw);
      68:         return(0);
      69:     }
      70:     once = 1;
      71:     return(1);
      72: }
      73:
      74: dkcmd(cmd, args)
      75:     char *cmd, *args;
      76: {
      77:
      78:         if (prefix(cmd, "display") || prefix(cmd, "add")) {
      79:                 dkselect(args, 1, dk_select);
      80:         return (1);
      81:         }
      82:         if (prefix(cmd, "ignore") || prefix(cmd, "delete")) {
      83:                 dkselect(args, 0, dk_select);
      84:         return (1);
      85:         }
      86:         if (prefix(cmd, "drives")) {
      87:         register int i;
      88:
      89:                 move(CMDLINE, 0); clrtoeol();
      90:                 for (i = 0; i < dk_ndrive; i++)
      91:                         if (dk_mspw[i] != 0.0)
      92:                                 printw("%s ", dr_name[i]);
      93:                 return (1);
      94:         }
      95:     return (0);
      96: }
      97:
      98: #define steal(where, var) \
      99:     lseek(kmem, where, L_SET); read(kmem, &var, sizeof var);
     100:
     101: #ifdef vax
     102: #include <vaxuba/ubavar.h>
     103: #include <vaxmba/mbavar.h>
     104:
     105: read_names()
     106: {
     107:     struct mba_device mdev;
     108:     struct mba_driver mdrv;
     109:     short two_char;
     110:     char *cp = (char *)&two_char;
     111:     struct uba_device udev;
     112:     struct uba_driver udrv;
     113:     register struct mba_device *mp;
     114:     register struct uba_device *up;
     115:
     116:     mp = (struct mba_device *)nlst[X_MBDINIT].n_value;
     117:     up = (struct uba_device *)nlst[X_UBDINIT].n_value;
     118:     if (mp == 0 && up == 0) {
     119:         error("Disk init info not in namelist\n");
     120:         return(0);
     121:     }
     122:     if (mp) for (;;) {
     123:         steal(mp++, mdev);
     124:         if (mdev.mi_driver == 0)
     125:             break;
     126:         if (mdev.mi_dk < 0 || mdev.mi_alive == 0)
     127:             continue;
     128:         steal(mdev.mi_driver, mdrv);
     129:         steal(mdrv.md_dname, two_char);
     130:         sprintf(dr_name[mdev.mi_dk], "%c%c%d",
     131:             cp[0], cp[1], mdev.mi_unit);
     132:     }
     133:     if (up) for (;;) {
     134:         steal(up++, udev);
     135:         if (udev.ui_driver == 0)
     136:             break;
     137:         if (udev.ui_dk < 0 || udev.ui_alive == 0)
     138:             continue;
     139:         steal(udev.ui_driver, udrv);
     140:         steal(udrv.ud_dname, two_char);
     141:         sprintf(dr_name[udev.ui_dk], "%c%c%d",
     142:             cp[0], cp[1], udev.ui_unit);
     143:     }
     144:     return(1);
     145: }
     146: #endif
     147:
     148: #ifdef sun
     149: #include <sundev/mbvar.h>
     150:
     151: read_names()
     152: {
     153:     static int once = 0;
     154:     struct mb_device mdev;
     155:     struct mb_driver mdrv;
     156:     short two_char;
     157:     char *cp = (char *) &two_char;
     158:     register struct mb_device *mp;
     159:
     160:     mp = (struct mb_device *)nlst[X_MBDINIT].n_value;
     161:     if (mp == 0) {
     162:         error("Disk init info not in namelist\n");
     163:         return(0);
     164:     }
     165:     for (;;) {
     166:         steal(mp++, mdev);
     167:         if (mdev.md_driver == 0)
     168:             break;
     169:         if (mdev.md_dk < 0 || mdev.md_alive == 0)
     170:             continue;
     171:         steal(mdev.md_driver, mdrv);
     172:         steal(mdrv.mdr_dname, two_char);
     173:         sprintf(dr_name[mdev.md_dk], "%c%c%d",
     174:             cp[0], cp[1], mdev.md_unit);
     175:     }
     176:     return(1);
     177: }
     178: #endif
     179:
     180: dkselect(args, truefalse, selections)
     181:     char *args;
     182:     int truefalse, selections[];
     183: {
     184:     register char *cp;
     185:     register int i;
     186:     char *index();
     187:
     188:     cp = index(args, '\n');
     189:     if (cp)
     190:         *cp = '\0';
     191:     for (;;) {
     192:         for (cp = args; *cp && isspace(*cp); cp++)
     193:             ;
     194:         args = cp;
     195:         for (; *cp && !isspace(*cp); cp++)
     196:             ;
     197:         if (*cp)
     198:             *cp++ = '\0';
     199:         if (cp - args == 0)
     200:             break;
     201:         for (i = 0; i < dk_ndrive; i++)
     202:             if (strcmp(args, dr_name[i]) == 0) {
     203:                 if (dk_mspw[i] != 0.0)
     204:                     selections[i] = truefalse;
     205:                 else
     206:                     error("%s: drive not configured",
     207:                         dr_name[i]);
     208:                 break;
     209:             }
     210:         if (i >= dk_ndrive)
     211:             error("%s: unknown drive", args);
     212:         args = cp;
     213:     }
     214: }

#### Defined functions

dkcmd defined in line 74; used 2 times

- in /usr/src/ucb/PORT/systat/iostat.c line 333
- in /usr/src/ucb/PORT/systat/vmstat.c line 523

dkinit defined in line 33; used 2 times

- in /usr/src/ucb/PORT/systat/iostat.c line 81
- in /usr/src/ucb/PORT/systat/vmstat.c line 170

dkselect defined in line 180; used 2 times

- in line 79-83(2)

read_names defined in line 151; used 1 times

- in line 64

#### Defined variables

nlst defined in line 15; used 7 times

- in line 42-47(3), 53, 116-117(2), 160

sccsid defined in line 8; never used

#### Defined macros

X_DK_MSPW defined in line 18; used 1 times

- in line 53

X_DK_NDRIVE defined in line 16; used 2 times

- in line 43-47(2)

X_MBDINIT defined in line 27; used 2 times

- in line 116, 160

X_UBDINIT defined in line 23; used 1 times

- in line 117

steal defined in line 98; used 9 times

- in line 123-140(6), 166-172(3)

Last modified: 1986-01-11 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 829 |