[BACK]Return to names.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / vmstat

Annotation of src/usr.bin/vmstat/names.c, Revision 1.2

1.2     ! deraadt     1: /*     $NetBSD: names.c,v 1.18 1995/12/17 05:30:05 jonathan Exp $      */
1.1       deraadt     2:
                      3: /*-
                      4:  * Copyright (c) 1991, 1993
                      5:  *     The Regents of the University of California.  All rights reserved.
                      6:  *
                      7:  * Redistribution and use in source and binary forms, with or without
                      8:  * modification, are permitted provided that the following conditions
                      9:  * are met:
                     10:  * 1. Redistributions of source code must retain the above copyright
                     11:  *    notice, this list of conditions and the following disclaimer.
                     12:  * 2. Redistributions in binary form must reproduce the above copyright
                     13:  *    notice, this list of conditions and the following disclaimer in the
                     14:  *    documentation and/or other materials provided with the distribution.
                     15:  * 3. All advertising materials mentioning features or use of this software
                     16:  *    must display the following acknowledgement:
                     17:  *     This product includes software developed by the University of
                     18:  *     California, Berkeley and its contributors.
                     19:  * 4. Neither the name of the University nor the names of its contributors
                     20:  *    may be used to endorse or promote products derived from this software
                     21:  *    without specific prior written permission.
                     22:  *
                     23:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     24:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     25:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     26:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     27:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     28:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     29:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     30:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     31:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     32:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     33:  * SUCH DAMAGE.
                     34:  *
                     35:  *     @(#)names.c     8.1 (Berkeley) 6/6/93
                     36:  */
                     37:
                     38: #if !defined(hp300) && !defined(tahoe) && !defined(luna68k) && !defined(mips)
                     39: char *defdrives[] = { 0 };
                     40: #endif
                     41:
                     42: #if defined(i386)
                     43: int
                     44: read_names()
                     45: {
                     46:        return 1;
                     47: }
                     48: #endif
                     49:
                     50: #if defined(pc532)
                     51: int
                     52: read_names()
                     53: {
                     54:        return 1;
                     55: }
                     56: #endif
                     57:
                     58: #if defined(sparc)
                     59: int
                     60: read_names()
                     61: {
                     62:        return 1;
                     63: }
                     64: #endif
                     65:
                     66: #if defined(m68k) && !defined(hp300)
                     67: int
                     68: read_names()
                     69: {
                     70:        return(1);
                     71: }
                     72: #endif
                     73:
                     74: #if defined(__alpha__)
                     75: int
                     76: read_names()
                     77: {
                     78:        return 1;
                     79: }
                     80: #endif
                     81:
                     82: #if defined(vax)
                     83: int
                     84: read_names()
                     85: {
                     86:        return 1;
                     87: }
                     88: #endif
                     89:
                     90: #if defined(hp300) || defined(luna68k)
                     91: #if defined(hp300)
                     92: #include <hp300/dev/device.h>
                     93: #else
                     94: #include <luna68k/dev/device.h>
                     95: #endif
                     96:
                     97: char *defdrives[] = { "sd0", "sd1", "sd2", "rd0", "rd1", "rd2", 0 };
                     98:
                     99: int
                    100: read_names()
                    101: {
                    102:        register char *p;
                    103:        register u_long hp;
                    104:        static char buf[BUFSIZ];
                    105:        struct hp_device hdev;
                    106:        struct driver hdrv;
                    107:        char name[10];
                    108:
                    109:        hp = namelist[X_HPDINIT].n_value;
                    110:        if (hp == 0) {
                    111:                (void)fprintf(stderr,
                    112:                    "disk init info not in namelist\n");
                    113:                return (0);
                    114:        }
                    115:        p = buf;
                    116:        for (;; hp += sizeof hdev) {
                    117:                (void)kvm_read(kd, hp, &hdev, sizeof hdev);
                    118:                if (hdev.hp_driver == 0)
                    119:                        break;
                    120:                if (hdev.hp_dk < 0 || hdev.hp_alive == 0 ||
                    121:                    hdev.hp_cdriver == 0)
                    122:                        continue;
                    123:                (void)kvm_read(kd, (u_long)hdev.hp_driver, &hdrv, sizeof hdrv);
                    124:                (void)kvm_read(kd, (u_long)hdrv.d_name, name, sizeof name);
                    125:                dr_name[hdev.hp_dk] = p;
                    126:                p += sprintf(p, "%s%d", name, hdev.hp_unit) + 1;
                    127:        }
                    128:        return (1);
                    129: }
                    130: #endif /* hp300 || luna68k */
                    131:
                    132: #ifdef tahoe
                    133: #include <tahoe/vba/vbavar.h>
                    134:
                    135: char *defdrives[] = { "dk0", "dk1", "dk2", 0 };
                    136:
                    137: int
                    138: read_names()
                    139: {
                    140:        register char *p;
                    141:        struct vba_device udev, *up;
                    142:        struct vba_driver udrv;
                    143:        char name[10];
                    144:        static char buf[BUFSIZ];
                    145:
                    146:        up = (struct vba_device *)namelist[X_VBDINIT].n_value;
                    147:        if (up == 0) {
                    148:                (void) fprintf(stderr,
                    149:                    "disk init info not in namelist\n");
                    150:                return (0);
                    151:        }
                    152:        p = buf;
                    153:        for (;; up += sizeof udev) {
                    154:                (void)kvm_read(kd, up, &udev, sizeof udev);
                    155:                if (udev.ui_driver == 0)
                    156:                        break;
                    157:                if (udev.ui_dk < 0 || udev.ui_alive == 0)
                    158:                        continue;
                    159:                (void)kvm_read(kd, udev.ui_driver, &udrv, sizeof udrv);
                    160:                (void)kvm_read(kd, udrv.ud_dname, name, sizeof name);
                    161:                dr_name[udev.ui_dk] = p;
                    162:                p += sprintf(p, "%s%d", name, udev.ui_unit);
                    163:        }
                    164:        return (1);
                    165: }
                    166: #endif /* tahoe */
                    167:
                    168: #ifdef sun
                    169: #include <sundev/mbvar.h>
                    170:
                    171: int
                    172: read_names()
                    173: {
                    174:        static int once = 0;
                    175:        struct mb_device mdev;
                    176:        struct mb_driver mdrv;
                    177:        short two_char;
                    178:        char *cp = (char *) &two_char;
                    179:        register struct mb_device *mp;
                    180:
                    181:        mp = (struct mb_device *)namelist[X_MBDINIT].n_value;
                    182:        if (mp == 0) {
                    183:                (void)fprintf(stderr,
                    184:                    "disk init info not in namelist\n");
                    185:                return (0);
                    186:        }
                    187:        for (;; ++mp) {
                    188:                (void)kvm_read(kd, mp++, &mdev, sizeof(mdev));
                    189:                if (mdev.md_driver == 0)
                    190:                        break;
                    191:                if (mdev.md_dk < 0 || mdev.md_alive == 0)
                    192:                        continue;
                    193:                (void)kvm_read(kd, mdev.md_driver, &mdrv, sizeof(mdrv));
                    194:                (void)kvm_read(kd, mdrv.mdr_dname, &two_char, sizeof(two_char));
                    195:                (void)sprintf(dr_name[mdev.md_dk],
                    196:                    "%c%c%d", cp[0], cp[1], mdev.md_unit);
                    197:        }
                    198:        return(1);
                    199: }
                    200: #endif /* sun */
                    201:
                    202: #if defined(mips)
                    203: #include <pmax/dev/device.h>
                    204:
                    205: char *defdrives[] = { "rz0", "rz1", "rz2", "rz3", "rz4", "rz5", "rz6", 0 };
                    206:
                    207: int
                    208: read_names()
                    209: {
                    210:        register char *p;
                    211:        register u_long sp;
                    212:        static char buf[BUFSIZ];
1.2     ! deraadt   213:        struct pmax_scsi_device sdev;
        !           214:        struct pmax_driver hdrv;
1.1       deraadt   215:        char name[10];
                    216:
                    217:        sp = namelist[X_SCSI_DINIT].n_value;
                    218:        if (sp == 0) {
                    219:                (void)fprintf(stderr, "disk init info not in namelist\n");
                    220:                return (0);
                    221:        }
                    222:        p = buf;
                    223:        for (;; sp += sizeof sdev) {
                    224:                (void)kvm_read(kd, sp, &sdev, sizeof sdev);
                    225:                if (sdev.sd_driver == 0)
                    226:                        break;
                    227:                if (sdev.sd_dk < 0 || sdev.sd_alive == 0 ||
                    228:                    sdev.sd_cdriver == 0)
                    229:                        continue;
                    230:                (void)kvm_read(kd, (u_long)sdev.sd_driver, &hdrv, sizeof hdrv);
                    231:                (void)kvm_read(kd, (u_long)hdrv.d_name, name, sizeof name);
                    232:                dr_name[sdev.sd_dk] = p;
                    233:                p += sprintf(p, "%s%d", name, sdev.sd_unit) + 1;
                    234:        }
                    235:        return (1);
                    236: }
                    237: #endif /* mips */