]>
git.proxmox.com Git - mirror_zfs.git/blob - zfs/lib/libsolcompat/include/sys/vtoc.h
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
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
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]
23 * Copyright 1997-1998,2002 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
28 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
29 /* All Rights Reserved */
37 #include <sys/dklabel.h>
44 * Note: the VTOC is not implemented fully, nor in the manner
45 * that AT&T implements it. AT&T puts the vtoc structure
46 * into a sector, usually the second sector (pdsector is first).
48 * Sun incorporates the tag, flag, version, and volume vtoc fields into
49 * its Disk Label, which already has some vtoc-equivalent fields.
50 * Upon reading the vtoc with read_vtoc(), the following exceptions
52 * v_bootinfo [all] returned as zero
53 * v_sanity returned as VTOC_SANE
54 * if Disk Label was sane
55 * v_sectorsz returned as 512
56 * v_reserved [all] retunred as zero
57 * timestamp [all] returned as zero
59 * See dklabel.h, read_vtoc(), and write_vtoc().
62 #define V_NUMPAR NDKMAP /* The number of partitions */
65 #define VTOC_SANE 0x600DDEEE /* Indicates a sane VTOC */
66 #define V_VERSION 0x01 /* layout version number */
69 * Partition identification tags
71 #define V_UNASSIGNED 0x00 /* unassigned partition */
72 #define V_BOOT 0x01 /* Boot partition */
73 #define V_ROOT 0x02 /* Root filesystem */
74 #define V_SWAP 0x03 /* Swap filesystem */
75 #define V_USR 0x04 /* Usr filesystem */
76 #define V_BACKUP 0x05 /* full disk */
77 #define V_STAND 0x06 /* Stand partition */
78 #define V_VAR 0x07 /* Var partition */
79 #define V_HOME 0x08 /* Home partition */
80 #define V_ALTSCTR 0x09 /* Alternate sector partition */
81 #define V_CACHE 0x0a /* Cache (cachefs) partition */
82 #define V_RESERVED 0x0b /* SMI reserved data */
85 * Partition permission flags
87 #define V_UNMNT 0x01 /* Unmountable partition */
88 #define V_RONLY 0x10 /* Read only */
91 * error codes for reading & writing vtoc
93 #define VT_ERROR (-2) /* errno supplies specific error */
94 #define VT_EIO (-3) /* I/O error accessing vtoc */
95 #define VT_EINVAL (-4) /* illegal value in vtoc or request */
96 #define VT_ENOTSUP (-5) /* VTOC op. not supported */
99 ushort_t p_tag
; /* ID tag of partition */
100 ushort_t p_flag
; /* permision flags */
101 daddr_t p_start
; /* start sector no of partition */
102 long p_size
; /* # of blocks in partition */
106 unsigned long v_bootinfo
[3]; /* info needed by mboot (unsupported) */
107 unsigned long v_sanity
; /* to verify vtoc sanity */
108 unsigned long v_version
; /* layout version */
109 char v_volume
[LEN_DKL_VVOL
]; /* volume name */
110 ushort_t v_sectorsz
; /* sector size in bytes */
111 ushort_t v_nparts
; /* number of partitions */
112 unsigned long v_reserved
[10]; /* free space */
113 struct partition v_part
[V_NUMPAR
]; /* partition headers */
114 time_t timestamp
[V_NUMPAR
]; /* partition timestamp (unsupported) */
115 char v_asciilabel
[LEN_DKL_ASCII
]; /* for compatibility */
118 #if defined(_SYSCALL32)
120 uint16_t p_tag
; /* ID tag of partition */
121 uint16_t p_flag
; /* permision flags */
122 daddr32_t p_start
; /* start sector no of partition */
123 int32_t p_size
; /* # of blocks in partition */
127 uint32_t v_bootinfo
[3]; /* info needed by mboot (unsupported) */
128 uint32_t v_sanity
; /* to verify vtoc sanity */
129 uint32_t v_version
; /* layout version */
130 char v_volume
[LEN_DKL_VVOL
]; /* volume name */
131 uint16_t v_sectorsz
; /* sector size in bytes */
132 uint16_t v_nparts
; /* number of partitions */
133 uint32_t v_reserved
[10]; /* free space */
134 struct partition32 v_part
[V_NUMPAR
]; /* partition headers */
135 time32_t timestamp
[V_NUMPAR
]; /* partition timestamp (unsupported) */
136 char v_asciilabel
[LEN_DKL_ASCII
]; /* for compatibility */
139 #define vtoc32tovtoc(v32, v) \
142 v.v_bootinfo[0] = v32.v_bootinfo[0]; \
143 v.v_bootinfo[1] = v32.v_bootinfo[1]; \
144 v.v_bootinfo[2] = v32.v_bootinfo[2]; \
145 v.v_sanity = v32.v_sanity; \
146 v.v_version = v32.v_version; \
147 bcopy(v32.v_volume, v.v_volume, LEN_DKL_VVOL); \
148 v.v_sectorsz = v32.v_sectorsz; \
149 v.v_nparts = v32.v_nparts; \
150 v.v_version = v32.v_version; \
151 for (i = 0; i < 10; i++) \
152 v.v_reserved[i] = v32.v_reserved[i]; \
153 for (i = 0; i < V_NUMPAR; i++) { \
154 v.v_part[i].p_tag = (ushort_t)v32.v_part[i].p_tag; \
155 v.v_part[i].p_flag = (ushort_t)v32.v_part[i].p_flag; \
156 v.v_part[i].p_start = (daddr_t)v32.v_part[i].p_start; \
157 v.v_part[i].p_size = (long)v32.v_part[i].p_size; \
159 for (i = 0; i < V_NUMPAR; i++) \
160 v.timestamp[i] = (time_t)v32.timestamp[i]; \
161 bcopy(v32.v_asciilabel, v.v_asciilabel, LEN_DKL_ASCII); \
164 #define vtoctovtoc32(v, v32) \
167 v32.v_bootinfo[0] = v.v_bootinfo[0]; \
168 v32.v_bootinfo[1] = v.v_bootinfo[1]; \
169 v32.v_bootinfo[2] = v.v_bootinfo[2]; \
170 v32.v_sanity = v.v_sanity; \
171 v32.v_version = v.v_version; \
172 bcopy(v.v_volume, v32.v_volume, LEN_DKL_VVOL); \
173 v32.v_sectorsz = v.v_sectorsz; \
174 v32.v_nparts = v.v_nparts; \
175 v32.v_version = v.v_version; \
176 for (i = 0; i < 10; i++) \
177 v32.v_reserved[i] = v.v_reserved[i]; \
178 for (i = 0; i < V_NUMPAR; i++) { \
179 v32.v_part[i].p_tag = (ushort_t)v.v_part[i].p_tag; \
180 v32.v_part[i].p_flag = (ushort_t)v.v_part[i].p_flag; \
181 v32.v_part[i].p_start = (daddr32_t)v.v_part[i].p_start; \
182 v32.v_part[i].p_size = (int32_t)v.v_part[i].p_size; \
184 for (i = 0; i < V_NUMPAR; i++) { \
185 if (v.timestamp[i] > TIME32_MAX) \
186 v32.timestamp[i] = TIME32_MAX; \
188 v32.timestamp[i] = (time32_t)v.timestamp[i]; \
190 bcopy(v.v_asciilabel, v32.v_asciilabel, LEN_DKL_ASCII); \
193 #endif /* _SYSCALL32 */
196 * These defines are the mode parameter for the checksum routines.
198 #define CK_CHECKSUM 0 /* check checksum */
199 #define CK_MAKESUM 1 /* generate checksum */
201 #if defined(__STDC__)
203 extern int read_vtoc(int, struct vtoc
*);
204 extern int write_vtoc(int, struct vtoc
*);
208 extern int read_vtoc();
209 extern int write_vtoc();
211 #endif /* __STDC__ */
217 #endif /* _SYS_VTOC_H */