/*- * Copyright (c) 2011 Andrey V. Elsukov * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD$ */ #ifndef _GEOM_VDI_H_ #define _GEOM_VDI_H_ #define G_VDI_SIGNATURE 0xbeda107f #define G_VDI_VERSION 0x00010001 #define G_VDI_COMMENT_SIZE 256 #define G_VDI_SECTOR_SIZE 512 #define G_VDI_BLOCK_SIZE 0x00100000 #define G_VDI_FREE_BLOCK ((uint32_t)~0) #define G_VDI_ZERO_BLOCK ((uint32_t)~1) #define DEB(...) if (bootverbose != 0) { \ printf("GEOM_VDI: " __VA_ARGS__); \ } enum g_vdi_type { G_VDI_T_NORMAL = 1, /* Dynamically growing image file. */ G_VDI_T_FIXED, /* Preallocated fixed size image file. */ G_VDI_T_UNDO, /* G_VDI_T_NORMAL with undo/commit support. */ G_VDI_T_DIFF, /* G_VDI_T_NORMAL with differencing support. */ }; struct g_vdi_geometry { uint32_t cylinders; uint32_t heads; uint32_t sectors; uint32_t sectorsize; }; struct g_vdi_header { uint32_t size; /* Header size in bytes. */ uint32_t type; /* Image type. */ uint32_t flags; /* Image flags. */ char comment[G_VDI_COMMENT_SIZE]; uint32_t blocks_offset; /* Offset of blocks array in bytes. */ uint32_t data_offset; /* Offset of image data in bytes. */ struct g_vdi_geometry legacy_geometry; /* Legacy image geometry. */ uint32_t dummy0; /* Not used. */ uint64_t mediasize; /* Disk size in bytes. */ uint32_t blocksize; /* Block size in bytes. */ uint32_t block_extrasize; /* Size of additional information of every block. */ uint32_t blocks; /* Number of blocks. */ uint32_t blocks_allocated; /* Number of allocated blocks. */ uint8_t uuid_create[16]; /* UUID of image. */ uint8_t uuid_modify[16]; /* UUID of last modification. */ uint8_t uuid_primary[16]; /* UUID of primary image. */ uint8_t uuid_primary_modify[16]; /* UUID of primary image's last modification. */ }; struct g_vdi_metadata { char md_finfo[64]; /* Text info about image. */ uint32_t md_signature; /* The image signature. */ uint32_t md_version; /* The image version. */ struct g_vdi_header md_header; }; #endif /* !_GEOM_VDI_H_ */