2 * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
30 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
32 * Copyright (c) 1987, 1988, 1993
33 * The Regents of the University of California. All rights reserved.
35 * Redistribution and use in source and binary forms, with or without
36 * modification, are permitted provided that the following conditions
38 * 1. Redistributions of source code must retain the above copyright
39 * notice, this list of conditions and the following disclaimer.
40 * 2. Redistributions in binary form must reproduce the above copyright
41 * notice, this list of conditions and the following disclaimer in the
42 * documentation and/or other materials provided with the distribution.
43 * 3. All advertising materials mentioning features or use of this software
44 * must display the following acknowledgement:
45 * This product includes software developed by the University of
46 * California, Berkeley and its contributors.
47 * 4. Neither the name of the University nor the names of its contributors
48 * may be used to endorse or promote products derived from this software
49 * without specific prior written permission.
51 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
52 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
53 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
54 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
55 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
56 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
57 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
58 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
59 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
60 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63 * @(#)disklabel.h 8.2 (Berkeley) 7/10/94
65 #ifndef _SYS_DISKLABEL_H_
66 #define _SYS_DISKLABEL_H_
68 #include <sys/appleapiopts.h>
69 #include <sys/types.h> /* for daddr_t */
71 #ifdef __APPLE_API_OBSOLETE
74 * Disk description table, see disktab(5)
76 #define _PATH_DISKTAB "/etc/disktab"
77 #define DISKTAB "/etc/disktab" /* deprecated */
80 * Each disk has a label which includes information about the hardware
81 * disk geometry, filesystem partitions, and drive specific information.
82 * The location of the label, as well as the number of partitions the
83 * label can describe and the number of the "whole disk" (raw)
84 * paritition are machine dependent.
86 #include <machine/disklabel.h>
89 * The absolute maximum number of disk partitions allowed.
90 * This is the maximum value of MAXPARTITIONS for which 'struct disklabel'
91 * is <= DEV_BSIZE bytes long. If MAXPARTITIONS is greater than this, beware.
93 #define MAXMAXPARTITIONS 22
94 #if MAXPARTITIONS > MAXMAXPARTITIONS
95 #warning beware: MAXPARTITIONS bigger than MAXMAXPARTITIONS
99 * Translate between device numbers and major/disk unit/disk partition.
101 #define DISKUNIT(dev) (minor(dev) / MAXPARTITIONS)
102 #define DISKPART(dev) (minor(dev) % MAXPARTITIONS)
103 #define MAKEDISKDEV(maj, unit, part) \
104 (makedev((maj), ((unit) * MAXPARTITIONS) + (part)))
106 #define DISKMAGIC ((u_int32_t)0x82564557) /* The disk magic number */
110 u_int32_t d_magic
; /* the magic number */
111 u_int16_t d_type
; /* drive type */
112 u_int16_t d_subtype
; /* controller/d_type specific */
113 char d_typename
[16]; /* type name, e.g. "eagle" */
116 * d_packname contains the pack identifier and is returned when
117 * the disklabel is read off the disk or in-core copy.
118 * d_boot0 and d_boot1 are the (optional) names of the
119 * primary (block 0) and secondary (block 1-15) bootstraps
120 * as found in /usr/mdec. These are returned when using
121 * getdiskbyname(3) to retrieve the values from /etc/disktab.
124 char un_d_packname
[16]; /* pack identifier */
126 char *un_d_boot0
; /* primary bootstrap name */
127 char *un_d_boot1
; /* secondary bootstrap name */
130 #define d_packname d_un.un_d_packname
131 #define d_boot0 d_un.un_b.un_d_boot0
132 #define d_boot1 d_un.un_b.un_d_boot1
135 u_int32_t d_secsize
; /* # of bytes per sector */
136 u_int32_t d_nsectors
; /* # of data sectors per track */
137 u_int32_t d_ntracks
; /* # of tracks per cylinder */
138 u_int32_t d_ncylinders
; /* # of data cylinders per unit */
139 u_int32_t d_secpercyl
; /* # of data sectors per cylinder */
140 u_int32_t d_secperunit
; /* # of data sectors per unit */
143 * Spares (bad sector replacements) below are not counted in
144 * d_nsectors or d_secpercyl. Spare sectors are assumed to
145 * be physical sectors which occupy space at the end of each
146 * track and/or cylinder.
148 u_int16_t d_sparespertrack
; /* # of spare sectors per track */
149 u_int16_t d_sparespercyl
; /* # of spare sectors per cylinder */
151 * Alternate cylinders include maintenance, replacement, configuration
152 * description areas, etc.
154 u_int32_t d_acylinders
; /* # of alt. cylinders per unit */
156 /* hardware characteristics: */
158 * d_interleave, d_trackskew and d_cylskew describe perturbations
159 * in the media format used to compensate for a slow controller.
160 * Interleave is physical sector interleave, set up by the
161 * formatter or controller when formatting. When interleaving is
162 * in use, logically adjacent sectors are not physically
163 * contiguous, but instead are separated by some number of
164 * sectors. It is specified as the ratio of physical sectors
165 * traversed per logical sector. Thus an interleave of 1:1
166 * implies contiguous layout, while 2:1 implies that logical
167 * sector 0 is separated by one sector from logical sector 1.
168 * d_trackskew is the offset of sector 0 on track N relative to
169 * sector 0 on track N-1 on the same cylinder. Finally, d_cylskew
170 * is the offset of sector 0 on cylinder N relative to sector 0
173 u_int16_t d_rpm
; /* rotational speed */
174 u_int16_t d_interleave
; /* hardware sector interleave */
175 u_int16_t d_trackskew
; /* sector 0 skew, per track */
176 u_int16_t d_cylskew
; /* sector 0 skew, per cylinder */
177 u_int32_t d_headswitch
; /* head switch time, usec */
178 u_int32_t d_trkseek
; /* track-to-track seek, usec */
179 u_int32_t d_flags
; /* generic flags */
181 u_int32_t d_drivedata
[NDDATA
]; /* drive-type specific information */
183 u_int32_t d_spare
[NSPARE
]; /* reserved for future use */
184 u_int32_t d_magic2
; /* the magic number (again) */
185 u_int16_t d_checksum
; /* xor of data incl. partitions */
187 /* filesystem and partition information: */
188 u_int16_t d_npartitions
; /* number of partitions in following */
189 u_int32_t d_bbsize
; /* size of boot area at sn0, bytes */
190 u_int32_t d_sbsize
; /* max size of fs superblock, bytes */
191 struct partition
{ /* the partition table */
192 u_int32_t p_size
; /* number of sectors in partition */
193 u_int32_t p_offset
; /* starting sector */
194 u_int32_t p_fsize
; /* filesystem basic fragment size */
195 u_int8_t p_fstype
; /* filesystem type, see below */
196 u_int8_t p_frag
; /* filesystem fragments per block */
198 u_int16_t cpg
; /* UFS: FS cylinders per group */
199 u_int16_t sgs
; /* LFS: FS segment shift */
201 #define p_cpg __partition_u1.cpg
202 #define p_sgs __partition_u1.sgs
203 } d_partitions
[MAXPARTITIONS
]; /* actually may be more */
207 * offsets for asm boot files.
215 .set d_end_
,276 /* size of disk label */
219 #define DTYPE_SMD 1 /* SMD, XSMD; VAX hp/up */
220 #define DTYPE_MSCP 2 /* MSCP */
221 #define DTYPE_DEC 3 /* other DEC (rk, rl) */
222 #define DTYPE_SCSI 4 /* SCSI */
223 #define DTYPE_ESDI 5 /* ESDI interface */
224 #define DTYPE_ST506 6 /* ST506 etc. */
225 #define DTYPE_HPIB 7 /* CS/80 on HP-IB */
226 #define DTYPE_HPFL 8 /* HP Fiber-link */
227 #define DTYPE_FLOPPY 10 /* floppy */
230 static char *dktypenames
[] = {
244 #define DKMAXTYPES (sizeof(dktypenames) / sizeof(dktypenames[0]) - 1)
248 * Filesystem type and version.
249 * Used to interpret other filesystem-specific
250 * per-partition information.
252 #define FS_UNUSED 0 /* unused */
253 #define FS_SWAP 1 /* swap */
254 #define FS_V6 2 /* Sixth Edition */
255 #define FS_V7 3 /* Seventh Edition */
256 #define FS_SYSV 4 /* System V */
257 #define FS_V71K 5 /* V7 with 1K blocks (4.1, 2.9) */
258 #define FS_V8 6 /* Eighth Edition, 4K blocks */
259 #define FS_BSDFFS 7 /* 4.2BSD fast file system */
260 #define FS_MSDOS 8 /* MSDOS file system */
261 #define FS_BSDLFS 9 /* 4.4BSD log-structured file system */
262 #define FS_OTHER 10 /* in use, but unknown/unsupported */
263 #define FS_HPFS 11 /* OS/2 high-performance file system */
264 #define FS_ISO9660 12 /* ISO 9660, normally CD-ROM */
265 #define FS_BOOT 13 /* partition contains bootstrap */
266 #define FS_ADOS 14 /* AmigaDOS fast file system */
267 #define FS_HFS 15 /* Macintosh HFS */
270 static char *fstypenames
[] = {
289 #define FSMAXTYPES (sizeof(fstypenames) / sizeof(fstypenames[0]) - 1)
293 * flags shared by various drives:
295 #define D_REMOVABLE 0x01 /* removable media */
296 #define D_ECC 0x02 /* supports ECC */
297 #define D_BADSECT 0x04 /* supports bad sector forw. */
298 #define D_RAMDISK 0x08 /* disk emulator */
299 #define D_CHAIN 0x10 /* can do back-back transfers */
302 * Drive data for SMD.
304 #define d_smdflags d_drivedata[0]
305 #define D_SSE 0x1 /* supports skip sectoring */
306 #define d_mindist d_drivedata[1]
307 #define d_maxdist d_drivedata[2]
308 #define d_sdist d_drivedata[3]
311 * Drive data for ST506.
313 #define d_precompcyl d_drivedata[0]
314 #define d_gap3 d_drivedata[1] /* used only when formatting */
317 * Drive data for SCSI.
319 #define d_blind d_drivedata[0]
323 * Structure used to perform a format or other raw operation, returning
324 * data and/or register values. Register identification and format
325 * are device- and driver-dependent.
329 int df_count
; /* value-result */
331 int df_reg
[8]; /* result */
335 * Structure used internally to retrieve information about a partition
339 struct disklabel
*disklab
;
340 struct partition
*part
;
344 * Disk-specific ioctls.
346 /* get and set disklabel; DIOCGPART used internally */
347 #define DIOCGDINFO _IOR('d', 101, struct disklabel)/* get */
348 #define DIOCSDINFO _IOW('d', 102, struct disklabel)/* set */
349 #define DIOCWDINFO _IOW('d', 103, struct disklabel)/* set, update disk */
350 #define DIOCGPART _IOW('d', 104, struct partinfo) /* get partition */
352 /* do format operation, read or write */
353 #define DIOCRFORMAT _IOWR('d', 105, struct format_op)
354 #define DIOCWFORMAT _IOWR('d', 106, struct format_op)
356 #define DIOCSSTEP _IOW('d', 107, int) /* set step rate */
357 #define DIOCSRETRIES _IOW('d', 108, int) /* set # of retries */
358 #define DIOCWLABEL _IOW('d', 109, int) /* write en/disable label */
360 #define DIOCSBAD _IOW('d', 110, struct dkbad) /* set kernel dkbad */
364 #if !defined(KERNEL) && !defined(LOCORE)
366 #include <sys/cdefs.h>
369 struct disklabel
*getdiskbyname(const char *);
374 #endif /* __APPLE_API_OBSOLETE */
376 #endif /* ! _SYS_DISKLABEL_H_ */