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