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