1 /*- 2 * Copyright (c) 1991 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)names.c 5.8 (Berkeley) 03/27/93 8 */ 9 10 #if !defined(hp300) && !defined(tahoe) && !defined(vax) && \ 11 !defined(luna68k) && !defined(mips) 12 char *defdrives[] = { 0 }; 13 #endif 14 15 #if defined(hp300) || defined(luna68k) 16 #if defined(hp300) 17 #include <hp/dev/device.h> 18 #else 19 #include <luna68k/dev/device.h> 20 #endif 21 22 char *defdrives[] = { "sd0", "sd1", "sd2", "rd0", "rd1", "rd2", 0 }; 23 24 int 25 read_names() 26 { 27 register char *p; 28 register u_long hp; 29 static char buf[BUFSIZ]; 30 struct hp_device hdev; 31 struct driver hdrv; 32 char name[10]; 33 34 hp = namelist[X_HPDINIT].n_value; 35 if (hp == 0) { 36 (void)fprintf(stderr, 37 "disk init info not in namelist\n"); 38 return (0); 39 } 40 p = buf; 41 for (;; hp += sizeof hdev) { 42 (void)kvm_read(kd, hp, &hdev, sizeof hdev); 43 if (hdev.hp_driver == 0) 44 break; 45 if (hdev.hp_dk < 0 || hdev.hp_alive == 0 || 46 hdev.hp_cdriver == 0) 47 continue; 48 (void)kvm_read(kd, (u_long)hdev.hp_driver, &hdrv, sizeof hdrv); 49 (void)kvm_read(kd, (u_long)hdrv.d_name, name, sizeof name); 50 dr_name[hdev.hp_dk] = p; 51 p += sprintf(p, "%s%d", name, hdev.hp_unit) + 1; 52 } 53 return (1); 54 } 55 #endif /* hp300 || luna68k */ 56 57 #ifdef tahoe 58 #include <tahoe/vba/vbavar.h> 59 60 char *defdrives[] = { "dk0", "dk1", "dk2", 0 }; 61 62 int 63 read_names() 64 { 65 register char *p; 66 struct vba_device udev, *up; 67 struct vba_driver udrv; 68 char name[10]; 69 static char buf[BUFSIZ]; 70 71 up = (struct vba_device *)namelist[X_VBDINIT].n_value; 72 if (up == 0) { 73 (void) fprintf(stderr, 74 "disk init info not in namelist\n"); 75 return (0); 76 } 77 p = buf; 78 for (;; up += sizeof udev) { 79 (void)kvm_read(kd, up, &udev, sizeof udev); 80 if (udev.ui_driver == 0) 81 break; 82 if (udev.ui_dk < 0 || udev.ui_alive == 0) 83 continue; 84 (void)kvm_read(kd, udev.ui_driver, &udrv, sizeof udrv); 85 (void)kvm_read(kd, udrv.ud_dname, name, sizeof name); 86 dr_name[udev.ui_dk] = p; 87 p += sprintf(p, "%s%d", name, udev.ui_unit); 88 } 89 return (1); 90 } 91 #endif /* tahoe */ 92 93 #ifdef vax 94 #include <vax/uba/ubavar.h> 95 #include <vax/mba/mbavar.h> 96 97 char *defdrives[] = { "hp0", "hp1", "hp2", 0 }; 98 99 int 100 read_names() 101 { 102 register char *p; 103 unsigned long mp, up; 104 struct mba_device mdev; 105 struct mba_driver mdrv; 106 struct uba_device udev; 107 struct uba_driver udrv; 108 char name[10]; 109 static char buf[BUFSIZ]; 110 111 mp = namelist[X_MBDINIT].n_value; 112 up = namelist[X_UBDINIT].n_value; 113 if (mp == 0 && up == 0) { 114 (void)fprintf(stderr, 115 "disk init info not in namelist\n"); 116 return (0); 117 } 118 p = buf; 119 if (mp) 120 for (;; mp += sizeof mdev) { 121 (void)kvm_read(kd, mp, &mdev, sizeof mdev); 122 if (mdev.mi_driver == 0) 123 break; 124 if (mdev.mi_dk < 0 || mdev.mi_alive == 0) 125 continue; 126 (void)kvm_read(kd, mdev.mi_driver, &mdrv, sizeof mdrv); 127 (void)kvm_rea(kd, mdrv.md_dname, name, sizeof name); 128 dr_name[mdev.mi_dk] = p; 129 p += sprintf(p, "%s%d", name, mdev.mi_unit); 130 } 131 if (up) 132 for (;; up += sizeof udev) { 133 (void)kvm_read(kd, up, &udev, sizeof udev); 134 if (udev.ui_driver == 0) 135 break; 136 if (udev.ui_dk < 0 || udev.ui_alive == 0) 137 continue; 138 (void)kvm_read(kd, udev.ui_driver, &udrv, sizeof udrv); 139 (void)kvm_read(kd, udrv.ud_dname, name, sizeof name); 140 dr_name[udev.ui_dk] = p; 141 p += sprintf(p, "%s%d", name, udev.ui_unit); 142 } 143 return (1); 144 } 145 #endif /* vax */ 146 147 #ifdef sun 148 #include <sundev/mbvar.h> 149 150 int 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 *)namelist[X_MBDINIT].n_value; 161 if (mp == 0) { 162 (void)fprintf(stderr, 163 "disk init info not in namelist\n"); 164 return (0); 165 } 166 for (;; ++mp) { 167 (void)kvm_read(kd, mp++, &mdev, sizeof(mdev)); 168 if (mdev.md_driver == 0) 169 break; 170 if (mdev.md_dk < 0 || mdev.md_alive == 0) 171 continue; 172 (void)kvm_read(kd, mdev.md_driver, &mdrv, sizeof(mdrv)); 173 (void)kvm_read(kd, mdrv.mdr_dname, &two_char, sizeof(two_char)); 174 (void)sprintf(dr_name[mdev.md_dk], 175 "%c%c%d", cp[0], cp[1], mdev.md_unit); 176 } 177 return(1); 178 } 179 #endif /* sun */ 180 181 #if defined(mips) 182 #include <pmax/dev/device.h> 183 184 char *defdrives[] = { "rz0", "rz1", "rz2", "rz3", "rz4", "rz5", "rz6", 0 }; 185 186 int 187 read_names() 188 { 189 register char *p; 190 register u_long sp; 191 static char buf[BUFSIZ]; 192 struct scsi_device sdev; 193 struct driver hdrv; 194 char name[10]; 195 196 sp = namelist[X_SCSI_DINIT].n_value; 197 if (sp == 0) { 198 (void)fprintf(stderr, "disk init info not in namelist\n"); 199 return (0); 200 } 201 p = buf; 202 for (;; sp += sizeof sdev) { 203 (void)kvm_read(kd, sp, &sdev, sizeof sdev); 204 if (sdev.sd_driver == 0) 205 break; 206 if (sdev.sd_dk < 0 || sdev.sd_alive == 0 || 207 sdev.sd_cdriver == 0) 208 continue; 209 (void)kvm_read(kd, (u_long)sdev.sd_driver, &hdrv, sizeof hdrv); 210 (void)kvm_read(kd, (u_long)hdrv.d_name, name, sizeof name); 211 dr_name[sdev.sd_dk] = p; 212 p += sprintf(p, "%s%d", name, sdev.sd_unit) + 1; 213 } 214 return (1); 215 } 216 #endif /* mips */ 217