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