150477Speter/*- 235388Smjacob * Copyright (c) 2005 Ivan Voras <ivoras@gmail.com> 335388Smjacob * All rights reserved. 435388Smjacob * 566189Smjacob * Redistribution and use in source and binary forms, with or without 635388Smjacob * modification, are permitted provided that the following conditions 752347Smjacob * are met: 835388Smjacob * 1. Redistributions of source code must retain the above copyright 935388Smjacob * notice, this list of conditions and the following disclaimer. 1035388Smjacob * 2. Redistributions in binary form must reproduce the above copyright 1135388Smjacob * notice, this list of conditions and the following disclaimer in the 1235388Smjacob * documentation and/or other materials provided with the distribution. 1335388Smjacob * 1466189Smjacob * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 1535388Smjacob * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1635388Smjacob * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1735388Smjacob * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE 1835388Smjacob * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1935388Smjacob * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2035388Smjacob * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2135388Smjacob * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2235388Smjacob * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2335388Smjacob * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2435388Smjacob * SUCH DAMAGE. 2535388Smjacob * 2635388Smjacob * $FreeBSD$ 2735388Smjacob */ 2835388Smjacob 2935388Smjacob 3035388Smjacob#ifndef _G_VIRSTOR_MD_H_ 3135388Smjacob#define _G_VIRSTOR_MD_H_ 3235388Smjacob 3335388Smjacob/* 3444819Smjacob * Metadata declaration 3535388Smjacob */ 3653487Smjacob 3753487Smjacob#define G_VIRSTOR_MAGIC "GEOM::VIRSTOR" 3856004Smjacob#define G_VIRSTOR_VERSION 1 3935388Smjacob 4053487Smjacob/* flag: provider is allocated */ 4135388Smjacob#define VIRSTOR_PROVIDER_ALLOCATED 1 4235388Smjacob/* flag: provider is currently being filled (usually it's the last 4353487Smjacob * provider with VIRSTOR_PROVIDER_ALLOCATED flag */ 4453487Smjacob#define VIRSTOR_PROVIDER_CURRENT 2 4556004Smjacob 4635388Smjacobstruct g_virstor_metadata { 4753487Smjacob /* Data global to the virstor device */ 4835388Smjacob char md_magic[16]; /* Magic value. */ 4942131Smjacob uint32_t md_version; /* Version number. */ 5053487Smjacob char md_name[16]; /* Device name (e.g. "mydata") */ 5153487Smjacob uint32_t md_id; /* Unique ID. */ 5256004Smjacob uint64_t md_virsize; /* Virtual device's size */ 5335388Smjacob uint32_t md_chunk_size; /* Chunk size in bytes */ 5453487Smjacob uint16_t md_count; /* Total number of providers */ 5535388Smjacob 5664087Smjacob /* Data local to this provider */ 5764087Smjacob char provider[16]; /* Hardcoded provider name */ 5839235Sgibbs uint16_t no; /* Provider number/index */ 5935388Smjacob uint64_t provsize; /* Provider's size */ 6043420Smjacob uint32_t chunk_count; /* Number of chunks in this pr. */ 6135388Smjacob uint32_t chunk_next; /* Next chunk to allocate */ 6235388Smjacob uint16_t chunk_reserved; /* Count of "reserved" chunks */ 6335388Smjacob uint16_t flags; /* Provider's flags */ 6435388Smjacob}; 6535388Smjacob 6635388Smjacobvoid virstor_metadata_encode(struct g_virstor_metadata *md, unsigned char *data); 6735388Smjacobvoid virstor_metadata_decode(unsigned char *data, struct g_virstor_metadata *md); 6864087Smjacob 6935388Smjacob#endif /* !_G_VIRSTOR_H_ */ 7064087Smjacob