lvm.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* lvm.h - On disk structures for LVM. */
  2. /*
  3. * 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. * (at your option) any later version.
  10. *
  11. * GRUB 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.
  15. *
  16. * 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. #ifndef GRUB_LVM_H
  20. #define GRUB_LVM_H 1
  21. #include <grub/types.h>
  22. #include <grub/diskfilter.h>
  23. /* Length of ID string, excluding terminating zero. */
  24. #define GRUB_LVM_ID_STRLEN 38
  25. #define GRUB_LVM_LABEL_SIZE GRUB_DISK_SECTOR_SIZE
  26. #define GRUB_LVM_LABEL_SCAN_SECTORS 4L
  27. #define GRUB_LVM_LABEL_ID "LABELONE"
  28. #define GRUB_LVM_LVM2_LABEL "LVM2 001"
  29. #define GRUB_LVM_ID_LEN 32
  30. /* On disk - 32 bytes */
  31. struct grub_lvm_label_header {
  32. grub_int8_t id[8]; /* LABELONE */
  33. grub_uint64_t sector_xl; /* Sector number of this label */
  34. grub_uint32_t crc_xl; /* From next field to end of sector */
  35. grub_uint32_t offset_xl; /* Offset from start of struct to contents */
  36. grub_int8_t type[8]; /* LVM2 001 */
  37. } GRUB_PACKED;
  38. /* On disk */
  39. struct grub_lvm_disk_locn {
  40. grub_uint64_t offset; /* Offset in bytes to start sector */
  41. grub_uint64_t size; /* Bytes */
  42. } GRUB_PACKED;
  43. /* Fields with the suffix _xl should be xlate'd wherever they appear */
  44. /* On disk */
  45. struct grub_lvm_pv_header {
  46. grub_int8_t pv_uuid[GRUB_LVM_ID_LEN];
  47. /* This size can be overridden if PV belongs to a VG */
  48. grub_uint64_t device_size_xl; /* Bytes */
  49. /* NULL-terminated list of data areas followed by */
  50. /* NULL-terminated list of metadata area headers */
  51. struct grub_lvm_disk_locn disk_areas_xl[0]; /* Two lists */
  52. } GRUB_PACKED;
  53. #define GRUB_LVM_FMTT_MAGIC "\040\114\126\115\062\040\170\133\065\101\045\162\060\116\052\076"
  54. #define GRUB_LVM_FMTT_VERSION 1
  55. #define GRUB_LVM_MDA_HEADER_SIZE 512
  56. /* On disk */
  57. struct grub_lvm_raw_locn {
  58. grub_uint64_t offset; /* Offset in bytes to start sector */
  59. grub_uint64_t size; /* Bytes */
  60. grub_uint32_t checksum;
  61. grub_uint32_t filler;
  62. } GRUB_PACKED;
  63. /* On disk */
  64. /* Structure size limited to one sector */
  65. struct grub_lvm_mda_header {
  66. grub_uint32_t checksum_xl; /* Checksum of rest of mda_header */
  67. grub_int8_t magic[16]; /* To aid scans for metadata */
  68. grub_uint32_t version;
  69. grub_uint64_t start; /* Absolute start byte of mda_header */
  70. grub_uint64_t size; /* Size of metadata area */
  71. struct grub_lvm_raw_locn raw_locns[0]; /* NULL-terminated list */
  72. } GRUB_PACKED;
  73. #endif /* ! GRUB_LVM_H */