BSD 4_3_Reno development
[unix-history] / usr / share / man / cat5 / disklabel.0
CommitLineData
5eaf1089
C
1
2
3
4DISKLABEL(5) 1990 DISKLABEL(5)
5
6
7
8N\bNA\bAM\bME\bE
9 disklabel - disk pack label
10
11S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
12 #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/d\bdi\bis\bsk\bkl\bla\bab\bbe\bel\bl.\b.h\bh>\b>
13
14D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
15 Each disk or disk pack on a system may contain a disk label
16 which provides detailed information about the geometry of
17 the disk and the partitions into which the disk is divided.
18 It should be initialized when the disk is formatted, and may
19 be changed later with the _\bd_\bi_\bs_\bk_\bl_\ba_\bb_\be_\bl(8) program. This infor-
20 mation is used by the system disk driver and by the
21 bootstrap program to determine how to program the drive and
22 where to find the filesystems on the disk partitions. Addi-
23 tional information is used by the filesystem in order to use
24 the disk most efficiently and to locate important filesystem
25 information. The description of each partition contains an
26 identifier for the partition type (standard filesystem, swap
27 area, etc.). The filesystem updates the in-core copy of the
28 label if it contains incomplete information about the
29 filesystem.
30
31 The label is located in sector number _\bL_\bA_\bB_\bE_\bL_\bS_\bE_\bC_\bT_\bO_\bR of the
32 drive, usually sector 0 where it may be found without any
33 information about the disk geometry. It is at an offset
34 _\bL_\bA_\bB_\bE_\bL_\bO_\bF_\bF_\bS_\bE_\bT from the beginning of the sector, to allow room
35 for the initial bootstrap. The disk sector containing the
36 label is normally made read-only so that it is not acciden-
37 tally overwritten by pack-to-pack copies or swap operations;
38 the DIOCWLABEL _\bi_\bo_\bc_\bt_\bl, which is done as needed by the _\bd_\bi_\bs_\bk_\bl_\ba_\b-
39 _\bb_\be_\bl(8) program.
40
41 A copy of the in-core label for a disk can be obtained with
42 the DIOCGDINFO _\bi_\bo_\bc_\bt_\bl; this works with a file descriptor for
43 a block or character (``raw'') device for any partition of
44 the disk. The in-core copy of the label is set by the
45 DIOCSDINFO _\bi_\bo_\bc_\bt_\bl. The offset of a partition cannot gen-
46 erally be changed while it is open, nor can it be made
47 smaller while it is open. One exception is that any change
48 is allowed if no label was found on the disk, and the driver
49 was able to construct only a skeletal label without parti-
50 tion information. Finally, the DIOCWDINFO _\bi_\bo_\bc_\bt_\bl operation
51 sets the in-core label and then updates the on-disk label;
52 there must be an existing label on the disk for this opera-
53 tion to succeed. Thus, the initial label for a disk or disk
54 pack must be installed by writing to the raw disk. All of
55 these operations are normally done using _\bd_\bi_\bs_\bk_\bl_\ba_\bb_\be_\bl(8).
56
57 The format of the disk label, as specified in
58 <_\bs_\by_\bs/_\bd_\bi_\bs_\bk_\bl_\ba_\bb_\be_\bl._\bh>, is
59 /*
60
61
62
63Printed 7/27/90 June 1
64
65
66
67
68
69
70DISKLABEL(5) 1990 DISKLABEL(5)
71
72
73
74 * Disk description table, see disktab(5)
75 */
76 #define DISKTAB "/etc/disktab"
77
78 /*
79 * Each disk has a label which includes information about the hardware
80 * disk geometry, filesystem partitions, and drive specific information.
81 * The label is in block 0 or 1, possibly offset from the beginning
82 * to leave room for a bootstrap, etc.
83 */
84 #define LABELSECTOR 0 /* sector containing label */
85 #define LABELOFFSET 64 /* offset of label in sector */
86 #define DISKMAGIC ((u_long) 0x82564557) /* The disk magic number */
87 #ifndef MAXPARTITIONS
88 #define MAXPARTITIONS 8
89 #endif
90
91
92 #ifndef LOCORE
93 struct disklabel {
94 u_long d_magic; /* the magic number */
95 short d_type; /* drive type */
96 short d_subtype; /* controller/d_type specific */
97 char d_typename[16]; /* type name, e.g. "eagle" */
98 /*
99 * d_packname contains the pack identifier and is returned when
100 * the disklabel is read off the disk or in-core copy.
101 * d_boot0 and d_boot1 are the (optional) names of the
102 * primary (block 0) and secondary (block 1-15) bootstraps
103 * as found in /usr/mdec. These are returned when using
104 * getdiskbyname(3) to retrieve the values from /etc/disktab.
105 */
106 #if defined(KERNEL) || defined(STANDALONE)
107 char d_packname[16]; /* pack identifier */
108 #else
109 union {
110 char un_d_packname[16]; /* pack identifier */
111 struct {
112 char *un_d_boot0; /* primary bootstrap name */
113 char *un_d_boot1; /* secondary bootstrap name */
114 } un_b;
115 } d_un;
116 #define d_packname d_un.un_d_packname
117 #define d_boot0 d_un.un_b.un_d_boot0
118 #define d_boot1 d_un.un_b.un_d_boot1
119 #endif /* ! KERNEL or STANDALONE */
120 /* disk geometry: */
121 u_long d_secsize; /* # of bytes per sector */
122 u_long d_nsectors; /* # of data sectors per track */
123 u_long d_ntracks; /* # of tracks per cylinder */
124 u_long d_ncylinders; /* # of data cylinders per unit */
125 u_long d_secpercyl; /* # of data sectors per cylinder */
126
127
128
129Printed 7/27/90 June 2
130
131
132
133
134
135
136DISKLABEL(5) 1990 DISKLABEL(5)
137
138
139
140 u_long d_secperunit; /* # of data sectors per unit */
141 /*
142 * Spares (bad sector replacements) below
143 * are not counted in d_nsectors or d_secpercyl.
144 * Spare sectors are assumed to be physical sectors
145 * which occupy space at the end of each track and/or cylinder.
146 */
147 u_short d_sparespertrack; /* # of spare sectors per track */
148 u_short d_sparespercyl; /* # of spare sectors per cylinder */
149 /*
150 * Alternate cylinders include maintenance, replacement,
151 * configuration description areas, etc.
152 */
153 u_long d_acylinders; /* # of alt. cylinders per unit */
154
155 /* hardware characteristics: */
156 /*
157 * d_interleave, d_trackskew and d_cylskew describe perturbations
158 * in the media format used to compensate for a slow controller.
159 * Interleave is physical sector interleave, set up by the formatter
160 * or controller when formatting. When interleaving is in use,
161 * logically adjacent sectors are not physically contiguous,
162 * but instead are separated by some number of sectors.
163 * It is specified as the ratio of physical sectors traversed
164 * per logical sector. Thus an interleave of 1:1 implies contiguous
165 * layout, while 2:1 implies that logical sector 0 is separated
166 * by one sector from logical sector 1.
167 * d_trackskew is the offset of sector 0 on track N
168 * relative to sector 0 on track N-1 on the same cylinder.
169 * Finally, d_cylskew is the offset of sector 0 on cylinder N
170 * relative to sector 0 on cylinder N-1.
171 */
172 u_short d_rpm; /* rotational speed */
173 u_short d_interleave; /* hardware sector interleave */
174 u_short d_trackskew; /* sector 0 skew, per track */
175 u_short d_cylskew; /* sector 0 skew, per cylinder */
176 u_long d_headswitch; /* head switch time, usec */
177 u_long d_trkseek; /* track-to-track seek, usec */
178 u_long d_flags; /* generic flags */
179 #define NDDATA 5
180 u_long d_drivedata[NDDATA]; /* drive-type specific information */
181 #define NSPARE 5
182 u_long d_spare[NSPARE]; /* reserved for future use */
183 u_long d_magic2; /* the magic number (again) */
184 u_short d_checksum; /* xor of data incl. partitions */
185
186 /* filesystem and partition information: */
187 u_short d_npartitions; /* number of partitions in following */
188 u_long d_bbsize; /* size of boot area at sn0, bytes */
189 u_long d_sbsize; /* max size of fs superblock, bytes */
190 struct partition { /* the partition table */
191 u_long p_size; /* number of sectors in partition */
192
193
194
195Printed 7/27/90 June 3
196
197
198
199
200
201
202DISKLABEL(5) 1990 DISKLABEL(5)
203
204
205
206 u_long p_offset; /* starting sector */
207 u_long p_fsize; /* filesystem basic fragment size */
208 u_char p_fstype; /* filesystem type, see below */
209 u_char p_frag; /* filesystem fragments per block */
210 u_short p_cpg; /* filesystem cylinders per group */
211 } d_partitions[MAXPARTITIONS]; /* actually may be more */
212 };
213
214 /* d_type values: */
215 #define DTYPE_SMD 1 /* SMD, XSMD; VAX hp/up */
216 #define DTYPE_MSCP 2 /* MSCP */
217 #define DTYPE_DEC 3 /* other DEC (rk, rl) */
218 #define DTYPE_SCSI 4 /* SCSI */
219 #define DTYPE_ESDI 5 /* ESDI interface */
220 #define DTYPE_ST506 6 /* ST506 etc. */
221 #define DTYPE_FLOPPY 10 /* floppy */
222
223 #ifdef DKTYPENAMES
224 static char *dktypenames[] = {
225 "unknown",
226 "SMD",
227 "MSCP",
228 "old DEC",
229 "SCSI",
230 "ESDI",
231 "type 6",
232 "type 7",
233 "type 8",
234 "type 9",
235 "floppy",
236 0
237 };
238 #define DKMAXTYPES (sizeof(dktypenames) / sizeof(dktypenames[0]) - 1)
239 #endif
240
241 /*
242 * Filesystem type and version.
243 * Used to interpret other filesystem-specific
244 * per-partition information.
245 */
246 #define FS_UNUSED 0 /* unused */
247 #define FS_SWAP 1 /* swap */
248 #define FS_V6 2 /* Sixth Edition */
249 #define FS_V7 3 /* Seventh Edition */
250 #define FS_SYSV 4 /* System V */
251 #define FS_V71K 5 /* V7 with 1K blocks (4.1, 2.9) */
252 #define FS_V8 6 /* Eighth Edition, 4K blocks */
253 #define FS_BSDFFS 7 /* 4.2BSD fast file system */
254
255 #ifdef DKTYPENAMES
256 static char *fstypenames[] = {
257 "unused",
258
259
260
261Printed 7/27/90 June 4
262
263
264
265
266
267
268DISKLABEL(5) 1990 DISKLABEL(5)
269
270
271
272 "swap",
273 "Version 6",
274 "Version 7",
275 "System V",
276 "4.1BSD",
277 "Eighth Edition",
278 "4.2BSD",
279 0
280 };
281 #define FSMAXTYPES (sizeof(fstypenames) / sizeof(fstypenames[0]) - 1)
282 #endif
283
284 /*
285 * flags shared by various drives:
286 */
287 #define D_REMOVABLE 0x01 /* removable media */
288 #define D_ECC 0x02 /* supports ECC */
289 #define D_BADSECT 0x04 /* supports bad sector forw. */
290 #define D_RAMDISK 0x08 /* disk emulator */
291 #define D_CHAIN 0x10 /* can do back-back transfers */
292
293 /*
294 * Drive data for SMD.
295 */
296 #define d_smdflags d_drivedata[0]
297 #define D_SSE 0x1 /* supports skip sectoring */
298 #define d_mindist d_drivedata[1]
299 #define d_maxdist d_drivedata[2]
300 #define d_sdist d_drivedata[3]
301
302 /*
303 * Drive data for ST506.
304 */
305 #define d_precompcyl d_drivedata[0]
306 #define d_gap3 d_drivedata[1] /* used only when formatting */
307
308 #ifndef LOCORE
309 /*
310 * Structure used to perform a format
311 * or other raw operation, returning data
312 * and/or register values.
313 * Register identification and format
314 * are device- and driver-dependent.
315 */
316 struct format_op {
317 char *df_buf;
318 int df_count; /* value-result */
319 daddr_t df_startblk;
320 int df_reg[8]; /* result */
321 };
322
323 /*
324
325
326
327Printed 7/27/90 June 5
328
329
330
331
332
333
334DISKLABEL(5) 1990 DISKLABEL(5)
335
336
337
338 * Structure used internally to retrieve
339 * information about a partition on a disk.
340 */
341 struct partinfo {
342 struct disklabel *disklab;
343 struct partition *part;
344 };
345
346 /*
347 * Disk-specific ioctls.
348 */
349 /* get and set disklabel; DIOCGPART used internally */
350 #define DIOCGDINFO _IOR('d', 101, struct disklabel) /* get */
351 #define DIOCSDINFO _IOW('d', 102, struct disklabel) /* set */
352 #define DIOCWDINFO _IOW('d', 103, struct disklabel) /* set, update disk */
353 #define DIOCGPART _IOW('d', 104, struct partinfo) /* get partition */
354
355 /* do format operation, read or write */
356 #define DIOCRFORMAT _IOWR('d', 105, struct format_op)
357 #define DIOCWFORMAT _IOWR('d', 106, struct format_op)
358
359 #define DIOCSSTEP _IOW('d', 107, int) /* set step rate */
360 #define DIOCSRETRIES _IOW('d', 108, int) /* set # of retries */
361 #define DIOCWLABEL _IOW('d', 109, int) /* write en/disable label */
362
363 #define DIOCSBAD _IOW('d', 110, struct dkbad) /* set kernel dkbad */
364
365 #endif LOCORE
366
367S\bSE\bEE\bE A\bAL\bLS\bSO\bO
368 disktab(5), disklabel(8)
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393Printed 7/27/90 June 6
394
395
396