xref: /onnv-gate/usr/src/uts/common/sys/vtoc.h (revision 8749:9d104a392c3d)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
56590Syl194034  * Common Development and Distribution License (the "License").
66590Syl194034  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
217563SPrasad.Singamsetty@Sun.COM 
220Sstevel@tonic-gate /*
23*8749SShidokht.Yadegari@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate 
280Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
290Sstevel@tonic-gate /*	  All Rights Reserved  	*/
300Sstevel@tonic-gate 
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #ifndef _SYS_VTOC_H
330Sstevel@tonic-gate #define	_SYS_VTOC_H
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #include <sys/dklabel.h>
360Sstevel@tonic-gate 
370Sstevel@tonic-gate #ifdef	__cplusplus
380Sstevel@tonic-gate extern "C" {
390Sstevel@tonic-gate #endif
400Sstevel@tonic-gate 
410Sstevel@tonic-gate /*
420Sstevel@tonic-gate  *	Note:  the VTOC is not implemented fully, nor in the manner
430Sstevel@tonic-gate  *	that AT&T implements it.  AT&T puts the vtoc structure
440Sstevel@tonic-gate  *	into a sector, usually the second sector (pdsector is first).
450Sstevel@tonic-gate  *
460Sstevel@tonic-gate  *	Sun incorporates the tag, flag, version, and volume vtoc fields into
470Sstevel@tonic-gate  *	its Disk Label, which already has some vtoc-equivalent fields.
480Sstevel@tonic-gate  *	Upon reading the vtoc with read_vtoc(), the following exceptions
490Sstevel@tonic-gate  *	occur:
500Sstevel@tonic-gate  *		v_bootinfo [all]	returned as zero
510Sstevel@tonic-gate  *		v_sanity		returned as VTOC_SANE
520Sstevel@tonic-gate  *						if Disk Label was sane
530Sstevel@tonic-gate  *		v_sectorsz		returned as 512
540Sstevel@tonic-gate  *		v_reserved [all]	retunred as zero
550Sstevel@tonic-gate  *		timestamp [all]		returned as zero
560Sstevel@tonic-gate  *
570Sstevel@tonic-gate  *	See  dklabel.h, read_vtoc(), and write_vtoc().
580Sstevel@tonic-gate  */
590Sstevel@tonic-gate 
600Sstevel@tonic-gate #define	V_NUMPAR 	NDKMAP		/* The number of partitions */
610Sstevel@tonic-gate 					/* (from dkio.h) */
620Sstevel@tonic-gate 
630Sstevel@tonic-gate #define	VTOC_SANE	0x600DDEEE	/* Indicates a sane VTOC */
640Sstevel@tonic-gate #define	V_VERSION	0x01		/* layout version number */
657563SPrasad.Singamsetty@Sun.COM #define	V_EXTVERSION	V_VERSION	/* extvtoc layout version number */
660Sstevel@tonic-gate 
670Sstevel@tonic-gate /*
680Sstevel@tonic-gate  * Partition identification tags
690Sstevel@tonic-gate  */
700Sstevel@tonic-gate #define	V_UNASSIGNED	0x00		/* unassigned partition */
710Sstevel@tonic-gate #define	V_BOOT		0x01		/* Boot partition */
720Sstevel@tonic-gate #define	V_ROOT		0x02		/* Root filesystem */
730Sstevel@tonic-gate #define	V_SWAP		0x03		/* Swap filesystem */
740Sstevel@tonic-gate #define	V_USR		0x04		/* Usr filesystem */
750Sstevel@tonic-gate #define	V_BACKUP	0x05		/* full disk */
760Sstevel@tonic-gate #define	V_STAND		0x06		/* Stand partition */
770Sstevel@tonic-gate #define	V_VAR		0x07		/* Var partition */
780Sstevel@tonic-gate #define	V_HOME		0x08		/* Home partition */
790Sstevel@tonic-gate #define	V_ALTSCTR	0x09		/* Alternate sector partition */
800Sstevel@tonic-gate #define	V_CACHE		0x0a		/* Cache (cachefs) partition */
810Sstevel@tonic-gate #define	V_RESERVED	0x0b		/* SMI reserved data */
820Sstevel@tonic-gate 
830Sstevel@tonic-gate /*
840Sstevel@tonic-gate  * Partition permission flags
850Sstevel@tonic-gate  */
860Sstevel@tonic-gate #define	V_UNMNT		0x01		/* Unmountable partition */
870Sstevel@tonic-gate #define	V_RONLY		0x10		/* Read only */
880Sstevel@tonic-gate 
890Sstevel@tonic-gate /*
900Sstevel@tonic-gate  * error codes for reading & writing vtoc
910Sstevel@tonic-gate  */
920Sstevel@tonic-gate #define	VT_ERROR	(-2)		/* errno supplies specific error */
930Sstevel@tonic-gate #define	VT_EIO		(-3)		/* I/O error accessing vtoc */
940Sstevel@tonic-gate #define	VT_EINVAL	(-4)		/* illegal value in vtoc or request */
950Sstevel@tonic-gate #define	VT_ENOTSUP	(-5)		/* VTOC op. not supported */
966590Syl194034 #define	VT_ENOSPC	(-6)		/* requested space not found */
977563SPrasad.Singamsetty@Sun.COM #define	VT_EOVERFLOW	(-7)		/* VTOC op. data struct limited */
980Sstevel@tonic-gate 
990Sstevel@tonic-gate struct partition	{
1000Sstevel@tonic-gate 	ushort_t p_tag;			/* ID tag of partition */
1017563SPrasad.Singamsetty@Sun.COM 	ushort_t p_flag;		/* permission flags */
1020Sstevel@tonic-gate 	daddr_t	p_start;		/* start sector no of partition */
1030Sstevel@tonic-gate 	long	p_size;			/* # of blocks in partition */
1040Sstevel@tonic-gate };
1050Sstevel@tonic-gate 
1060Sstevel@tonic-gate struct vtoc {
1070Sstevel@tonic-gate 	unsigned long	v_bootinfo[3];	/* info needed by mboot (unsupported) */
1080Sstevel@tonic-gate 	unsigned long	v_sanity;	/* to verify vtoc sanity */
1090Sstevel@tonic-gate 	unsigned long	v_version;	/* layout version */
1100Sstevel@tonic-gate 	char	v_volume[LEN_DKL_VVOL];	/* volume name */
1110Sstevel@tonic-gate 	ushort_t	v_sectorsz;	/* sector size in bytes */
1120Sstevel@tonic-gate 	ushort_t	v_nparts;	/* number of partitions */
1130Sstevel@tonic-gate 	unsigned long	v_reserved[10];	/* free space */
1140Sstevel@tonic-gate 	struct partition v_part[V_NUMPAR]; /* partition headers */
1150Sstevel@tonic-gate 	time_t	timestamp[V_NUMPAR];	/* partition timestamp (unsupported) */
1160Sstevel@tonic-gate 	char	v_asciilabel[LEN_DKL_ASCII];	/* for compatibility */
1170Sstevel@tonic-gate };
1180Sstevel@tonic-gate 
1197563SPrasad.Singamsetty@Sun.COM struct extpartition {
1207563SPrasad.Singamsetty@Sun.COM 	ushort_t p_tag;			/* ID tag of partition */
1217563SPrasad.Singamsetty@Sun.COM 	ushort_t p_flag;		/* permission flags */
1227563SPrasad.Singamsetty@Sun.COM 	ushort_t p_pad[2];
1237563SPrasad.Singamsetty@Sun.COM 	diskaddr_t p_start;		/* start sector no of partition */
1247563SPrasad.Singamsetty@Sun.COM 	diskaddr_t p_size;			/* # of blocks in partition */
1257563SPrasad.Singamsetty@Sun.COM };
1267563SPrasad.Singamsetty@Sun.COM 
1277563SPrasad.Singamsetty@Sun.COM 
1287563SPrasad.Singamsetty@Sun.COM struct extvtoc {
1297563SPrasad.Singamsetty@Sun.COM 	uint64_t	v_bootinfo[3];	/* info needed by mboot (unsupported) */
1307563SPrasad.Singamsetty@Sun.COM 	uint64_t	v_sanity;	/* to verify vtoc sanity */
1317563SPrasad.Singamsetty@Sun.COM 	uint64_t	v_version;	/* layout version */
1327563SPrasad.Singamsetty@Sun.COM 	char	v_volume[LEN_DKL_VVOL];	/* volume name */
1337563SPrasad.Singamsetty@Sun.COM 	ushort_t	v_sectorsz;	/* sector size in bytes */
1347563SPrasad.Singamsetty@Sun.COM 	ushort_t	v_nparts;	/* number of partitions */
1357563SPrasad.Singamsetty@Sun.COM 	ushort_t	pad[2];
1367563SPrasad.Singamsetty@Sun.COM 	uint64_t	v_reserved[10];
1377563SPrasad.Singamsetty@Sun.COM 	struct extpartition v_part[V_NUMPAR]; /* partition headers */
1387563SPrasad.Singamsetty@Sun.COM 	uint64_t timestamp[V_NUMPAR];	/* partition timestamp (unsupported) */
1397563SPrasad.Singamsetty@Sun.COM 	char	v_asciilabel[LEN_DKL_ASCII];	/* for compatibility */
1407563SPrasad.Singamsetty@Sun.COM };
1417563SPrasad.Singamsetty@Sun.COM 
1427563SPrasad.Singamsetty@Sun.COM #ifdef _KERNEL
1437563SPrasad.Singamsetty@Sun.COM #define	extvtoctovtoc(extv, v)						\
1447563SPrasad.Singamsetty@Sun.COM 	{								\
1457563SPrasad.Singamsetty@Sun.COM 	int i;								\
1467563SPrasad.Singamsetty@Sun.COM 	v.v_bootinfo[0]		= (unsigned long)extv.v_bootinfo[0];	\
1477563SPrasad.Singamsetty@Sun.COM 	v.v_bootinfo[1]		= (unsigned long)extv.v_bootinfo[1];	\
1487563SPrasad.Singamsetty@Sun.COM 	v.v_bootinfo[2]		= (unsigned long)extv.v_bootinfo[2];	\
1497563SPrasad.Singamsetty@Sun.COM 	v.v_sanity		= (unsigned long)extv.v_sanity;		\
1507563SPrasad.Singamsetty@Sun.COM 	v.v_version		= (unsigned long)extv.v_version;	\
1517563SPrasad.Singamsetty@Sun.COM 	bcopy(extv.v_volume, v.v_volume, LEN_DKL_VVOL);			\
1527563SPrasad.Singamsetty@Sun.COM 	v.v_sectorsz		= extv.v_sectorsz;			\
1537563SPrasad.Singamsetty@Sun.COM 	v.v_nparts		= extv.v_nparts;			\
1547563SPrasad.Singamsetty@Sun.COM 	for (i = 0; i < 10; i++)					\
1557563SPrasad.Singamsetty@Sun.COM 		v.v_reserved[i] = (unsigned long)extv.v_reserved[i];	\
1567563SPrasad.Singamsetty@Sun.COM 	for (i = 0; i < V_NUMPAR; i++) {				\
1577563SPrasad.Singamsetty@Sun.COM 		v.v_part[i].p_tag = extv.v_part[i].p_tag;		\
1587563SPrasad.Singamsetty@Sun.COM 		v.v_part[i].p_flag = extv.v_part[i].p_flag;		\
1597563SPrasad.Singamsetty@Sun.COM 		v.v_part[i].p_start = (daddr_t)extv.v_part[i].p_start;	\
1607563SPrasad.Singamsetty@Sun.COM 		v.v_part[i].p_size = (long)extv.v_part[i].p_size;	\
161*8749SShidokht.Yadegari@Sun.COM 		v.timestamp[i] = (time_t)extv.timestamp[i];		\
1627563SPrasad.Singamsetty@Sun.COM 	}								\
1637563SPrasad.Singamsetty@Sun.COM 	bcopy(extv.v_asciilabel, v.v_asciilabel, LEN_DKL_ASCII);	\
1647563SPrasad.Singamsetty@Sun.COM 	}
1657563SPrasad.Singamsetty@Sun.COM 
1667563SPrasad.Singamsetty@Sun.COM #define	vtoctoextvtoc(v, extv)						\
1677563SPrasad.Singamsetty@Sun.COM 	{								\
1687563SPrasad.Singamsetty@Sun.COM 	int i;								\
1697563SPrasad.Singamsetty@Sun.COM 	extv.v_bootinfo[0]	= (uint64_t)v.v_bootinfo[0];		\
1707563SPrasad.Singamsetty@Sun.COM 	extv.v_bootinfo[1]	= (uint64_t)v.v_bootinfo[1];		\
1717563SPrasad.Singamsetty@Sun.COM 	extv.v_bootinfo[2]	= (uint64_t)v.v_bootinfo[2];		\
1727563SPrasad.Singamsetty@Sun.COM 	extv.v_sanity		= (uint64_t)v.v_sanity;			\
1737563SPrasad.Singamsetty@Sun.COM 	extv.v_version		= (uint64_t)v.v_version;		\
1747563SPrasad.Singamsetty@Sun.COM 	bcopy(v.v_volume, extv.v_volume, LEN_DKL_VVOL);			\
1757563SPrasad.Singamsetty@Sun.COM 	extv.v_sectorsz		= v.v_sectorsz;				\
1767563SPrasad.Singamsetty@Sun.COM 	extv.v_nparts		= v.v_nparts;				\
1777563SPrasad.Singamsetty@Sun.COM 	for (i = 0; i < 10; i++)					\
1787563SPrasad.Singamsetty@Sun.COM 		extv.v_reserved[i] = (uint64_t)v.v_reserved[i];		\
1797563SPrasad.Singamsetty@Sun.COM 	for (i = 0; i < V_NUMPAR; i++) {				\
1807563SPrasad.Singamsetty@Sun.COM 		extv.v_part[i].p_tag = v.v_part[i].p_tag;		\
1817563SPrasad.Singamsetty@Sun.COM 		extv.v_part[i].p_flag = v.v_part[i].p_flag;		\
1827563SPrasad.Singamsetty@Sun.COM 		extv.v_part[i].p_start =				\
1837563SPrasad.Singamsetty@Sun.COM 		    (diskaddr_t)(unsigned long)v.v_part[i].p_start;	\
1847563SPrasad.Singamsetty@Sun.COM 		extv.v_part[i].p_size =					\
1857563SPrasad.Singamsetty@Sun.COM 		    (diskaddr_t)(unsigned long)v.v_part[i].p_size;	\
1867563SPrasad.Singamsetty@Sun.COM 		extv.timestamp[i] = (uint64_t)v.timestamp[i];		\
1877563SPrasad.Singamsetty@Sun.COM 	}								\
1887563SPrasad.Singamsetty@Sun.COM 	bcopy(v.v_asciilabel, extv.v_asciilabel, LEN_DKL_ASCII);	\
1897563SPrasad.Singamsetty@Sun.COM 	}
1907563SPrasad.Singamsetty@Sun.COM #endif /* _KERNEL */
1917563SPrasad.Singamsetty@Sun.COM 
1920Sstevel@tonic-gate #if defined(_SYSCALL32)
1930Sstevel@tonic-gate struct partition32	{
1940Sstevel@tonic-gate 	uint16_t	p_tag;		/* ID tag of partition */
1957563SPrasad.Singamsetty@Sun.COM 	uint16_t	p_flag;		/* permission flags */
1960Sstevel@tonic-gate 	daddr32_t	p_start;	/* start sector no of partition */
1970Sstevel@tonic-gate 	int32_t		p_size;		/* # of blocks in partition */
1980Sstevel@tonic-gate };
1990Sstevel@tonic-gate 
2000Sstevel@tonic-gate struct vtoc32 {
2010Sstevel@tonic-gate 	uint32_t	v_bootinfo[3];	/* info needed by mboot (unsupported) */
2020Sstevel@tonic-gate 	uint32_t	v_sanity;	/* to verify vtoc sanity */
2030Sstevel@tonic-gate 	uint32_t	v_version;	/* layout version */
2040Sstevel@tonic-gate 	char	v_volume[LEN_DKL_VVOL];	/* volume name */
2050Sstevel@tonic-gate 	uint16_t	v_sectorsz;	/* sector size in bytes */
2060Sstevel@tonic-gate 	uint16_t	v_nparts;	/* number of partitions */
2070Sstevel@tonic-gate 	uint32_t	v_reserved[10];	/* free space */
2080Sstevel@tonic-gate 	struct partition32 v_part[V_NUMPAR]; /* partition headers */
2090Sstevel@tonic-gate 	time32_t timestamp[V_NUMPAR];	/* partition timestamp (unsupported) */
2100Sstevel@tonic-gate 	char	v_asciilabel[LEN_DKL_ASCII];	/* for compatibility */
2110Sstevel@tonic-gate };
2120Sstevel@tonic-gate 
2130Sstevel@tonic-gate #define	vtoc32tovtoc(v32, v)				\
2140Sstevel@tonic-gate 	{						\
2150Sstevel@tonic-gate 	int i;						\
2160Sstevel@tonic-gate 	v.v_bootinfo[0]		= v32.v_bootinfo[0];	\
2170Sstevel@tonic-gate 	v.v_bootinfo[1]		= v32.v_bootinfo[1];	\
2180Sstevel@tonic-gate 	v.v_bootinfo[2]		= v32.v_bootinfo[2];	\
2190Sstevel@tonic-gate 	v.v_sanity		= v32.v_sanity;		\
2200Sstevel@tonic-gate 	v.v_version		= v32.v_version;	\
2210Sstevel@tonic-gate 	bcopy(v32.v_volume, v.v_volume, LEN_DKL_VVOL);	\
2220Sstevel@tonic-gate 	v.v_sectorsz		= v32.v_sectorsz;	\
2230Sstevel@tonic-gate 	v.v_nparts		= v32.v_nparts;		\
2240Sstevel@tonic-gate 	v.v_version		= v32.v_version;	\
2250Sstevel@tonic-gate 	for (i = 0; i < 10; i++)			\
2260Sstevel@tonic-gate 		v.v_reserved[i] = v32.v_reserved[i];	\
2270Sstevel@tonic-gate 	for (i = 0; i < V_NUMPAR; i++) {		\
2280Sstevel@tonic-gate 		v.v_part[i].p_tag = (ushort_t)v32.v_part[i].p_tag;	\
2290Sstevel@tonic-gate 		v.v_part[i].p_flag = (ushort_t)v32.v_part[i].p_flag;	\
2307563SPrasad.Singamsetty@Sun.COM 		v.v_part[i].p_start = (unsigned)v32.v_part[i].p_start;	\
2317563SPrasad.Singamsetty@Sun.COM 		v.v_part[i].p_size = (unsigned)v32.v_part[i].p_size;	\
2320Sstevel@tonic-gate 	}						\
2330Sstevel@tonic-gate 	for (i = 0; i < V_NUMPAR; i++)			\
2340Sstevel@tonic-gate 		v.timestamp[i] = (time_t)v32.timestamp[i];		\
2350Sstevel@tonic-gate 	bcopy(v32.v_asciilabel, v.v_asciilabel, LEN_DKL_ASCII);		\
2360Sstevel@tonic-gate 	}
2370Sstevel@tonic-gate 
2387563SPrasad.Singamsetty@Sun.COM #define	vtoc32toextvtoc(v32, extv)					\
2397563SPrasad.Singamsetty@Sun.COM 	{								\
2407563SPrasad.Singamsetty@Sun.COM 	int i;								\
2417563SPrasad.Singamsetty@Sun.COM 	extv.v_bootinfo[0]		= v32.v_bootinfo[0];		\
2427563SPrasad.Singamsetty@Sun.COM 	extv.v_bootinfo[1]		= v32.v_bootinfo[1];		\
2437563SPrasad.Singamsetty@Sun.COM 	extv.v_bootinfo[2]		= v32.v_bootinfo[2];		\
2447563SPrasad.Singamsetty@Sun.COM 	extv.v_sanity		= v32.v_sanity;				\
2457563SPrasad.Singamsetty@Sun.COM 	extv.v_version		= v32.v_version;			\
2467563SPrasad.Singamsetty@Sun.COM 	bcopy(v32.v_volume, extv.v_volume, LEN_DKL_VVOL);		\
2477563SPrasad.Singamsetty@Sun.COM 	extv.v_sectorsz		= v32.v_sectorsz;			\
2487563SPrasad.Singamsetty@Sun.COM 	extv.v_nparts		= v32.v_nparts;				\
2497563SPrasad.Singamsetty@Sun.COM 	extv.v_version		= v32.v_version;			\
2507563SPrasad.Singamsetty@Sun.COM 	for (i = 0; i < 10; i++)					\
2517563SPrasad.Singamsetty@Sun.COM 		extv.v_reserved[i] = v32.v_reserved[i];			\
2527563SPrasad.Singamsetty@Sun.COM 	for (i = 0; i < V_NUMPAR; i++) {				\
2537563SPrasad.Singamsetty@Sun.COM 		extv.v_part[i].p_tag = (ushort_t)v32.v_part[i].p_tag;	\
2547563SPrasad.Singamsetty@Sun.COM 		extv.v_part[i].p_flag = (ushort_t)v32.v_part[i].p_flag;	\
2557563SPrasad.Singamsetty@Sun.COM 		extv.v_part[i].p_start = (diskaddr_t)v32.v_part[i].p_start; \
2567563SPrasad.Singamsetty@Sun.COM 		extv.v_part[i].p_size = (diskaddr_t)v32.v_part[i].p_size; \
2577563SPrasad.Singamsetty@Sun.COM 		extv.timestamp[i] = (time_t)v32.timestamp[i];		\
2587563SPrasad.Singamsetty@Sun.COM 	}								\
2597563SPrasad.Singamsetty@Sun.COM 	bcopy(v32.v_asciilabel, extv.v_asciilabel, LEN_DKL_ASCII);	\
2607563SPrasad.Singamsetty@Sun.COM 	}
2617563SPrasad.Singamsetty@Sun.COM 
2627563SPrasad.Singamsetty@Sun.COM 
2630Sstevel@tonic-gate #define	vtoctovtoc32(v, v32)				\
2640Sstevel@tonic-gate 	{						\
2650Sstevel@tonic-gate 	int i;						\
2660Sstevel@tonic-gate 	v32.v_bootinfo[0]	= v.v_bootinfo[0];	\
2670Sstevel@tonic-gate 	v32.v_bootinfo[1]	= v.v_bootinfo[1];	\
2680Sstevel@tonic-gate 	v32.v_bootinfo[2]	= v.v_bootinfo[2];	\
2690Sstevel@tonic-gate 	v32.v_sanity		= v.v_sanity;		\
2700Sstevel@tonic-gate 	v32.v_version		= v.v_version;		\
2710Sstevel@tonic-gate 	bcopy(v.v_volume, v32.v_volume, LEN_DKL_VVOL);	\
2720Sstevel@tonic-gate 	v32.v_sectorsz		= v.v_sectorsz;		\
2730Sstevel@tonic-gate 	v32.v_nparts		= v.v_nparts;		\
2740Sstevel@tonic-gate 	v32.v_version		= v.v_version;		\
2750Sstevel@tonic-gate 	for (i = 0; i < 10; i++)			\
2760Sstevel@tonic-gate 		v32.v_reserved[i] = v.v_reserved[i];	\
2770Sstevel@tonic-gate 	for (i = 0; i < V_NUMPAR; i++) {		\
2780Sstevel@tonic-gate 		v32.v_part[i].p_tag = (ushort_t)v.v_part[i].p_tag;	\
2790Sstevel@tonic-gate 		v32.v_part[i].p_flag = (ushort_t)v.v_part[i].p_flag;	\
2807563SPrasad.Singamsetty@Sun.COM 		v32.v_part[i].p_start = (unsigned)v.v_part[i].p_start;	\
2817563SPrasad.Singamsetty@Sun.COM 		v32.v_part[i].p_size = (unsigned)v.v_part[i].p_size;	\
2820Sstevel@tonic-gate 	}						\
2830Sstevel@tonic-gate 	for (i = 0; i < V_NUMPAR; i++) {		\
2840Sstevel@tonic-gate 		if (v.timestamp[i] > TIME32_MAX)	\
2850Sstevel@tonic-gate 			v32.timestamp[i] = TIME32_MAX;	\
2860Sstevel@tonic-gate 		else 					\
2870Sstevel@tonic-gate 			v32.timestamp[i] = (time32_t)v.timestamp[i];	\
2880Sstevel@tonic-gate 	}						\
2890Sstevel@tonic-gate 	bcopy(v.v_asciilabel, v32.v_asciilabel, LEN_DKL_ASCII);		\
2900Sstevel@tonic-gate 	}
2910Sstevel@tonic-gate 
2927563SPrasad.Singamsetty@Sun.COM #define	extvtoctovtoc32(extv, v32)				\
2937563SPrasad.Singamsetty@Sun.COM 	{						\
2947563SPrasad.Singamsetty@Sun.COM 	int i;						\
2957563SPrasad.Singamsetty@Sun.COM 	v32.v_bootinfo[0]	= extv.v_bootinfo[0];	\
2967563SPrasad.Singamsetty@Sun.COM 	v32.v_bootinfo[1]	= extv.v_bootinfo[1];	\
2977563SPrasad.Singamsetty@Sun.COM 	v32.v_bootinfo[2]	= extv.v_bootinfo[2];	\
2987563SPrasad.Singamsetty@Sun.COM 	v32.v_sanity		= extv.v_sanity;		\
2997563SPrasad.Singamsetty@Sun.COM 	v32.v_version		= extv.v_version;		\
3007563SPrasad.Singamsetty@Sun.COM 	bcopy(extv.v_volume, v32.v_volume, LEN_DKL_VVOL);	\
3017563SPrasad.Singamsetty@Sun.COM 	v32.v_sectorsz		= extv.v_sectorsz;		\
3027563SPrasad.Singamsetty@Sun.COM 	v32.v_nparts		= extv.v_nparts;		\
3037563SPrasad.Singamsetty@Sun.COM 	v32.v_version		= extv.v_version;		\
3047563SPrasad.Singamsetty@Sun.COM 	for (i = 0; i < 10; i++)			\
3057563SPrasad.Singamsetty@Sun.COM 		v32.v_reserved[i] = extv.v_reserved[i];	\
3067563SPrasad.Singamsetty@Sun.COM 	for (i = 0; i < V_NUMPAR; i++) {		\
3077563SPrasad.Singamsetty@Sun.COM 		v32.v_part[i].p_tag = (ushort_t)extv.v_part[i].p_tag;	\
3087563SPrasad.Singamsetty@Sun.COM 		v32.v_part[i].p_flag = (ushort_t)extv.v_part[i].p_flag;	\
3097563SPrasad.Singamsetty@Sun.COM 		v32.v_part[i].p_start = (unsigned)extv.v_part[i].p_start; \
3107563SPrasad.Singamsetty@Sun.COM 		v32.v_part[i].p_size = (unsigned)extv.v_part[i].p_size;	\
3117563SPrasad.Singamsetty@Sun.COM 	}						\
3127563SPrasad.Singamsetty@Sun.COM 	for (i = 0; i < V_NUMPAR; i++) {		\
3137563SPrasad.Singamsetty@Sun.COM 		if (extv.timestamp[i] > TIME32_MAX)	\
3147563SPrasad.Singamsetty@Sun.COM 			v32.timestamp[i] = TIME32_MAX;	\
3157563SPrasad.Singamsetty@Sun.COM 		else 					\
3167563SPrasad.Singamsetty@Sun.COM 			v32.timestamp[i] = (time32_t)extv.timestamp[i];	\
3177563SPrasad.Singamsetty@Sun.COM 	}						\
3187563SPrasad.Singamsetty@Sun.COM 	bcopy(extv.v_asciilabel, v32.v_asciilabel, LEN_DKL_ASCII);	\
3197563SPrasad.Singamsetty@Sun.COM 	}
3207563SPrasad.Singamsetty@Sun.COM 
3217563SPrasad.Singamsetty@Sun.COM 
3220Sstevel@tonic-gate #endif /* _SYSCALL32 */
3230Sstevel@tonic-gate 
3240Sstevel@tonic-gate /*
3250Sstevel@tonic-gate  * These defines are the mode parameter for the checksum routines.
3260Sstevel@tonic-gate  */
3270Sstevel@tonic-gate #define	CK_CHECKSUM	0	/* check checksum */
3280Sstevel@tonic-gate #define	CK_MAKESUM	1	/* generate checksum */
3290Sstevel@tonic-gate 
3300Sstevel@tonic-gate #if defined(__STDC__)
3310Sstevel@tonic-gate 
3320Sstevel@tonic-gate extern	int	read_vtoc(int, struct vtoc *);
3330Sstevel@tonic-gate extern	int	write_vtoc(int, struct vtoc *);
3347563SPrasad.Singamsetty@Sun.COM extern	int	read_extvtoc(int, struct extvtoc *);
3357563SPrasad.Singamsetty@Sun.COM extern	int	write_extvtoc(int, struct extvtoc *);
3360Sstevel@tonic-gate 
3370Sstevel@tonic-gate #else
3380Sstevel@tonic-gate 
3390Sstevel@tonic-gate extern	int	read_vtoc();
3400Sstevel@tonic-gate extern	int	write_vtoc();
3417563SPrasad.Singamsetty@Sun.COM extern	int	read_extvtoc();
3427563SPrasad.Singamsetty@Sun.COM extern	int	write_extvtoc();
3430Sstevel@tonic-gate 
3440Sstevel@tonic-gate #endif 	/* __STDC__ */
3450Sstevel@tonic-gate 
3460Sstevel@tonic-gate #ifdef	__cplusplus
3470Sstevel@tonic-gate }
3480Sstevel@tonic-gate #endif
3490Sstevel@tonic-gate 
3500Sstevel@tonic-gate #endif	/* _SYS_VTOC_H */
351