disklabel.c revision 1.3.2.2 1 1.3.2.2 yamt /* $NetBSD: disklabel.c,v 1.3.2.2 2013/01/23 00:05:53 yamt Exp $ */
2 1.3.2.2 yamt
3 1.3.2.2 yamt /*
4 1.3.2.2 yamt * Copyright (c) 1992 OMRON Corporation.
5 1.3.2.2 yamt *
6 1.3.2.2 yamt * This code is derived from software contributed to Berkeley by
7 1.3.2.2 yamt * OMRON Corporation.
8 1.3.2.2 yamt *
9 1.3.2.2 yamt * Redistribution and use in source and binary forms, with or without
10 1.3.2.2 yamt * modification, are permitted provided that the following conditions
11 1.3.2.2 yamt * are met:
12 1.3.2.2 yamt * 1. Redistributions of source code must retain the above copyright
13 1.3.2.2 yamt * notice, this list of conditions and the following disclaimer.
14 1.3.2.2 yamt * 2. Redistributions in binary form must reproduce the above copyright
15 1.3.2.2 yamt * notice, this list of conditions and the following disclaimer in the
16 1.3.2.2 yamt * documentation and/or other materials provided with the distribution.
17 1.3.2.2 yamt * 3. All advertising materials mentioning features or use of this software
18 1.3.2.2 yamt * must display the following acknowledgement:
19 1.3.2.2 yamt * This product includes software developed by the University of
20 1.3.2.2 yamt * California, Berkeley and its contributors.
21 1.3.2.2 yamt * 4. Neither the name of the University nor the names of its contributors
22 1.3.2.2 yamt * may be used to endorse or promote products derived from this software
23 1.3.2.2 yamt * without specific prior written permission.
24 1.3.2.2 yamt *
25 1.3.2.2 yamt * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 1.3.2.2 yamt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 1.3.2.2 yamt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 1.3.2.2 yamt * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 1.3.2.2 yamt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 1.3.2.2 yamt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 1.3.2.2 yamt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 1.3.2.2 yamt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 1.3.2.2 yamt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 1.3.2.2 yamt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 1.3.2.2 yamt * SUCH DAMAGE.
36 1.3.2.2 yamt *
37 1.3.2.2 yamt * @(#)disklabel.c 8.1 (Berkeley) 6/10/93
38 1.3.2.2 yamt */
39 1.3.2.2 yamt /*
40 1.3.2.2 yamt * Copyright (c) 1992, 1993
41 1.3.2.2 yamt * The Regents of the University of California. All rights reserved.
42 1.3.2.2 yamt *
43 1.3.2.2 yamt * This code is derived from software contributed to Berkeley by
44 1.3.2.2 yamt * OMRON Corporation.
45 1.3.2.2 yamt *
46 1.3.2.2 yamt * Redistribution and use in source and binary forms, with or without
47 1.3.2.2 yamt * modification, are permitted provided that the following conditions
48 1.3.2.2 yamt * are met:
49 1.3.2.2 yamt * 1. Redistributions of source code must retain the above copyright
50 1.3.2.2 yamt * notice, this list of conditions and the following disclaimer.
51 1.3.2.2 yamt * 2. Redistributions in binary form must reproduce the above copyright
52 1.3.2.2 yamt * notice, this list of conditions and the following disclaimer in the
53 1.3.2.2 yamt * documentation and/or other materials provided with the distribution.
54 1.3.2.2 yamt * 3. Neither the name of the University nor the names of its contributors
55 1.3.2.2 yamt * may be used to endorse or promote products derived from this software
56 1.3.2.2 yamt * without specific prior written permission.
57 1.3.2.2 yamt *
58 1.3.2.2 yamt * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
59 1.3.2.2 yamt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60 1.3.2.2 yamt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
61 1.3.2.2 yamt * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
62 1.3.2.2 yamt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
63 1.3.2.2 yamt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
64 1.3.2.2 yamt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65 1.3.2.2 yamt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
66 1.3.2.2 yamt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
67 1.3.2.2 yamt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
68 1.3.2.2 yamt * SUCH DAMAGE.
69 1.3.2.2 yamt *
70 1.3.2.2 yamt * @(#)disklabel.c 8.1 (Berkeley) 6/10/93
71 1.3.2.2 yamt */
72 1.3.2.2 yamt
73 1.3.2.2 yamt /*
74 1.3.2.2 yamt * disklabel.c -- operate disklabel for BSD & OMRON
75 1.3.2.2 yamt * by A.Fujita, FEB-17-1992
76 1.3.2.2 yamt */
77 1.3.2.2 yamt
78 1.3.2.2 yamt #include <sys/param.h>
79 1.3.2.2 yamt #define DKTYPENAMES
80 1.3.2.2 yamt #define FSTYPENAMES
81 1.3.2.2 yamt #include <sys/disklabel.h>
82 1.3.2.2 yamt #include <ufs/ffs/fs.h>
83 1.3.2.2 yamt #include <lib/libkern/libkern.h>
84 1.3.2.2 yamt #include <luna68k/stand/boot/samachdep.h>
85 1.3.2.2 yamt #include <luna68k/stand/boot/status.h>
86 1.3.2.2 yamt #include <luna68k/stand/boot/omron_disklabel.h>
87 1.3.2.2 yamt
88 1.3.2.2 yamt static void display(struct disklabel *);
89 1.3.2.2 yamt
90 1.3.2.2 yamt #define SBSIZE SBLOCKSIZE
91 1.3.2.2 yamt #define FS_MAGIC FS_UFS1_MAGIC
92 1.3.2.2 yamt #define LABEL_SIZE BBSIZE
93 1.3.2.2 yamt
94 1.3.2.2 yamt u_char lbl_buff[LABEL_SIZE];
95 1.3.2.2 yamt
96 1.3.2.2 yamt #if 0
97 1.3.2.2 yamt u_short
98 1.3.2.2 yamt dkcksum(struct disklabel *lp)
99 1.3.2.2 yamt {
100 1.3.2.2 yamt u_short *start, *end;
101 1.3.2.2 yamt u_short sum = 0;
102 1.3.2.2 yamt
103 1.3.2.2 yamt start = (u_short *)lp;
104 1.3.2.2 yamt end = (u_short *)&lp->d_partitions[lp->d_npartitions];
105 1.3.2.2 yamt while (start < end)
106 1.3.2.2 yamt sum ^= *start++;
107 1.3.2.2 yamt return (sum);
108 1.3.2.2 yamt }
109 1.3.2.2 yamt #endif
110 1.3.2.2 yamt
111 1.3.2.2 yamt int
112 1.3.2.2 yamt disklabel(int argc, char *argv[])
113 1.3.2.2 yamt {
114 1.3.2.2 yamt struct scd_dk_label *omp = (struct scd_dk_label *) lbl_buff;
115 1.3.2.2 yamt struct disklabel *bp = (struct disklabel *)&lbl_buff[LABELOFFSET];
116 1.3.2.2 yamt struct fs *fp = (struct fs *) lbl_buff;
117 1.3.2.2 yamt u_short *p;
118 1.3.2.2 yamt u_long chksum, count;
119 1.3.2.2 yamt char *q;
120 1.3.2.2 yamt int i, j;
121 1.3.2.2 yamt
122 1.3.2.2 yamt if (argc < 2) {
123 1.3.2.2 yamt printf("This command is required sub command !!\n");
124 1.3.2.2 yamt return(ST_ERROR);
125 1.3.2.2 yamt }
126 1.3.2.2 yamt
127 1.3.2.2 yamt if (!strcmp(argv[1], "help")) {
128 1.3.2.2 yamt printf("Subcommand of disklabel\n\n");
129 1.3.2.2 yamt printf("\thelp:\t\tthis command\n");
130 1.3.2.2 yamt printf("\tread:\t\tread disklabel from scsi_device\n");
131 1.3.2.2 yamt printf("\twrite:\t\twrite disklabel to scsi_device\n");
132 1.3.2.2 yamt printf("\tomron:\t\tshow OMRON disklabel infomation\n");
133 1.3.2.2 yamt printf("\tbsd:\t\tshow BSD disklabel infomation\n");
134 1.3.2.2 yamt printf("\tcopy:\t\tcopy disklabel infomation from OMRON to BSD\n");
135 1.3.2.2 yamt printf("\tchecksum:\tdoing checksum\n");
136 1.3.2.2 yamt printf("\tset:\t\tchange BSD disklabel infomation\n");
137 1.3.2.2 yamt printf("\n\n");
138 1.3.2.2 yamt } else if (!strcmp(argv[1], "read")) {
139 1.3.2.2 yamt if (scsi_read( 0, lbl_buff, LABEL_SIZE)) {
140 1.3.2.2 yamt printf("Disk Label read done.\n");
141 1.3.2.2 yamt } else {
142 1.3.2.2 yamt printf("Disk Label read error !!\n");
143 1.3.2.2 yamt }
144 1.3.2.2 yamt } else if (!strcmp(argv[1], "omron")) {
145 1.3.2.2 yamt i = (int) &omp->dkl_badchk;
146 1.3.2.2 yamt i -= (int) lbl_buff;
147 1.3.2.2 yamt printf("Offset = %d\n", i);
148 1.3.2.2 yamt printf("\n");
149 1.3.2.2 yamt printf("Checksum of Bad Track:\t0x%x\n", omp->dkl_badchk);
150 1.3.2.2 yamt printf("Logical Block Total:\t%u(0x%x)\n", omp->dkl_maxblk, omp->dkl_maxblk);
151 1.3.2.2 yamt printf("Disk Drive Type:\t0x%x\n", omp->dkl_dtype);
152 1.3.2.2 yamt printf("Number of Disk Drives:\t%d(0x%x)\n", omp->dkl_ndisk, omp->dkl_ndisk);
153 1.3.2.2 yamt printf("Number of Data Cylinders:\t%d(0x%x)\n", omp->dkl_ncyl, omp->dkl_ncyl);
154 1.3.2.2 yamt printf("Number of Alternate Cylinders:\t%d(0x%x)\n",
155 1.3.2.2 yamt omp->dkl_acyl,omp->dkl_acyl);
156 1.3.2.2 yamt printf("Number of Heads in This Partition:\t%d(0x%x)\n",
157 1.3.2.2 yamt omp->dkl_nhead, omp->dkl_nhead);
158 1.3.2.2 yamt printf("Number of 512 byte Sectors per Track:\t%d(0x%x)\n",
159 1.3.2.2 yamt omp->dkl_nsect, omp->dkl_nsect);
160 1.3.2.2 yamt printf("Identifies Proper Label Locations:\t0x%x\n",
161 1.3.2.2 yamt omp->dkl_bhead);
162 1.3.2.2 yamt printf("Physical Partition Number:\t%d(0x%x)\n",
163 1.3.2.2 yamt omp->dkl_ppart, omp->dkl_ppart);
164 1.3.2.2 yamt for (i = 0; i < NLPART; i++)
165 1.3.2.2 yamt printf("\t%d:\t%d\t%d\n", i,
166 1.3.2.2 yamt omp->dkl_map[i].dkl_blkno, omp->dkl_map[i].dkl_nblk);
167 1.3.2.2 yamt printf("Identifies This Label Format:\t0x%x\n", omp->dkl_magic);
168 1.3.2.2 yamt printf("XOR Checksum of Sector:\t0x%x\n", omp->dkl_cksum);
169 1.3.2.2 yamt } else if (!strcmp(argv[1], "checksum")) {
170 1.3.2.2 yamt if (omp->dkl_magic == DKL_MAGIC){
171 1.3.2.2 yamt /* checksum of disk-label */
172 1.3.2.2 yamt chksum = 0;
173 1.3.2.2 yamt count = sizeof(struct scd_dk_label) / sizeof(short int);
174 1.3.2.2 yamt for (p= (u_short *) lbl_buff; count > 0; count--) {
175 1.3.2.2 yamt if (count == 1)
176 1.3.2.2 yamt printf("Check Sum: 0x%lx\n", chksum);
177 1.3.2.2 yamt chksum ^= *p++;
178 1.3.2.2 yamt }
179 1.3.2.2 yamt
180 1.3.2.2 yamt printf("dkl_cksum: 0x%x\n", omp->dkl_cksum);
181 1.3.2.2 yamt
182 1.3.2.2 yamt if (chksum != 0) {
183 1.3.2.2 yamt printf("OMRON Disklabel check sum error.\n");
184 1.3.2.2 yamt }
185 1.3.2.2 yamt } else {
186 1.3.2.2 yamt printf("OMRON Disklabel not found.\n");
187 1.3.2.2 yamt }
188 1.3.2.2 yamt } else if (!strcmp(argv[1], "copy")) {
189 1.3.2.2 yamt memset(bp, 0, sizeof(struct disklabel));
190 1.3.2.2 yamt
191 1.3.2.2 yamt memcpy(bp->d_typename, lbl_buff, 16);
192 1.3.2.2 yamt
193 1.3.2.2 yamt bp->d_secsize = DEV_BSIZE;
194 1.3.2.2 yamt bp->d_nsectors = 38;
195 1.3.2.2 yamt bp->d_ntracks = 12;
196 1.3.2.2 yamt bp->d_ncylinders = 1076;
197 1.3.2.2 yamt
198 1.3.2.2 yamt bp->d_type = DTYPE_SCSI;
199 1.3.2.2 yamt
200 1.3.2.2 yamt bp->d_secpercyl = bp->d_nsectors * bp->d_ntracks;
201 1.3.2.2 yamt bp->d_secperunit = bp->d_secpercyl * bp->d_ncylinders;
202 1.3.2.2 yamt bp->d_rpm = 3600;
203 1.3.2.2 yamt bp->d_interleave = 1;
204 1.3.2.2 yamt bp->d_trackskew = 0;
205 1.3.2.2 yamt bp->d_cylskew = 0;
206 1.3.2.2 yamt bp->d_headswitch = 0;
207 1.3.2.2 yamt bp->d_trkseek = 0;
208 1.3.2.2 yamt bp->d_bbsize = BBSIZE;
209 1.3.2.2 yamt bp->d_sbsize = SBSIZE;
210 1.3.2.2 yamt
211 1.3.2.2 yamt for (i = 0; i < MAXPARTITIONS; i++) {
212 1.3.2.2 yamt bp->d_partitions[i].p_size = omp->dkl_map[i].dkl_nblk;
213 1.3.2.2 yamt bp->d_partitions[i].p_offset = omp->dkl_map[i].dkl_blkno;
214 1.3.2.2 yamt bp->d_partitions[i].p_fsize = 1024;
215 1.3.2.2 yamt bp->d_partitions[i].p_frag = 8192 / 1024;
216 1.3.2.2 yamt bp->d_partitions[i].p_fstype = FS_UNUSED;
217 1.3.2.2 yamt }
218 1.3.2.2 yamt
219 1.3.2.2 yamt bp->d_npartitions = MAXPARTITIONS;
220 1.3.2.2 yamt
221 1.3.2.2 yamt for (i = 0; i < NDDATA; i++) {
222 1.3.2.2 yamt bp->d_drivedata[i] = 0;
223 1.3.2.2 yamt }
224 1.3.2.2 yamt
225 1.3.2.2 yamt memset(bp->d_packname, 0, 16);
226 1.3.2.2 yamt
227 1.3.2.2 yamt bp->d_magic = DISKMAGIC;
228 1.3.2.2 yamt bp->d_magic2 = DISKMAGIC;
229 1.3.2.2 yamt bp->d_checksum = 0;
230 1.3.2.2 yamt bp->d_checksum = dkcksum(bp);
231 1.3.2.2 yamt
232 1.3.2.2 yamt /* restump checksum of OMRON disklabel */
233 1.3.2.2 yamt chksum = 0;
234 1.3.2.2 yamt count = sizeof(struct scd_dk_label) / sizeof(short int);
235 1.3.2.2 yamt for (p= (u_short *) lbl_buff; count > 1; count--) {
236 1.3.2.2 yamt chksum ^= *p++;
237 1.3.2.2 yamt }
238 1.3.2.2 yamt printf("chksum: 0x%lx\n", chksum);
239 1.3.2.2 yamt
240 1.3.2.2 yamt omp->dkl_cksum = chksum;
241 1.3.2.2 yamt printf("dkl_cksum: 0x%x\n", omp->dkl_cksum);
242 1.3.2.2 yamt } else if (!strcmp(argv[1], "bsd")) {
243 1.3.2.2 yamt display(bp);
244 1.3.2.2 yamt } else if (!strcmp(argv[1], "write")) {
245 1.3.2.2 yamt if (scsi_write( 0, lbl_buff, LABEL_SIZE)) {
246 1.3.2.2 yamt printf("Disk Label write done.\n");
247 1.3.2.2 yamt } else {
248 1.3.2.2 yamt printf("Disk Label write error !!\n");
249 1.3.2.2 yamt }
250 1.3.2.2 yamt } else if (!strcmp(argv[1], "set")) {
251 1.3.2.2 yamt i = (argv[2])[1] - 'a';
252 1.3.2.2 yamt for (q = argv[3], j = 0; *q != '\0'; q++) {
253 1.3.2.2 yamt j = (j * 10) + (*q - '0');
254 1.3.2.2 yamt }
255 1.3.2.2 yamt switch (*argv[2]) {
256 1.3.2.2 yamt case 'b':
257 1.3.2.2 yamt bp->d_partitions[i].p_frag = j / bp->d_partitions[i].p_fsize;
258 1.3.2.2 yamt break;
259 1.3.2.2 yamt case 'f': /* fragment size */
260 1.3.2.2 yamt bp->d_partitions[i].p_fsize = j;
261 1.3.2.2 yamt break;
262 1.3.2.2 yamt case 'o': /* offset */
263 1.3.2.2 yamt bp->d_partitions[i].p_offset = j;
264 1.3.2.2 yamt omp->dkl_map[i].dkl_blkno = j;
265 1.3.2.2 yamt break;
266 1.3.2.2 yamt case 'p': /* size */
267 1.3.2.2 yamt bp->d_partitions[i].p_size = j;
268 1.3.2.2 yamt omp->dkl_map[i].dkl_nblk = j;
269 1.3.2.2 yamt break;
270 1.3.2.2 yamt case 't': /* FS type */
271 1.3.2.2 yamt bp->d_partitions[i].p_fstype = j;
272 1.3.2.2 yamt break;
273 1.3.2.2 yamt default:
274 1.3.2.2 yamt break;
275 1.3.2.2 yamt }
276 1.3.2.2 yamt
277 1.3.2.2 yamt /* restump checksum of BSD disklabel */
278 1.3.2.2 yamt bp->d_checksum = 0;
279 1.3.2.2 yamt bp->d_checksum = dkcksum(bp);
280 1.3.2.2 yamt
281 1.3.2.2 yamt /* restump checksum of OMRON disklabel */
282 1.3.2.2 yamt chksum = 0;
283 1.3.2.2 yamt count = sizeof(struct scd_dk_label) / sizeof(short int);
284 1.3.2.2 yamt for (p= (u_short *) lbl_buff; count > 1; count--) {
285 1.3.2.2 yamt chksum ^= *p++;
286 1.3.2.2 yamt }
287 1.3.2.2 yamt omp->dkl_cksum = chksum;
288 1.3.2.2 yamt
289 1.3.2.2 yamt } else if (!strcmp(argv[1], "sb")) {
290 1.3.2.2 yamt #define BLOCK_SIZE SBSIZE
291 1.3.2.2 yamt
292 1.3.2.2 yamt printf("checking Super Block: block size = %d bytes, seek amount = 1 blocks\n",
293 1.3.2.2 yamt BLOCK_SIZE);
294 1.3.2.2 yamt i = j = 0;
295 1.3.2.2 yamt while(1) {
296 1.3.2.2 yamt if (!scsi_read( i, lbl_buff, BLOCK_SIZE))
297 1.3.2.2 yamt break;
298 1.3.2.2 yamt
299 1.3.2.2 yamt if (fp->fs_magic == FS_MAGIC) {
300 1.3.2.2 yamt printf("%d, (%d)\n", i, i - j);
301 1.3.2.2 yamt j = i;
302 1.3.2.2 yamt }
303 1.3.2.2 yamt i++;
304 1.3.2.2 yamt }
305 1.3.2.2 yamt } else if (!strcmp(argv[1], "sbcopy")) {
306 1.3.2.2 yamt if (!scsi_read(32, lbl_buff, BLOCK_SIZE)) {
307 1.3.2.2 yamt printf("sbcopy: read failed\n");
308 1.3.2.2 yamt return(ST_ERROR);
309 1.3.2.2 yamt }
310 1.3.2.2 yamt if (scsi_write(16, lbl_buff, BLOCK_SIZE)) {
311 1.3.2.2 yamt printf("sbcopy: copy done\n");
312 1.3.2.2 yamt } else {
313 1.3.2.2 yamt printf("sbcopy: write failed\n");
314 1.3.2.2 yamt }
315 1.3.2.2 yamt }
316 1.3.2.2 yamt
317 1.3.2.2 yamt return(ST_NORMAL);
318 1.3.2.2 yamt }
319 1.3.2.2 yamt
320 1.3.2.2 yamt void
321 1.3.2.2 yamt display(struct disklabel *lp)
322 1.3.2.2 yamt {
323 1.3.2.2 yamt int i, j;
324 1.3.2.2 yamt struct partition *pp;
325 1.3.2.2 yamt
326 1.3.2.2 yamt if ((unsigned) lp->d_type < DKMAXTYPES)
327 1.3.2.2 yamt printf("type: %s\n", dktypenames[lp->d_type]);
328 1.3.2.2 yamt else
329 1.3.2.2 yamt printf("type: %d\n", lp->d_type);
330 1.3.2.2 yamt printf("disk: %s\n", lp->d_typename);
331 1.3.2.2 yamt printf("label: %s\n", lp->d_packname);
332 1.3.2.2 yamt printf("flags:");
333 1.3.2.2 yamt if (lp->d_flags & D_REMOVABLE)
334 1.3.2.2 yamt printf(" removeable");
335 1.3.2.2 yamt if (lp->d_flags & D_ECC)
336 1.3.2.2 yamt printf(" ecc");
337 1.3.2.2 yamt if (lp->d_flags & D_BADSECT)
338 1.3.2.2 yamt printf(" badsect");
339 1.3.2.2 yamt printf("\n");
340 1.3.2.2 yamt printf("bytes/sector: %d\n", lp->d_secsize);
341 1.3.2.2 yamt printf("sectors/track: %d\n", lp->d_nsectors);
342 1.3.2.2 yamt printf("tracks/cylinder: %d\n", lp->d_ntracks);
343 1.3.2.2 yamt printf("sectors/cylinder: %d\n", lp->d_secpercyl);
344 1.3.2.2 yamt printf("cylinders: %d\n", lp->d_ncylinders);
345 1.3.2.2 yamt printf("rpm: %d\n", lp->d_rpm);
346 1.3.2.2 yamt printf("interleave: %d\n", lp->d_interleave);
347 1.3.2.2 yamt printf("trackskew: %d\n", lp->d_trackskew);
348 1.3.2.2 yamt printf("cylinderskew: %d\n", lp->d_cylskew);
349 1.3.2.2 yamt printf("headswitch: %d\t\t# milliseconds\n", lp->d_headswitch);
350 1.3.2.2 yamt printf("track-to-track seek: %d\t# milliseconds\n", lp->d_trkseek);
351 1.3.2.2 yamt printf("drivedata: ");
352 1.3.2.2 yamt for (i = NDDATA - 1; i >= 0; i--)
353 1.3.2.2 yamt if (lp->d_drivedata[i])
354 1.3.2.2 yamt break;
355 1.3.2.2 yamt if (i < 0)
356 1.3.2.2 yamt i = 0;
357 1.3.2.2 yamt for (j = 0; j <= i; j++)
358 1.3.2.2 yamt printf("%d ", lp->d_drivedata[j]);
359 1.3.2.2 yamt printf("\n\n%d partitions:\n", lp->d_npartitions);
360 1.3.2.2 yamt printf("# size offset fstype [fsize bsize cpg]\n");
361 1.3.2.2 yamt pp = lp->d_partitions;
362 1.3.2.2 yamt for (i = 0; i < lp->d_npartitions; i++, pp++) {
363 1.3.2.2 yamt if (pp->p_size) {
364 1.3.2.2 yamt printf(" %c: %d %d ", 'a' + i,
365 1.3.2.2 yamt pp->p_size, pp->p_offset);
366 1.3.2.2 yamt if ((unsigned) pp->p_fstype < FSMAXTYPES)
367 1.3.2.2 yamt printf("%s", fstypenames[pp->p_fstype]);
368 1.3.2.2 yamt else
369 1.3.2.2 yamt printf("%d", pp->p_fstype);
370 1.3.2.2 yamt switch (pp->p_fstype) {
371 1.3.2.2 yamt
372 1.3.2.2 yamt case FS_UNUSED: /* XXX */
373 1.3.2.2 yamt printf(" %d %d %s ",
374 1.3.2.2 yamt pp->p_fsize, pp->p_fsize * pp->p_frag, "");
375 1.3.2.2 yamt break;
376 1.3.2.2 yamt
377 1.3.2.2 yamt case FS_BSDFFS:
378 1.3.2.2 yamt printf(" %d %d %d ",
379 1.3.2.2 yamt pp->p_fsize, pp->p_fsize * pp->p_frag,
380 1.3.2.2 yamt pp->p_cpg);
381 1.3.2.2 yamt break;
382 1.3.2.2 yamt
383 1.3.2.2 yamt default:
384 1.3.2.2 yamt printf("%s", "");
385 1.3.2.2 yamt break;
386 1.3.2.2 yamt }
387 1.3.2.2 yamt printf("\t# (Cyl. %d",
388 1.3.2.2 yamt pp->p_offset / lp->d_secpercyl);
389 1.3.2.2 yamt if (pp->p_offset % lp->d_secpercyl)
390 1.3.2.2 yamt cnputc('*');
391 1.3.2.2 yamt else
392 1.3.2.2 yamt cnputc(' ');
393 1.3.2.2 yamt printf("- %d",
394 1.3.2.2 yamt (pp->p_offset +
395 1.3.2.2 yamt pp->p_size + lp->d_secpercyl - 1) /
396 1.3.2.2 yamt lp->d_secpercyl - 1);
397 1.3.2.2 yamt if (pp->p_size % lp->d_secpercyl)
398 1.3.2.2 yamt cnputc('*');
399 1.3.2.2 yamt printf(")\n");
400 1.3.2.2 yamt }
401 1.3.2.2 yamt }
402 1.3.2.2 yamt }
403