1172302Spjd/*- 2172302Spjd * Copyright (c) 2005 Ivan Voras <ivoras@gmail.com> 3172302Spjd * All rights reserved. 4172302Spjd * 5172302Spjd * Redistribution and use in source and binary forms, with or without 6172302Spjd * modification, are permitted provided that the following conditions 7172302Spjd * are met: 8172302Spjd * 1. Redistributions of source code must retain the above copyright 9172302Spjd * notice, this list of conditions and the following disclaimer. 10172302Spjd * 2. Redistributions in binary form must reproduce the above copyright 11172302Spjd * notice, this list of conditions and the following disclaimer in the 12172302Spjd * documentation and/or other materials provided with the distribution. 13172302Spjd * 14172302Spjd * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 15172302Spjd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16172302Spjd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17172302Spjd * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE 18172302Spjd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19172302Spjd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20172302Spjd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21172302Spjd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22172302Spjd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23172302Spjd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24172302Spjd * SUCH DAMAGE. 25172302Spjd * 26172302Spjd * $FreeBSD$ 27172302Spjd */ 28172302Spjd 29172302Spjd 30172302Spjd#ifndef _G_VIRSTOR_MD_H_ 31172302Spjd#define _G_VIRSTOR_MD_H_ 32172302Spjd 33172302Spjd/* 34172302Spjd * Metadata declaration 35172302Spjd */ 36172302Spjd 37172302Spjd#define G_VIRSTOR_MAGIC "GEOM::VIRSTOR" 38172302Spjd#define G_VIRSTOR_VERSION 1 39172302Spjd 40172302Spjd/* flag: provider is allocated */ 41172302Spjd#define VIRSTOR_PROVIDER_ALLOCATED 1 42172302Spjd/* flag: provider is currently being filled (usually it's the last 43172302Spjd * provider with VIRSTOR_PROVIDER_ALLOCATED flag */ 44172302Spjd#define VIRSTOR_PROVIDER_CURRENT 2 45172302Spjd 46172302Spjdstruct g_virstor_metadata { 47172302Spjd /* Data global to the virstor device */ 48172302Spjd char md_magic[16]; /* Magic value. */ 49172302Spjd uint32_t md_version; /* Version number. */ 50172302Spjd char md_name[16]; /* Device name (e.g. "mydata") */ 51172302Spjd uint32_t md_id; /* Unique ID. */ 52172302Spjd uint64_t md_virsize; /* Virtual device's size */ 53172302Spjd uint32_t md_chunk_size; /* Chunk size in bytes */ 54172302Spjd uint16_t md_count; /* Total number of providers */ 55172302Spjd 56172302Spjd /* Data local to this provider */ 57172302Spjd char provider[16]; /* Hardcoded provider name */ 58172302Spjd uint16_t no; /* Provider number/index */ 59172302Spjd uint64_t provsize; /* Provider's size */ 60172302Spjd uint32_t chunk_count; /* Number of chunks in this pr. */ 61172302Spjd uint32_t chunk_next; /* Next chunk to allocate */ 62172302Spjd uint16_t chunk_reserved; /* Count of "reserved" chunks */ 63172302Spjd uint16_t flags; /* Provider's flags */ 64172302Spjd}; 65172302Spjd 66172302Spjdvoid virstor_metadata_encode(struct g_virstor_metadata *md, unsigned char *data); 67172302Spjdvoid virstor_metadata_decode(unsigned char *data, struct g_virstor_metadata *md); 68172302Spjd 69172302Spjd#endif /* !_G_VIRSTOR_H_ */ 70