Merge common RAID and LVM logic to an abstract diskfilter.
Add LDM support using the same framework. * Makefile.util.def (libgrubkern): Add grub-core/disk/ldm.c, grub-core/disk/diskfilter.c and grub-core/partmap/gpt.c. (libgrubmods): Remove grub-core/disk/raid.c and grub-core/partmap/gpt.c. * grub-core/Makefile.core.def (ldm): New module. (raid): Renamed to diskfilter. All users updated. * grub-core/disk/raid.c: Moved to ... * grub-core/disk/diskfilter.c: ... here. * grub-core/disk/diskfilter.c: Rename grub_raid_ to grub_diskfilter_. (lv_num): New var. (find_array): Renamed to ... (find_lv): ... this. Support multi-LV. Skip nameless LVs (grub_is_array_readable): Renamed to ... (grub_is_lv_readable): ... this. Support multinode hierarchy. (insert_array): New argument id. (is_node_readable): New function. (scan_device): Rename to ... (scan_disk): .. this. Restrict to one disk. (scan_devices): New function. (grub_diskfilter_iterate): Support multi-LV. Skip invisible and nameless LVs. (grub_diskfilter_memberlist): Support multi-LV. (grub_diskfilter_read_node): New function. (grub_raid_read): Most of logic moved to ... (read_segment): ... here (read_lv): New function. (grub_diskfilter_get_vg_by_uuid): New function. (grub_diskfilter_make_raid): Likewise. * grub-core/disk/ldm.c: New file. * grub-core/disk/lvm.c (vg_list): Removed. (lv_count): Likewise. (scan_depth): Likewise. (is_lv_readable): Likewise. (grub_lvm_getvalue): Advance pointer past the number. (find_lv): Removed. (do_lvm_scan): Refactored into ... (grub_lvm_detect): ... this. Support raid. (grub_lvm_iterate): Removed. (grub_lvm_memberlist): Likewise. (grub_lvm_open): Likewise. (grub_lvm_close): Likewise. (read_lv): Likewise. (read_node): Likewise. (is_node_readable): Likewise. (is_lv_readable): Likewise. (grub_lvm_read): Likewise. (grub_lvm_write): Likewise. (grub_lvm_dev): Use diskfilter (GRUB_MOD_INIT): Likewise. (GRUB_MOD_FINI): Likewise. * grub-core/disk/dmraid_nvidia.c (grub_dmraid_nv_detect): Use new interface. * grub-core/disk/mdraid1x_linux.c (grub_mdraid_detect): Likewise. * grub-core/disk/mdraid_linux.c (grub_mdraid_detect): Likewise. * grub-core/disk/raid5_recover.c (grub_raid5_recover): Use grub_diskfilter_read_node. Fix a bug with xor. * grub-core/disk/raid6_recover.c (grub_raid6_recover): Use grub_diskfilter_read_node. Support GRUB_RAID_LAYOUT_MUL_FROM_POS. * grub-core/kern/disk.c (grub_disk_dev_list): Make global. (grub_disk_dev_iterate): Move from here... * include/grub/disk.h (grub_disk_dev_iterate): ... to here. Inlined. * grub-core/kern/emu/hostdisk.c (grub_hostdisk_find_partition_start): Make global. (grub_hostdisk_find_partition_start): Likewise. (grub_hostdisk_os_dev_to_grub_drive): New function. (grub_util_biosdisk_get_osdev): Check that disk is biosdisk. * grub-core/kern/emu/hostdisk.c (make_device_name): Move to ... * util/getroot.c (make_device_name): ... here. * grub-core/kern/emu/hostdisk.c (grub_util_get_dm_node_linear_info): Move to ... * util/getroot.c (grub_util_get_dm_node_linear_info): ...here. * grub-core/kern/emu/hostdisk.c (convert_system_partition_to_system_disk): Move to ... * util/getroot.c (convert_system_partition_to_system_disk): ...here. * grub-core/kern/emu/hostdisk.c (device_is_wholedisk): Move to ... * util/getroot.c (device_is_wholedisk): ... here. * grub-core/kern/emu/hostdisk.c (find_system_device): Move to ... * util/getroot.c (find_system_device): ... here. * grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_is_present): Move to ... * util/getroot.c (grub_util_biosdisk_is_present): ...here. * grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_get_grub_dev): Move to ... * util/getroot.c (grub_util_biosdisk_get_grub_dev): ... here. Handle LDM. * grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_is_floppy): Move to ... * util/getroot.c (grub_util_biosdisk_is_floppy): ... here. * grub-core/partmap/gpt.c (grub_gpt_partition_map_iterate): Made global. * include/grub/disk.h (grub_disk_dev_id): Replaced RAID and LVM with DISKFILTER. * include/grub/raid.h: Renamed to ... * include/grub/diskfilter.h: ... this. * include/grub/diskfilter.h: Rename grub_raid_* to grub_diskfilter_* (GRUB_RAID_LAYOUT_*): Make into array. (GRUB_RAID_LAYOUT_MUL_FROM_POS): New value. (grub_diskfilter_vg): New struct. (grub_diskfilter_pv_id): Likewise. (grub_raid_member): Removed. (grub_raid_array): Likewise. (grub_diskfilter_pv): New struct. (grub_diskfilter_lv): Likewise. (grub_diskfilter_segment): Likewise. (grub_diskfilter_node): Likewise. (grub_diskfilter_get_vg_by_uuid): New proto. (grub_raid_register): Inline. (grub_diskfilter_unregister): Likewise. (grub_diskfilter_make_raid): New proto. (grub_diskfilter_vg_register): Likewise. (grub_diskfilter_read_node): Likewise. (grub_diskfilter_get_pv_from_disk) [GRUB_UTIL]: Likewise. * include/grub/emu/hostdisk.h (grub_util_get_ldm): New proto. (grub_util_is_ldm): Likewise. (grub_util_ldm_embed) [GRUB_UTIL]: Likewise. (grub_hostdisk_find_partition_start): Likewise. (grub_hostdisk_os_dev_to_grub_drive): Likewise. * include/grub/gpt_partition.h (GRUB_GPT_PARTITION_TYPE_LDM): New definition. (grub_gpt_partition_map_iterate): New proto. * include/grub/lvm.h (grub_lvm_vg): Removed. (grub_lvm_pv): Likewise. (grub_lvm_lv): Likewise. (grub_lvm_segment): Likewise. (grub_lvm_node): Likewise. * util/getroot.c [...] * util/grub-probe.c (probe_raid_level): Handle diskfilter. (probe_abstraction): Likewise. * util/grub-setup.c (setup): Remove must_embed. Support LDM. (main): Remove dead logic.
This commit is contained in:
parent
8a7f9b9c50
commit
076e7c0fda
27 changed files with 4249 additions and 3052 deletions
|
@ -32,8 +32,7 @@ enum grub_disk_dev_id
|
|||
GRUB_DISK_DEVICE_OFDISK_ID,
|
||||
GRUB_DISK_DEVICE_LOOPBACK_ID,
|
||||
GRUB_DISK_DEVICE_EFIDISK_ID,
|
||||
GRUB_DISK_DEVICE_RAID_ID,
|
||||
GRUB_DISK_DEVICE_LVM_ID,
|
||||
GRUB_DISK_DEVICE_DISKFILTER_ID,
|
||||
GRUB_DISK_DEVICE_HOST_ID,
|
||||
GRUB_DISK_DEVICE_ATA_ID,
|
||||
GRUB_DISK_DEVICE_MEMDISK_ID,
|
||||
|
@ -96,6 +95,8 @@ struct grub_disk_dev
|
|||
};
|
||||
typedef struct grub_disk_dev *grub_disk_dev_t;
|
||||
|
||||
extern grub_disk_dev_t EXPORT_VAR (grub_disk_dev_list);
|
||||
|
||||
struct grub_partition;
|
||||
|
||||
/* Disk. */
|
||||
|
@ -158,7 +159,19 @@ void grub_disk_cache_invalidate_all (void);
|
|||
|
||||
void EXPORT_FUNC(grub_disk_dev_register) (grub_disk_dev_t dev);
|
||||
void EXPORT_FUNC(grub_disk_dev_unregister) (grub_disk_dev_t dev);
|
||||
int EXPORT_FUNC(grub_disk_dev_iterate) (int (*hook) (const char *name));
|
||||
static inline int
|
||||
grub_disk_dev_iterate (int (*hook) (const char *name))
|
||||
{
|
||||
grub_disk_dev_t p;
|
||||
grub_disk_pull_t pull;
|
||||
|
||||
for (pull = 0; pull < GRUB_DISK_PULL_MAX; pull++)
|
||||
for (p = grub_disk_dev_list; p; p = p->next)
|
||||
if (p->iterate && (p->iterate) (hook, pull))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_disk_t EXPORT_FUNC(grub_disk_open) (const char *name);
|
||||
void EXPORT_FUNC(grub_disk_close) (grub_disk_t disk);
|
||||
|
@ -185,13 +198,15 @@ extern int EXPORT_VAR(grub_disk_firmware_is_tainted);
|
|||
|
||||
#if defined (GRUB_UTIL) || defined (GRUB_MACHINE_EMU)
|
||||
void grub_lvm_init (void);
|
||||
void grub_ldm_init (void);
|
||||
void grub_mdraid09_init (void);
|
||||
void grub_mdraid1x_init (void);
|
||||
void grub_raid_init (void);
|
||||
void grub_diskfilter_init (void);
|
||||
void grub_lvm_fini (void);
|
||||
void grub_ldm_fini (void);
|
||||
void grub_mdraid09_fini (void);
|
||||
void grub_mdraid1x_fini (void);
|
||||
void grub_raid_fini (void);
|
||||
void grub_diskfilter_fini (void);
|
||||
#endif
|
||||
|
||||
#endif /* ! GRUB_DISK_HEADER */
|
||||
|
|
191
include/grub/diskfilter.h
Normal file
191
include/grub/diskfilter.h
Normal file
|
@ -0,0 +1,191 @@
|
|||
/* diskfilter.h - On disk structures for RAID. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2006,2007,2008,2010 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_DISKFILTER_H
|
||||
#define GRUB_DISKFILTER_H 1
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/list.h>
|
||||
|
||||
enum
|
||||
{
|
||||
GRUB_RAID_LAYOUT_RIGHT_MASK = 1,
|
||||
GRUB_RAID_LAYOUT_SYMMETRIC_MASK = 2,
|
||||
GRUB_RAID_LAYOUT_MUL_FROM_POS = 4,
|
||||
|
||||
GRUB_RAID_LAYOUT_LEFT_ASYMMETRIC = 0,
|
||||
GRUB_RAID_LAYOUT_RIGHT_ASYMMETRIC = GRUB_RAID_LAYOUT_RIGHT_MASK,
|
||||
GRUB_RAID_LAYOUT_LEFT_SYMMETRIC = GRUB_RAID_LAYOUT_SYMMETRIC_MASK,
|
||||
GRUB_RAID_LAYOUT_RIGHT_SYMMETRIC = (GRUB_RAID_LAYOUT_RIGHT_MASK
|
||||
| GRUB_RAID_LAYOUT_SYMMETRIC_MASK)
|
||||
};
|
||||
|
||||
|
||||
struct grub_diskfilter_vg {
|
||||
char *uuid;
|
||||
grub_size_t uuid_len;
|
||||
/* Optional. */
|
||||
char *name;
|
||||
int extent_size;
|
||||
struct grub_diskfilter_pv *pvs;
|
||||
struct grub_diskfilter_lv *lvs;
|
||||
struct grub_diskfilter_vg *next;
|
||||
|
||||
#ifdef GRUB_UTIL
|
||||
struct grub_diskfilter *driver;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct grub_diskfilter_pv_id {
|
||||
union
|
||||
{
|
||||
char *uuid;
|
||||
int id;
|
||||
};
|
||||
grub_size_t uuidlen;
|
||||
};
|
||||
|
||||
struct grub_diskfilter_pv {
|
||||
struct grub_diskfilter_pv_id id;
|
||||
/* Optional. */
|
||||
char *name;
|
||||
grub_disk_t disk;
|
||||
grub_disk_addr_t part_start;
|
||||
grub_disk_addr_t part_size;
|
||||
grub_disk_addr_t start_sector; /* Sector number where the data area starts. */
|
||||
struct grub_diskfilter_pv *next;
|
||||
/* Optional. */
|
||||
grub_uint8_t *internal_id;
|
||||
};
|
||||
|
||||
struct grub_diskfilter_lv {
|
||||
/* Name used for disk. */
|
||||
char *fullname;
|
||||
/* Optional. */
|
||||
char *name;
|
||||
int number;
|
||||
unsigned int segment_count;
|
||||
grub_size_t segment_alloc;
|
||||
grub_uint64_t size;
|
||||
int became_readable_at;
|
||||
|
||||
int visible;
|
||||
|
||||
/* Pointer to segment_count segments. */
|
||||
struct grub_diskfilter_segment *segments;
|
||||
struct grub_diskfilter_vg *vg;
|
||||
struct grub_diskfilter_lv *next;
|
||||
|
||||
/* Optional. */
|
||||
char *internal_id;
|
||||
};
|
||||
|
||||
struct grub_diskfilter_segment {
|
||||
unsigned int start_extent;
|
||||
unsigned int extent_count;
|
||||
enum
|
||||
{
|
||||
GRUB_DISKFILTER_STRIPED = 0,
|
||||
GRUB_DISKFILTER_MIRROR = 1,
|
||||
GRUB_DISKFILTER_RAID4 = 4,
|
||||
GRUB_DISKFILTER_RAID5 = 5,
|
||||
GRUB_DISKFILTER_RAID6 = 6,
|
||||
GRUB_DISKFILTER_RAID10 = 10,
|
||||
} type;
|
||||
int layout;
|
||||
/* valid only for raid10. */
|
||||
grub_uint64_t raid_member_size;
|
||||
|
||||
unsigned int node_count;
|
||||
unsigned int node_alloc;
|
||||
struct grub_diskfilter_node *nodes;
|
||||
|
||||
unsigned int stripe_size;
|
||||
};
|
||||
|
||||
struct grub_diskfilter_node {
|
||||
grub_disk_addr_t start;
|
||||
/* Optional. */
|
||||
char *name;
|
||||
struct grub_diskfilter_pv *pv;
|
||||
struct grub_diskfilter_lv *lv;
|
||||
};
|
||||
|
||||
struct grub_diskfilter_vg *
|
||||
grub_diskfilter_get_vg_by_uuid (grub_size_t uuidlen, char *uuid);
|
||||
|
||||
struct grub_diskfilter
|
||||
{
|
||||
struct grub_diskfilter *next;
|
||||
struct grub_diskfilter **prev;
|
||||
|
||||
const char *name;
|
||||
|
||||
struct grub_diskfilter_vg * (*detect) (grub_disk_t disk,
|
||||
struct grub_diskfilter_pv_id *id,
|
||||
grub_disk_addr_t *start_sector);
|
||||
};
|
||||
typedef struct grub_diskfilter *grub_diskfilter_t;
|
||||
|
||||
extern grub_diskfilter_t grub_diskfilter_list;
|
||||
static inline void
|
||||
grub_diskfilter_register (grub_diskfilter_t diskfilter)
|
||||
{
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_diskfilter_list),
|
||||
GRUB_AS_LIST (diskfilter));
|
||||
}
|
||||
static inline void
|
||||
grub_diskfilter_unregister (grub_diskfilter_t diskfilter)
|
||||
{
|
||||
grub_list_remove (GRUB_AS_LIST (diskfilter));
|
||||
}
|
||||
|
||||
struct grub_diskfilter_vg *
|
||||
grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
|
||||
char *name, grub_uint64_t disk_size,
|
||||
grub_uint64_t stripe_size,
|
||||
int layout, int level);
|
||||
|
||||
typedef grub_err_t (*grub_raid5_recover_func_t) (struct grub_diskfilter_segment *array,
|
||||
int disknr, char *buf,
|
||||
grub_disk_addr_t sector,
|
||||
int size);
|
||||
|
||||
typedef grub_err_t (*grub_raid6_recover_func_t) (struct grub_diskfilter_segment *array,
|
||||
int disknr, int p, char *buf,
|
||||
grub_disk_addr_t sector,
|
||||
int size);
|
||||
|
||||
extern grub_raid5_recover_func_t grub_raid5_recover_func;
|
||||
extern grub_raid6_recover_func_t grub_raid6_recover_func;
|
||||
|
||||
grub_err_t grub_diskfilter_vg_register (struct grub_diskfilter_vg *vg);
|
||||
|
||||
grub_err_t
|
||||
grub_diskfilter_read_node (const struct grub_diskfilter_node *node,
|
||||
grub_disk_addr_t sector,
|
||||
grub_size_t size, char *buf);
|
||||
|
||||
#ifdef GRUB_UTIL
|
||||
struct grub_diskfilter_pv *
|
||||
grub_diskfilter_get_pv_from_disk (grub_disk_t disk,
|
||||
struct grub_diskfilter_vg **vg);
|
||||
#endif
|
||||
|
||||
#endif /* ! GRUB_RAID_H */
|
|
@ -21,6 +21,7 @@
|
|||
#define GRUB_BIOSDISK_MACHINE_UTIL_HEADER 1
|
||||
|
||||
#include <grub/disk.h>
|
||||
#include <grub/partition.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
void grub_util_biosdisk_init (const char *dev_map);
|
||||
|
@ -39,6 +40,21 @@ ssize_t grub_util_fd_read (int fd, char *buf, size_t len);
|
|||
grub_err_t
|
||||
grub_cryptodisk_cheat_mount (const char *sourcedev, const char *cheat);
|
||||
void grub_util_cryptodisk_print_uuid (grub_disk_t disk);
|
||||
char *
|
||||
grub_util_get_ldm (grub_disk_t disk, grub_disk_addr_t start);
|
||||
int
|
||||
grub_util_is_ldm (grub_disk_t disk);
|
||||
#ifdef GRUB_UTIL
|
||||
grub_err_t
|
||||
grub_util_ldm_embed (struct grub_disk *disk, unsigned int *nsectors,
|
||||
grub_embed_type_t embed_type,
|
||||
grub_disk_addr_t **sectors);
|
||||
#endif
|
||||
grub_disk_addr_t
|
||||
grub_hostdisk_find_partition_start (const char *dev);
|
||||
const char *
|
||||
grub_hostdisk_os_dev_to_grub_drive (const char *os_dev, int add);
|
||||
|
||||
#if !defined(__MINGW32__)
|
||||
grub_uint64_t
|
||||
grub_util_get_fd_sectors (int fd, unsigned *log_secsize);
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#define GRUB_GPT_PARTITION_HEADER 1
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/partition.h>
|
||||
|
||||
struct grub_gpt_part_type
|
||||
{
|
||||
|
@ -36,10 +37,19 @@ typedef struct grub_gpt_part_type grub_gpt_part_type_t;
|
|||
}
|
||||
|
||||
#define GRUB_GPT_PARTITION_TYPE_BIOS_BOOT \
|
||||
{ grub_cpu_to_le32_compile_time (0x21686148), grub_cpu_to_le16_compile_time (0x6449), grub_cpu_to_le16_compile_time (0x6e6f), \
|
||||
{ grub_cpu_to_le32_compile_time (0x21686148), \
|
||||
grub_cpu_to_le16_compile_time (0x6449), \
|
||||
grub_cpu_to_le16_compile_time (0x6e6f), \
|
||||
{ 0x74, 0x4e, 0x65, 0x65, 0x64, 0x45, 0x46, 0x49 } \
|
||||
}
|
||||
|
||||
#define GRUB_GPT_PARTITION_TYPE_LDM \
|
||||
{ grub_cpu_to_le32_compile_time (0x5808C8AAU),\
|
||||
grub_cpu_to_le16_compile_time (0x7E8F), \
|
||||
grub_cpu_to_le16_compile_time (0x42E0), \
|
||||
{ 0x85, 0xD2, 0xE1, 0xE9, 0x04, 0x34, 0xCF, 0xB3 } \
|
||||
}
|
||||
|
||||
struct grub_gpt_header
|
||||
{
|
||||
grub_uint8_t magic[8];
|
||||
|
@ -68,4 +78,10 @@ struct grub_gpt_partentry
|
|||
char name[72];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
grub_err_t
|
||||
grub_gpt_partition_map_iterate (grub_disk_t disk,
|
||||
int (*hook) (grub_disk_t disk,
|
||||
const grub_partition_t partition));
|
||||
|
||||
|
||||
#endif /* ! GRUB_GPT_PARTITION_HEADER */
|
||||
|
|
|
@ -21,60 +21,11 @@
|
|||
#define GRUB_LVM_H 1
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/diskfilter.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;
|
||||
grub_disk_addr_t start; /* Sector number where the data area starts. */
|
||||
struct grub_lvm_pv *next;
|
||||
};
|
||||
|
||||
struct grub_lvm_lv {
|
||||
char *name;
|
||||
char *fullname;
|
||||
char *compatname;
|
||||
unsigned int number;
|
||||
unsigned int segment_count;
|
||||
grub_uint64_t size;
|
||||
|
||||
int visible;
|
||||
|
||||
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;
|
||||
enum { GRUB_LVM_STRIPED, GRUB_LVM_MIRROR } type;
|
||||
|
||||
unsigned int node_count;
|
||||
struct grub_lvm_node *nodes;
|
||||
|
||||
unsigned int stripe_size;
|
||||
};
|
||||
|
||||
struct grub_lvm_node {
|
||||
grub_disk_addr_t start;
|
||||
char *name;
|
||||
struct grub_lvm_pv *pv;
|
||||
struct grub_lvm_lv *lv;
|
||||
};
|
||||
|
||||
#define GRUB_LVM_LABEL_SIZE GRUB_DISK_SECTOR_SIZE
|
||||
#define GRUB_LVM_LABEL_SCAN_SECTORS 4L
|
||||
|
||||
|
|
|
@ -1,97 +0,0 @@
|
|||
/* raid.h - On disk structures for RAID. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2006,2007,2008,2010 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_RAID_H
|
||||
#define GRUB_RAID_H 1
|
||||
|
||||
#include <grub/types.h>
|
||||
|
||||
#define GRUB_RAID_LAYOUT_LEFT_ASYMMETRIC 0
|
||||
#define GRUB_RAID_LAYOUT_RIGHT_ASYMMETRIC 1
|
||||
#define GRUB_RAID_LAYOUT_LEFT_SYMMETRIC 2
|
||||
#define GRUB_RAID_LAYOUT_RIGHT_SYMMETRIC 3
|
||||
|
||||
#define GRUB_RAID_LAYOUT_RIGHT_MASK 1
|
||||
#define GRUB_RAID_LAYOUT_SYMMETRIC_MASK 2
|
||||
|
||||
struct grub_raid_member
|
||||
{
|
||||
grub_disk_t device; /* Array of total_devs devices. */
|
||||
grub_disk_addr_t start_sector;
|
||||
/* Start of each device, in 512 byte sectors. */
|
||||
};
|
||||
|
||||
struct grub_raid_array
|
||||
{
|
||||
int number; /* The device number, taken from md_minor so we
|
||||
are consistent with the device name in
|
||||
Linux. */
|
||||
int became_readable_at;
|
||||
int level; /* RAID levels, only 0, 1 or 5 at the moment. */
|
||||
int layout; /* Layout for RAID 5/6. */
|
||||
unsigned int total_devs; /* Total number of devices in the array. */
|
||||
grub_size_t chunk_size; /* The size of a chunk, in 512 byte sectors. */
|
||||
grub_uint64_t disk_size; /* Size of an individual disk, in 512 byte
|
||||
sectors. */
|
||||
unsigned int index; /* Index of current device. */
|
||||
int uuid_len; /* The length of uuid. */
|
||||
char *uuid; /* The UUID of the device. */
|
||||
|
||||
/* The following field is setup by the caller. */
|
||||
char *name; /* That will be "md<number>". */
|
||||
unsigned int nr_devs; /* The number of devices we've found so far. */
|
||||
unsigned int allocated_devs;
|
||||
struct grub_raid_member *members;
|
||||
struct grub_raid_array *next;
|
||||
|
||||
#ifdef GRUB_UTIL
|
||||
struct grub_raid *driver;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct grub_raid
|
||||
{
|
||||
const char *name;
|
||||
|
||||
grub_err_t (*detect) (grub_disk_t disk, struct grub_raid_array *array,
|
||||
grub_disk_addr_t *start_sector);
|
||||
|
||||
struct grub_raid *next;
|
||||
};
|
||||
typedef struct grub_raid *grub_raid_t;
|
||||
|
||||
void grub_raid_register (grub_raid_t raid);
|
||||
void grub_raid_unregister (grub_raid_t raid);
|
||||
|
||||
void grub_raid_block_xor (char *buf1, const char *buf2, int size);
|
||||
|
||||
typedef grub_err_t (*grub_raid5_recover_func_t) (struct grub_raid_array *array,
|
||||
int disknr, char *buf,
|
||||
grub_disk_addr_t sector,
|
||||
int size);
|
||||
|
||||
typedef grub_err_t (*grub_raid6_recover_func_t) (struct grub_raid_array *array,
|
||||
int disknr, int p, char *buf,
|
||||
grub_disk_addr_t sector,
|
||||
int size);
|
||||
|
||||
extern grub_raid5_recover_func_t grub_raid5_recover_func;
|
||||
extern grub_raid6_recover_func_t grub_raid6_recover_func;
|
||||
|
||||
#endif /* ! GRUB_RAID_H */
|
Loading…
Add table
Add a link
Reference in a new issue