mirror of
https://git.proxmox.com/git/grub2
synced 2025-05-19 11:39:03 +00:00

* DISTLIST: Added commands/echo.c, disk/lvm.c, disk/raid.c, include/grub/bitmap.h, include/grub/lvm.h, include/grub/raid.h, include/grub/i386/pc/vbeutil.h, include/grub/util/lvm.h, include/grub/util/raid.h, util/lvm.c, util/raid.c, video/bitmap.c, video/readers/tga.c and video/i386/pc/vbeutil.c. 2006-10-14 Jeroen Dekkers <jeroen@dekkers.cx> Added support for RAID and LVM. * disk/lvm.c: New file. * disk/raid.c: Likewise. * include/grub/lvm.h: Likewise. * include/grub/raid.h: Likewise. * include/grub/util/lvm.h: Likewise. * include/grub/util/raid.h: Likewise. * util/lvm.c: Likewise. * util/raid.c: Likewise. * include/grub/disk.h (grub_disk_dev_id): Add GRUB_DISK_DEVICE_RAID_ID and GRUB_DISK_DEVICE_LVM_ID. (grub_disk_get_size): New prototype. * kern/disk.c (grub_disk_open): Check whether grub_partition_probe() returns a partition. (grub_disk_get_size): New function. * kern/i386/pc/init.c (make_install_device): Copy the prefix verbatim if grub_install_dos_part is -2. * util/i386/pc/getroot.c (grub_guess_root_device): Support RAID and LVM devices. * util/i386/pc/grub-setup.c (setup): New argument MUST_EMBED. Force embedding of GRUB when the argument is true. Close FILE before returning. (main): Add support for RAID and LVM. * conf/common.rmk: Add RAID and LVM modules. * conf/i386-pc.rmk (grub_setup_SOURCES): Add util/raid.c and util/lvm.c. (grub_emu_SOURCES): Add disk/raid.c and disk/lvm.c. * kern/misc.c (grub_strstr): New function. * include/grub/misc.h (grub_strstr): New prototype.
130 lines
3.8 KiB
C
130 lines
3.8 KiB
C
/* lvm.h - On disk structures for LVM. */
|
|
/*
|
|
* GRUB -- GRand Unified Bootloader
|
|
* Copyright (C) 2006 Free Software Foundation, Inc.
|
|
*
|
|
* GRUB is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* 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
|
|
* along with GRUB; if not, write to the Free Software
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
*/
|
|
|
|
#ifndef GRUB_LVM_H
|
|
#define GRUB_LVM_H 1
|
|
|
|
#include <grub/types.h>
|
|
|
|
/* Length of ID string, excluding terminating zero. */
|
|
#define GRUB_LVM_ID_STRLEN 38
|
|
|
|
struct grub_lvm_vg {
|
|
char id[GRUB_LVM_ID_STRLEN+1];
|
|
char *name;
|
|
int extent_size;
|
|
struct grub_lvm_pv *pvs;
|
|
struct grub_lvm_lv *lvs;
|
|
struct grub_lvm_vg *next;
|
|
};
|
|
|
|
struct grub_lvm_pv {
|
|
char id[GRUB_LVM_ID_STRLEN+1];
|
|
char *name;
|
|
grub_disk_t disk;
|
|
int start; /* Sector number where the data area starts. */
|
|
struct grub_lvm_pv *next;
|
|
};
|
|
|
|
struct grub_lvm_lv {
|
|
char *name;
|
|
unsigned int number;
|
|
unsigned int segment_count;
|
|
grub_uint64_t size;
|
|
struct grub_lvm_segment *segments; /* Pointer to segment_count segments. */
|
|
struct grub_lvm_vg *vg;
|
|
struct grub_lvm_lv *next;
|
|
};
|
|
|
|
struct grub_lvm_segment {
|
|
unsigned int start_extent;
|
|
unsigned int extent_count;
|
|
unsigned int stripe_count;
|
|
unsigned int stripe_size;
|
|
struct grub_lvm_stripe *stripes; /* Pointer to stripe_count stripes. */
|
|
};
|
|
|
|
struct grub_lvm_stripe {
|
|
int start;
|
|
struct grub_lvm_pv *pv;
|
|
};
|
|
|
|
#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 */
|
|
} __attribute__ ((packed));
|
|
|
|
/* On disk */
|
|
struct grub_lvm_disk_locn {
|
|
grub_uint64_t offset; /* Offset in bytes to start sector */
|
|
grub_uint64_t size; /* Bytes */
|
|
} __attribute__ ((packed));
|
|
|
|
/* 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 */
|
|
} __attribute__ ((packed));
|
|
|
|
#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
|
|
|
|
/* 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;
|
|
} __attribute__ ((packed));
|
|
|
|
/* 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 */
|
|
|
|
struct grub_lvm_raw_locn raw_locns[0]; /* NULL-terminated list */
|
|
} __attribute__ ((packed));
|
|
|
|
|
|
#endif /* ! GRUB_LVM_H */
|