186d7f5d3SJohn Marino /* $NetBSD: layout.h,v 1.1.1.1 2008/12/22 00:18:17 haad Exp $ */ 286d7f5d3SJohn Marino 386d7f5d3SJohn Marino /* 486d7f5d3SJohn Marino * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. 586d7f5d3SJohn Marino * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. 686d7f5d3SJohn Marino * 786d7f5d3SJohn Marino * This file is part of LVM2. 886d7f5d3SJohn Marino * 986d7f5d3SJohn Marino * This copyrighted material is made available to anyone wishing to use, 1086d7f5d3SJohn Marino * modify, copy, or redistribute it subject to the terms and conditions 1186d7f5d3SJohn Marino * of the GNU Lesser General Public License v.2.1. 1286d7f5d3SJohn Marino * 1386d7f5d3SJohn Marino * You should have received a copy of the GNU Lesser General Public License 1486d7f5d3SJohn Marino * along with this program; if not, write to the Free Software Foundation, 1586d7f5d3SJohn Marino * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 1686d7f5d3SJohn Marino */ 1786d7f5d3SJohn Marino 1886d7f5d3SJohn Marino #ifndef _LVM_TEXT_LAYOUT_H 1986d7f5d3SJohn Marino #define _LVM_TEXT_LAYOUT_H 2086d7f5d3SJohn Marino 2186d7f5d3SJohn Marino #include "config.h" 2286d7f5d3SJohn Marino #include "lvm-types.h" 2386d7f5d3SJohn Marino #include "metadata.h" 2486d7f5d3SJohn Marino #include "uuid.h" 2586d7f5d3SJohn Marino 2686d7f5d3SJohn Marino /* On disk */ 2786d7f5d3SJohn Marino struct disk_locn { 2886d7f5d3SJohn Marino uint64_t offset; /* Offset in bytes to start sector */ 2986d7f5d3SJohn Marino uint64_t size; /* Bytes */ 3086d7f5d3SJohn Marino } __attribute__ ((packed)); 3186d7f5d3SJohn Marino 3286d7f5d3SJohn Marino /* Data areas (holding PEs) */ 3386d7f5d3SJohn Marino struct data_area_list { 3486d7f5d3SJohn Marino struct dm_list list; 3586d7f5d3SJohn Marino struct disk_locn disk_locn; 3686d7f5d3SJohn Marino }; 3786d7f5d3SJohn Marino 3886d7f5d3SJohn Marino /* Fields with the suffix _xl should be xlate'd wherever they appear */ 3986d7f5d3SJohn Marino /* On disk */ 4086d7f5d3SJohn Marino struct pv_header { 4186d7f5d3SJohn Marino int8_t pv_uuid[ID_LEN]; 4286d7f5d3SJohn Marino 4386d7f5d3SJohn Marino /* This size can be overridden if PV belongs to a VG */ 4486d7f5d3SJohn Marino uint64_t device_size_xl; /* Bytes */ 4586d7f5d3SJohn Marino 4686d7f5d3SJohn Marino /* NULL-terminated list of data areas followed by */ 4786d7f5d3SJohn Marino /* NULL-terminated list of metadata area headers */ 4886d7f5d3SJohn Marino struct disk_locn disk_areas_xl[0]; /* Two lists */ 4986d7f5d3SJohn Marino } __attribute__ ((packed)); 5086d7f5d3SJohn Marino 5186d7f5d3SJohn Marino /* On disk */ 5286d7f5d3SJohn Marino struct raw_locn { 5386d7f5d3SJohn Marino uint64_t offset; /* Offset in bytes to start sector */ 5486d7f5d3SJohn Marino uint64_t size; /* Bytes */ 5586d7f5d3SJohn Marino uint32_t checksum; 5686d7f5d3SJohn Marino uint32_t filler; 5786d7f5d3SJohn Marino } __attribute__ ((packed)); 5886d7f5d3SJohn Marino 5986d7f5d3SJohn Marino /* On disk */ 6086d7f5d3SJohn Marino /* Structure size limited to one sector */ 6186d7f5d3SJohn Marino struct mda_header { 6286d7f5d3SJohn Marino uint32_t checksum_xl; /* Checksum of rest of mda_header */ 6386d7f5d3SJohn Marino int8_t magic[16]; /* To aid scans for metadata */ 6486d7f5d3SJohn Marino uint32_t version; 6586d7f5d3SJohn Marino uint64_t start; /* Absolute start byte of mda_header */ 6686d7f5d3SJohn Marino uint64_t size; /* Size of metadata area */ 6786d7f5d3SJohn Marino 6886d7f5d3SJohn Marino struct raw_locn raw_locns[0]; /* NULL-terminated list */ 6986d7f5d3SJohn Marino } __attribute__ ((packed)); 7086d7f5d3SJohn Marino 7186d7f5d3SJohn Marino struct mda_lists { 7286d7f5d3SJohn Marino struct dm_list dirs; 7386d7f5d3SJohn Marino struct dm_list raws; 7486d7f5d3SJohn Marino struct metadata_area_ops *file_ops; 7586d7f5d3SJohn Marino struct metadata_area_ops *raw_ops; 7686d7f5d3SJohn Marino }; 7786d7f5d3SJohn Marino 7886d7f5d3SJohn Marino struct mda_context { 7986d7f5d3SJohn Marino struct device_area area; 8086d7f5d3SJohn Marino uint64_t free_sectors; 8186d7f5d3SJohn Marino struct raw_locn rlocn; /* Store inbetween write and commit */ 8286d7f5d3SJohn Marino }; 8386d7f5d3SJohn Marino 8486d7f5d3SJohn Marino /* FIXME Convert this at runtime */ 8586d7f5d3SJohn Marino #define FMTT_MAGIC "\040\114\126\115\062\040\170\133\065\101\045\162\060\116\052\076" 8686d7f5d3SJohn Marino #define FMTT_VERSION 1 8786d7f5d3SJohn Marino #define MDA_HEADER_SIZE 512 8886d7f5d3SJohn Marino #define LVM2_LABEL "LVM2 001" 8986d7f5d3SJohn Marino #define MDA_SIZE_MIN (8 * (unsigned) lvm_getpagesize()) 9086d7f5d3SJohn Marino 9186d7f5d3SJohn Marino #endif 92