disklabel.c revision 1.3.2.3 1 1.3.2.3 yamt /* $NetBSD: disklabel.c,v 1.3.2.3 2014/05/22 11:39:55 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.3 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.3 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.3 yamt printf("\tomron:\t\tshow OMRON disklabel information\n");
133 1.3.2.3 yamt printf("\tbsd:\t\tshow BSD disklabel information\n");
134 1.3.2.3 yamt printf("\tcopy:\t\tcopy disklabel information from OMRON"
135 1.3.2.3 yamt " to BSD\n");
136 1.3.2.2 yamt printf("\tchecksum:\tdoing checksum\n");
137 1.3.2.3 yamt printf("\tset:\t\tchange BSD disklabel information\n");
138 1.3.2.2 yamt printf("\n\n");
139 1.3.2.2 yamt } else if (!strcmp(argv[1], "read")) {
140 1.3.2.2 yamt if (scsi_read( 0, lbl_buff, LABEL_SIZE)) {
141 1.3.2.2 yamt printf("Disk Label read done.\n");
142 1.3.2.2 yamt } else {
143 1.3.2.2 yamt printf("Disk Label read error !!\n");
144 1.3.2.2 yamt }
145 1.3.2.2 yamt } else if (!strcmp(argv[1], "omron")) {
146 1.3.2.2 yamt i = (int) &omp->dkl_badchk;
147 1.3.2.2 yamt i -= (int) lbl_buff;
148 1.3.2.2 yamt printf("Offset = %d\n", i);
149 1.3.2.2 yamt printf("\n");
150 1.3.2.3 yamt printf("Checksum of Bad Track:\t0x%x\n",
151 1.3.2.3 yamt omp->dkl_badchk);
152 1.3.2.3 yamt printf("Logical Block Total:\t%u(0x%x)\n",
153 1.3.2.3 yamt omp->dkl_maxblk, omp->dkl_maxblk);
154 1.3.2.3 yamt printf("Disk Drive Type:\t0x%x\n",
155 1.3.2.3 yamt omp->dkl_dtype);
156 1.3.2.3 yamt printf("Number of Disk Drives:\t%d(0x%x)\n",
157 1.3.2.3 yamt omp->dkl_ndisk, omp->dkl_ndisk);
158 1.3.2.3 yamt printf("Number of Data Cylinders:\t%d(0x%x)\n",
159 1.3.2.3 yamt omp->dkl_ncyl, omp->dkl_ncyl);
160 1.3.2.2 yamt printf("Number of Alternate Cylinders:\t%d(0x%x)\n",
161 1.3.2.3 yamt omp->dkl_acyl,omp->dkl_acyl);
162 1.3.2.2 yamt printf("Number of Heads in This Partition:\t%d(0x%x)\n",
163 1.3.2.3 yamt omp->dkl_nhead, omp->dkl_nhead);
164 1.3.2.2 yamt printf("Number of 512 byte Sectors per Track:\t%d(0x%x)\n",
165 1.3.2.3 yamt omp->dkl_nsect, omp->dkl_nsect);
166 1.3.2.2 yamt printf("Identifies Proper Label Locations:\t0x%x\n",
167 1.3.2.3 yamt omp->dkl_bhead);
168 1.3.2.2 yamt printf("Physical Partition Number:\t%d(0x%x)\n",
169 1.3.2.3 yamt omp->dkl_ppart, omp->dkl_ppart);
170 1.3.2.2 yamt for (i = 0; i < NLPART; i++)
171 1.3.2.2 yamt printf("\t%d:\t%d\t%d\n", i,
172 1.3.2.3 yamt omp->dkl_map[i].dkl_blkno,
173 1.3.2.3 yamt omp->dkl_map[i].dkl_nblk);
174 1.3.2.3 yamt printf("Identifies This Label Format:\t0x%x\n",
175 1.3.2.3 yamt omp->dkl_magic);
176 1.3.2.3 yamt printf("XOR Checksum of Sector:\t0x%x\n",
177 1.3.2.3 yamt omp->dkl_cksum);
178 1.3.2.2 yamt } else if (!strcmp(argv[1], "checksum")) {
179 1.3.2.2 yamt if (omp->dkl_magic == DKL_MAGIC){
180 1.3.2.3 yamt /* checksum of disk-label */
181 1.3.2.2 yamt chksum = 0;
182 1.3.2.2 yamt count = sizeof(struct scd_dk_label) / sizeof(short int);
183 1.3.2.2 yamt for (p= (u_short *) lbl_buff; count > 0; count--) {
184 1.3.2.2 yamt if (count == 1)
185 1.3.2.2 yamt printf("Check Sum: 0x%lx\n", chksum);
186 1.3.2.2 yamt chksum ^= *p++;
187 1.3.2.2 yamt }
188 1.3.2.2 yamt
189 1.3.2.2 yamt printf("dkl_cksum: 0x%x\n", omp->dkl_cksum);
190 1.3.2.2 yamt
191 1.3.2.2 yamt if (chksum != 0) {
192 1.3.2.2 yamt printf("OMRON Disklabel check sum error.\n");
193 1.3.2.2 yamt }
194 1.3.2.2 yamt } else {
195 1.3.2.2 yamt printf("OMRON Disklabel not found.\n");
196 1.3.2.2 yamt }
197 1.3.2.2 yamt } else if (!strcmp(argv[1], "copy")) {
198 1.3.2.2 yamt memset(bp, 0, sizeof(struct disklabel));
199 1.3.2.2 yamt
200 1.3.2.2 yamt memcpy(bp->d_typename, lbl_buff, 16);
201 1.3.2.2 yamt
202 1.3.2.2 yamt bp->d_secsize = DEV_BSIZE;
203 1.3.2.2 yamt bp->d_nsectors = 38;
204 1.3.2.2 yamt bp->d_ntracks = 12;
205 1.3.2.2 yamt bp->d_ncylinders = 1076;
206 1.3.2.2 yamt
207 1.3.2.2 yamt bp->d_type = DTYPE_SCSI;
208 1.3.2.2 yamt
209 1.3.2.2 yamt bp->d_secpercyl = bp->d_nsectors * bp->d_ntracks;
210 1.3.2.2 yamt bp->d_secperunit = bp->d_secpercyl * bp->d_ncylinders;
211 1.3.2.2 yamt bp->d_rpm = 3600;
212 1.3.2.2 yamt bp->d_interleave = 1;
213 1.3.2.2 yamt bp->d_trackskew = 0;
214 1.3.2.2 yamt bp->d_cylskew = 0;
215 1.3.2.2 yamt bp->d_headswitch = 0;
216 1.3.2.2 yamt bp->d_trkseek = 0;
217 1.3.2.2 yamt bp->d_bbsize = BBSIZE;
218 1.3.2.2 yamt bp->d_sbsize = SBSIZE;
219 1.3.2.2 yamt
220 1.3.2.2 yamt for (i = 0; i < MAXPARTITIONS; i++) {
221 1.3.2.3 yamt bp->d_partitions[i].p_size =
222 1.3.2.3 yamt omp->dkl_map[i].dkl_nblk;
223 1.3.2.3 yamt bp->d_partitions[i].p_offset =
224 1.3.2.3 yamt omp->dkl_map[i].dkl_blkno;
225 1.3.2.2 yamt bp->d_partitions[i].p_fsize = 1024;
226 1.3.2.2 yamt bp->d_partitions[i].p_frag = 8192 / 1024;
227 1.3.2.2 yamt bp->d_partitions[i].p_fstype = FS_UNUSED;
228 1.3.2.2 yamt }
229 1.3.2.2 yamt
230 1.3.2.2 yamt bp->d_npartitions = MAXPARTITIONS;
231 1.3.2.2 yamt
232 1.3.2.2 yamt for (i = 0; i < NDDATA; i++) {
233 1.3.2.2 yamt bp->d_drivedata[i] = 0;
234 1.3.2.2 yamt }
235 1.3.2.2 yamt
236 1.3.2.2 yamt memset(bp->d_packname, 0, 16);
237 1.3.2.2 yamt
238 1.3.2.2 yamt bp->d_magic = DISKMAGIC;
239 1.3.2.2 yamt bp->d_magic2 = DISKMAGIC;
240 1.3.2.2 yamt bp->d_checksum = 0;
241 1.3.2.2 yamt bp->d_checksum = dkcksum(bp);
242 1.3.2.2 yamt
243 1.3.2.2 yamt /* restump checksum of OMRON disklabel */
244 1.3.2.2 yamt chksum = 0;
245 1.3.2.2 yamt count = sizeof(struct scd_dk_label) / sizeof(short int);
246 1.3.2.2 yamt for (p= (u_short *) lbl_buff; count > 1; count--) {
247 1.3.2.2 yamt chksum ^= *p++;
248 1.3.2.2 yamt }
249 1.3.2.2 yamt printf("chksum: 0x%lx\n", chksum);
250 1.3.2.2 yamt
251 1.3.2.2 yamt omp->dkl_cksum = chksum;
252 1.3.2.2 yamt printf("dkl_cksum: 0x%x\n", omp->dkl_cksum);
253 1.3.2.2 yamt } else if (!strcmp(argv[1], "bsd")) {
254 1.3.2.2 yamt display(bp);
255 1.3.2.2 yamt } else if (!strcmp(argv[1], "write")) {
256 1.3.2.2 yamt if (scsi_write( 0, lbl_buff, LABEL_SIZE)) {
257 1.3.2.2 yamt printf("Disk Label write done.\n");
258 1.3.2.2 yamt } else {
259 1.3.2.2 yamt printf("Disk Label write error !!\n");
260 1.3.2.2 yamt }
261 1.3.2.2 yamt } else if (!strcmp(argv[1], "set")) {
262 1.3.2.2 yamt i = (argv[2])[1] - 'a';
263 1.3.2.2 yamt for (q = argv[3], j = 0; *q != '\0'; q++) {
264 1.3.2.2 yamt j = (j * 10) + (*q - '0');
265 1.3.2.2 yamt }
266 1.3.2.2 yamt switch (*argv[2]) {
267 1.3.2.2 yamt case 'b':
268 1.3.2.3 yamt bp->d_partitions[i].p_frag =
269 1.3.2.3 yamt j / bp->d_partitions[i].p_fsize;
270 1.3.2.2 yamt break;
271 1.3.2.2 yamt case 'f': /* fragment size */
272 1.3.2.2 yamt bp->d_partitions[i].p_fsize = j;
273 1.3.2.2 yamt break;
274 1.3.2.2 yamt case 'o': /* offset */
275 1.3.2.2 yamt bp->d_partitions[i].p_offset = j;
276 1.3.2.2 yamt omp->dkl_map[i].dkl_blkno = j;
277 1.3.2.2 yamt break;
278 1.3.2.2 yamt case 'p': /* size */
279 1.3.2.2 yamt bp->d_partitions[i].p_size = j;
280 1.3.2.2 yamt omp->dkl_map[i].dkl_nblk = j;
281 1.3.2.2 yamt break;
282 1.3.2.2 yamt case 't': /* FS type */
283 1.3.2.2 yamt bp->d_partitions[i].p_fstype = j;
284 1.3.2.2 yamt break;
285 1.3.2.2 yamt default:
286 1.3.2.2 yamt break;
287 1.3.2.2 yamt }
288 1.3.2.2 yamt
289 1.3.2.2 yamt /* restump checksum of BSD disklabel */
290 1.3.2.2 yamt bp->d_checksum = 0;
291 1.3.2.2 yamt bp->d_checksum = dkcksum(bp);
292 1.3.2.2 yamt
293 1.3.2.2 yamt /* restump checksum of OMRON disklabel */
294 1.3.2.2 yamt chksum = 0;
295 1.3.2.2 yamt count = sizeof(struct scd_dk_label) / sizeof(short int);
296 1.3.2.3 yamt for (p = (u_short *)lbl_buff; count > 1; count--) {
297 1.3.2.2 yamt chksum ^= *p++;
298 1.3.2.2 yamt }
299 1.3.2.2 yamt omp->dkl_cksum = chksum;
300 1.3.2.2 yamt
301 1.3.2.2 yamt } else if (!strcmp(argv[1], "sb")) {
302 1.3.2.2 yamt #define BLOCK_SIZE SBSIZE
303 1.3.2.2 yamt
304 1.3.2.3 yamt printf("checking Super Block: block size = %d bytes,"
305 1.3.2.3 yamt " seek amount = 1 blocks\n", BLOCK_SIZE);
306 1.3.2.2 yamt i = j = 0;
307 1.3.2.3 yamt while (1) {
308 1.3.2.2 yamt if (!scsi_read( i, lbl_buff, BLOCK_SIZE))
309 1.3.2.2 yamt break;
310 1.3.2.2 yamt
311 1.3.2.2 yamt if (fp->fs_magic == FS_MAGIC) {
312 1.3.2.2 yamt printf("%d, (%d)\n", i, i - j);
313 1.3.2.2 yamt j = i;
314 1.3.2.2 yamt }
315 1.3.2.2 yamt i++;
316 1.3.2.2 yamt }
317 1.3.2.2 yamt } else if (!strcmp(argv[1], "sbcopy")) {
318 1.3.2.2 yamt if (!scsi_read(32, lbl_buff, BLOCK_SIZE)) {
319 1.3.2.2 yamt printf("sbcopy: read failed\n");
320 1.3.2.3 yamt return ST_ERROR;
321 1.3.2.2 yamt }
322 1.3.2.2 yamt if (scsi_write(16, lbl_buff, BLOCK_SIZE)) {
323 1.3.2.2 yamt printf("sbcopy: copy done\n");
324 1.3.2.2 yamt } else {
325 1.3.2.2 yamt printf("sbcopy: write failed\n");
326 1.3.2.2 yamt }
327 1.3.2.2 yamt }
328 1.3.2.2 yamt
329 1.3.2.3 yamt return ST_NORMAL;
330 1.3.2.2 yamt }
331 1.3.2.2 yamt
332 1.3.2.2 yamt void
333 1.3.2.2 yamt display(struct disklabel *lp)
334 1.3.2.2 yamt {
335 1.3.2.2 yamt int i, j;
336 1.3.2.2 yamt struct partition *pp;
337 1.3.2.2 yamt
338 1.3.2.2 yamt if ((unsigned) lp->d_type < DKMAXTYPES)
339 1.3.2.2 yamt printf("type: %s\n", dktypenames[lp->d_type]);
340 1.3.2.2 yamt else
341 1.3.2.2 yamt printf("type: %d\n", lp->d_type);
342 1.3.2.2 yamt printf("disk: %s\n", lp->d_typename);
343 1.3.2.2 yamt printf("label: %s\n", lp->d_packname);
344 1.3.2.2 yamt printf("flags:");
345 1.3.2.2 yamt if (lp->d_flags & D_REMOVABLE)
346 1.3.2.2 yamt printf(" removeable");
347 1.3.2.2 yamt if (lp->d_flags & D_ECC)
348 1.3.2.2 yamt printf(" ecc");
349 1.3.2.2 yamt if (lp->d_flags & D_BADSECT)
350 1.3.2.2 yamt printf(" badsect");
351 1.3.2.2 yamt printf("\n");
352 1.3.2.2 yamt printf("bytes/sector: %d\n", lp->d_secsize);
353 1.3.2.2 yamt printf("sectors/track: %d\n", lp->d_nsectors);
354 1.3.2.2 yamt printf("tracks/cylinder: %d\n", lp->d_ntracks);
355 1.3.2.2 yamt printf("sectors/cylinder: %d\n", lp->d_secpercyl);
356 1.3.2.2 yamt printf("cylinders: %d\n", lp->d_ncylinders);
357 1.3.2.2 yamt printf("rpm: %d\n", lp->d_rpm);
358 1.3.2.2 yamt printf("interleave: %d\n", lp->d_interleave);
359 1.3.2.2 yamt printf("trackskew: %d\n", lp->d_trackskew);
360 1.3.2.2 yamt printf("cylinderskew: %d\n", lp->d_cylskew);
361 1.3.2.2 yamt printf("headswitch: %d\t\t# milliseconds\n", lp->d_headswitch);
362 1.3.2.2 yamt printf("track-to-track seek: %d\t# milliseconds\n", lp->d_trkseek);
363 1.3.2.2 yamt printf("drivedata: ");
364 1.3.2.2 yamt for (i = NDDATA - 1; i >= 0; i--)
365 1.3.2.2 yamt if (lp->d_drivedata[i])
366 1.3.2.2 yamt break;
367 1.3.2.2 yamt if (i < 0)
368 1.3.2.2 yamt i = 0;
369 1.3.2.2 yamt for (j = 0; j <= i; j++)
370 1.3.2.2 yamt printf("%d ", lp->d_drivedata[j]);
371 1.3.2.2 yamt printf("\n\n%d partitions:\n", lp->d_npartitions);
372 1.3.2.2 yamt printf("# size offset fstype [fsize bsize cpg]\n");
373 1.3.2.2 yamt pp = lp->d_partitions;
374 1.3.2.2 yamt for (i = 0; i < lp->d_npartitions; i++, pp++) {
375 1.3.2.2 yamt if (pp->p_size) {
376 1.3.2.2 yamt printf(" %c: %d %d ", 'a' + i,
377 1.3.2.2 yamt pp->p_size, pp->p_offset);
378 1.3.2.2 yamt if ((unsigned) pp->p_fstype < FSMAXTYPES)
379 1.3.2.2 yamt printf("%s", fstypenames[pp->p_fstype]);
380 1.3.2.2 yamt else
381 1.3.2.2 yamt printf("%d", pp->p_fstype);
382 1.3.2.2 yamt switch (pp->p_fstype) {
383 1.3.2.2 yamt
384 1.3.2.2 yamt case FS_UNUSED: /* XXX */
385 1.3.2.2 yamt printf(" %d %d %s ",
386 1.3.2.2 yamt pp->p_fsize, pp->p_fsize * pp->p_frag, "");
387 1.3.2.2 yamt break;
388 1.3.2.2 yamt
389 1.3.2.2 yamt case FS_BSDFFS:
390 1.3.2.2 yamt printf(" %d %d %d ",
391 1.3.2.2 yamt pp->p_fsize, pp->p_fsize * pp->p_frag,
392 1.3.2.2 yamt pp->p_cpg);
393 1.3.2.2 yamt break;
394 1.3.2.2 yamt
395 1.3.2.2 yamt default:
396 1.3.2.2 yamt printf("%s", "");
397 1.3.2.2 yamt break;
398 1.3.2.2 yamt }
399 1.3.2.2 yamt printf("\t# (Cyl. %d",
400 1.3.2.2 yamt pp->p_offset / lp->d_secpercyl);
401 1.3.2.2 yamt if (pp->p_offset % lp->d_secpercyl)
402 1.3.2.2 yamt cnputc('*');
403 1.3.2.2 yamt else
404 1.3.2.2 yamt cnputc(' ');
405 1.3.2.2 yamt printf("- %d",
406 1.3.2.3 yamt (pp->p_offset +
407 1.3.2.2 yamt pp->p_size + lp->d_secpercyl - 1) /
408 1.3.2.2 yamt lp->d_secpercyl - 1);
409 1.3.2.2 yamt if (pp->p_size % lp->d_secpercyl)
410 1.3.2.2 yamt cnputc('*');
411 1.3.2.2 yamt printf(")\n");
412 1.3.2.2 yamt }
413 1.3.2.2 yamt }
414 1.3.2.2 yamt }
415