Commit | Line | Data |
---|---|---|
0313acd6 WJ |
1 | .\" Copyright (c) 1987, 1991 Regents of the University of California. |
2 | .\" All rights reserved. | |
3 | .\" | |
4 | .\" This code is derived from software contributed to Berkeley by | |
5 | .\" Symmetric Computer Systems. | |
6 | .\" | |
7 | .\" Redistribution and use in source and binary forms, with or without | |
8 | .\" modification, are permitted provided that the following conditions | |
9 | .\" are met: | |
10 | .\" 1. Redistributions of source code must retain the above copyright | |
11 | .\" notice, this list of conditions and the following disclaimer. | |
12 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
13 | .\" notice, this list of conditions and the following disclaimer in the | |
14 | .\" documentation and/or other materials provided with the distribution. | |
15 | .\" 3. All advertising materials mentioning features or use of this software | |
16 | .\" must display the following acknowledgement: | |
17 | .\" This product includes software developed by the University of | |
18 | .\" California, Berkeley and its contributors. | |
19 | .\" 4. Neither the name of the University nor the names of its contributors | |
20 | .\" may be used to endorse or promote products derived from this software | |
21 | .\" without specific prior written permission. | |
22 | .\" | |
23 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
24 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
25 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
26 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
27 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
28 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
29 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
30 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
31 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
32 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
33 | .\" SUCH DAMAGE. | |
34 | .\" | |
35 | .\" @(#)disklabel.5.5 6.6 (Berkeley) 5/10/91 | |
36 | .\" | |
37 | .Dd May 10, 1991 | |
38 | .Dt DISKLABEL 5 | |
39 | .Os | |
40 | .Sh NAME | |
41 | .Nm disklabel | |
42 | .Nd disk pack label | |
43 | .Sh SYNOPSIS | |
44 | .Fd #include <sys/disklabel.h> | |
45 | .Sh DESCRIPTION | |
46 | Each disk or disk pack on a system may contain a disk label | |
47 | which provides detailed information | |
48 | about the geometry of the disk and the partitions into which the disk | |
49 | is divided. | |
50 | It should be initialized when the disk is formatted, | |
51 | and may be changed later with the | |
52 | .Xr disklabel 8 | |
53 | program. | |
54 | This information is used by the system disk driver and by the bootstrap | |
55 | program to determine how to program the drive | |
56 | and where to find the filesystems on the disk partitions. | |
57 | Additional information is used by the filesystem in order | |
58 | to use the disk most efficiently and to locate important filesystem information. | |
59 | The description of each partition contains an identifier for the partition | |
60 | type (standard filesystem, swap area, etc.). | |
61 | The filesystem updates the in-core copy of the label if it contains | |
62 | incomplete information about the filesystem. | |
63 | .Pp | |
64 | The label is located in sector number | |
65 | .Dv LABELSECTOR | |
66 | of the drive, usually sector 0 where it may be found | |
67 | without any information about the disk geometry. | |
68 | It is at an offset | |
69 | .Dv LABELOFFSET | |
70 | from the beginning of the sector, to allow room for the initial bootstrap. | |
71 | The disk sector containing the label is normally made read-only | |
72 | so that it is not accidentally overwritten by pack-to-pack copies | |
73 | or swap operations; | |
74 | the | |
75 | .Dv DIOCWLABEL | |
76 | .Xr ioctl 2 , | |
77 | which is done as needed by the | |
78 | .Xr disklabel | |
79 | program. | |
80 | .Pp | |
81 | A copy of the in-core label for a disk can be obtained with the | |
82 | .Dv DIOCGDINFO | |
83 | .Xr ioctl ; | |
84 | this works with a file descriptor for a block or character (``raw'') device | |
85 | for any partition of the disk. | |
86 | The in-core copy of the label is set by the | |
87 | .Dv DIOCSDINFO | |
88 | .Xr ioctl . | |
89 | The offset of a partition cannot generally be changed while it is open, | |
90 | nor can it be made smaller while it is open. | |
91 | One exception is that any change is allowed if no label was found | |
92 | on the disk, and the driver was able to construct only a skeletal label | |
93 | without partition information. | |
94 | Finally, the | |
95 | .Dv DIOCWDINFO | |
96 | .Xr ioctl | |
97 | operation sets the in-core label and then updates the on-disk label; | |
98 | there must be an existing label on the disk for this operation to succeed. | |
99 | Thus, the initial label for a disk or disk pack must be installed | |
100 | by writing to the raw disk. | |
101 | All of these operations are normally done using | |
102 | .Xr disklabel . | |
103 | .Pp | |
104 | The format of the disk label, as specified in | |
105 | .Aw Pa sys/disklabel.h , | |
106 | is | |
107 | .Bd -literal | |
108 | /* | |
109 | * Disk description table, see disktab(5) | |
110 | */ | |
111 | #define DISKTAB "/etc/disktab" | |
112 | ||
113 | /* | |
114 | * Each disk has a label which includes information about the hardware | |
115 | * disk geometry, filesystem partitions, and drive specific information. | |
116 | * The label is in block 0 or 1, possibly offset from the beginning | |
117 | * to leave room for a bootstrap, etc. | |
118 | */ | |
119 | ||
120 | #define LABELSECTOR 0 /* sector containing label */ | |
121 | #define LABELOFFSET 64 /* offset of label in sector */ | |
122 | #define DISKMAGIC ((u_long) 0x82564557) /* The disk magic number */ | |
123 | #ifndef MAXPARTITIONS | |
124 | #define MAXPARTITIONS 8 | |
125 | #endif | |
126 | ||
127 | #ifndef LOCORE | |
128 | struct disklabel { | |
129 | u_long d_magic; /* the magic number */ | |
130 | short d_type; /* drive type */ | |
131 | short d_subtype; /* controller/d_type specific */ | |
132 | char d_typename[16]; /* type name, e.g. "eagle" */ | |
133 | /* | |
134 | * d_packname contains the pack identifier and is returned when | |
135 | * the disklabel is read off the disk or in-core copy. | |
136 | * d_boot0 and d_boot1 are the (optional) names of the | |
137 | * primary (block 0) and secondary (block 1-15) bootstraps | |
138 | * as found in /usr/mdec. These are returned when using | |
139 | * getdiskbyname(3) | |
140 | to retrieve the values from /etc/disktab. | |
141 | */ | |
142 | #if defined(KERNEL) || defined(STANDALONE) | |
143 | char d_packname[16]; /* pack identifier */ | |
144 | #else | |
145 | union { | |
146 | char un_d_packname[16]; /* pack identifier */ | |
147 | struct { | |
148 | char *un_d_boot0; /* primary bootstrap name */ | |
149 | char *un_d_boot1; /* secondary bootstrap name */ | |
150 | } un_b; | |
151 | } d_un; | |
152 | ||
153 | #define d_packname d_un.un_d_packname | |
154 | #define d_boot0 d_un.un_b.un_d_boot0 | |
155 | #define d_boot1 d_un.un_b.un_d_boot1 | |
156 | #endif /* ! KERNEL or STANDALONE */ | |
157 | ||
158 | /* disk geometry: */ | |
159 | u_long d_secsize; /* # of bytes per sector */ | |
160 | u_long d_nsectors; /* # of data sectors per track */ | |
161 | u_long d_ntracks; /* # of tracks per cylinder */ | |
162 | u_long d_ncylinders; /* # of data cylinders per unit */ | |
163 | u_long d_secpercyl; /* # of data sectors per cylinder */ | |
164 | u_long d_secperunit; /* # of data sectors per unit */ | |
165 | /* | |
166 | * Spares (bad sector replacements) below | |
167 | * are not counted in d_nsectors or d_secpercyl. | |
168 | * Spare sectors are assumed to be physical sectors | |
169 | * which occupy space at the end of each track and/or cylinder. | |
170 | */ | |
171 | u_short d_sparespertrack; /* # of spare sectors per track */ | |
172 | u_short d_sparespercyl; /* # of spare sectors per cylinder */ | |
173 | /* | |
174 | * Alternate cylinders include maintenance, replacement, | |
175 | * configuration description areas, etc. | |
176 | */ | |
177 | u_long d_acylinders; /* # of alt. cylinders per unit */ | |
178 | ||
179 | /* hardware characteristics: */ | |
180 | /* | |
181 | * d_interleave, d_trackskew and d_cylskew describe perturbations | |
182 | * in the media format used to compensate for a slow controller. | |
183 | * Interleave is physical sector interleave, set up by the formatter | |
184 | * or controller when formatting. When interleaving is in use, | |
185 | * logically adjacent sectors are not physically contiguous, | |
186 | * but instead are separated by some number of sectors. | |
187 | * It is specified as the ratio of physical sectors traversed | |
188 | * per logical sector. Thus an interleave of 1:1 implies contiguous | |
189 | * layout, while 2:1 implies that logical sector 0 is separated | |
190 | * by one sector from logical sector 1. | |
191 | * d_trackskew is the offset of sector 0 on track N | |
192 | * relative to sector 0 on track N-1 on the same cylinder. | |
193 | * Finally, d_cylskew is the offset of sector 0 on cylinder N | |
194 | * relative to sector 0 on cylinder N-1. | |
195 | */ | |
196 | u_short d_rpm; /* rotational speed */ | |
197 | u_short d_interleave; /* hardware sector interleave */ | |
198 | u_short d_trackskew; /* sector 0 skew, per track */ | |
199 | u_short d_cylskew; /* sector 0 skew, per cylinder */ | |
200 | u_long d_headswitch; /* head switch time, usec */ | |
201 | u_long d_trkseek; /* track-to-track seek, usec */ | |
202 | u_long d_flags; /* generic flags */ | |
203 | #define NDDATA 5 | |
204 | u_long d_drivedata[NDDATA]; /* drive-type specific information */ | |
205 | #define NSPARE 5 | |
206 | u_long d_spare[NSPARE]; /* reserved for future use */ | |
207 | u_long d_magic2; /* the magic number (again) */ | |
208 | u_short d_checksum; /* xor of data incl. partitions */ | |
209 | ||
210 | /* filesystem and partition information: */ | |
211 | u_short d_npartitions; /* number of partitions in following */ | |
212 | u_long d_bbsize; /* size of boot area at sn0, bytes */ | |
213 | u_long d_sbsize; /* max size of fs superblock, bytes */ | |
214 | struct partition { /* the partition table */ | |
215 | u_long p_size; /* number of sectors in partition */ | |
216 | u_long p_offset; /* starting sector */ | |
217 | u_long p_fsize; /* filesystem basic fragment size */ | |
218 | u_char p_fstype; /* filesystem type, see below */ | |
219 | u_char p_frag; /* filesystem fragments per block */ | |
220 | u_short p_cpg; /* filesystem cylinders per group */ | |
221 | } d_partitions[MAXPARTITIONS]; /* actually may be more */ | |
222 | }; | |
223 | ||
224 | /* d_type values: */ | |
225 | #define DTYPE_SMD 1 /* SMD, XSMD; VAX hp/up */ | |
226 | #define DTYPE_MSCP 2 /* MSCP */ | |
227 | #define DTYPE_DEC 3 /* other DEC (rk, rl) */ | |
228 | #define DTYPE_SCSI 4 /* SCSI */ | |
229 | #define DTYPE_ESDI 5 /* ESDI interface */ | |
230 | #define DTYPE_ST506 6 /* ST506 etc. */ | |
231 | #define DTYPE_FLOPPY 10 /* floppy */ | |
232 | ||
233 | #ifdef DKTYPENAMES | |
234 | static char *dktypenames[] = { | |
235 | "unknown", | |
236 | "SMD", | |
237 | "MSCP", | |
238 | "old DEC", | |
239 | "SCSI", | |
240 | "ESDI", | |
241 | "type 6", | |
242 | "type 7", | |
243 | "type 8", | |
244 | "type 9", | |
245 | "floppy", | |
246 | 0 | |
247 | }; | |
248 | #define DKMAXTYPES (sizeof(dktypenames) / sizeof(dktypenames[0]) - 1) | |
249 | #endif | |
250 | ||
251 | /* | |
252 | * Filesystem type and version. | |
253 | * Used to interpret other filesystem-specific | |
254 | * per-partition information. | |
255 | */ | |
256 | #define FS_UNUSED 0 /* unused */ | |
257 | #define FS_SWAP 1 /* swap */ | |
258 | #define FS_V6 2 /* Sixth Edition */ | |
259 | #define FS_V7 3 /* Seventh Edition */ | |
260 | #define FS_SYSV 4 /* System V */ | |
261 | #define FS_V71K 5 /* V7 with 1K blocks (4.1, 2.9) */ | |
262 | #define FS_V8 6 /* Eighth Edition, 4K blocks */ | |
263 | #define FS_BSDFFS 7 /* 4.2BSD fast file system */ | |
264 | ||
265 | #ifdef DKTYPENAMES | |
266 | static char *fstypenames[] = { | |
267 | "unused", | |
268 | "swap", | |
269 | "Version 6", | |
270 | "Version 7", | |
271 | "System V", | |
272 | "4.1BSD", | |
273 | "Eighth Edition", | |
274 | "4.2BSD", | |
275 | 0 | |
276 | }; | |
277 | #define FSMAXTYPES (sizeof(fstypenames) / sizeof(fstypenames[0]) - 1) | |
278 | #endif | |
279 | ||
280 | /* | |
281 | * flags shared by various drives: | |
282 | */ | |
283 | #define D_REMOVABLE 0x01 /* removable media */ | |
284 | #define D_ECC 0x02 /* supports ECC */ | |
285 | #define D_BADSECT 0x04 /* supports bad sector forw. */ | |
286 | #define D_RAMDISK 0x08 /* disk emulator */ | |
287 | #define D_CHAIN 0x10 /* can do back-back transfers */ | |
288 | ||
289 | /* | |
290 | * Drive data for SMD. | |
291 | */ | |
292 | ||
293 | #define d_smdflags d_drivedata[0] | |
294 | #define D_SSE 0x1 /* supports skip sectoring */ | |
295 | #define d_mindist d_drivedata[1] | |
296 | #define d_maxdist d_drivedata[2] | |
297 | #define d_sdist d_drivedata[3] | |
298 | ||
299 | /* | |
300 | * Drive data for ST506. | |
301 | */ | |
302 | #define d_precompcyl d_drivedata[0] | |
303 | #define d_gap3 d_drivedata[1] /* used only when formatting */ | |
304 | ||
305 | #ifndef LOCORE | |
306 | /* | |
307 | * Structure used to perform a format | |
308 | * or other raw operation, returning data | |
309 | * and/or register values. | |
310 | * Register identification and format | |
311 | * are device- and driver-dependent. | |
312 | */ | |
313 | struct format_op { | |
314 | char *df_buf; | |
315 | int df_count; /* value-result */ | |
316 | daddr_t df_startblk; | |
317 | int df_reg[8]; /* result */ | |
318 | }; | |
319 | ||
320 | /* | |
321 | * Structure used internally to retrieve | |
322 | * information about a partition on a disk. | |
323 | */ | |
324 | struct partinfo { | |
325 | struct disklabel *disklab; | |
326 | struct partition *part; | |
327 | }; | |
328 | ||
329 | /* | |
330 | * Disk-specific ioctls. | |
331 | */ | |
332 | /* get and set disklabel; DIOCGPART used internally */ | |
333 | #define DIOCGDINFO _IOR('d', 101, struct disklabel) /* get */ | |
334 | #define DIOCSDINFO _IOW('d', 102, struct disklabel) /* set */ | |
335 | #define DIOCWDINFO _IOW('d', 103, struct disklabel) /* set, update disk */ | |
336 | #define DIOCGPART _IOW('d', 104, struct partinfo) /* get partition */ | |
337 | ||
338 | /* do format operation, read or write */ | |
339 | #define DIOCRFORMAT _IOWR('d', 105, struct format_op) | |
340 | #define DIOCWFORMAT _IOWR('d', 106, struct format_op) | |
341 | ||
342 | #define DIOCSSTEP _IOW('d', 107, int) /* set step rate */ | |
343 | #define DIOCSRETRIES _IOW('d', 108, int) /* set # of retries */ | |
344 | #define DIOCWLABEL _IOW('d', 109, int) /* write en/disable label */ | |
345 | ||
346 | #define DIOCSBAD _IOW('d', 110, struct dkbad) /* set kernel dkbad */ | |
347 | ||
348 | #endif LOCORE | |
349 | .Ed | |
350 | .Sh SEE ALSO | |
351 | .Xr disktab 5 , | |
352 | .Xr disklabel 8 | |
353 | .Sh HISTORY | |
354 | The | |
355 | .Nm | |
356 | file format is | |
357 | .Ud . |