1176417Sthompsa/*- 2176417Sthompsa * Copyright (c) 2008 Andrew Thompson <thompsa@FreeBSD.org> 3176417Sthompsa * All rights reserved. 4176417Sthompsa * 5176417Sthompsa * Redistribution and use in source and binary forms, with or without 6176417Sthompsa * modification, are permitted provided that the following conditions 7176417Sthompsa * are met: 8176417Sthompsa * 1. Redistributions of source code must retain the above copyright 9176417Sthompsa * notice, this list of conditions and the following disclaimer. 10176417Sthompsa * 2. Redistributions in binary form must reproduce the above copyright 11176417Sthompsa * notice, this list of conditions and the following disclaimer in the 12176417Sthompsa * documentation and/or other materials provided with the distribution. 13176417Sthompsa * 14176417Sthompsa * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 15176417Sthompsa * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16176417Sthompsa * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17176417Sthompsa * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE 18176417Sthompsa * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19176417Sthompsa * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20176417Sthompsa * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21176417Sthompsa * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22176417Sthompsa * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23176417Sthompsa * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24176417Sthompsa * SUCH DAMAGE. 25176417Sthompsa * 26176417Sthompsa * $FreeBSD$ 27176417Sthompsa */ 28176417Sthompsa 29176417Sthompsa#define G_LLVM_DEBUG(lvl, ...) do { \ 30176417Sthompsa if (g_llvm_debug >= (lvl)) { \ 31176417Sthompsa printf("GEOM_LINUX_LVM"); \ 32176417Sthompsa if (g_llvm_debug > 0) \ 33176417Sthompsa printf("[%u]", lvl); \ 34176417Sthompsa printf(": "); \ 35176417Sthompsa printf(__VA_ARGS__); \ 36176417Sthompsa printf("\n"); \ 37176417Sthompsa } \ 38176417Sthompsa} while (0) 39176417Sthompsa 40176417Sthompsa#define G_LLVM_CLASS_NAME "LINUX_LVM" 41176417Sthompsa#define G_LLVM_NAMELEN 128 42176417Sthompsa#define G_LLVM_UUIDLEN 40 43176417Sthompsa#define G_LLVM_MAGIC "\040\114\126\115\062\040\170\133" \ 44176417Sthompsa "\065\101\045\162\060\116\052\076" 45176417Sthompsa 46176417Sthompsastruct g_llvm_label { 47176417Sthompsa uint64_t ll_sector; 48176417Sthompsa uint32_t ll_crc; 49176417Sthompsa uint32_t ll_offset; 50176417Sthompsa char ll_uuid[G_LLVM_UUIDLEN]; 51176417Sthompsa uint64_t ll_size; 52176417Sthompsa uint64_t ll_pestart; 53176417Sthompsa uint64_t ll_md_offset; 54176417Sthompsa uint64_t ll_md_size; 55176417Sthompsa}; 56176417Sthompsa 57176417Sthompsastruct g_llvm_metadata { 58176417Sthompsa uint32_t md_csum; 59176417Sthompsa uint32_t md_version; 60176417Sthompsa uint64_t md_start; 61176417Sthompsa uint64_t md_size; 62176417Sthompsa uint64_t md_reloffset; 63176417Sthompsa uint64_t md_relsize; 64176417Sthompsa struct g_llvm_vg *md_vg; 65176417Sthompsa}; 66176417Sthompsa 67176417Sthompsastruct g_llvm_lv { 68176417Sthompsa LIST_ENTRY(g_llvm_lv) lv_next; 69176417Sthompsa struct g_llvm_vg *lv_vg; 70176417Sthompsa char lv_name[G_LLVM_NAMELEN]; 71176417Sthompsa char lv_uuid[G_LLVM_UUIDLEN]; 72176417Sthompsa int lv_sgcount; 73176417Sthompsa int lv_sgactive; 74176417Sthompsa struct g_provider *lv_gprov; 75176417Sthompsa int lv_extentcount; 76176417Sthompsa LIST_HEAD(, g_llvm_segment) lv_segs; 77176417Sthompsa int lv_numsegs; 78176417Sthompsa struct g_llvm_segment *lv_firstsg; 79176417Sthompsa}; 80176417Sthompsa 81176417Sthompsastruct g_llvm_pv { 82176417Sthompsa LIST_ENTRY(g_llvm_pv) pv_next; 83176417Sthompsa struct g_llvm_vg *pv_vg; 84176417Sthompsa char pv_name[G_LLVM_NAMELEN]; 85176417Sthompsa char pv_uuid[G_LLVM_UUIDLEN]; 86176417Sthompsa size_t pv_size; 87176417Sthompsa off_t pv_start; 88176417Sthompsa int pv_count; 89176417Sthompsa struct g_provider *pv_gprov; 90176417Sthompsa struct g_consumer *pv_gcons; 91176417Sthompsa}; 92176417Sthompsa 93176417Sthompsastruct g_llvm_segment { 94176417Sthompsa LIST_ENTRY(g_llvm_segment) sg_next; 95176417Sthompsa int sg_start; 96176417Sthompsa int sg_end; 97176417Sthompsa int sg_count; 98176417Sthompsa char sg_pvname[G_LLVM_NAMELEN]; 99176417Sthompsa struct g_llvm_pv *sg_pv; 100176417Sthompsa int sg_pvstart; 101176417Sthompsa off_t sg_pvoffset; 102176417Sthompsa}; 103176417Sthompsa 104176417Sthompsastruct g_llvm_vg { 105176417Sthompsa LIST_ENTRY(g_llvm_vg) vg_next; 106176417Sthompsa char vg_name[G_LLVM_NAMELEN]; 107176417Sthompsa char vg_uuid[G_LLVM_UUIDLEN]; 108176417Sthompsa size_t vg_extentsize; 109176417Sthompsa int vg_sectorsize; 110176417Sthompsa struct g_geom *vg_geom; 111176417Sthompsa LIST_HEAD(, g_llvm_pv) vg_pvs; 112176417Sthompsa LIST_HEAD(, g_llvm_lv) vg_lvs; 113176417Sthompsa}; 114