1 /*	$NetBSD: disklbl.h,v 1.3 2005/12/11 12:17:00 christos Exp $	*/
2 
3 /*
4  * Copyright (c) 1987, 1988, 1993
5  *	The Regents of the University of California.  All rights reserved.
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. Neither the name of the University nor the names of its contributors
16  *    may be used to endorse or promote products derived from this software
17  *    without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  *
31  *	@(#)disklabel.h	8.2 (Berkeley) 7/10/94
32  */
33 
34 #ifndef DISKLABEL_H
35 #define DISKLABEL_H
36 
37 #define	DISKMAGIC	((u_int32_t)0x82564557)	/* The disk magic number */
38 
39 struct disklabel {
40 	u_int32_t d_magic;		/* the magic number */
41 	u_int16_t d_type;		/* drive type */
42 	u_int16_t d_subtype;		/* controller/d_type specific */
43 	char	  d_typename[16];	/* type name, e.g. "eagle" */
44 
45 	/*
46 	 * d_packname contains the pack identifier and is returned when
47 	 * the disklabel is read off the disk or in-core copy.
48 	 * d_boot0 and d_boot1 are the (optional) names of the
49 	 * primary (block 0) and secondary (block 1-15) bootstraps
50 	 * as found in /usr/mdec.  These are returned when using
51 	 * getdiskbyname(3) to retrieve the values from /etc/disktab.
52 	 */
53 	union {
54 		char	un_d_packname[16];	/* pack identifier */
55 		struct {
56 			char *un_d_boot0;	/* primary bootstrap name */
57 			char *un_d_boot1;	/* secondary bootstrap name */
58 		} un_b;
59 	} d_un;
60 #define	d_packname	d_un.un_d_packname
61 #define	d_boot0		d_un.un_b.un_d_boot0
62 #define	d_boot1		d_un.un_b.un_d_boot1
63 
64 			/* disk geometry: */
65 	u_int32_t d_secsize;		/* # of bytes per sector */
66 	u_int32_t d_nsectors;		/* # of data sectors per track */
67 	u_int32_t d_ntracks;		/* # of tracks per cylinder */
68 	u_int32_t d_ncylinders;		/* # of data cylinders per unit */
69 	u_int32_t d_secpercyl;		/* # of data sectors per cylinder */
70 	u_int32_t d_secperunit;		/* # of data sectors per unit */
71 
72 	/*
73 	 * Spares (bad sector replacements) below are not counted in
74 	 * d_nsectors or d_secpercyl.  Spare sectors are assumed to
75 	 * be physical sectors which occupy space at the end of each
76 	 * track and/or cylinder.
77 	 */
78 	u_int16_t d_sparespertrack;	/* # of spare sectors per track */
79 	u_int16_t d_sparespercyl;	/* # of spare sectors per cylinder */
80 	/*
81 	 * Alternate cylinders include maintenance, replacement, configuration
82 	 * description areas, etc.
83 	 */
84 	u_int32_t d_acylinders;		/* # of alt. cylinders per unit */
85 
86 			/* hardware characteristics: */
87 	/*
88 	 * d_interleave, d_trackskew and d_cylskew describe perturbations
89 	 * in the media format used to compensate for a slow controller.
90 	 * Interleave is physical sector interleave, set up by the
91 	 * formatter or controller when formatting.  When interleaving is
92 	 * in use, logically adjacent sectors are not physically
93 	 * contiguous, but instead are separated by some number of
94 	 * sectors.  It is specified as the ratio of physical sectors
95 	 * traversed per logical sector.  Thus an interleave of 1:1
96 	 * implies contiguous layout, while 2:1 implies that logical
97 	 * sector 0 is separated by one sector from logical sector 1.
98 	 * d_trackskew is the offset of sector 0 on track N relative to
99 	 * sector 0 on track N-1 on the same cylinder.  Finally, d_cylskew
100 	 * is the offset of sector 0 on cylinder N relative to sector 0
101 	 * on cylinder N-1.
102 	 */
103 	u_int16_t d_rpm;		/* rotational speed */
104 	u_int16_t d_interleave;		/* hardware sector interleave */
105 	u_int16_t d_trackskew;		/* sector 0 skew, per track */
106 	u_int16_t d_cylskew;		/* sector 0 skew, per cylinder */
107 	u_int32_t d_headswitch;		/* head switch time, usec */
108 	u_int32_t d_trkseek;		/* track-to-track seek, usec */
109 	u_int32_t d_flags;		/* generic flags */
110 #define	NDDATA 5
111 	u_int32_t d_drivedata[NDDATA];	/* drive-type specific information */
112 #define	NSPARE 5
113 	u_int32_t d_spare[NSPARE];	/* reserved for future use */
114 	u_int32_t d_magic2;		/* the magic number (again) */
115 	u_int16_t d_checksum;		/* xor of data incl. partitions */
116 
117 			/* filesystem and partition information: */
118 	u_int16_t d_npartitions;	/* number of partitions in following */
119 	u_int32_t d_bbsize;		/* size of boot area at sn0, bytes */
120 	u_int32_t d_sbsize;		/* max size of fs superblock, bytes */
121 	struct	partition {		/* the partition table */
122 		u_int32_t p_size;	/* number of sectors in partition */
123 		u_int32_t p_offset;	/* starting sector */
124 		u_int32_t p_fsize;	/* filesystem basic fragment size */
125 		u_int8_t p_fstype;	/* filesystem type, see below */
126 		u_int8_t p_frag;	/* filesystem fragments per block */
127 		union {
128 			u_int16_t cpg;	/* UFS: FS cylinders per group */
129 			u_int16_t sgs;	/* LFS: FS segment shift */
130 		} __partition_u1;
131 #define	p_cpg	__partition_u1.cpg
132 #define	p_sgs	__partition_u1.sgs
133 	} d_partitions[MAXPARTITIONS];	/* actually may be more */
134 };
135 
136 #endif /* DISKLABEL_H */
137