]>
Commit | Line | Data |
---|---|---|
726f69e2 KZ |
1 | /* |
2 | * Copyright (c) 1987, 1988 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 | ||
34 | #define BSD_DISKMAGIC ((u_long) 0x82564557) | |
35 | #define BSD_MAXPARTITIONS 8 | |
36 | #define BSD_LINUX_BOOTDIR "/usr/ucb/mdec" | |
37 | ||
38 | #if defined (i386) | |
39 | #define BSD_LABELSECTOR 1 | |
40 | #define BSD_LABELOFFSET 0 | |
41 | #define BSD_BBSIZE 8192 /* size of boot area, with label */ | |
42 | #define BSD_SBSIZE 8192 /* max size of fs superblock */ | |
43 | #elif defined (__alpha__) | |
44 | #error LABELSECTOR, LABELOFFSET, BBSIZE & SBSIZE are undefined for __alpha__ | |
45 | #define BSD_LABELSECTOR 0 | |
46 | #define BSD_LABELOFFSET 0 | |
47 | #define BSD_BBSIZE 0 | |
48 | #define BSD_SBSIZE 0 | |
49 | #else | |
50 | #error unknown architecture | |
51 | #endif | |
52 | ||
53 | struct disklabel { | |
54 | u_long d_magic; /* the magic number */ | |
55 | short d_type; /* drive type */ | |
56 | short d_subtype; /* controller/d_type specific */ | |
57 | char d_typename[16]; /* type name, e.g. "eagle" */ | |
58 | /* | |
59 | * d_packname contains the pack identifier and is returned when | |
60 | * the disklabel is read off the disk or in-core copy. | |
61 | * d_boot0 and d_boot1 are the (optional) names of the | |
62 | * primary (block 0) and secondary (block 1-15) bootstraps | |
63 | * as found in /usr/mdec. These are returned when using | |
64 | * getdiskbyname(3) to retrieve the values from /etc/disktab. | |
65 | */ | |
66 | #if defined(KERNEL) || defined(STANDALONE) | |
67 | char d_packname[16]; /* pack identifier */ | |
68 | #else | |
69 | union { | |
70 | char un_d_packname[16]; /* pack identifier */ | |
71 | struct { | |
72 | char *un_d_boot0; /* primary bootstrap name */ | |
73 | char *un_d_boot1; /* secondary bootstrap name */ | |
74 | } un_b; | |
75 | } d_un; | |
76 | #define d_packname d_un.un_d_packname | |
77 | #define d_boot0 d_un.un_b.un_d_boot0 | |
78 | #define d_boot1 d_un.un_b.un_d_boot1 | |
79 | #endif /* ! KERNEL or STANDALONE */ | |
80 | /* disk geometry: */ | |
81 | u_long d_secsize; /* # of bytes per sector */ | |
82 | u_long d_nsectors; /* # of data sectors per track */ | |
83 | u_long d_ntracks; /* # of tracks per cylinder */ | |
84 | u_long d_ncylinders; /* # of data cylinders per unit */ | |
85 | u_long d_secpercyl; /* # of data sectors per cylinder */ | |
86 | u_long d_secperunit; /* # of data sectors per unit */ | |
87 | /* | |
88 | * Spares (bad sector replacements) below | |
89 | * are not counted in d_nsectors or d_secpercyl. | |
90 | * Spare sectors are assumed to be physical sectors | |
91 | * which occupy space at the end of each track and/or cylinder. | |
92 | */ | |
93 | u_short d_sparespertrack; /* # of spare sectors per track */ | |
94 | u_short d_sparespercyl; /* # of spare sectors per cylinder */ | |
95 | /* | |
96 | * Alternate cylinders include maintenance, replacement, | |
97 | * configuration description areas, etc. | |
98 | */ | |
99 | u_long d_acylinders; /* # of alt. cylinders per unit */ | |
100 | ||
101 | /* hardware characteristics: */ | |
102 | /* | |
103 | * d_interleave, d_trackskew and d_cylskew describe perturbations | |
104 | * in the media format used to compensate for a slow controller. | |
105 | * Interleave is physical sector interleave, set up by the formatter | |
106 | * or controller when formatting. When interleaving is in use, | |
107 | * logically adjacent sectors are not physically contiguous, | |
108 | * but instead are separated by some number of sectors. | |
109 | * It is specified as the ratio of physical sectors traversed | |
110 | * per logical sector. Thus an interleave of 1:1 implies contiguous | |
111 | * layout, while 2:1 implies that logical sector 0 is separated | |
112 | * by one sector from logical sector 1. | |
113 | * d_trackskew is the offset of sector 0 on track N | |
114 | * relative to sector 0 on track N-1 on the same cylinder. | |
115 | * Finally, d_cylskew is the offset of sector 0 on cylinder N | |
116 | * relative to sector 0 on cylinder N-1. | |
117 | */ | |
118 | u_short d_rpm; /* rotational speed */ | |
119 | u_short d_interleave; /* hardware sector interleave */ | |
120 | u_short d_trackskew; /* sector 0 skew, per track */ | |
121 | u_short d_cylskew; /* sector 0 skew, per cylinder */ | |
122 | u_long d_headswitch; /* head switch time, usec */ | |
123 | u_long d_trkseek; /* track-to-track seek, usec */ | |
124 | u_long d_flags; /* generic flags */ | |
125 | #define NDDATA 5 | |
126 | u_long d_drivedata[NDDATA]; /* drive-type specific information */ | |
127 | #define NSPARE 5 | |
128 | u_long d_spare[NSPARE]; /* reserved for future use */ | |
129 | u_long d_magic2; /* the magic number (again) */ | |
130 | u_short d_checksum; /* xor of data incl. partitions */ | |
131 | /* filesystem and partition information: */ | |
132 | u_short d_npartitions; /* number of partitions in following */ | |
133 | u_long d_bbsize; /* size of boot area at sn0, bytes */ | |
134 | u_long d_sbsize; /* max size of fs superblock, bytes */ | |
135 | struct bsd_partition { /* the partition table */ | |
136 | u_long p_size; /* number of sectors in partition */ | |
137 | u_long p_offset; /* starting sector */ | |
138 | u_long p_fsize; /* filesystem basic fragment size */ | |
139 | u_char p_fstype; /* filesystem type, see below */ | |
140 | u_char p_frag; /* filesystem fragments per block */ | |
141 | u_short p_cpg; /* filesystem cylinders per group */ | |
142 | } d_partitions[BSD_MAXPARTITIONS]; /* actually may be more */ | |
143 | }; | |
144 | ||
145 | /* d_type values: */ | |
146 | #define BSD_DTYPE_SMD 1 /* SMD, XSMD; VAX hp/up */ | |
147 | #define BSD_DTYPE_MSCP 2 /* MSCP */ | |
148 | #define BSD_DTYPE_DEC 3 /* other DEC (rk, rl) */ | |
149 | #define BSD_DTYPE_SCSI 4 /* SCSI */ | |
150 | #define BSD_DTYPE_ESDI 5 /* ESDI interface */ | |
151 | #define BSD_DTYPE_ST506 6 /* ST506 etc. */ | |
152 | #define BSD_DTYPE_HPIB 7 /* CS/80 on HP-IB */ | |
153 | #define BSD_DTYPE_HPFL 8 /* HP Fiber-link */ | |
154 | #define BSD_DTYPE_FLOPPY 10 /* floppy */ | |
155 | ||
156 | /* d_subtype values: */ | |
157 | #define BSD_DSTYPE_INDOSPART 0x8 /* is inside dos partition */ | |
158 | #define BSD_DSTYPE_DOSPART(s) ((s) & 3) /* dos partition number */ | |
159 | #define BSD_DSTYPE_GEOMETRY 0x10 /* drive params in label */ | |
160 | ||
161 | #ifdef DKTYPENAMES | |
162 | static char *bsd_dktypenames[] = { | |
163 | "unknown", | |
164 | "SMD", | |
165 | "MSCP", | |
166 | "old DEC", | |
167 | "SCSI", | |
168 | "ESDI", | |
169 | "ST506", | |
170 | "HP-IB", | |
171 | "HP-FL", | |
172 | "type 9", | |
173 | "floppy", | |
174 | 0 | |
175 | }; | |
176 | #define BSD_DKMAXTYPES (sizeof(bsd_dktypenames) / sizeof(bsd_dktypenames[0]) - 1) | |
177 | #endif | |
178 | ||
179 | /* | |
180 | * Filesystem type and version. | |
181 | * Used to interpret other filesystem-specific | |
182 | * per-partition information. | |
183 | */ | |
184 | #define BSD_FS_UNUSED 0 /* unused */ | |
185 | #define BSD_FS_SWAP 1 /* swap */ | |
186 | #define BSD_FS_V6 2 /* Sixth Edition */ | |
187 | #define BSD_FS_V7 3 /* Seventh Edition */ | |
188 | #define BSD_FS_SYSV 4 /* System V */ | |
189 | #define BSD_FS_V71K 5 /* V7 with 1K blocks (4.1, 2.9) */ | |
190 | #define BSD_FS_V8 6 /* Eighth Edition, 4K blocks */ | |
191 | #define BSD_FS_BSDFFS 7 /* 4.2BSD fast file system */ | |
192 | #define BSD_FS_MSDOS 8 /* MS-DOS file system */ | |
193 | #define BSD_FS_BSDLFS 9 /* 4.4BSD log-structured file system */ | |
194 | #define BSD_FS_OTHER 10 /* in use, but unknown/unsupported */ | |
195 | #define BSD_FS_HPFS 11 /* OS/2 high-performance file system */ | |
196 | #define BSD_FS_ISO9660 12 /* ISO-9660 filesystem (cdrom) */ | |
197 | #define BSD_FS_ISOFS BSD_FS_ISO9660 | |
198 | #define BSD_FS_BOOT 13 /* partition contains bootstrap */ | |
199 | #define BSD_FS_ADOS 14 /* AmigaDOS fast file system */ | |
200 | #define BSD_FS_HFS 15 /* Macintosh HFS */ | |
201 | ||
202 | #ifdef DKTYPENAMES | |
203 | static struct systypes bsd_fstypes[] = { | |
204 | {BSD_FS_UNUSED, "unused"}, | |
205 | {BSD_FS_SWAP, "swap"}, | |
206 | {BSD_FS_V6, "Version 6"}, | |
207 | {BSD_FS_V7, "Version 7"}, | |
208 | {BSD_FS_SYSV, "System V"}, | |
209 | {BSD_FS_V71K, "4.1BSD"}, | |
210 | {BSD_FS_V8, "Eighth Edition"}, | |
211 | {BSD_FS_BSDFFS, "4.2BSD"}, | |
212 | {BSD_FS_MSDOS, "MS-DOS"}, | |
213 | {BSD_FS_BSDLFS, "4.4LFS"}, | |
214 | {BSD_FS_OTHER, "unknown"}, | |
215 | {BSD_FS_HPFS, "HPFS"}, | |
216 | {BSD_FS_ISO9660,"ISO-9660"}, | |
217 | {BSD_FS_BOOT, "boot"}, | |
218 | {BSD_FS_ADOS, "ADOS"}, | |
219 | {BSD_FS_HFS, "HFS"} | |
220 | }; | |
221 | ||
222 | #define BSD_FSMAXTYPES (sizeof(bsd_fstypes) / sizeof(struct systypes)) | |
223 | #endif | |
224 | ||
225 | /* | |
226 | * flags shared by various drives: | |
227 | */ | |
228 | #define BSD_D_REMOVABLE 0x01 /* removable media */ | |
229 | #define BSD_D_ECC 0x02 /* supports ECC */ | |
230 | #define BSD_D_BADSECT 0x04 /* supports bad sector forw. */ | |
231 | #define BSD_D_RAMDISK 0x08 /* disk emulator */ | |
232 | #define BSD_D_CHAIN 0x10 /* can do back-back transfers */ | |
233 | #define BSD_D_DOSPART 0x20 /* within MSDOS partition */ |