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