xref: /dflybsd-src/contrib/lvm2/dist/lib/format_text/layout.h (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
1*86d7f5d3SJohn Marino /*	$NetBSD: layout.h,v 1.1.1.1 2008/12/22 00:18:17 haad Exp $	*/
2*86d7f5d3SJohn Marino 
3*86d7f5d3SJohn Marino /*
4*86d7f5d3SJohn Marino  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
5*86d7f5d3SJohn Marino  * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
6*86d7f5d3SJohn Marino  *
7*86d7f5d3SJohn Marino  * This file is part of LVM2.
8*86d7f5d3SJohn Marino  *
9*86d7f5d3SJohn Marino  * This copyrighted material is made available to anyone wishing to use,
10*86d7f5d3SJohn Marino  * modify, copy, or redistribute it subject to the terms and conditions
11*86d7f5d3SJohn Marino  * of the GNU Lesser General Public License v.2.1.
12*86d7f5d3SJohn Marino  *
13*86d7f5d3SJohn Marino  * You should have received a copy of the GNU Lesser General Public License
14*86d7f5d3SJohn Marino  * along with this program; if not, write to the Free Software Foundation,
15*86d7f5d3SJohn Marino  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16*86d7f5d3SJohn Marino  */
17*86d7f5d3SJohn Marino 
18*86d7f5d3SJohn Marino #ifndef _LVM_TEXT_LAYOUT_H
19*86d7f5d3SJohn Marino #define _LVM_TEXT_LAYOUT_H
20*86d7f5d3SJohn Marino 
21*86d7f5d3SJohn Marino #include "config.h"
22*86d7f5d3SJohn Marino #include "lvm-types.h"
23*86d7f5d3SJohn Marino #include "metadata.h"
24*86d7f5d3SJohn Marino #include "uuid.h"
25*86d7f5d3SJohn Marino 
26*86d7f5d3SJohn Marino /* On disk */
27*86d7f5d3SJohn Marino struct disk_locn {
28*86d7f5d3SJohn Marino 	uint64_t offset;	/* Offset in bytes to start sector */
29*86d7f5d3SJohn Marino 	uint64_t size;		/* Bytes */
30*86d7f5d3SJohn Marino } __attribute__ ((packed));
31*86d7f5d3SJohn Marino 
32*86d7f5d3SJohn Marino /* Data areas (holding PEs) */
33*86d7f5d3SJohn Marino struct data_area_list {
34*86d7f5d3SJohn Marino 	struct dm_list list;
35*86d7f5d3SJohn Marino 	struct disk_locn disk_locn;
36*86d7f5d3SJohn Marino };
37*86d7f5d3SJohn Marino 
38*86d7f5d3SJohn Marino /* Fields with the suffix _xl should be xlate'd wherever they appear */
39*86d7f5d3SJohn Marino /* On disk */
40*86d7f5d3SJohn Marino struct pv_header {
41*86d7f5d3SJohn Marino 	int8_t pv_uuid[ID_LEN];
42*86d7f5d3SJohn Marino 
43*86d7f5d3SJohn Marino 	/* This size can be overridden if PV belongs to a VG */
44*86d7f5d3SJohn Marino 	uint64_t device_size_xl;	/* Bytes */
45*86d7f5d3SJohn Marino 
46*86d7f5d3SJohn Marino 	/* NULL-terminated list of data areas followed by */
47*86d7f5d3SJohn Marino 	/* NULL-terminated list of metadata area headers */
48*86d7f5d3SJohn Marino 	struct disk_locn disk_areas_xl[0];	/* Two lists */
49*86d7f5d3SJohn Marino } __attribute__ ((packed));
50*86d7f5d3SJohn Marino 
51*86d7f5d3SJohn Marino /* On disk */
52*86d7f5d3SJohn Marino struct raw_locn {
53*86d7f5d3SJohn Marino 	uint64_t offset;	/* Offset in bytes to start sector */
54*86d7f5d3SJohn Marino 	uint64_t size;		/* Bytes */
55*86d7f5d3SJohn Marino 	uint32_t checksum;
56*86d7f5d3SJohn Marino 	uint32_t filler;
57*86d7f5d3SJohn Marino } __attribute__ ((packed));
58*86d7f5d3SJohn Marino 
59*86d7f5d3SJohn Marino /* On disk */
60*86d7f5d3SJohn Marino /* Structure size limited to one sector */
61*86d7f5d3SJohn Marino struct mda_header {
62*86d7f5d3SJohn Marino 	uint32_t checksum_xl;	/* Checksum of rest of mda_header */
63*86d7f5d3SJohn Marino 	int8_t magic[16];	/* To aid scans for metadata */
64*86d7f5d3SJohn Marino 	uint32_t version;
65*86d7f5d3SJohn Marino 	uint64_t start;		/* Absolute start byte of mda_header */
66*86d7f5d3SJohn Marino 	uint64_t size;		/* Size of metadata area */
67*86d7f5d3SJohn Marino 
68*86d7f5d3SJohn Marino 	struct raw_locn raw_locns[0];	/* NULL-terminated list */
69*86d7f5d3SJohn Marino } __attribute__ ((packed));
70*86d7f5d3SJohn Marino 
71*86d7f5d3SJohn Marino struct mda_lists {
72*86d7f5d3SJohn Marino 	struct dm_list dirs;
73*86d7f5d3SJohn Marino 	struct dm_list raws;
74*86d7f5d3SJohn Marino 	struct metadata_area_ops *file_ops;
75*86d7f5d3SJohn Marino 	struct metadata_area_ops *raw_ops;
76*86d7f5d3SJohn Marino };
77*86d7f5d3SJohn Marino 
78*86d7f5d3SJohn Marino struct mda_context {
79*86d7f5d3SJohn Marino 	struct device_area area;
80*86d7f5d3SJohn Marino 	uint64_t free_sectors;
81*86d7f5d3SJohn Marino 	struct raw_locn rlocn;	/* Store inbetween write and commit */
82*86d7f5d3SJohn Marino };
83*86d7f5d3SJohn Marino 
84*86d7f5d3SJohn Marino /* FIXME Convert this at runtime */
85*86d7f5d3SJohn Marino #define FMTT_MAGIC "\040\114\126\115\062\040\170\133\065\101\045\162\060\116\052\076"
86*86d7f5d3SJohn Marino #define FMTT_VERSION 1
87*86d7f5d3SJohn Marino #define MDA_HEADER_SIZE 512
88*86d7f5d3SJohn Marino #define LVM2_LABEL "LVM2 001"
89*86d7f5d3SJohn Marino #define MDA_SIZE_MIN (8 * (unsigned) lvm_getpagesize())
90*86d7f5d3SJohn Marino 
91*86d7f5d3SJohn Marino #endif
92