Revert "Temporarily disable Direct IO by default"
[zfs.git] / lib / libspl / include / sys / dklabel.h
bloba1fddd34799a9c0ac1f379e3b31b6e65fd1d4c60
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or https://opensource.org/licenses/CDDL-1.0.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright 1990-2002 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _SYS_DKLABEL_H
28 #define _SYS_DKLABEL_H
32 #include <sys/isa_defs.h>
33 #include <sys/types32.h>
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
40 * Miscellaneous defines
42 #define DKL_MAGIC 0xDABE /* magic number */
43 #define FKL_MAGIC 0xff /* magic number for DOS floppies */
45 #if defined(_SUNOS_VTOC_16)
46 #define NDKMAP 16 /* # of logical partitions */
47 #define DK_LABEL_LOC 1 /* location of disk label */
48 #elif defined(_SUNOS_VTOC_8)
49 #define NDKMAP 8 /* # of logical partitions */
50 #define DK_LABEL_LOC 0 /* location of disk label */
51 #else
52 #error "No VTOC format defined."
53 #endif
55 #define LEN_DKL_ASCII 128 /* length of dkl_asciilabel */
56 #define LEN_DKL_VVOL 8 /* length of v_volume */
57 #define DK_LABEL_SIZE 512 /* size of disk label */
58 #define DK_MAX_BLOCKS 0x7fffffff /* max # of blocks handled */
61 * Reserve two cylinders on SCSI disks.
62 * One is for the backup disk label and the other is for the deviceid.
64 * IPI disks only reserve one cylinder, but they will go away soon.
65 * CDROMs do not reserve any cylinders.
67 #define DK_ACYL 2
70 * Format of a Sun disk label.
71 * Resides in cylinder 0, head 0, sector 0.
73 * sizeof (struct dk_label) should be 512 (the current sector size),
74 * but should the sector size increase, this structure should remain
75 * at the beginning of the sector.
79 * partition headers: section 1
80 * Returned in struct dk_allmap by ioctl DKIOC[SG]APART (dkio(7I))
82 struct dk_map {
83 uint64_t dkl_cylno; /* starting cylinder */
84 uint64_t dkl_nblk; /* number of blocks; if == 0, */
85 /* partition is undefined */
89 * partition headers: section 1
90 * Fixed size for on-disk dk_label
92 struct dk_map32 {
93 daddr32_t dkl_cylno; /* starting cylinder */
94 daddr32_t dkl_nblk; /* number of blocks; if == 0, */
95 /* partition is undefined */
99 * partition headers: section 2,
100 * brought over from AT&T SVr4 vtoc structure.
102 struct dk_map2 {
103 uint16_t p_tag; /* ID tag of partition */
104 uint16_t p_flag; /* permission flag */
107 struct dkl_partition {
108 uint16_t p_tag; /* ID tag of partition */
109 uint16_t p_flag; /* permission flags */
110 daddr32_t p_start; /* start sector no of partition */
111 int32_t p_size; /* # of blocks in partition */
116 * VTOC inclusions from AT&T SVr4
117 * Fixed sized types for on-disk VTOC
120 struct dk_vtoc {
121 #if defined(_SUNOS_VTOC_16)
122 uint32_t v_bootinfo[3]; /* info for mboot (unsupported) */
123 uint32_t v_sanity; /* to verify vtoc sanity */
124 uint32_t v_version; /* layout version */
125 char v_volume[LEN_DKL_VVOL]; /* volume name */
126 uint16_t v_sectorsz; /* sector size in bytes */
127 uint16_t v_nparts; /* number of partitions */
128 uint32_t v_reserved[10]; /* free space */
129 struct dkl_partition v_part[NDKMAP]; /* partition headers */
130 time32_t timestamp[NDKMAP]; /* partition timestamp (unsupported) */
131 char v_asciilabel[LEN_DKL_ASCII]; /* for compatibility */
132 #elif defined(_SUNOS_VTOC_8)
133 uint32_t v_version; /* layout version */
134 char v_volume[LEN_DKL_VVOL]; /* volume name */
135 uint16_t v_nparts; /* number of partitions */
136 struct dk_map2 v_part[NDKMAP]; /* partition hdrs, sec 2 */
137 uint32_t v_bootinfo[3]; /* info needed by mboot */
138 uint32_t v_sanity; /* to verify vtoc sanity */
139 uint32_t v_reserved[10]; /* free space */
140 time32_t v_timestamp[NDKMAP]; /* partition timestamp */
141 #else
142 #error "No VTOC format defined."
143 #endif
147 * define the amount of disk label padding needed to make
148 * the entire structure occupy 512 bytes.
150 #if defined(_SUNOS_VTOC_16)
151 #define LEN_DKL_PAD (DK_LABEL_SIZE - \
152 ((sizeof (struct dk_vtoc) + \
153 (4 * sizeof (uint32_t)) + \
154 (12 * sizeof (uint16_t)) + \
155 (2 * (sizeof (uint16_t))))))
156 #elif defined(_SUNOS_VTOC_8)
157 #define LEN_DKL_PAD (DK_LABEL_SIZE \
158 - ((LEN_DKL_ASCII) + \
159 (sizeof (struct dk_vtoc)) + \
160 (sizeof (struct dk_map32) * NDKMAP) + \
161 (14 * (sizeof (uint16_t))) + \
162 (2 * (sizeof (uint16_t)))))
163 #else
164 #error "No VTOC format defined."
165 #endif
168 struct dk_label {
169 #if defined(_SUNOS_VTOC_16)
170 struct dk_vtoc dkl_vtoc; /* vtoc inclusions from AT&T SVr4 */
171 uint32_t dkl_pcyl; /* # of physical cylinders */
172 uint32_t dkl_ncyl; /* # of data cylinders */
173 uint16_t dkl_acyl; /* # of alternate cylinders */
174 uint16_t dkl_bcyl; /* cyl offset (for fixed head area) */
175 uint32_t dkl_nhead; /* # of heads */
176 uint32_t dkl_nsect; /* # of data sectors per track */
177 uint16_t dkl_intrlv; /* interleave factor */
178 uint16_t dkl_skew; /* skew factor */
179 uint16_t dkl_apc; /* alternates per cyl (SCSI only) */
180 uint16_t dkl_rpm; /* revolutions per minute */
181 uint16_t dkl_write_reinstruct; /* # sectors to skip, writes */
182 uint16_t dkl_read_reinstruct; /* # sectors to skip, reads */
183 uint16_t dkl_extra[4]; /* for compatible expansion */
184 char dkl_pad[LEN_DKL_PAD]; /* unused part of 512 bytes */
185 #elif defined(_SUNOS_VTOC_8)
186 char dkl_asciilabel[LEN_DKL_ASCII]; /* for compatibility */
187 struct dk_vtoc dkl_vtoc; /* vtoc inclusions from AT&T SVr4 */
188 uint16_t dkl_write_reinstruct; /* # sectors to skip, writes */
189 uint16_t dkl_read_reinstruct; /* # sectors to skip, reads */
190 char dkl_pad[LEN_DKL_PAD]; /* unused part of 512 bytes */
191 uint16_t dkl_rpm; /* rotations per minute */
192 uint16_t dkl_pcyl; /* # physical cylinders */
193 uint16_t dkl_apc; /* alternates per cylinder */
194 uint16_t dkl_obs1; /* obsolete */
195 uint16_t dkl_obs2; /* obsolete */
196 uint16_t dkl_intrlv; /* interleave factor */
197 uint16_t dkl_ncyl; /* # of data cylinders */
198 uint16_t dkl_acyl; /* # of alternate cylinders */
199 uint16_t dkl_nhead; /* # of heads in this partition */
200 uint16_t dkl_nsect; /* # of 512 byte sectors per track */
201 uint16_t dkl_obs3; /* obsolete */
202 uint16_t dkl_obs4; /* obsolete */
203 struct dk_map32 dkl_map[NDKMAP]; /* logical partition headers */
204 #else
205 #error "No VTOC format defined."
206 #endif
207 uint16_t dkl_magic; /* identifies this label format */
208 uint16_t dkl_cksum; /* xor checksum of sector */
211 #if defined(_SUNOS_VTOC_16)
212 #define dkl_asciilabel dkl_vtoc.v_asciilabel
213 #define v_timestamp timestamp
215 #elif defined(_SUNOS_VTOC_8)
218 * These defines are for historic compatibility with old drivers.
220 #define dkl_gap1 dkl_obs1 /* used to be gap1 */
221 #define dkl_gap2 dkl_obs2 /* used to be gap2 */
222 #define dkl_bhead dkl_obs3 /* used to be label head offset */
223 #define dkl_ppart dkl_obs4 /* used to by physical partition */
224 #else
225 #error "No VTOC format defined."
226 #endif
228 struct fk_label { /* DOS floppy label */
229 uchar_t fkl_type;
230 uchar_t fkl_magich;
231 uchar_t fkl_magicl;
232 uchar_t filler;
236 * Layout of stored fabricated device id (on-disk)
238 #define DK_DEVID_BLKSIZE (512)
239 #define DK_DEVID_SIZE (DK_DEVID_BLKSIZE - ((sizeof (uchar_t) * 7)))
240 #define DK_DEVID_REV_MSB (0)
241 #define DK_DEVID_REV_LSB (1)
243 struct dk_devid {
244 uchar_t dkd_rev_hi; /* revision (MSB) */
245 uchar_t dkd_rev_lo; /* revision (LSB) */
246 uchar_t dkd_flags; /* flags (not used yet) */
247 uchar_t dkd_devid[DK_DEVID_SIZE]; /* devid stored here */
248 uchar_t dkd_checksum3; /* checksum (MSB) */
249 uchar_t dkd_checksum2;
250 uchar_t dkd_checksum1;
251 uchar_t dkd_checksum0; /* checksum (LSB) */
254 #define DKD_GETCHKSUM(dkd) ((dkd)->dkd_checksum3 << 24) + \
255 ((dkd)->dkd_checksum2 << 16) + \
256 ((dkd)->dkd_checksum1 << 8) + \
257 ((dkd)->dkd_checksum0)
259 #define DKD_FORMCHKSUM(c, dkd) (dkd)->dkd_checksum3 = hibyte(hiword((c))); \
260 (dkd)->dkd_checksum2 = lobyte(hiword((c))); \
261 (dkd)->dkd_checksum1 = hibyte(loword((c))); \
262 (dkd)->dkd_checksum0 = lobyte(loword((c)));
263 #ifdef __cplusplus
265 #endif
267 #endif /* _SYS_DKLABEL_H */