Print this page
6198 Let's EOL cachefs
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/sys/vtoc.h
+++ new/usr/src/uts/common/sys/vtoc.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24 24 *
25 25 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
26 26 * Use is subject to license terms.
27 + * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
27 28 */
28 29
29 30
30 31 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
31 32 /* All Rights Reserved */
32 33
33 34
34 35 #ifndef _SYS_VTOC_H
35 36 #define _SYS_VTOC_H
36 37
37 38 #include <sys/dklabel.h>
38 39
39 40 #ifdef __cplusplus
40 41 extern "C" {
41 42 #endif
42 43
43 44 /*
44 45 * Note: the VTOC is not implemented fully, nor in the manner
45 46 * that AT&T implements it. AT&T puts the vtoc structure
46 47 * into a sector, usually the second sector (pdsector is first).
47 48 *
48 49 * Sun incorporates the tag, flag, version, and volume vtoc fields into
49 50 * its Disk Label, which already has some vtoc-equivalent fields.
50 51 * Upon reading the vtoc with read_vtoc(), the following exceptions
51 52 * occur:
52 53 * v_bootinfo [all] returned as zero
53 54 * v_sanity returned as VTOC_SANE
54 55 * if Disk Label was sane
55 56 * v_sectorsz returned as 512
56 57 * v_reserved [all] retunred as zero
57 58 * timestamp [all] returned as zero
58 59 *
59 60 * See dklabel.h, read_vtoc(), and write_vtoc().
60 61 */
61 62
62 63 #define V_NUMPAR NDKMAP /* The number of partitions */
63 64 /* (from dkio.h) */
64 65
65 66 #define VTOC_SANE 0x600DDEEE /* Indicates a sane VTOC */
66 67 #define V_VERSION 0x01 /* layout version number */
67 68 #define V_EXTVERSION V_VERSION /* extvtoc layout version number */
68 69
69 70 /*
70 71 * Partition identification tags
71 72 */
↓ open down ↓ |
35 lines elided |
↑ open up ↑ |
72 73 #define V_UNASSIGNED 0x00 /* unassigned partition */
73 74 #define V_BOOT 0x01 /* Boot partition */
74 75 #define V_ROOT 0x02 /* Root filesystem */
75 76 #define V_SWAP 0x03 /* Swap filesystem */
76 77 #define V_USR 0x04 /* Usr filesystem */
77 78 #define V_BACKUP 0x05 /* full disk */
78 79 #define V_STAND 0x06 /* Stand partition */
79 80 #define V_VAR 0x07 /* Var partition */
80 81 #define V_HOME 0x08 /* Home partition */
81 82 #define V_ALTSCTR 0x09 /* Alternate sector partition */
82 -#define V_CACHE 0x0a /* Cache (cachefs) partition */
83 +#define V_CACHE 0x0a /* CacheFS partition (obsolete) */
83 84
84 85 /* Tags for EFI/GPT labels */
85 86 #define V_RESERVED 0x0b /* SMI reserved data */
86 87 #define V_SYSTEM 0x0c /* EFI/GPT system partition */
87 88 #define V_BIOS_BOOT 0x18 /* BIOS Boot partition */
88 89
89 90 #define V_UNKNOWN 0xff /* Unknown partition */
90 91
91 92 /*
92 93 * Partition permission flags
93 94 */
94 95 #define V_UNMNT 0x01 /* Unmountable partition */
95 96 #define V_RONLY 0x10 /* Read only */
96 97
97 98 /*
98 99 * error codes for reading & writing vtoc
99 100 */
100 101 #define VT_ERROR (-2) /* errno supplies specific error */
101 102 #define VT_EIO (-3) /* I/O error accessing vtoc */
102 103 #define VT_EINVAL (-4) /* illegal value in vtoc or request */
103 104 #define VT_ENOTSUP (-5) /* VTOC op. not supported */
104 105 #define VT_ENOSPC (-6) /* requested space not found */
105 106 #define VT_EOVERFLOW (-7) /* VTOC op. data struct limited */
106 107
107 108 struct partition {
108 109 ushort_t p_tag; /* ID tag of partition */
109 110 ushort_t p_flag; /* permission flags */
110 111 daddr_t p_start; /* start sector no of partition */
111 112 long p_size; /* # of blocks in partition */
112 113 };
113 114
114 115 struct vtoc {
115 116 unsigned long v_bootinfo[3]; /* info needed by mboot (unsupported) */
116 117 unsigned long v_sanity; /* to verify vtoc sanity */
117 118 unsigned long v_version; /* layout version */
118 119 char v_volume[LEN_DKL_VVOL]; /* volume name */
119 120 ushort_t v_sectorsz; /* sector size in bytes */
120 121 ushort_t v_nparts; /* number of partitions */
121 122 unsigned long v_reserved[10]; /* free space */
122 123 struct partition v_part[V_NUMPAR]; /* partition headers */
123 124 time_t timestamp[V_NUMPAR]; /* partition timestamp (unsupported) */
124 125 char v_asciilabel[LEN_DKL_ASCII]; /* for compatibility */
125 126 };
126 127
127 128 struct extpartition {
128 129 ushort_t p_tag; /* ID tag of partition */
129 130 ushort_t p_flag; /* permission flags */
130 131 ushort_t p_pad[2];
131 132 diskaddr_t p_start; /* start sector no of partition */
132 133 diskaddr_t p_size; /* # of blocks in partition */
133 134 };
134 135
135 136
136 137 struct extvtoc {
137 138 uint64_t v_bootinfo[3]; /* info needed by mboot (unsupported) */
138 139 uint64_t v_sanity; /* to verify vtoc sanity */
139 140 uint64_t v_version; /* layout version */
140 141 char v_volume[LEN_DKL_VVOL]; /* volume name */
141 142 ushort_t v_sectorsz; /* sector size in bytes */
142 143 ushort_t v_nparts; /* number of partitions */
143 144 ushort_t pad[2];
144 145 uint64_t v_reserved[10];
145 146 struct extpartition v_part[V_NUMPAR]; /* partition headers */
146 147 uint64_t timestamp[V_NUMPAR]; /* partition timestamp (unsupported) */
147 148 char v_asciilabel[LEN_DKL_ASCII]; /* for compatibility */
148 149 };
149 150
150 151 #ifdef _KERNEL
151 152 #define extvtoctovtoc(extv, v) \
152 153 { \
153 154 int i; \
154 155 v.v_bootinfo[0] = (unsigned long)extv.v_bootinfo[0]; \
155 156 v.v_bootinfo[1] = (unsigned long)extv.v_bootinfo[1]; \
156 157 v.v_bootinfo[2] = (unsigned long)extv.v_bootinfo[2]; \
157 158 v.v_sanity = (unsigned long)extv.v_sanity; \
158 159 v.v_version = (unsigned long)extv.v_version; \
159 160 bcopy(extv.v_volume, v.v_volume, LEN_DKL_VVOL); \
160 161 v.v_sectorsz = extv.v_sectorsz; \
161 162 v.v_nparts = extv.v_nparts; \
162 163 for (i = 0; i < 10; i++) \
163 164 v.v_reserved[i] = (unsigned long)extv.v_reserved[i]; \
164 165 for (i = 0; i < V_NUMPAR; i++) { \
165 166 v.v_part[i].p_tag = extv.v_part[i].p_tag; \
166 167 v.v_part[i].p_flag = extv.v_part[i].p_flag; \
167 168 v.v_part[i].p_start = (daddr_t)extv.v_part[i].p_start; \
168 169 v.v_part[i].p_size = (long)extv.v_part[i].p_size; \
169 170 v.timestamp[i] = (time_t)extv.timestamp[i]; \
170 171 } \
171 172 bcopy(extv.v_asciilabel, v.v_asciilabel, LEN_DKL_ASCII); \
172 173 }
173 174
174 175 #define vtoctoextvtoc(v, extv) \
175 176 { \
176 177 int i; \
177 178 extv.v_bootinfo[0] = (uint64_t)v.v_bootinfo[0]; \
178 179 extv.v_bootinfo[1] = (uint64_t)v.v_bootinfo[1]; \
179 180 extv.v_bootinfo[2] = (uint64_t)v.v_bootinfo[2]; \
180 181 extv.v_sanity = (uint64_t)v.v_sanity; \
181 182 extv.v_version = (uint64_t)v.v_version; \
182 183 bcopy(v.v_volume, extv.v_volume, LEN_DKL_VVOL); \
183 184 extv.v_sectorsz = v.v_sectorsz; \
184 185 extv.v_nparts = v.v_nparts; \
185 186 for (i = 0; i < 10; i++) \
186 187 extv.v_reserved[i] = (uint64_t)v.v_reserved[i]; \
187 188 for (i = 0; i < V_NUMPAR; i++) { \
188 189 extv.v_part[i].p_tag = v.v_part[i].p_tag; \
189 190 extv.v_part[i].p_flag = v.v_part[i].p_flag; \
190 191 extv.v_part[i].p_start = \
191 192 (diskaddr_t)(unsigned long)v.v_part[i].p_start; \
192 193 extv.v_part[i].p_size = \
193 194 (diskaddr_t)(unsigned long)v.v_part[i].p_size; \
194 195 extv.timestamp[i] = (uint64_t)v.timestamp[i]; \
195 196 } \
196 197 bcopy(v.v_asciilabel, extv.v_asciilabel, LEN_DKL_ASCII); \
197 198 }
198 199 #endif /* _KERNEL */
199 200
200 201 #if defined(_SYSCALL32)
201 202 struct partition32 {
202 203 uint16_t p_tag; /* ID tag of partition */
203 204 uint16_t p_flag; /* permission flags */
204 205 daddr32_t p_start; /* start sector no of partition */
205 206 int32_t p_size; /* # of blocks in partition */
206 207 };
207 208
208 209 struct vtoc32 {
209 210 uint32_t v_bootinfo[3]; /* info needed by mboot (unsupported) */
210 211 uint32_t v_sanity; /* to verify vtoc sanity */
211 212 uint32_t v_version; /* layout version */
212 213 char v_volume[LEN_DKL_VVOL]; /* volume name */
213 214 uint16_t v_sectorsz; /* sector size in bytes */
214 215 uint16_t v_nparts; /* number of partitions */
215 216 uint32_t v_reserved[10]; /* free space */
216 217 struct partition32 v_part[V_NUMPAR]; /* partition headers */
217 218 time32_t timestamp[V_NUMPAR]; /* partition timestamp (unsupported) */
218 219 char v_asciilabel[LEN_DKL_ASCII]; /* for compatibility */
219 220 };
220 221
221 222 #define vtoc32tovtoc(v32, v) \
222 223 { \
223 224 int i; \
224 225 v.v_bootinfo[0] = v32.v_bootinfo[0]; \
225 226 v.v_bootinfo[1] = v32.v_bootinfo[1]; \
226 227 v.v_bootinfo[2] = v32.v_bootinfo[2]; \
227 228 v.v_sanity = v32.v_sanity; \
228 229 v.v_version = v32.v_version; \
229 230 bcopy(v32.v_volume, v.v_volume, LEN_DKL_VVOL); \
230 231 v.v_sectorsz = v32.v_sectorsz; \
231 232 v.v_nparts = v32.v_nparts; \
232 233 v.v_version = v32.v_version; \
233 234 for (i = 0; i < 10; i++) \
234 235 v.v_reserved[i] = v32.v_reserved[i]; \
235 236 for (i = 0; i < V_NUMPAR; i++) { \
236 237 v.v_part[i].p_tag = (ushort_t)v32.v_part[i].p_tag; \
237 238 v.v_part[i].p_flag = (ushort_t)v32.v_part[i].p_flag; \
238 239 v.v_part[i].p_start = (unsigned)v32.v_part[i].p_start; \
239 240 v.v_part[i].p_size = (unsigned)v32.v_part[i].p_size; \
240 241 } \
241 242 for (i = 0; i < V_NUMPAR; i++) \
242 243 v.timestamp[i] = (time_t)v32.timestamp[i]; \
243 244 bcopy(v32.v_asciilabel, v.v_asciilabel, LEN_DKL_ASCII); \
244 245 }
245 246
246 247 #define vtoc32toextvtoc(v32, extv) \
247 248 { \
248 249 int i; \
249 250 extv.v_bootinfo[0] = v32.v_bootinfo[0]; \
250 251 extv.v_bootinfo[1] = v32.v_bootinfo[1]; \
251 252 extv.v_bootinfo[2] = v32.v_bootinfo[2]; \
252 253 extv.v_sanity = v32.v_sanity; \
253 254 extv.v_version = v32.v_version; \
254 255 bcopy(v32.v_volume, extv.v_volume, LEN_DKL_VVOL); \
255 256 extv.v_sectorsz = v32.v_sectorsz; \
256 257 extv.v_nparts = v32.v_nparts; \
257 258 extv.v_version = v32.v_version; \
258 259 for (i = 0; i < 10; i++) \
259 260 extv.v_reserved[i] = v32.v_reserved[i]; \
260 261 for (i = 0; i < V_NUMPAR; i++) { \
261 262 extv.v_part[i].p_tag = (ushort_t)v32.v_part[i].p_tag; \
262 263 extv.v_part[i].p_flag = (ushort_t)v32.v_part[i].p_flag; \
263 264 extv.v_part[i].p_start = (diskaddr_t)v32.v_part[i].p_start; \
264 265 extv.v_part[i].p_size = (diskaddr_t)v32.v_part[i].p_size; \
265 266 extv.timestamp[i] = (time_t)v32.timestamp[i]; \
266 267 } \
267 268 bcopy(v32.v_asciilabel, extv.v_asciilabel, LEN_DKL_ASCII); \
268 269 }
269 270
270 271
271 272 #define vtoctovtoc32(v, v32) \
272 273 { \
273 274 int i; \
274 275 v32.v_bootinfo[0] = v.v_bootinfo[0]; \
275 276 v32.v_bootinfo[1] = v.v_bootinfo[1]; \
276 277 v32.v_bootinfo[2] = v.v_bootinfo[2]; \
277 278 v32.v_sanity = v.v_sanity; \
278 279 v32.v_version = v.v_version; \
279 280 bcopy(v.v_volume, v32.v_volume, LEN_DKL_VVOL); \
280 281 v32.v_sectorsz = v.v_sectorsz; \
281 282 v32.v_nparts = v.v_nparts; \
282 283 v32.v_version = v.v_version; \
283 284 for (i = 0; i < 10; i++) \
284 285 v32.v_reserved[i] = v.v_reserved[i]; \
285 286 for (i = 0; i < V_NUMPAR; i++) { \
286 287 v32.v_part[i].p_tag = (ushort_t)v.v_part[i].p_tag; \
287 288 v32.v_part[i].p_flag = (ushort_t)v.v_part[i].p_flag; \
288 289 v32.v_part[i].p_start = (unsigned)v.v_part[i].p_start; \
289 290 v32.v_part[i].p_size = (unsigned)v.v_part[i].p_size; \
290 291 } \
291 292 for (i = 0; i < V_NUMPAR; i++) { \
292 293 if (v.timestamp[i] > TIME32_MAX) \
293 294 v32.timestamp[i] = TIME32_MAX; \
294 295 else \
295 296 v32.timestamp[i] = (time32_t)v.timestamp[i]; \
296 297 } \
297 298 bcopy(v.v_asciilabel, v32.v_asciilabel, LEN_DKL_ASCII); \
298 299 }
299 300
300 301 #define extvtoctovtoc32(extv, v32) \
301 302 { \
302 303 int i; \
303 304 v32.v_bootinfo[0] = extv.v_bootinfo[0]; \
304 305 v32.v_bootinfo[1] = extv.v_bootinfo[1]; \
305 306 v32.v_bootinfo[2] = extv.v_bootinfo[2]; \
306 307 v32.v_sanity = extv.v_sanity; \
307 308 v32.v_version = extv.v_version; \
308 309 bcopy(extv.v_volume, v32.v_volume, LEN_DKL_VVOL); \
309 310 v32.v_sectorsz = extv.v_sectorsz; \
310 311 v32.v_nparts = extv.v_nparts; \
311 312 v32.v_version = extv.v_version; \
312 313 for (i = 0; i < 10; i++) \
313 314 v32.v_reserved[i] = extv.v_reserved[i]; \
314 315 for (i = 0; i < V_NUMPAR; i++) { \
315 316 v32.v_part[i].p_tag = (ushort_t)extv.v_part[i].p_tag; \
316 317 v32.v_part[i].p_flag = (ushort_t)extv.v_part[i].p_flag; \
317 318 v32.v_part[i].p_start = (unsigned)extv.v_part[i].p_start; \
318 319 v32.v_part[i].p_size = (unsigned)extv.v_part[i].p_size; \
319 320 } \
320 321 for (i = 0; i < V_NUMPAR; i++) { \
321 322 if (extv.timestamp[i] > TIME32_MAX) \
322 323 v32.timestamp[i] = TIME32_MAX; \
323 324 else \
324 325 v32.timestamp[i] = (time32_t)extv.timestamp[i]; \
325 326 } \
326 327 bcopy(extv.v_asciilabel, v32.v_asciilabel, LEN_DKL_ASCII); \
327 328 }
328 329
329 330
330 331 #endif /* _SYSCALL32 */
331 332
332 333 /*
333 334 * These defines are the mode parameter for the checksum routines.
334 335 */
335 336 #define CK_CHECKSUM 0 /* check checksum */
336 337 #define CK_MAKESUM 1 /* generate checksum */
337 338
338 339 extern int read_vtoc(int, struct vtoc *);
339 340 extern int write_vtoc(int, struct vtoc *);
340 341 extern int read_extvtoc(int, struct extvtoc *);
341 342 extern int write_extvtoc(int, struct extvtoc *);
342 343
343 344 #ifdef __cplusplus
344 345 }
345 346 #endif
346 347
347 348 #endif /* _SYS_VTOC_H */
↓ open down ↓ |
255 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX