lvm.h 2.87 KB
Newer Older
1 2 3
/* lvm.h - On disk structures for LVM. */
/*
 *  GRUB  --  GRand Unified Bootloader
4
 *  Copyright (C) 2006,2007  Free Software Foundation, Inc.
5
 *
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 3 of the License, or
9 10
 *  (at your option) any later version.
 *
11
 *  GRUB is distributed in the hope that it will be useful,
12 13 14 15 16
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
17
 *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
18 19 20 21 22 23
 */

#ifndef GRUB_LVM_H
#define GRUB_LVM_H	1

#include <grub/types.h>
24
#include <grub/diskfilter.h>
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43

/* Length of ID string, excluding terminating zero. */
#define GRUB_LVM_ID_STRLEN 38

#define GRUB_LVM_LABEL_SIZE GRUB_DISK_SECTOR_SIZE
#define GRUB_LVM_LABEL_SCAN_SECTORS 4L

#define GRUB_LVM_LABEL_ID "LABELONE"
#define GRUB_LVM_LVM2_LABEL "LVM2 001"

#define GRUB_LVM_ID_LEN 32

/* On disk - 32 bytes */
struct grub_lvm_label_header {
  grub_int8_t id[8];		/* LABELONE */
  grub_uint64_t sector_xl;	/* Sector number of this label */
  grub_uint32_t crc_xl;		/* From next field to end of sector */
  grub_uint32_t offset_xl;	/* Offset from start of struct to contents */
  grub_int8_t type[8];		/* LVM2 001 */
44
} GRUB_PACKED;
45 46 47 48 49

/* On disk */
struct grub_lvm_disk_locn {
  grub_uint64_t offset;		/* Offset in bytes to start sector */
  grub_uint64_t size;		/* Bytes */
50
} GRUB_PACKED;
51 52 53 54 55 56 57 58 59 60 61 62

/* Fields with the suffix _xl should be xlate'd wherever they appear */
/* On disk */
struct grub_lvm_pv_header {
  grub_int8_t pv_uuid[GRUB_LVM_ID_LEN];

  /* This size can be overridden if PV belongs to a VG */
  grub_uint64_t device_size_xl;	/* Bytes */

  /* NULL-terminated list of data areas followed by */
  /* NULL-terminated list of metadata area headers */
  struct grub_lvm_disk_locn disk_areas_xl[0];	/* Two lists */
63
} GRUB_PACKED;
64 65 66

#define GRUB_LVM_FMTT_MAGIC "\040\114\126\115\062\040\170\133\065\101\045\162\060\116\052\076"
#define GRUB_LVM_FMTT_VERSION 1
67
#define GRUB_LVM_MDA_HEADER_SIZE 512
68 69 70 71 72 73 74

/* On disk */
struct grub_lvm_raw_locn {
  grub_uint64_t offset;		/* Offset in bytes to start sector */
  grub_uint64_t size;		/* Bytes */
  grub_uint32_t checksum;
  grub_uint32_t filler;
75
} GRUB_PACKED;
76 77 78 79 80 81 82 83 84

/* On disk */
/* Structure size limited to one sector */
struct grub_lvm_mda_header {
  grub_uint32_t checksum_xl;	/* Checksum of rest of mda_header */
  grub_int8_t magic[16];	/* To aid scans for metadata */
  grub_uint32_t version;
  grub_uint64_t start;		/* Absolute start byte of mda_header */
  grub_uint64_t size;		/* Size of metadata area */
85

86
  struct grub_lvm_raw_locn raw_locns[0];	/* NULL-terminated list */
87
} GRUB_PACKED;
88 89 90


#endif /* ! GRUB_LVM_H */