17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5af007057Syl * Common Development and Distribution License (the "License"). 6af007057Syl * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 21342440ecSPrasad Singamsetty 227c478bd9Sstevel@tonic-gate /* 23ba3594baSGarrett D'Amore * Copyright 2014 Garrett D'Amore <garrett@damore.org> 24ba3594baSGarrett D'Amore * 257e70b434SShidokht Yadegari * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 267c478bd9Sstevel@tonic-gate * Use is subject to license terms. 27bd93c05dSAlexander Eremin * Copyright 2015 Nexenta Systems, Inc. All rights reserved. 28406fc510SToomas Soome * Copyright 2016 Toomas Soome <tsoome@me.com> 297c478bd9Sstevel@tonic-gate */ 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 33b4203d75SMarcel Telka /* All Rights Reserved */ 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #ifndef _SYS_VTOC_H 377c478bd9Sstevel@tonic-gate #define _SYS_VTOC_H 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #include <sys/dklabel.h> 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate #ifdef __cplusplus 427c478bd9Sstevel@tonic-gate extern "C" { 437c478bd9Sstevel@tonic-gate #endif 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate /* 467c478bd9Sstevel@tonic-gate * Note: the VTOC is not implemented fully, nor in the manner 477c478bd9Sstevel@tonic-gate * that AT&T implements it. AT&T puts the vtoc structure 487c478bd9Sstevel@tonic-gate * into a sector, usually the second sector (pdsector is first). 497c478bd9Sstevel@tonic-gate * 507c478bd9Sstevel@tonic-gate * Sun incorporates the tag, flag, version, and volume vtoc fields into 517c478bd9Sstevel@tonic-gate * its Disk Label, which already has some vtoc-equivalent fields. 527c478bd9Sstevel@tonic-gate * Upon reading the vtoc with read_vtoc(), the following exceptions 537c478bd9Sstevel@tonic-gate * occur: 547c478bd9Sstevel@tonic-gate * v_bootinfo [all] returned as zero 557c478bd9Sstevel@tonic-gate * v_sanity returned as VTOC_SANE 567c478bd9Sstevel@tonic-gate * if Disk Label was sane 577c478bd9Sstevel@tonic-gate * v_sectorsz returned as 512 587c478bd9Sstevel@tonic-gate * v_reserved [all] retunred as zero 597c478bd9Sstevel@tonic-gate * timestamp [all] returned as zero 607c478bd9Sstevel@tonic-gate * 617c478bd9Sstevel@tonic-gate * See dklabel.h, read_vtoc(), and write_vtoc(). 627c478bd9Sstevel@tonic-gate */ 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate #define V_NUMPAR NDKMAP /* The number of partitions */ 657c478bd9Sstevel@tonic-gate /* (from dkio.h) */ 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate #define VTOC_SANE 0x600DDEEE /* Indicates a sane VTOC */ 687c478bd9Sstevel@tonic-gate #define V_VERSION 0x01 /* layout version number */ 69342440ecSPrasad Singamsetty #define V_EXTVERSION V_VERSION /* extvtoc layout version number */ 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate /* 727c478bd9Sstevel@tonic-gate * Partition identification tags 737c478bd9Sstevel@tonic-gate */ 747c478bd9Sstevel@tonic-gate #define V_UNASSIGNED 0x00 /* unassigned partition */ 757c478bd9Sstevel@tonic-gate #define V_BOOT 0x01 /* Boot partition */ 767c478bd9Sstevel@tonic-gate #define V_ROOT 0x02 /* Root filesystem */ 777c478bd9Sstevel@tonic-gate #define V_SWAP 0x03 /* Swap filesystem */ 787c478bd9Sstevel@tonic-gate #define V_USR 0x04 /* Usr filesystem */ 797c478bd9Sstevel@tonic-gate #define V_BACKUP 0x05 /* full disk */ 807c478bd9Sstevel@tonic-gate #define V_STAND 0x06 /* Stand partition */ 817c478bd9Sstevel@tonic-gate #define V_VAR 0x07 /* Var partition */ 827c478bd9Sstevel@tonic-gate #define V_HOME 0x08 /* Home partition */ 837c478bd9Sstevel@tonic-gate #define V_ALTSCTR 0x09 /* Alternate sector partition */ 84bd93c05dSAlexander Eremin #define V_CACHE 0x0a /* CacheFS partition (obsolete) */ 85e088753cSToomas Soome 86e088753cSToomas Soome /* Tags for EFI/GPT labels */ 877c478bd9Sstevel@tonic-gate #define V_RESERVED 0x0b /* SMI reserved data */ 88e088753cSToomas Soome #define V_SYSTEM 0x0c /* EFI/GPT system partition */ 89e088753cSToomas Soome 90*d06952d0SToomas Soome #define V_VXVM_PUB 0x0e /* VxVM public region */ 91*d06952d0SToomas Soome #define V_VXVM_PRIV 0x0f /* VxVM private region */ 92*d06952d0SToomas Soome 93*d06952d0SToomas Soome #define V_BIOS_BOOT 0x18 /* Grub2 BIOS Boot partition */ 94*d06952d0SToomas Soome 95*d06952d0SToomas Soome /* NetBSD/mips defines this */ 96*d06952d0SToomas Soome #define V_NETBSD_FFS 0xff 97*d06952d0SToomas Soome 98*d06952d0SToomas Soome /* FreeBSD tags: the high byte equals ELFOSABI_FREEBSD */ 99*d06952d0SToomas Soome #define V_FREEBSD_BOOT 0x0900 100*d06952d0SToomas Soome #define V_FREEBSD_SWAP 0x0901 101*d06952d0SToomas Soome #define V_FREEBSD_UFS 0x0902 102*d06952d0SToomas Soome #define V_FREEBSD_VINUM 0x0903 103*d06952d0SToomas Soome #define V_FREEBSD_ZFS 0x0904 104*d06952d0SToomas Soome #define V_FREEBSD_NANDFS 0x0905 105*d06952d0SToomas Soome 106*d06952d0SToomas Soome #define V_UNKNOWN 0xffff /* Unknown partition */ 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate /* 1097c478bd9Sstevel@tonic-gate * Partition permission flags 1107c478bd9Sstevel@tonic-gate */ 1117c478bd9Sstevel@tonic-gate #define V_UNMNT 0x01 /* Unmountable partition */ 1127c478bd9Sstevel@tonic-gate #define V_RONLY 0x10 /* Read only */ 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate /* 1157c478bd9Sstevel@tonic-gate * error codes for reading & writing vtoc 1167c478bd9Sstevel@tonic-gate */ 1177c478bd9Sstevel@tonic-gate #define VT_ERROR (-2) /* errno supplies specific error */ 1187c478bd9Sstevel@tonic-gate #define VT_EIO (-3) /* I/O error accessing vtoc */ 1197c478bd9Sstevel@tonic-gate #define VT_EINVAL (-4) /* illegal value in vtoc or request */ 1207c478bd9Sstevel@tonic-gate #define VT_ENOTSUP (-5) /* VTOC op. not supported */ 121af007057Syl #define VT_ENOSPC (-6) /* requested space not found */ 122342440ecSPrasad Singamsetty #define VT_EOVERFLOW (-7) /* VTOC op. data struct limited */ 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate struct partition { 1257c478bd9Sstevel@tonic-gate ushort_t p_tag; /* ID tag of partition */ 126342440ecSPrasad Singamsetty ushort_t p_flag; /* permission flags */ 1277c478bd9Sstevel@tonic-gate daddr_t p_start; /* start sector no of partition */ 1287c478bd9Sstevel@tonic-gate long p_size; /* # of blocks in partition */ 1297c478bd9Sstevel@tonic-gate }; 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate struct vtoc { 1327c478bd9Sstevel@tonic-gate unsigned long v_bootinfo[3]; /* info needed by mboot (unsupported) */ 1337c478bd9Sstevel@tonic-gate unsigned long v_sanity; /* to verify vtoc sanity */ 1347c478bd9Sstevel@tonic-gate unsigned long v_version; /* layout version */ 1357c478bd9Sstevel@tonic-gate char v_volume[LEN_DKL_VVOL]; /* volume name */ 1367c478bd9Sstevel@tonic-gate ushort_t v_sectorsz; /* sector size in bytes */ 1377c478bd9Sstevel@tonic-gate ushort_t v_nparts; /* number of partitions */ 1387c478bd9Sstevel@tonic-gate unsigned long v_reserved[10]; /* free space */ 1397c478bd9Sstevel@tonic-gate struct partition v_part[V_NUMPAR]; /* partition headers */ 1407c478bd9Sstevel@tonic-gate time_t timestamp[V_NUMPAR]; /* partition timestamp (unsupported) */ 1417c478bd9Sstevel@tonic-gate char v_asciilabel[LEN_DKL_ASCII]; /* for compatibility */ 1427c478bd9Sstevel@tonic-gate }; 1437c478bd9Sstevel@tonic-gate 144342440ecSPrasad Singamsetty struct extpartition { 145342440ecSPrasad Singamsetty ushort_t p_tag; /* ID tag of partition */ 146342440ecSPrasad Singamsetty ushort_t p_flag; /* permission flags */ 147342440ecSPrasad Singamsetty ushort_t p_pad[2]; 148342440ecSPrasad Singamsetty diskaddr_t p_start; /* start sector no of partition */ 149342440ecSPrasad Singamsetty diskaddr_t p_size; /* # of blocks in partition */ 150342440ecSPrasad Singamsetty }; 151342440ecSPrasad Singamsetty 152342440ecSPrasad Singamsetty 153342440ecSPrasad Singamsetty struct extvtoc { 154342440ecSPrasad Singamsetty uint64_t v_bootinfo[3]; /* info needed by mboot (unsupported) */ 155342440ecSPrasad Singamsetty uint64_t v_sanity; /* to verify vtoc sanity */ 156342440ecSPrasad Singamsetty uint64_t v_version; /* layout version */ 157342440ecSPrasad Singamsetty char v_volume[LEN_DKL_VVOL]; /* volume name */ 158342440ecSPrasad Singamsetty ushort_t v_sectorsz; /* sector size in bytes */ 159342440ecSPrasad Singamsetty ushort_t v_nparts; /* number of partitions */ 160342440ecSPrasad Singamsetty ushort_t pad[2]; 161342440ecSPrasad Singamsetty uint64_t v_reserved[10]; 162342440ecSPrasad Singamsetty struct extpartition v_part[V_NUMPAR]; /* partition headers */ 163342440ecSPrasad Singamsetty uint64_t timestamp[V_NUMPAR]; /* partition timestamp (unsupported) */ 164342440ecSPrasad Singamsetty char v_asciilabel[LEN_DKL_ASCII]; /* for compatibility */ 165342440ecSPrasad Singamsetty }; 166342440ecSPrasad Singamsetty 167342440ecSPrasad Singamsetty #ifdef _KERNEL 168342440ecSPrasad Singamsetty #define extvtoctovtoc(extv, v) \ 169342440ecSPrasad Singamsetty { \ 170342440ecSPrasad Singamsetty int i; \ 171342440ecSPrasad Singamsetty v.v_bootinfo[0] = (unsigned long)extv.v_bootinfo[0]; \ 172342440ecSPrasad Singamsetty v.v_bootinfo[1] = (unsigned long)extv.v_bootinfo[1]; \ 173342440ecSPrasad Singamsetty v.v_bootinfo[2] = (unsigned long)extv.v_bootinfo[2]; \ 174342440ecSPrasad Singamsetty v.v_sanity = (unsigned long)extv.v_sanity; \ 175342440ecSPrasad Singamsetty v.v_version = (unsigned long)extv.v_version; \ 176342440ecSPrasad Singamsetty bcopy(extv.v_volume, v.v_volume, LEN_DKL_VVOL); \ 177342440ecSPrasad Singamsetty v.v_sectorsz = extv.v_sectorsz; \ 178342440ecSPrasad Singamsetty v.v_nparts = extv.v_nparts; \ 179342440ecSPrasad Singamsetty for (i = 0; i < 10; i++) \ 180342440ecSPrasad Singamsetty v.v_reserved[i] = (unsigned long)extv.v_reserved[i]; \ 181342440ecSPrasad Singamsetty for (i = 0; i < V_NUMPAR; i++) { \ 182342440ecSPrasad Singamsetty v.v_part[i].p_tag = extv.v_part[i].p_tag; \ 183342440ecSPrasad Singamsetty v.v_part[i].p_flag = extv.v_part[i].p_flag; \ 184342440ecSPrasad Singamsetty v.v_part[i].p_start = (daddr_t)extv.v_part[i].p_start; \ 185342440ecSPrasad Singamsetty v.v_part[i].p_size = (long)extv.v_part[i].p_size; \ 1867e70b434SShidokht Yadegari v.timestamp[i] = (time_t)extv.timestamp[i]; \ 187342440ecSPrasad Singamsetty } \ 188342440ecSPrasad Singamsetty bcopy(extv.v_asciilabel, v.v_asciilabel, LEN_DKL_ASCII); \ 189342440ecSPrasad Singamsetty } 190342440ecSPrasad Singamsetty 191342440ecSPrasad Singamsetty #define vtoctoextvtoc(v, extv) \ 192342440ecSPrasad Singamsetty { \ 193342440ecSPrasad Singamsetty int i; \ 194342440ecSPrasad Singamsetty extv.v_bootinfo[0] = (uint64_t)v.v_bootinfo[0]; \ 195342440ecSPrasad Singamsetty extv.v_bootinfo[1] = (uint64_t)v.v_bootinfo[1]; \ 196342440ecSPrasad Singamsetty extv.v_bootinfo[2] = (uint64_t)v.v_bootinfo[2]; \ 197342440ecSPrasad Singamsetty extv.v_sanity = (uint64_t)v.v_sanity; \ 198342440ecSPrasad Singamsetty extv.v_version = (uint64_t)v.v_version; \ 199342440ecSPrasad Singamsetty bcopy(v.v_volume, extv.v_volume, LEN_DKL_VVOL); \ 200342440ecSPrasad Singamsetty extv.v_sectorsz = v.v_sectorsz; \ 201342440ecSPrasad Singamsetty extv.v_nparts = v.v_nparts; \ 202342440ecSPrasad Singamsetty for (i = 0; i < 10; i++) \ 203342440ecSPrasad Singamsetty extv.v_reserved[i] = (uint64_t)v.v_reserved[i]; \ 204342440ecSPrasad Singamsetty for (i = 0; i < V_NUMPAR; i++) { \ 205342440ecSPrasad Singamsetty extv.v_part[i].p_tag = v.v_part[i].p_tag; \ 206342440ecSPrasad Singamsetty extv.v_part[i].p_flag = v.v_part[i].p_flag; \ 207342440ecSPrasad Singamsetty extv.v_part[i].p_start = \ 208342440ecSPrasad Singamsetty (diskaddr_t)(unsigned long)v.v_part[i].p_start; \ 209342440ecSPrasad Singamsetty extv.v_part[i].p_size = \ 210342440ecSPrasad Singamsetty (diskaddr_t)(unsigned long)v.v_part[i].p_size; \ 211342440ecSPrasad Singamsetty extv.timestamp[i] = (uint64_t)v.timestamp[i]; \ 212342440ecSPrasad Singamsetty } \ 213342440ecSPrasad Singamsetty bcopy(v.v_asciilabel, extv.v_asciilabel, LEN_DKL_ASCII); \ 214342440ecSPrasad Singamsetty } 215342440ecSPrasad Singamsetty #endif /* _KERNEL */ 216342440ecSPrasad Singamsetty 2177c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32) 2187c478bd9Sstevel@tonic-gate struct partition32 { 2197c478bd9Sstevel@tonic-gate uint16_t p_tag; /* ID tag of partition */ 220342440ecSPrasad Singamsetty uint16_t p_flag; /* permission flags */ 2217c478bd9Sstevel@tonic-gate daddr32_t p_start; /* start sector no of partition */ 2227c478bd9Sstevel@tonic-gate int32_t p_size; /* # of blocks in partition */ 2237c478bd9Sstevel@tonic-gate }; 2247c478bd9Sstevel@tonic-gate 2257c478bd9Sstevel@tonic-gate struct vtoc32 { 2267c478bd9Sstevel@tonic-gate uint32_t v_bootinfo[3]; /* info needed by mboot (unsupported) */ 2277c478bd9Sstevel@tonic-gate uint32_t v_sanity; /* to verify vtoc sanity */ 2287c478bd9Sstevel@tonic-gate uint32_t v_version; /* layout version */ 2297c478bd9Sstevel@tonic-gate char v_volume[LEN_DKL_VVOL]; /* volume name */ 2307c478bd9Sstevel@tonic-gate uint16_t v_sectorsz; /* sector size in bytes */ 2317c478bd9Sstevel@tonic-gate uint16_t v_nparts; /* number of partitions */ 2327c478bd9Sstevel@tonic-gate uint32_t v_reserved[10]; /* free space */ 2337c478bd9Sstevel@tonic-gate struct partition32 v_part[V_NUMPAR]; /* partition headers */ 2347c478bd9Sstevel@tonic-gate time32_t timestamp[V_NUMPAR]; /* partition timestamp (unsupported) */ 2357c478bd9Sstevel@tonic-gate char v_asciilabel[LEN_DKL_ASCII]; /* for compatibility */ 2367c478bd9Sstevel@tonic-gate }; 2377c478bd9Sstevel@tonic-gate 2387c478bd9Sstevel@tonic-gate #define vtoc32tovtoc(v32, v) \ 2397c478bd9Sstevel@tonic-gate { \ 2407c478bd9Sstevel@tonic-gate int i; \ 2417c478bd9Sstevel@tonic-gate v.v_bootinfo[0] = v32.v_bootinfo[0]; \ 2427c478bd9Sstevel@tonic-gate v.v_bootinfo[1] = v32.v_bootinfo[1]; \ 2437c478bd9Sstevel@tonic-gate v.v_bootinfo[2] = v32.v_bootinfo[2]; \ 2447c478bd9Sstevel@tonic-gate v.v_sanity = v32.v_sanity; \ 2457c478bd9Sstevel@tonic-gate v.v_version = v32.v_version; \ 2467c478bd9Sstevel@tonic-gate bcopy(v32.v_volume, v.v_volume, LEN_DKL_VVOL); \ 2477c478bd9Sstevel@tonic-gate v.v_sectorsz = v32.v_sectorsz; \ 2487c478bd9Sstevel@tonic-gate v.v_nparts = v32.v_nparts; \ 2497c478bd9Sstevel@tonic-gate v.v_version = v32.v_version; \ 2507c478bd9Sstevel@tonic-gate for (i = 0; i < 10; i++) \ 2517c478bd9Sstevel@tonic-gate v.v_reserved[i] = v32.v_reserved[i]; \ 2527c478bd9Sstevel@tonic-gate for (i = 0; i < V_NUMPAR; i++) { \ 2537c478bd9Sstevel@tonic-gate v.v_part[i].p_tag = (ushort_t)v32.v_part[i].p_tag; \ 2547c478bd9Sstevel@tonic-gate v.v_part[i].p_flag = (ushort_t)v32.v_part[i].p_flag; \ 255342440ecSPrasad Singamsetty v.v_part[i].p_start = (unsigned)v32.v_part[i].p_start; \ 256342440ecSPrasad Singamsetty v.v_part[i].p_size = (unsigned)v32.v_part[i].p_size; \ 2577c478bd9Sstevel@tonic-gate } \ 2587c478bd9Sstevel@tonic-gate for (i = 0; i < V_NUMPAR; i++) \ 2597c478bd9Sstevel@tonic-gate v.timestamp[i] = (time_t)v32.timestamp[i]; \ 2607c478bd9Sstevel@tonic-gate bcopy(v32.v_asciilabel, v.v_asciilabel, LEN_DKL_ASCII); \ 2617c478bd9Sstevel@tonic-gate } 2627c478bd9Sstevel@tonic-gate 263342440ecSPrasad Singamsetty #define vtoc32toextvtoc(v32, extv) \ 264342440ecSPrasad Singamsetty { \ 265342440ecSPrasad Singamsetty int i; \ 266342440ecSPrasad Singamsetty extv.v_bootinfo[0] = v32.v_bootinfo[0]; \ 267342440ecSPrasad Singamsetty extv.v_bootinfo[1] = v32.v_bootinfo[1]; \ 268342440ecSPrasad Singamsetty extv.v_bootinfo[2] = v32.v_bootinfo[2]; \ 269342440ecSPrasad Singamsetty extv.v_sanity = v32.v_sanity; \ 270342440ecSPrasad Singamsetty extv.v_version = v32.v_version; \ 271342440ecSPrasad Singamsetty bcopy(v32.v_volume, extv.v_volume, LEN_DKL_VVOL); \ 272342440ecSPrasad Singamsetty extv.v_sectorsz = v32.v_sectorsz; \ 273342440ecSPrasad Singamsetty extv.v_nparts = v32.v_nparts; \ 274342440ecSPrasad Singamsetty extv.v_version = v32.v_version; \ 275342440ecSPrasad Singamsetty for (i = 0; i < 10; i++) \ 276342440ecSPrasad Singamsetty extv.v_reserved[i] = v32.v_reserved[i]; \ 277342440ecSPrasad Singamsetty for (i = 0; i < V_NUMPAR; i++) { \ 278342440ecSPrasad Singamsetty extv.v_part[i].p_tag = (ushort_t)v32.v_part[i].p_tag; \ 279342440ecSPrasad Singamsetty extv.v_part[i].p_flag = (ushort_t)v32.v_part[i].p_flag; \ 280342440ecSPrasad Singamsetty extv.v_part[i].p_start = (diskaddr_t)v32.v_part[i].p_start; \ 281342440ecSPrasad Singamsetty extv.v_part[i].p_size = (diskaddr_t)v32.v_part[i].p_size; \ 282342440ecSPrasad Singamsetty extv.timestamp[i] = (time_t)v32.timestamp[i]; \ 283342440ecSPrasad Singamsetty } \ 284342440ecSPrasad Singamsetty bcopy(v32.v_asciilabel, extv.v_asciilabel, LEN_DKL_ASCII); \ 285342440ecSPrasad Singamsetty } 286342440ecSPrasad Singamsetty 287342440ecSPrasad Singamsetty 2887c478bd9Sstevel@tonic-gate #define vtoctovtoc32(v, v32) \ 2897c478bd9Sstevel@tonic-gate { \ 2907c478bd9Sstevel@tonic-gate int i; \ 291406fc510SToomas Soome v32.v_bootinfo[0] = (uint32_t)v.v_bootinfo[0]; \ 292406fc510SToomas Soome v32.v_bootinfo[1] = (uint32_t)v.v_bootinfo[1]; \ 293406fc510SToomas Soome v32.v_bootinfo[2] = (uint32_t)v.v_bootinfo[2]; \ 294406fc510SToomas Soome v32.v_sanity = (uint32_t)v.v_sanity; \ 295406fc510SToomas Soome v32.v_version = (uint32_t)v.v_version; \ 2967c478bd9Sstevel@tonic-gate bcopy(v.v_volume, v32.v_volume, LEN_DKL_VVOL); \ 2977c478bd9Sstevel@tonic-gate v32.v_sectorsz = v.v_sectorsz; \ 2987c478bd9Sstevel@tonic-gate v32.v_nparts = v.v_nparts; \ 299406fc510SToomas Soome v32.v_version = (uint32_t)v.v_version; \ 3007c478bd9Sstevel@tonic-gate for (i = 0; i < 10; i++) \ 3017c478bd9Sstevel@tonic-gate v32.v_reserved[i] = v.v_reserved[i]; \ 3027c478bd9Sstevel@tonic-gate for (i = 0; i < V_NUMPAR; i++) { \ 3037c478bd9Sstevel@tonic-gate v32.v_part[i].p_tag = (ushort_t)v.v_part[i].p_tag; \ 3047c478bd9Sstevel@tonic-gate v32.v_part[i].p_flag = (ushort_t)v.v_part[i].p_flag; \ 305342440ecSPrasad Singamsetty v32.v_part[i].p_start = (unsigned)v.v_part[i].p_start; \ 306342440ecSPrasad Singamsetty v32.v_part[i].p_size = (unsigned)v.v_part[i].p_size; \ 3077c478bd9Sstevel@tonic-gate } \ 3087c478bd9Sstevel@tonic-gate for (i = 0; i < V_NUMPAR; i++) { \ 3097c478bd9Sstevel@tonic-gate if (v.timestamp[i] > TIME32_MAX) \ 3107c478bd9Sstevel@tonic-gate v32.timestamp[i] = TIME32_MAX; \ 3117c478bd9Sstevel@tonic-gate else \ 3127c478bd9Sstevel@tonic-gate v32.timestamp[i] = (time32_t)v.timestamp[i]; \ 3137c478bd9Sstevel@tonic-gate } \ 3147c478bd9Sstevel@tonic-gate bcopy(v.v_asciilabel, v32.v_asciilabel, LEN_DKL_ASCII); \ 3157c478bd9Sstevel@tonic-gate } 3167c478bd9Sstevel@tonic-gate 317342440ecSPrasad Singamsetty #define extvtoctovtoc32(extv, v32) \ 318342440ecSPrasad Singamsetty { \ 319342440ecSPrasad Singamsetty int i; \ 320342440ecSPrasad Singamsetty v32.v_bootinfo[0] = extv.v_bootinfo[0]; \ 321342440ecSPrasad Singamsetty v32.v_bootinfo[1] = extv.v_bootinfo[1]; \ 322342440ecSPrasad Singamsetty v32.v_bootinfo[2] = extv.v_bootinfo[2]; \ 323342440ecSPrasad Singamsetty v32.v_sanity = extv.v_sanity; \ 324342440ecSPrasad Singamsetty v32.v_version = extv.v_version; \ 325342440ecSPrasad Singamsetty bcopy(extv.v_volume, v32.v_volume, LEN_DKL_VVOL); \ 326342440ecSPrasad Singamsetty v32.v_sectorsz = extv.v_sectorsz; \ 327342440ecSPrasad Singamsetty v32.v_nparts = extv.v_nparts; \ 328342440ecSPrasad Singamsetty v32.v_version = extv.v_version; \ 329342440ecSPrasad Singamsetty for (i = 0; i < 10; i++) \ 330342440ecSPrasad Singamsetty v32.v_reserved[i] = extv.v_reserved[i]; \ 331342440ecSPrasad Singamsetty for (i = 0; i < V_NUMPAR; i++) { \ 332342440ecSPrasad Singamsetty v32.v_part[i].p_tag = (ushort_t)extv.v_part[i].p_tag; \ 333342440ecSPrasad Singamsetty v32.v_part[i].p_flag = (ushort_t)extv.v_part[i].p_flag; \ 334342440ecSPrasad Singamsetty v32.v_part[i].p_start = (unsigned)extv.v_part[i].p_start; \ 335342440ecSPrasad Singamsetty v32.v_part[i].p_size = (unsigned)extv.v_part[i].p_size; \ 336342440ecSPrasad Singamsetty } \ 337342440ecSPrasad Singamsetty for (i = 0; i < V_NUMPAR; i++) { \ 338342440ecSPrasad Singamsetty if (extv.timestamp[i] > TIME32_MAX) \ 339342440ecSPrasad Singamsetty v32.timestamp[i] = TIME32_MAX; \ 340342440ecSPrasad Singamsetty else \ 341342440ecSPrasad Singamsetty v32.timestamp[i] = (time32_t)extv.timestamp[i]; \ 342342440ecSPrasad Singamsetty } \ 343342440ecSPrasad Singamsetty bcopy(extv.v_asciilabel, v32.v_asciilabel, LEN_DKL_ASCII); \ 344342440ecSPrasad Singamsetty } 345342440ecSPrasad Singamsetty 346342440ecSPrasad Singamsetty 3477c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */ 3487c478bd9Sstevel@tonic-gate 3497c478bd9Sstevel@tonic-gate /* 3507c478bd9Sstevel@tonic-gate * These defines are the mode parameter for the checksum routines. 3517c478bd9Sstevel@tonic-gate */ 3527c478bd9Sstevel@tonic-gate #define CK_CHECKSUM 0 /* check checksum */ 3537c478bd9Sstevel@tonic-gate #define CK_MAKESUM 1 /* generate checksum */ 3547c478bd9Sstevel@tonic-gate 3557c478bd9Sstevel@tonic-gate extern int read_vtoc(int, struct vtoc *); 3567c478bd9Sstevel@tonic-gate extern int write_vtoc(int, struct vtoc *); 357342440ecSPrasad Singamsetty extern int read_extvtoc(int, struct extvtoc *); 358342440ecSPrasad Singamsetty extern int write_extvtoc(int, struct extvtoc *); 3597c478bd9Sstevel@tonic-gate 3607c478bd9Sstevel@tonic-gate #ifdef __cplusplus 3617c478bd9Sstevel@tonic-gate } 3627c478bd9Sstevel@tonic-gate #endif 3637c478bd9Sstevel@tonic-gate 3647c478bd9Sstevel@tonic-gate #endif /* _SYS_VTOC_H */ 365