Commit | Line | Data |
---|---|---|
15637ed4 RG |
1 | /*- |
2 | * Copyright (c) 1991 The Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
5 | * Redistribution and use in source and binary forms, with or without | |
6 | * modification, are permitted provided that the following conditions | |
7 | * are met: | |
8 | * 1. Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * 2. Redistributions in binary form must reproduce the above copyright | |
11 | * notice, this list of conditions and the following disclaimer in the | |
12 | * documentation and/or other materials provided with the distribution. | |
13 | * 3. All advertising materials mentioning features or use of this software | |
14 | * must display the following acknowledgement: | |
15 | * This product includes software developed by the University of | |
16 | * California, Berkeley and its contributors. | |
17 | * 4. Neither the name of the University nor the names of its contributors | |
18 | * may be used to endorse or promote products derived from this software | |
19 | * without specific prior written permission. | |
20 | * | |
21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
31 | * SUCH DAMAGE. | |
32 | * | |
33 | * @(#)names.c 5.2 (Berkeley) 6/4/91 | |
34 | */ | |
35 | ||
36 | #if !defined(hp300) && !defined(tahoe) && !defined(vax) && !defined(__386BSD__) | |
37 | char *defdrives[] = { 0 }; | |
38 | ||
39 | void read_names() | |
40 | { | |
41 | } | |
42 | #endif | |
43 | ||
44 | #ifdef __386BSD__ | |
45 | /* | |
46 | * 386BSD support added by Rodney W. Grimes, rgrimes@agora.rain.com 3/24/93 | |
47 | */ | |
48 | #include <i386/isa/isa_device.h> | |
49 | ||
50 | char *defdrives[] = { "fd0", "fd1", "wd0", "wd1", | |
51 | "as0", "as1", "sd0", "sd1", 0 }; | |
52 | ||
53 | void | |
54 | read_names() | |
55 | { | |
56 | register char *p; | |
57 | register u_long isa_bio; | |
58 | static char buf[BUFSIZ]; | |
59 | struct isa_device dev; | |
60 | struct isa_driver drv; | |
61 | char name[10]; | |
62 | int i = 0; | |
63 | int dummydk = 0; | |
64 | int fdunit = 0; | |
65 | int wdunit = 0; | |
66 | int ahaunit = 0; | |
67 | ||
68 | isa_bio = nl[X_ISA_BIO].n_value; | |
69 | if (isa_bio == 0) { | |
70 | (void) fprintf(stderr, | |
71 | "vmstat: disk init info not in namelist\n"); | |
72 | exit(1); | |
73 | } | |
74 | ||
75 | p = buf; | |
76 | for (;; isa_bio += sizeof dev) { | |
77 | (void)kvm_read((void *)isa_bio, &dev, sizeof dev); | |
78 | if (dev.id_driver == 0) | |
79 | break; | |
80 | if (dev.id_alive == 0) | |
81 | continue; | |
82 | (void)kvm_read(dev.id_driver, &drv, sizeof drv); | |
83 | (void)kvm_read(drv.name, name, sizeof name); | |
84 | ||
85 | /* | |
86 | * 386bsd is kinda brain dead about dk_units, or at least | |
87 | * I can't figure out how to get the real unit mappings | |
88 | */ | |
89 | if (strcmp(name, "fd") == 0) dummydk = fdunit++; | |
90 | if (strcmp(name, "wd") == 0) dummydk = wdunit++; | |
91 | if (strcmp(name, "aha") == 0) dummydk = ahaunit++; | |
92 | ||
93 | dr_name[i] = p; | |
94 | p += sprintf(p, "%s%d", name, dummydk) + 1; | |
95 | i++; | |
96 | } | |
97 | } | |
98 | #endif /* __386BSD__ */ | |
99 | ||
100 | #ifdef hp300 | |
101 | #include <hp300/dev/device.h> | |
102 | ||
103 | char *defdrives[] = { "sd0", "sd1", "sd2", "rd0", "rd1", "rd2", 0 }; | |
104 | ||
105 | void | |
106 | read_names() | |
107 | { | |
108 | register char *p; | |
109 | register u_long hp; | |
110 | static char buf[BUFSIZ]; | |
111 | struct hp_device hdev; | |
112 | struct driver hdrv; | |
113 | char name[10]; | |
114 | ||
115 | hp = nl[X_HPDINIT].n_value; | |
116 | if (hp == 0) { | |
117 | (void) fprintf(stderr, | |
118 | "vmstat: disk init info not in namelist\n"); | |
119 | exit(1); | |
120 | } | |
121 | p = buf; | |
122 | for (;; hp += sizeof hdev) { | |
123 | (void)kvm_read((void *)hp, &hdev, sizeof hdev); | |
124 | if (hdev.hp_driver == 0) | |
125 | break; | |
126 | if (hdev.hp_dk < 0 || hdev.hp_alive == 0 || | |
127 | hdev.hp_cdriver == 0) | |
128 | continue; | |
129 | (void)kvm_read(hdev.hp_driver, &hdrv, sizeof hdrv); | |
130 | (void)kvm_read(hdrv.d_name, name, sizeof name); | |
131 | dr_name[hdev.hp_dk] = p; | |
132 | p += sprintf(p, "%s%d", name, hdev.hp_unit) + 1; | |
133 | } | |
134 | } | |
135 | #endif /* hp300 */ | |
136 | ||
137 | #ifdef tahoe | |
138 | #include <tahoe/vba/vbavar.h> | |
139 | ||
140 | char *defdrives[] = { "dk0", "dk1", "dk2", 0 }; | |
141 | ||
142 | void | |
143 | read_names() | |
144 | { | |
145 | register char *p; | |
146 | struct vba_device udev, *up; | |
147 | struct vba_driver udrv; | |
148 | char name[10]; | |
149 | static char buf[BUFSIZ]; | |
150 | ||
151 | up = (struct vba_device *) nl[X_VBDINIT].n_value; | |
152 | if (up == 0) { | |
153 | (void) fprintf(stderr, | |
154 | "vmstat: disk init info not in namelist\n"); | |
155 | exit(1); | |
156 | } | |
157 | p = buf; | |
158 | for (;; up += sizeof udev) { | |
159 | (void)kvm_read(up, &udev, sizeof udev); | |
160 | if (udev.ui_driver == 0) | |
161 | break; | |
162 | if (udev.ui_dk < 0 || udev.ui_alive == 0) | |
163 | continue; | |
164 | (void)kvm_read(udev.ui_driver, &udrv, sizeof udrv); | |
165 | (void)kvm_read(udrv.ud_dname, name, sizeof name); | |
166 | dr_name[udev.ui_dk] = p; | |
167 | p += sprintf(p, "%s%d", name, udev.ui_unit); | |
168 | } | |
169 | } | |
170 | #endif /* tahoe */ | |
171 | ||
172 | #ifdef vax | |
173 | #include <vax/uba/ubavar.h> | |
174 | #include <vax/mba/mbavar.h> | |
175 | ||
176 | char *defdrives[] = { "hp0", "hp1", "hp2", 0 }; | |
177 | ||
178 | void | |
179 | read_names() | |
180 | { | |
181 | register char *p; | |
182 | unsigned long mp, up; | |
183 | struct mba_device mdev; | |
184 | struct mba_driver mdrv; | |
185 | struct uba_device udev; | |
186 | struct uba_driver udrv; | |
187 | char name[10]; | |
188 | static char buf[BUFSIZ]; | |
189 | ||
190 | mp = nl[X_MBDINIT].n_value; | |
191 | up = nl[X_UBDINIT].n_value; | |
192 | if (mp == 0 && up == 0) { | |
193 | (void) fprintf(stderr, | |
194 | "vmstat: disk init info not in namelist\n"); | |
195 | exit(1); | |
196 | } | |
197 | p = buf; | |
198 | if (mp) for (;; mp += sizeof mdev) { | |
199 | (void)kvm_read(mp, &mdev, sizeof mdev); | |
200 | if (mdev.mi_driver == 0) | |
201 | break; | |
202 | if (mdev.mi_dk < 0 || mdev.mi_alive == 0) | |
203 | continue; | |
204 | (void)kvm_read(mdev.mi_driver, &mdrv, sizeof mdrv); | |
205 | (void)kvm_read(mdrv.md_dname, name, sizeof name); | |
206 | dr_name[mdev.mi_dk] = p; | |
207 | p += sprintf(p, "%s%d", name, mdev.mi_unit); | |
208 | } | |
209 | if (up) for (;; up += sizeof udev) { | |
210 | (void)kvm_read(up, &udev, sizeof udev); | |
211 | if (udev.ui_driver == 0) | |
212 | break; | |
213 | if (udev.ui_dk < 0 || udev.ui_alive == 0) | |
214 | continue; | |
215 | (void)kvm_read(udev.ui_driver, &udrv, sizeof udrv); | |
216 | (void)kvm_read(udrv.ud_dname, name, sizeof name); | |
217 | dr_name[udev.ui_dk] = p; | |
218 | p += sprintf(p, "%s%d", name, udev.ui_unit); | |
219 | } | |
220 | } | |
221 | #endif /* vax */ |