1
/* lvm.h - On disk structures for LVM. */
3
* GRUB -- GRand Unified Bootloader
4
* Copyright (C) 2006 Free Software Foundation, Inc.
6
* GRUB is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with GRUB; if not, write to the Free Software
18
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24
#include <grub/types.h>
26
/* Length of ID string, excluding terminating zero. */
27
#define GRUB_LVM_ID_STRLEN 38
30
char id[GRUB_LVM_ID_STRLEN+1];
33
struct grub_lvm_pv *pvs;
34
struct grub_lvm_lv *lvs;
35
struct grub_lvm_vg *next;
39
char id[GRUB_LVM_ID_STRLEN+1];
42
int start; /* Sector number where the data area starts. */
43
struct grub_lvm_pv *next;
49
unsigned int segment_count;
51
struct grub_lvm_segment *segments; /* Pointer to segment_count segments. */
52
struct grub_lvm_vg *vg;
53
struct grub_lvm_lv *next;
56
struct grub_lvm_segment {
57
unsigned int start_extent;
58
unsigned int extent_count;
59
unsigned int stripe_count;
60
unsigned int stripe_size;
61
struct grub_lvm_stripe *stripes; /* Pointer to stripe_count stripes. */
64
struct grub_lvm_stripe {
66
struct grub_lvm_pv *pv;
69
#define GRUB_LVM_LABEL_SIZE GRUB_DISK_SECTOR_SIZE
70
#define GRUB_LVM_LABEL_SCAN_SECTORS 4L
72
#define GRUB_LVM_LABEL_ID "LABELONE"
73
#define GRUB_LVM_LVM2_LABEL "LVM2 001"
75
#define GRUB_LVM_ID_LEN 32
77
/* On disk - 32 bytes */
78
struct grub_lvm_label_header {
79
grub_int8_t id[8]; /* LABELONE */
80
grub_uint64_t sector_xl; /* Sector number of this label */
81
grub_uint32_t crc_xl; /* From next field to end of sector */
82
grub_uint32_t offset_xl; /* Offset from start of struct to contents */
83
grub_int8_t type[8]; /* LVM2 001 */
84
} __attribute__ ((packed));
87
struct grub_lvm_disk_locn {
88
grub_uint64_t offset; /* Offset in bytes to start sector */
89
grub_uint64_t size; /* Bytes */
90
} __attribute__ ((packed));
92
/* Fields with the suffix _xl should be xlate'd wherever they appear */
94
struct grub_lvm_pv_header {
95
grub_int8_t pv_uuid[GRUB_LVM_ID_LEN];
97
/* This size can be overridden if PV belongs to a VG */
98
grub_uint64_t device_size_xl; /* Bytes */
100
/* NULL-terminated list of data areas followed by */
101
/* NULL-terminated list of metadata area headers */
102
struct grub_lvm_disk_locn disk_areas_xl[0]; /* Two lists */
103
} __attribute__ ((packed));
105
#define GRUB_LVM_FMTT_MAGIC "\040\114\126\115\062\040\170\133\065\101\045\162\060\116\052\076"
106
#define GRUB_LVM_FMTT_VERSION 1
109
struct grub_lvm_raw_locn {
110
grub_uint64_t offset; /* Offset in bytes to start sector */
111
grub_uint64_t size; /* Bytes */
112
grub_uint32_t checksum;
113
grub_uint32_t filler;
114
} __attribute__ ((packed));
117
/* Structure size limited to one sector */
118
struct grub_lvm_mda_header {
119
grub_uint32_t checksum_xl; /* Checksum of rest of mda_header */
120
grub_int8_t magic[16]; /* To aid scans for metadata */
121
grub_uint32_t version;
122
grub_uint64_t start; /* Absolute start byte of mda_header */
123
grub_uint64_t size; /* Size of metadata area */
125
struct grub_lvm_raw_locn raw_locns[0]; /* NULL-terminated list */
126
} __attribute__ ((packed));
129
#endif /* ! GRUB_LVM_H */