grub/grub-core/disk/mdraid_linux.c

299 lines
8.9 KiB
C
Raw Normal View History

/* mdraid_linux.c - module to handle Linux Software RAID. */
2008-08-23 Bean <bean123ch@gmail.com> * conf/common.rmk (grub_probe_SOURCES): Add disk/mdraid_linux.c. (grub_fstest_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c and lib/crc.c. (pkglib_MODULES): Add raid5rec.mod, raid6rec.mod, mdraid.mod and dm_nv.mod. (raid5rec_mod_SOURCES): New macro. (raid5rec_mod_CFLAGS): Likewise. (raid5rec_mod_LDFLAGS): Likewise. (raid6rec_mod_SOURCES): Likewise. (raid6rec_mod_CFLAGS): Likewise. (raid6rec_mod_LDFLAGS): Likewise. (mdraid_mod_SOURCES): Likewise. (mdraid_mod_CFLAGS): Likewise. (mdraid_mod_LDFLAGS): Likewise. (dm_nv_mod_SOURCES): Likewise. (dm_nv_mod_CFLAGS): Likewise. (dm_nv_mod_LDFLAGS): Likewise. * conf/i386-pc.rmk (grub_setup_SOURCES): Add disk/mdraid_linux.c. (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-coreboot.rmk (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-efi.rmk (grub_emu_SOURCES): Likewise. * conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise. * conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise. * disk/raid5_recover.c: New file. * disk/raid6_recover.c: Likewise. * disk/mdraid_linux.c: Likewise. * disk/dmraid_nvidia.c: Likewise. * disk/i386/pc/biosdisk.c: Set total_sectors of cdrom device to ULONG_MAX. * disk/raid.c (grub_raid_open): Use the size of the smallest disk to calculate the size of raid device. (grub_raid_read): Simplify raid0 code. Support raid4, raid6 and four different layout of raid5. (grub_raid_scan_device): Remove code specific to mdraid. (grub_raid_list): New variable. (free_array): New function. (grub_raid_register): Likewise. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (GRUB_MOD_INIT): Don't iterate device here. (GRUB_MOD_FINI): Use free_array to release resource. * include/grub/raid.h: Remove macro and structure specific to mdraid. (grub_raid5_recover_func_t): New function variable type. (grub_raid6_recover_func_t): Likewise. (grub_raid5_recover_func): New variable. (grub_raid6_recover_func): Likewise. (grub_raid_register): New function. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (grub_raid_block_xor): Likewise. * util/grub-fstest.c: Add #include <grub/raid.h> and <grub/lib/crc.h>. (CMD_CRC): New macro. (part): Removed. (read_file): Handle device as well as file. (cmd_crc): New function. (fstest): Handle multiple disks. (options): Remove part, raw and long, add root and diskcount. (usage): Add crc, remove -p, -r, -l, add -r and -c. (main): Find the first non option entry and ignore subsequence options, add handling for the new options, support multiple disks. * util/grub-probe.c (probe): Add mdraid to abstraction_name.
2008-08-23 14:51:19 +00:00
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2008,2009,2010 Free Software Foundation, Inc.
2008-08-23 Bean <bean123ch@gmail.com> * conf/common.rmk (grub_probe_SOURCES): Add disk/mdraid_linux.c. (grub_fstest_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c and lib/crc.c. (pkglib_MODULES): Add raid5rec.mod, raid6rec.mod, mdraid.mod and dm_nv.mod. (raid5rec_mod_SOURCES): New macro. (raid5rec_mod_CFLAGS): Likewise. (raid5rec_mod_LDFLAGS): Likewise. (raid6rec_mod_SOURCES): Likewise. (raid6rec_mod_CFLAGS): Likewise. (raid6rec_mod_LDFLAGS): Likewise. (mdraid_mod_SOURCES): Likewise. (mdraid_mod_CFLAGS): Likewise. (mdraid_mod_LDFLAGS): Likewise. (dm_nv_mod_SOURCES): Likewise. (dm_nv_mod_CFLAGS): Likewise. (dm_nv_mod_LDFLAGS): Likewise. * conf/i386-pc.rmk (grub_setup_SOURCES): Add disk/mdraid_linux.c. (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-coreboot.rmk (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-efi.rmk (grub_emu_SOURCES): Likewise. * conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise. * conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise. * disk/raid5_recover.c: New file. * disk/raid6_recover.c: Likewise. * disk/mdraid_linux.c: Likewise. * disk/dmraid_nvidia.c: Likewise. * disk/i386/pc/biosdisk.c: Set total_sectors of cdrom device to ULONG_MAX. * disk/raid.c (grub_raid_open): Use the size of the smallest disk to calculate the size of raid device. (grub_raid_read): Simplify raid0 code. Support raid4, raid6 and four different layout of raid5. (grub_raid_scan_device): Remove code specific to mdraid. (grub_raid_list): New variable. (free_array): New function. (grub_raid_register): Likewise. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (GRUB_MOD_INIT): Don't iterate device here. (GRUB_MOD_FINI): Use free_array to release resource. * include/grub/raid.h: Remove macro and structure specific to mdraid. (grub_raid5_recover_func_t): New function variable type. (grub_raid6_recover_func_t): Likewise. (grub_raid5_recover_func): New variable. (grub_raid6_recover_func): Likewise. (grub_raid_register): New function. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (grub_raid_block_xor): Likewise. * util/grub-fstest.c: Add #include <grub/raid.h> and <grub/lib/crc.h>. (CMD_CRC): New macro. (part): Removed. (read_file): Handle device as well as file. (cmd_crc): New function. (fstest): Handle multiple disks. (options): Remove part, raw and long, add root and diskcount. (usage): Add crc, remove -p, -r, -l, add -r and -c. (main): Find the first non option entry and ignore subsequence options, add handling for the new options, support multiple disks. * util/grub-probe.c (probe): Add mdraid to abstraction_name.
2008-08-23 14:51:19 +00:00
*
* 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/>.
*/
#include <grub/dl.h>
#include <grub/disk.h>
#include <grub/mm.h>
#include <grub/err.h>
#include <grub/misc.h>
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.
2012-01-29 13:28:01 +00:00
#include <grub/diskfilter.h>
2008-08-23 Bean <bean123ch@gmail.com> * conf/common.rmk (grub_probe_SOURCES): Add disk/mdraid_linux.c. (grub_fstest_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c and lib/crc.c. (pkglib_MODULES): Add raid5rec.mod, raid6rec.mod, mdraid.mod and dm_nv.mod. (raid5rec_mod_SOURCES): New macro. (raid5rec_mod_CFLAGS): Likewise. (raid5rec_mod_LDFLAGS): Likewise. (raid6rec_mod_SOURCES): Likewise. (raid6rec_mod_CFLAGS): Likewise. (raid6rec_mod_LDFLAGS): Likewise. (mdraid_mod_SOURCES): Likewise. (mdraid_mod_CFLAGS): Likewise. (mdraid_mod_LDFLAGS): Likewise. (dm_nv_mod_SOURCES): Likewise. (dm_nv_mod_CFLAGS): Likewise. (dm_nv_mod_LDFLAGS): Likewise. * conf/i386-pc.rmk (grub_setup_SOURCES): Add disk/mdraid_linux.c. (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-coreboot.rmk (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-efi.rmk (grub_emu_SOURCES): Likewise. * conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise. * conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise. * disk/raid5_recover.c: New file. * disk/raid6_recover.c: Likewise. * disk/mdraid_linux.c: Likewise. * disk/dmraid_nvidia.c: Likewise. * disk/i386/pc/biosdisk.c: Set total_sectors of cdrom device to ULONG_MAX. * disk/raid.c (grub_raid_open): Use the size of the smallest disk to calculate the size of raid device. (grub_raid_read): Simplify raid0 code. Support raid4, raid6 and four different layout of raid5. (grub_raid_scan_device): Remove code specific to mdraid. (grub_raid_list): New variable. (free_array): New function. (grub_raid_register): Likewise. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (GRUB_MOD_INIT): Don't iterate device here. (GRUB_MOD_FINI): Use free_array to release resource. * include/grub/raid.h: Remove macro and structure specific to mdraid. (grub_raid5_recover_func_t): New function variable type. (grub_raid6_recover_func_t): Likewise. (grub_raid5_recover_func): New variable. (grub_raid6_recover_func): Likewise. (grub_raid_register): New function. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (grub_raid_block_xor): Likewise. * util/grub-fstest.c: Add #include <grub/raid.h> and <grub/lib/crc.h>. (CMD_CRC): New macro. (part): Removed. (read_file): Handle device as well as file. (cmd_crc): New function. (fstest): Handle multiple disks. (options): Remove part, raw and long, add root and diskcount. (usage): Add crc, remove -p, -r, -l, add -r and -c. (main): Find the first non option entry and ignore subsequence options, add handling for the new options, support multiple disks. * util/grub-probe.c (probe): Add mdraid to abstraction_name.
2008-08-23 14:51:19 +00:00
/* Linux RAID on disk structures and constants,
copied from include/linux/raid/md_p.h. */
GRUB_MOD_LICENSE ("GPLv3+");
#ifdef MODE_BIGENDIAN
#define grub_md_to_cpu64 grub_be_to_cpu64
#define grub_md_to_cpu32 grub_be_to_cpu32
#define grub_md_to_cpu16 grub_be_to_cpu16
#define grub_cpu_to_md64_compile_time grub_cpu_to_be64_compile_time
#define grub_cpu_to_md32_compile_time grub_cpu_to_be32_compile_time
#define grub_cpu_to_md16_compile_time grub_cpu_to_be16_compile_time
#else
#define grub_md_to_cpu64 grub_le_to_cpu64
#define grub_md_to_cpu32 grub_le_to_cpu32
#define grub_md_to_cpu16 grub_le_to_cpu16
#define grub_cpu_to_md64_compile_time grub_cpu_to_le64_compile_time
#define grub_cpu_to_md32_compile_time grub_cpu_to_le32_compile_time
#define grub_cpu_to_md16_compile_time grub_cpu_to_le16_compile_time
#endif
2008-08-23 Bean <bean123ch@gmail.com> * conf/common.rmk (grub_probe_SOURCES): Add disk/mdraid_linux.c. (grub_fstest_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c and lib/crc.c. (pkglib_MODULES): Add raid5rec.mod, raid6rec.mod, mdraid.mod and dm_nv.mod. (raid5rec_mod_SOURCES): New macro. (raid5rec_mod_CFLAGS): Likewise. (raid5rec_mod_LDFLAGS): Likewise. (raid6rec_mod_SOURCES): Likewise. (raid6rec_mod_CFLAGS): Likewise. (raid6rec_mod_LDFLAGS): Likewise. (mdraid_mod_SOURCES): Likewise. (mdraid_mod_CFLAGS): Likewise. (mdraid_mod_LDFLAGS): Likewise. (dm_nv_mod_SOURCES): Likewise. (dm_nv_mod_CFLAGS): Likewise. (dm_nv_mod_LDFLAGS): Likewise. * conf/i386-pc.rmk (grub_setup_SOURCES): Add disk/mdraid_linux.c. (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-coreboot.rmk (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-efi.rmk (grub_emu_SOURCES): Likewise. * conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise. * conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise. * disk/raid5_recover.c: New file. * disk/raid6_recover.c: Likewise. * disk/mdraid_linux.c: Likewise. * disk/dmraid_nvidia.c: Likewise. * disk/i386/pc/biosdisk.c: Set total_sectors of cdrom device to ULONG_MAX. * disk/raid.c (grub_raid_open): Use the size of the smallest disk to calculate the size of raid device. (grub_raid_read): Simplify raid0 code. Support raid4, raid6 and four different layout of raid5. (grub_raid_scan_device): Remove code specific to mdraid. (grub_raid_list): New variable. (free_array): New function. (grub_raid_register): Likewise. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (GRUB_MOD_INIT): Don't iterate device here. (GRUB_MOD_FINI): Use free_array to release resource. * include/grub/raid.h: Remove macro and structure specific to mdraid. (grub_raid5_recover_func_t): New function variable type. (grub_raid6_recover_func_t): Likewise. (grub_raid5_recover_func): New variable. (grub_raid6_recover_func): Likewise. (grub_raid_register): New function. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (grub_raid_block_xor): Likewise. * util/grub-fstest.c: Add #include <grub/raid.h> and <grub/lib/crc.h>. (CMD_CRC): New macro. (part): Removed. (read_file): Handle device as well as file. (cmd_crc): New function. (fstest): Handle multiple disks. (options): Remove part, raw and long, add root and diskcount. (usage): Add crc, remove -p, -r, -l, add -r and -c. (main): Find the first non option entry and ignore subsequence options, add handling for the new options, support multiple disks. * util/grub-probe.c (probe): Add mdraid to abstraction_name.
2008-08-23 14:51:19 +00:00
#define RESERVED_BYTES (64 * 1024)
#define RESERVED_SECTORS (RESERVED_BYTES / 512)
#define NEW_SIZE_SECTORS(x) ((x & ~(RESERVED_SECTORS - 1)) \
- RESERVED_SECTORS)
#define SB_BYTES 4096
#define SB_WORDS (SB_BYTES / 4)
#define SB_SECTORS (SB_BYTES / 512)
/*
* The following are counted in 32-bit words
*/
#define SB_GENERIC_OFFSET 0
#define SB_PERSONALITY_OFFSET 64
#define SB_DISKS_OFFSET 128
#define SB_DESCRIPTOR_OFFSET 992
#define SB_GENERIC_CONSTANT_WORDS 32
#define SB_GENERIC_STATE_WORDS 32
#define SB_GENERIC_WORDS (SB_GENERIC_CONSTANT_WORDS + \
SB_GENERIC_STATE_WORDS)
#define SB_PERSONALITY_WORDS 64
#define SB_DESCRIPTOR_WORDS 32
#define SB_DISKS 27
#define SB_DISKS_WORDS (SB_DISKS * SB_DESCRIPTOR_WORDS)
#define SB_RESERVED_WORDS (1024 \
- SB_GENERIC_WORDS \
- SB_PERSONALITY_WORDS \
- SB_DISKS_WORDS \
- SB_DESCRIPTOR_WORDS)
#define SB_EQUAL_WORDS (SB_GENERIC_WORDS \
+ SB_PERSONALITY_WORDS \
+ SB_DISKS_WORDS)
/*
* Device "operational" state bits
*/
#define DISK_FAULTY 0
#define DISK_ACTIVE 1
#define DISK_SYNC 2
#define DISK_REMOVED 3
#define DISK_WRITEMOSTLY 9
#define SB_MAGIC 0xa92b4efc
/*
* Superblock state bits
*/
#define SB_CLEAN 0
#define SB_ERRORS 1
#define SB_BITMAP_PRESENT 8
struct grub_raid_disk_09
{
grub_uint32_t number; /* Device number in the entire set. */
grub_uint32_t major; /* Device major number. */
grub_uint32_t minor; /* Device minor number. */
grub_uint32_t raid_disk; /* The role of the device in the raid set. */
grub_uint32_t state; /* Operational state. */
grub_uint32_t reserved[SB_DESCRIPTOR_WORDS - 5];
};
struct grub_raid_super_09
{
/*
* Constant generic information
*/
grub_uint32_t md_magic; /* MD identifier. */
grub_uint32_t major_version; /* Major version. */
grub_uint32_t minor_version; /* Minor version. */
grub_uint32_t patch_version; /* Patchlevel version. */
grub_uint32_t gvalid_words; /* Number of used words in this section. */
grub_uint32_t set_uuid0; /* Raid set identifier. */
grub_uint32_t ctime; /* Creation time. */
grub_uint32_t level; /* Raid personality. */
grub_uint32_t size; /* Apparent size of each individual disk. */
grub_uint32_t nr_disks; /* Total disks in the raid set. */
grub_uint32_t raid_disks; /* Disks in a fully functional raid set. */
grub_uint32_t md_minor; /* Preferred MD minor device number. */
grub_uint32_t not_persistent; /* Does it have a persistent superblock. */
grub_uint32_t set_uuid1; /* Raid set identifier #2. */
grub_uint32_t set_uuid2; /* Raid set identifier #3. */
grub_uint32_t set_uuid3; /* Raid set identifier #4. */
grub_uint32_t gstate_creserved[SB_GENERIC_CONSTANT_WORDS - 16];
/*
* Generic state information
*/
grub_uint32_t utime; /* Superblock update time. */
grub_uint32_t state; /* State bits (clean, ...). */
grub_uint32_t active_disks; /* Number of currently active disks. */
grub_uint32_t working_disks; /* Number of working disks. */
grub_uint32_t failed_disks; /* Number of failed disks. */
grub_uint32_t spare_disks; /* Number of spare disks. */
grub_uint32_t sb_csum; /* Checksum of the whole superblock. */
grub_uint64_t events; /* Superblock update count. */
grub_uint64_t cp_events; /* Checkpoint update count. */
grub_uint32_t recovery_cp; /* Recovery checkpoint sector count. */
grub_uint32_t gstate_sreserved[SB_GENERIC_STATE_WORDS - 12];
/*
* Personality information
*/
grub_uint32_t layout; /* The array's physical layout. */
grub_uint32_t chunk_size; /* Chunk size in bytes. */
grub_uint32_t root_pv; /* LV root PV. */
grub_uint32_t root_block; /* LV root block. */
grub_uint32_t pstate_reserved[SB_PERSONALITY_WORDS - 4];
/*
* Disks information
*/
struct grub_raid_disk_09 disks[SB_DISKS];
/*
* Reserved
*/
grub_uint32_t reserved[SB_RESERVED_WORDS];
/*
* Active descriptor
*/
struct grub_raid_disk_09 this_disk;
} GRUB_PACKED;
2008-08-23 Bean <bean123ch@gmail.com> * conf/common.rmk (grub_probe_SOURCES): Add disk/mdraid_linux.c. (grub_fstest_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c and lib/crc.c. (pkglib_MODULES): Add raid5rec.mod, raid6rec.mod, mdraid.mod and dm_nv.mod. (raid5rec_mod_SOURCES): New macro. (raid5rec_mod_CFLAGS): Likewise. (raid5rec_mod_LDFLAGS): Likewise. (raid6rec_mod_SOURCES): Likewise. (raid6rec_mod_CFLAGS): Likewise. (raid6rec_mod_LDFLAGS): Likewise. (mdraid_mod_SOURCES): Likewise. (mdraid_mod_CFLAGS): Likewise. (mdraid_mod_LDFLAGS): Likewise. (dm_nv_mod_SOURCES): Likewise. (dm_nv_mod_CFLAGS): Likewise. (dm_nv_mod_LDFLAGS): Likewise. * conf/i386-pc.rmk (grub_setup_SOURCES): Add disk/mdraid_linux.c. (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-coreboot.rmk (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-efi.rmk (grub_emu_SOURCES): Likewise. * conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise. * conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise. * disk/raid5_recover.c: New file. * disk/raid6_recover.c: Likewise. * disk/mdraid_linux.c: Likewise. * disk/dmraid_nvidia.c: Likewise. * disk/i386/pc/biosdisk.c: Set total_sectors of cdrom device to ULONG_MAX. * disk/raid.c (grub_raid_open): Use the size of the smallest disk to calculate the size of raid device. (grub_raid_read): Simplify raid0 code. Support raid4, raid6 and four different layout of raid5. (grub_raid_scan_device): Remove code specific to mdraid. (grub_raid_list): New variable. (free_array): New function. (grub_raid_register): Likewise. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (GRUB_MOD_INIT): Don't iterate device here. (GRUB_MOD_FINI): Use free_array to release resource. * include/grub/raid.h: Remove macro and structure specific to mdraid. (grub_raid5_recover_func_t): New function variable type. (grub_raid6_recover_func_t): Likewise. (grub_raid5_recover_func): New variable. (grub_raid6_recover_func): Likewise. (grub_raid_register): New function. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (grub_raid_block_xor): Likewise. * util/grub-fstest.c: Add #include <grub/raid.h> and <grub/lib/crc.h>. (CMD_CRC): New macro. (part): Removed. (read_file): Handle device as well as file. (cmd_crc): New function. (fstest): Handle multiple disks. (options): Remove part, raw and long, add root and diskcount. (usage): Add crc, remove -p, -r, -l, add -r and -c. (main): Find the first non option entry and ignore subsequence options, add handling for the new options, support multiple disks. * util/grub-probe.c (probe): Add mdraid to abstraction_name.
2008-08-23 14:51:19 +00:00
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.
2012-01-29 13:28:01 +00:00
static struct grub_diskfilter_vg *
grub_mdraid_detect (grub_disk_t disk,
struct grub_diskfilter_pv_id *id,
grub_disk_addr_t *start_sector)
2008-08-23 Bean <bean123ch@gmail.com> * conf/common.rmk (grub_probe_SOURCES): Add disk/mdraid_linux.c. (grub_fstest_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c and lib/crc.c. (pkglib_MODULES): Add raid5rec.mod, raid6rec.mod, mdraid.mod and dm_nv.mod. (raid5rec_mod_SOURCES): New macro. (raid5rec_mod_CFLAGS): Likewise. (raid5rec_mod_LDFLAGS): Likewise. (raid6rec_mod_SOURCES): Likewise. (raid6rec_mod_CFLAGS): Likewise. (raid6rec_mod_LDFLAGS): Likewise. (mdraid_mod_SOURCES): Likewise. (mdraid_mod_CFLAGS): Likewise. (mdraid_mod_LDFLAGS): Likewise. (dm_nv_mod_SOURCES): Likewise. (dm_nv_mod_CFLAGS): Likewise. (dm_nv_mod_LDFLAGS): Likewise. * conf/i386-pc.rmk (grub_setup_SOURCES): Add disk/mdraid_linux.c. (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-coreboot.rmk (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-efi.rmk (grub_emu_SOURCES): Likewise. * conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise. * conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise. * disk/raid5_recover.c: New file. * disk/raid6_recover.c: Likewise. * disk/mdraid_linux.c: Likewise. * disk/dmraid_nvidia.c: Likewise. * disk/i386/pc/biosdisk.c: Set total_sectors of cdrom device to ULONG_MAX. * disk/raid.c (grub_raid_open): Use the size of the smallest disk to calculate the size of raid device. (grub_raid_read): Simplify raid0 code. Support raid4, raid6 and four different layout of raid5. (grub_raid_scan_device): Remove code specific to mdraid. (grub_raid_list): New variable. (free_array): New function. (grub_raid_register): Likewise. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (GRUB_MOD_INIT): Don't iterate device here. (GRUB_MOD_FINI): Use free_array to release resource. * include/grub/raid.h: Remove macro and structure specific to mdraid. (grub_raid5_recover_func_t): New function variable type. (grub_raid6_recover_func_t): Likewise. (grub_raid5_recover_func): New variable. (grub_raid6_recover_func): Likewise. (grub_raid_register): New function. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (grub_raid_block_xor): Likewise. * util/grub-fstest.c: Add #include <grub/raid.h> and <grub/lib/crc.h>. (CMD_CRC): New macro. (part): Removed. (read_file): Handle device as well as file. (cmd_crc): New function. (fstest): Handle multiple disks. (options): Remove part, raw and long, add root and diskcount. (usage): Add crc, remove -p, -r, -l, add -r and -c. (main): Find the first non option entry and ignore subsequence options, add handling for the new options, support multiple disks. * util/grub-probe.c (probe): Add mdraid to abstraction_name.
2008-08-23 14:51:19 +00:00
{
grub_disk_addr_t sector;
grub_uint64_t size;
struct grub_raid_super_09 *sb = NULL;
2008-08-23 Bean <bean123ch@gmail.com> * conf/common.rmk (grub_probe_SOURCES): Add disk/mdraid_linux.c. (grub_fstest_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c and lib/crc.c. (pkglib_MODULES): Add raid5rec.mod, raid6rec.mod, mdraid.mod and dm_nv.mod. (raid5rec_mod_SOURCES): New macro. (raid5rec_mod_CFLAGS): Likewise. (raid5rec_mod_LDFLAGS): Likewise. (raid6rec_mod_SOURCES): Likewise. (raid6rec_mod_CFLAGS): Likewise. (raid6rec_mod_LDFLAGS): Likewise. (mdraid_mod_SOURCES): Likewise. (mdraid_mod_CFLAGS): Likewise. (mdraid_mod_LDFLAGS): Likewise. (dm_nv_mod_SOURCES): Likewise. (dm_nv_mod_CFLAGS): Likewise. (dm_nv_mod_LDFLAGS): Likewise. * conf/i386-pc.rmk (grub_setup_SOURCES): Add disk/mdraid_linux.c. (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-coreboot.rmk (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-efi.rmk (grub_emu_SOURCES): Likewise. * conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise. * conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise. * disk/raid5_recover.c: New file. * disk/raid6_recover.c: Likewise. * disk/mdraid_linux.c: Likewise. * disk/dmraid_nvidia.c: Likewise. * disk/i386/pc/biosdisk.c: Set total_sectors of cdrom device to ULONG_MAX. * disk/raid.c (grub_raid_open): Use the size of the smallest disk to calculate the size of raid device. (grub_raid_read): Simplify raid0 code. Support raid4, raid6 and four different layout of raid5. (grub_raid_scan_device): Remove code specific to mdraid. (grub_raid_list): New variable. (free_array): New function. (grub_raid_register): Likewise. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (GRUB_MOD_INIT): Don't iterate device here. (GRUB_MOD_FINI): Use free_array to release resource. * include/grub/raid.h: Remove macro and structure specific to mdraid. (grub_raid5_recover_func_t): New function variable type. (grub_raid6_recover_func_t): Likewise. (grub_raid5_recover_func): New variable. (grub_raid6_recover_func): Likewise. (grub_raid_register): New function. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (grub_raid_block_xor): Likewise. * util/grub-fstest.c: Add #include <grub/raid.h> and <grub/lib/crc.h>. (CMD_CRC): New macro. (part): Removed. (read_file): Handle device as well as file. (cmd_crc): New function. (fstest): Handle multiple disks. (options): Remove part, raw and long, add root and diskcount. (usage): Add crc, remove -p, -r, -l, add -r and -c. (main): Find the first non option entry and ignore subsequence options, add handling for the new options, support multiple disks. * util/grub-probe.c (probe): Add mdraid to abstraction_name.
2008-08-23 14:51:19 +00:00
grub_uint32_t *uuid;
grub_uint32_t level;
struct grub_diskfilter_vg *ret;
/* The sector where the mdraid 0.90 superblock is stored, if available. */
size = grub_disk_get_size (disk);
if (size == GRUB_DISK_SIZE_UNKNOWN)
/* not 0.9x raid. */
return NULL;
sector = NEW_SIZE_SECTORS (size);
sb = grub_malloc (sizeof (*sb));
if (!sb)
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.
2012-01-29 13:28:01 +00:00
return NULL;
if (grub_disk_read (disk, sector, 0, SB_BYTES, sb))
goto fail;
/* Look whether there is a mdraid 0.90 superblock. */
if (sb->md_magic != grub_cpu_to_md32_compile_time (SB_MAGIC))
/* not 0.9x raid. */
goto fail;
if (sb->major_version != grub_cpu_to_md32_compile_time (0)
|| sb->minor_version != grub_cpu_to_md32_compile_time (90))
/* Unsupported version. */
goto fail;
2008-08-23 Bean <bean123ch@gmail.com> * conf/common.rmk (grub_probe_SOURCES): Add disk/mdraid_linux.c. (grub_fstest_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c and lib/crc.c. (pkglib_MODULES): Add raid5rec.mod, raid6rec.mod, mdraid.mod and dm_nv.mod. (raid5rec_mod_SOURCES): New macro. (raid5rec_mod_CFLAGS): Likewise. (raid5rec_mod_LDFLAGS): Likewise. (raid6rec_mod_SOURCES): Likewise. (raid6rec_mod_CFLAGS): Likewise. (raid6rec_mod_LDFLAGS): Likewise. (mdraid_mod_SOURCES): Likewise. (mdraid_mod_CFLAGS): Likewise. (mdraid_mod_LDFLAGS): Likewise. (dm_nv_mod_SOURCES): Likewise. (dm_nv_mod_CFLAGS): Likewise. (dm_nv_mod_LDFLAGS): Likewise. * conf/i386-pc.rmk (grub_setup_SOURCES): Add disk/mdraid_linux.c. (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-coreboot.rmk (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-efi.rmk (grub_emu_SOURCES): Likewise. * conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise. * conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise. * disk/raid5_recover.c: New file. * disk/raid6_recover.c: Likewise. * disk/mdraid_linux.c: Likewise. * disk/dmraid_nvidia.c: Likewise. * disk/i386/pc/biosdisk.c: Set total_sectors of cdrom device to ULONG_MAX. * disk/raid.c (grub_raid_open): Use the size of the smallest disk to calculate the size of raid device. (grub_raid_read): Simplify raid0 code. Support raid4, raid6 and four different layout of raid5. (grub_raid_scan_device): Remove code specific to mdraid. (grub_raid_list): New variable. (free_array): New function. (grub_raid_register): Likewise. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (GRUB_MOD_INIT): Don't iterate device here. (GRUB_MOD_FINI): Use free_array to release resource. * include/grub/raid.h: Remove macro and structure specific to mdraid. (grub_raid5_recover_func_t): New function variable type. (grub_raid6_recover_func_t): Likewise. (grub_raid5_recover_func): New variable. (grub_raid6_recover_func): Likewise. (grub_raid_register): New function. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (grub_raid_block_xor): Likewise. * util/grub-fstest.c: Add #include <grub/raid.h> and <grub/lib/crc.h>. (CMD_CRC): New macro. (part): Removed. (read_file): Handle device as well as file. (cmd_crc): New function. (fstest): Handle multiple disks. (options): Remove part, raw and long, add root and diskcount. (usage): Add crc, remove -p, -r, -l, add -r and -c. (main): Find the first non option entry and ignore subsequence options, add handling for the new options, support multiple disks. * util/grub-probe.c (probe): Add mdraid to abstraction_name.
2008-08-23 14:51:19 +00:00
/* No need for explicit check that sb->size is 0 (unspecified) since
0 >= non-0 is false. */
if (((grub_disk_addr_t) grub_md_to_cpu32 (sb->size)) * 2 >= size)
goto fail;
/* FIXME: Check the checksum. */
2008-08-23 Bean <bean123ch@gmail.com> * conf/common.rmk (grub_probe_SOURCES): Add disk/mdraid_linux.c. (grub_fstest_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c and lib/crc.c. (pkglib_MODULES): Add raid5rec.mod, raid6rec.mod, mdraid.mod and dm_nv.mod. (raid5rec_mod_SOURCES): New macro. (raid5rec_mod_CFLAGS): Likewise. (raid5rec_mod_LDFLAGS): Likewise. (raid6rec_mod_SOURCES): Likewise. (raid6rec_mod_CFLAGS): Likewise. (raid6rec_mod_LDFLAGS): Likewise. (mdraid_mod_SOURCES): Likewise. (mdraid_mod_CFLAGS): Likewise. (mdraid_mod_LDFLAGS): Likewise. (dm_nv_mod_SOURCES): Likewise. (dm_nv_mod_CFLAGS): Likewise. (dm_nv_mod_LDFLAGS): Likewise. * conf/i386-pc.rmk (grub_setup_SOURCES): Add disk/mdraid_linux.c. (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-coreboot.rmk (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-efi.rmk (grub_emu_SOURCES): Likewise. * conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise. * conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise. * disk/raid5_recover.c: New file. * disk/raid6_recover.c: Likewise. * disk/mdraid_linux.c: Likewise. * disk/dmraid_nvidia.c: Likewise. * disk/i386/pc/biosdisk.c: Set total_sectors of cdrom device to ULONG_MAX. * disk/raid.c (grub_raid_open): Use the size of the smallest disk to calculate the size of raid device. (grub_raid_read): Simplify raid0 code. Support raid4, raid6 and four different layout of raid5. (grub_raid_scan_device): Remove code specific to mdraid. (grub_raid_list): New variable. (free_array): New function. (grub_raid_register): Likewise. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (GRUB_MOD_INIT): Don't iterate device here. (GRUB_MOD_FINI): Use free_array to release resource. * include/grub/raid.h: Remove macro and structure specific to mdraid. (grub_raid5_recover_func_t): New function variable type. (grub_raid6_recover_func_t): Likewise. (grub_raid5_recover_func): New variable. (grub_raid6_recover_func): Likewise. (grub_raid_register): New function. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (grub_raid_block_xor): Likewise. * util/grub-fstest.c: Add #include <grub/raid.h> and <grub/lib/crc.h>. (CMD_CRC): New macro. (part): Removed. (read_file): Handle device as well as file. (cmd_crc): New function. (fstest): Handle multiple disks. (options): Remove part, raw and long, add root and diskcount. (usage): Add crc, remove -p, -r, -l, add -r and -c. (main): Find the first non option entry and ignore subsequence options, add handling for the new options, support multiple disks. * util/grub-probe.c (probe): Add mdraid to abstraction_name.
2008-08-23 14:51:19 +00:00
level = grub_md_to_cpu32 (sb->level);
2008-08-23 Bean <bean123ch@gmail.com> * conf/common.rmk (grub_probe_SOURCES): Add disk/mdraid_linux.c. (grub_fstest_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c and lib/crc.c. (pkglib_MODULES): Add raid5rec.mod, raid6rec.mod, mdraid.mod and dm_nv.mod. (raid5rec_mod_SOURCES): New macro. (raid5rec_mod_CFLAGS): Likewise. (raid5rec_mod_LDFLAGS): Likewise. (raid6rec_mod_SOURCES): Likewise. (raid6rec_mod_CFLAGS): Likewise. (raid6rec_mod_LDFLAGS): Likewise. (mdraid_mod_SOURCES): Likewise. (mdraid_mod_CFLAGS): Likewise. (mdraid_mod_LDFLAGS): Likewise. (dm_nv_mod_SOURCES): Likewise. (dm_nv_mod_CFLAGS): Likewise. (dm_nv_mod_LDFLAGS): Likewise. * conf/i386-pc.rmk (grub_setup_SOURCES): Add disk/mdraid_linux.c. (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-coreboot.rmk (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-efi.rmk (grub_emu_SOURCES): Likewise. * conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise. * conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise. * disk/raid5_recover.c: New file. * disk/raid6_recover.c: Likewise. * disk/mdraid_linux.c: Likewise. * disk/dmraid_nvidia.c: Likewise. * disk/i386/pc/biosdisk.c: Set total_sectors of cdrom device to ULONG_MAX. * disk/raid.c (grub_raid_open): Use the size of the smallest disk to calculate the size of raid device. (grub_raid_read): Simplify raid0 code. Support raid4, raid6 and four different layout of raid5. (grub_raid_scan_device): Remove code specific to mdraid. (grub_raid_list): New variable. (free_array): New function. (grub_raid_register): Likewise. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (GRUB_MOD_INIT): Don't iterate device here. (GRUB_MOD_FINI): Use free_array to release resource. * include/grub/raid.h: Remove macro and structure specific to mdraid. (grub_raid5_recover_func_t): New function variable type. (grub_raid6_recover_func_t): Likewise. (grub_raid5_recover_func): New variable. (grub_raid6_recover_func): Likewise. (grub_raid_register): New function. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (grub_raid_block_xor): Likewise. * util/grub-fstest.c: Add #include <grub/raid.h> and <grub/lib/crc.h>. (CMD_CRC): New macro. (part): Removed. (read_file): Handle device as well as file. (cmd_crc): New function. (fstest): Handle multiple disks. (options): Remove part, raw and long, add root and diskcount. (usage): Add crc, remove -p, -r, -l, add -r and -c. (main): Find the first non option entry and ignore subsequence options, add handling for the new options, support multiple disks. * util/grub-probe.c (probe): Add mdraid to abstraction_name.
2008-08-23 14:51:19 +00:00
/* Multipath. */
if ((int) level == -4)
level = 1;
2008-08-23 Bean <bean123ch@gmail.com> * conf/common.rmk (grub_probe_SOURCES): Add disk/mdraid_linux.c. (grub_fstest_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c and lib/crc.c. (pkglib_MODULES): Add raid5rec.mod, raid6rec.mod, mdraid.mod and dm_nv.mod. (raid5rec_mod_SOURCES): New macro. (raid5rec_mod_CFLAGS): Likewise. (raid5rec_mod_LDFLAGS): Likewise. (raid6rec_mod_SOURCES): Likewise. (raid6rec_mod_CFLAGS): Likewise. (raid6rec_mod_LDFLAGS): Likewise. (mdraid_mod_SOURCES): Likewise. (mdraid_mod_CFLAGS): Likewise. (mdraid_mod_LDFLAGS): Likewise. (dm_nv_mod_SOURCES): Likewise. (dm_nv_mod_CFLAGS): Likewise. (dm_nv_mod_LDFLAGS): Likewise. * conf/i386-pc.rmk (grub_setup_SOURCES): Add disk/mdraid_linux.c. (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-coreboot.rmk (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-efi.rmk (grub_emu_SOURCES): Likewise. * conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise. * conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise. * disk/raid5_recover.c: New file. * disk/raid6_recover.c: Likewise. * disk/mdraid_linux.c: Likewise. * disk/dmraid_nvidia.c: Likewise. * disk/i386/pc/biosdisk.c: Set total_sectors of cdrom device to ULONG_MAX. * disk/raid.c (grub_raid_open): Use the size of the smallest disk to calculate the size of raid device. (grub_raid_read): Simplify raid0 code. Support raid4, raid6 and four different layout of raid5. (grub_raid_scan_device): Remove code specific to mdraid. (grub_raid_list): New variable. (free_array): New function. (grub_raid_register): Likewise. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (GRUB_MOD_INIT): Don't iterate device here. (GRUB_MOD_FINI): Use free_array to release resource. * include/grub/raid.h: Remove macro and structure specific to mdraid. (grub_raid5_recover_func_t): New function variable type. (grub_raid6_recover_func_t): Likewise. (grub_raid5_recover_func): New variable. (grub_raid6_recover_func): Likewise. (grub_raid_register): New function. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (grub_raid_block_xor): Likewise. * util/grub-fstest.c: Add #include <grub/raid.h> and <grub/lib/crc.h>. (CMD_CRC): New macro. (part): Removed. (read_file): Handle device as well as file. (cmd_crc): New function. (fstest): Handle multiple disks. (options): Remove part, raw and long, add root and diskcount. (usage): Add crc, remove -p, -r, -l, add -r and -c. (main): Find the first non option entry and ignore subsequence options, add handling for the new options, support multiple disks. * util/grub-probe.c (probe): Add mdraid to abstraction_name.
2008-08-23 14:51:19 +00:00
if (level != 0 && level != 1 && level != 4 &&
level != 5 && level != 6 && level != 10)
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.
2012-01-29 13:28:01 +00:00
{
grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"unsupported RAID level: %d", level);
goto fail;
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.
2012-01-29 13:28:01 +00:00
}
if (grub_md_to_cpu32 (sb->this_disk.number) == 0xffff
|| grub_md_to_cpu32 (sb->this_disk.number) == 0xfffe)
/* Spares aren't implemented. */
goto fail;
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.
2012-01-29 13:28:01 +00:00
uuid = grub_malloc (16);
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.
2012-01-29 13:28:01 +00:00
if (!uuid)
goto fail;
2008-08-23 Bean <bean123ch@gmail.com> * conf/common.rmk (grub_probe_SOURCES): Add disk/mdraid_linux.c. (grub_fstest_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c and lib/crc.c. (pkglib_MODULES): Add raid5rec.mod, raid6rec.mod, mdraid.mod and dm_nv.mod. (raid5rec_mod_SOURCES): New macro. (raid5rec_mod_CFLAGS): Likewise. (raid5rec_mod_LDFLAGS): Likewise. (raid6rec_mod_SOURCES): Likewise. (raid6rec_mod_CFLAGS): Likewise. (raid6rec_mod_LDFLAGS): Likewise. (mdraid_mod_SOURCES): Likewise. (mdraid_mod_CFLAGS): Likewise. (mdraid_mod_LDFLAGS): Likewise. (dm_nv_mod_SOURCES): Likewise. (dm_nv_mod_CFLAGS): Likewise. (dm_nv_mod_LDFLAGS): Likewise. * conf/i386-pc.rmk (grub_setup_SOURCES): Add disk/mdraid_linux.c. (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-coreboot.rmk (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-efi.rmk (grub_emu_SOURCES): Likewise. * conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise. * conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise. * disk/raid5_recover.c: New file. * disk/raid6_recover.c: Likewise. * disk/mdraid_linux.c: Likewise. * disk/dmraid_nvidia.c: Likewise. * disk/i386/pc/biosdisk.c: Set total_sectors of cdrom device to ULONG_MAX. * disk/raid.c (grub_raid_open): Use the size of the smallest disk to calculate the size of raid device. (grub_raid_read): Simplify raid0 code. Support raid4, raid6 and four different layout of raid5. (grub_raid_scan_device): Remove code specific to mdraid. (grub_raid_list): New variable. (free_array): New function. (grub_raid_register): Likewise. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (GRUB_MOD_INIT): Don't iterate device here. (GRUB_MOD_FINI): Use free_array to release resource. * include/grub/raid.h: Remove macro and structure specific to mdraid. (grub_raid5_recover_func_t): New function variable type. (grub_raid6_recover_func_t): Likewise. (grub_raid5_recover_func): New variable. (grub_raid6_recover_func): Likewise. (grub_raid_register): New function. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (grub_raid_block_xor): Likewise. * util/grub-fstest.c: Add #include <grub/raid.h> and <grub/lib/crc.h>. (CMD_CRC): New macro. (part): Removed. (read_file): Handle device as well as file. (cmd_crc): New function. (fstest): Handle multiple disks. (options): Remove part, raw and long, add root and diskcount. (usage): Add crc, remove -p, -r, -l, add -r and -c. (main): Find the first non option entry and ignore subsequence options, add handling for the new options, support multiple disks. * util/grub-probe.c (probe): Add mdraid to abstraction_name.
2008-08-23 14:51:19 +00:00
uuid[0] = grub_swap_bytes32 (sb->set_uuid0);
uuid[1] = grub_swap_bytes32 (sb->set_uuid1);
uuid[2] = grub_swap_bytes32 (sb->set_uuid2);
uuid[3] = grub_swap_bytes32 (sb->set_uuid3);
2008-08-23 Bean <bean123ch@gmail.com> * conf/common.rmk (grub_probe_SOURCES): Add disk/mdraid_linux.c. (grub_fstest_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c and lib/crc.c. (pkglib_MODULES): Add raid5rec.mod, raid6rec.mod, mdraid.mod and dm_nv.mod. (raid5rec_mod_SOURCES): New macro. (raid5rec_mod_CFLAGS): Likewise. (raid5rec_mod_LDFLAGS): Likewise. (raid6rec_mod_SOURCES): Likewise. (raid6rec_mod_CFLAGS): Likewise. (raid6rec_mod_LDFLAGS): Likewise. (mdraid_mod_SOURCES): Likewise. (mdraid_mod_CFLAGS): Likewise. (mdraid_mod_LDFLAGS): Likewise. (dm_nv_mod_SOURCES): Likewise. (dm_nv_mod_CFLAGS): Likewise. (dm_nv_mod_LDFLAGS): Likewise. * conf/i386-pc.rmk (grub_setup_SOURCES): Add disk/mdraid_linux.c. (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-coreboot.rmk (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-efi.rmk (grub_emu_SOURCES): Likewise. * conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise. * conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise. * disk/raid5_recover.c: New file. * disk/raid6_recover.c: Likewise. * disk/mdraid_linux.c: Likewise. * disk/dmraid_nvidia.c: Likewise. * disk/i386/pc/biosdisk.c: Set total_sectors of cdrom device to ULONG_MAX. * disk/raid.c (grub_raid_open): Use the size of the smallest disk to calculate the size of raid device. (grub_raid_read): Simplify raid0 code. Support raid4, raid6 and four different layout of raid5. (grub_raid_scan_device): Remove code specific to mdraid. (grub_raid_list): New variable. (free_array): New function. (grub_raid_register): Likewise. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (GRUB_MOD_INIT): Don't iterate device here. (GRUB_MOD_FINI): Use free_array to release resource. * include/grub/raid.h: Remove macro and structure specific to mdraid. (grub_raid5_recover_func_t): New function variable type. (grub_raid6_recover_func_t): Likewise. (grub_raid5_recover_func): New variable. (grub_raid6_recover_func): Likewise. (grub_raid_register): New function. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (grub_raid_block_xor): Likewise. * util/grub-fstest.c: Add #include <grub/raid.h> and <grub/lib/crc.h>. (CMD_CRC): New macro. (part): Removed. (read_file): Handle device as well as file. (cmd_crc): New function. (fstest): Handle multiple disks. (options): Remove part, raw and long, add root and diskcount. (usage): Add crc, remove -p, -r, -l, add -r and -c. (main): Find the first non option entry and ignore subsequence options, add handling for the new options, support multiple disks. * util/grub-probe.c (probe): Add mdraid to abstraction_name.
2008-08-23 14:51:19 +00:00
*start_sector = 0;
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.
2012-01-29 13:28:01 +00:00
id->uuidlen = 0;
id->id = grub_md_to_cpu32 (sb->this_disk.number);
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.
2012-01-29 13:28:01 +00:00
char buf[32];
grub_snprintf (buf, sizeof (buf), "md%d", grub_md_to_cpu32 (sb->md_minor));
ret = grub_diskfilter_make_raid (16, (char *) uuid,
grub_md_to_cpu32 (sb->raid_disks), buf,
(sb->size) ? ((grub_disk_addr_t)
grub_md_to_cpu32 (sb->size)) * 2
: sector,
grub_md_to_cpu32 (sb->chunk_size) >> 9,
grub_md_to_cpu32 (sb->layout),
level);
grub_free (sb);
return ret;
fail:
grub_free (sb);
return NULL;
}
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.
2012-01-29 13:28:01 +00:00
static struct grub_diskfilter grub_mdraid_dev = {
#ifdef MODE_BIGENDIAN
.name = "mdraid09_be",
#else
.name = "mdraid09",
#endif
2008-08-23 Bean <bean123ch@gmail.com> * conf/common.rmk (grub_probe_SOURCES): Add disk/mdraid_linux.c. (grub_fstest_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c and lib/crc.c. (pkglib_MODULES): Add raid5rec.mod, raid6rec.mod, mdraid.mod and dm_nv.mod. (raid5rec_mod_SOURCES): New macro. (raid5rec_mod_CFLAGS): Likewise. (raid5rec_mod_LDFLAGS): Likewise. (raid6rec_mod_SOURCES): Likewise. (raid6rec_mod_CFLAGS): Likewise. (raid6rec_mod_LDFLAGS): Likewise. (mdraid_mod_SOURCES): Likewise. (mdraid_mod_CFLAGS): Likewise. (mdraid_mod_LDFLAGS): Likewise. (dm_nv_mod_SOURCES): Likewise. (dm_nv_mod_CFLAGS): Likewise. (dm_nv_mod_LDFLAGS): Likewise. * conf/i386-pc.rmk (grub_setup_SOURCES): Add disk/mdraid_linux.c. (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-coreboot.rmk (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-efi.rmk (grub_emu_SOURCES): Likewise. * conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise. * conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise. * disk/raid5_recover.c: New file. * disk/raid6_recover.c: Likewise. * disk/mdraid_linux.c: Likewise. * disk/dmraid_nvidia.c: Likewise. * disk/i386/pc/biosdisk.c: Set total_sectors of cdrom device to ULONG_MAX. * disk/raid.c (grub_raid_open): Use the size of the smallest disk to calculate the size of raid device. (grub_raid_read): Simplify raid0 code. Support raid4, raid6 and four different layout of raid5. (grub_raid_scan_device): Remove code specific to mdraid. (grub_raid_list): New variable. (free_array): New function. (grub_raid_register): Likewise. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (GRUB_MOD_INIT): Don't iterate device here. (GRUB_MOD_FINI): Use free_array to release resource. * include/grub/raid.h: Remove macro and structure specific to mdraid. (grub_raid5_recover_func_t): New function variable type. (grub_raid6_recover_func_t): Likewise. (grub_raid5_recover_func): New variable. (grub_raid6_recover_func): Likewise. (grub_raid_register): New function. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (grub_raid_block_xor): Likewise. * util/grub-fstest.c: Add #include <grub/raid.h> and <grub/lib/crc.h>. (CMD_CRC): New macro. (part): Removed. (read_file): Handle device as well as file. (cmd_crc): New function. (fstest): Handle multiple disks. (options): Remove part, raw and long, add root and diskcount. (usage): Add crc, remove -p, -r, -l, add -r and -c. (main): Find the first non option entry and ignore subsequence options, add handling for the new options, support multiple disks. * util/grub-probe.c (probe): Add mdraid to abstraction_name.
2008-08-23 14:51:19 +00:00
.detect = grub_mdraid_detect,
.next = 0
};
#ifdef MODE_BIGENDIAN
GRUB_MOD_INIT (mdraid09_be)
#else
GRUB_MOD_INIT (mdraid09)
#endif
2008-08-23 Bean <bean123ch@gmail.com> * conf/common.rmk (grub_probe_SOURCES): Add disk/mdraid_linux.c. (grub_fstest_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c and lib/crc.c. (pkglib_MODULES): Add raid5rec.mod, raid6rec.mod, mdraid.mod and dm_nv.mod. (raid5rec_mod_SOURCES): New macro. (raid5rec_mod_CFLAGS): Likewise. (raid5rec_mod_LDFLAGS): Likewise. (raid6rec_mod_SOURCES): Likewise. (raid6rec_mod_CFLAGS): Likewise. (raid6rec_mod_LDFLAGS): Likewise. (mdraid_mod_SOURCES): Likewise. (mdraid_mod_CFLAGS): Likewise. (mdraid_mod_LDFLAGS): Likewise. (dm_nv_mod_SOURCES): Likewise. (dm_nv_mod_CFLAGS): Likewise. (dm_nv_mod_LDFLAGS): Likewise. * conf/i386-pc.rmk (grub_setup_SOURCES): Add disk/mdraid_linux.c. (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-coreboot.rmk (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-efi.rmk (grub_emu_SOURCES): Likewise. * conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise. * conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise. * disk/raid5_recover.c: New file. * disk/raid6_recover.c: Likewise. * disk/mdraid_linux.c: Likewise. * disk/dmraid_nvidia.c: Likewise. * disk/i386/pc/biosdisk.c: Set total_sectors of cdrom device to ULONG_MAX. * disk/raid.c (grub_raid_open): Use the size of the smallest disk to calculate the size of raid device. (grub_raid_read): Simplify raid0 code. Support raid4, raid6 and four different layout of raid5. (grub_raid_scan_device): Remove code specific to mdraid. (grub_raid_list): New variable. (free_array): New function. (grub_raid_register): Likewise. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (GRUB_MOD_INIT): Don't iterate device here. (GRUB_MOD_FINI): Use free_array to release resource. * include/grub/raid.h: Remove macro and structure specific to mdraid. (grub_raid5_recover_func_t): New function variable type. (grub_raid6_recover_func_t): Likewise. (grub_raid5_recover_func): New variable. (grub_raid6_recover_func): Likewise. (grub_raid_register): New function. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (grub_raid_block_xor): Likewise. * util/grub-fstest.c: Add #include <grub/raid.h> and <grub/lib/crc.h>. (CMD_CRC): New macro. (part): Removed. (read_file): Handle device as well as file. (cmd_crc): New function. (fstest): Handle multiple disks. (options): Remove part, raw and long, add root and diskcount. (usage): Add crc, remove -p, -r, -l, add -r and -c. (main): Find the first non option entry and ignore subsequence options, add handling for the new options, support multiple disks. * util/grub-probe.c (probe): Add mdraid to abstraction_name.
2008-08-23 14:51:19 +00:00
{
grub_diskfilter_register_front (&grub_mdraid_dev);
2008-08-23 Bean <bean123ch@gmail.com> * conf/common.rmk (grub_probe_SOURCES): Add disk/mdraid_linux.c. (grub_fstest_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c and lib/crc.c. (pkglib_MODULES): Add raid5rec.mod, raid6rec.mod, mdraid.mod and dm_nv.mod. (raid5rec_mod_SOURCES): New macro. (raid5rec_mod_CFLAGS): Likewise. (raid5rec_mod_LDFLAGS): Likewise. (raid6rec_mod_SOURCES): Likewise. (raid6rec_mod_CFLAGS): Likewise. (raid6rec_mod_LDFLAGS): Likewise. (mdraid_mod_SOURCES): Likewise. (mdraid_mod_CFLAGS): Likewise. (mdraid_mod_LDFLAGS): Likewise. (dm_nv_mod_SOURCES): Likewise. (dm_nv_mod_CFLAGS): Likewise. (dm_nv_mod_LDFLAGS): Likewise. * conf/i386-pc.rmk (grub_setup_SOURCES): Add disk/mdraid_linux.c. (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-coreboot.rmk (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-efi.rmk (grub_emu_SOURCES): Likewise. * conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise. * conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise. * disk/raid5_recover.c: New file. * disk/raid6_recover.c: Likewise. * disk/mdraid_linux.c: Likewise. * disk/dmraid_nvidia.c: Likewise. * disk/i386/pc/biosdisk.c: Set total_sectors of cdrom device to ULONG_MAX. * disk/raid.c (grub_raid_open): Use the size of the smallest disk to calculate the size of raid device. (grub_raid_read): Simplify raid0 code. Support raid4, raid6 and four different layout of raid5. (grub_raid_scan_device): Remove code specific to mdraid. (grub_raid_list): New variable. (free_array): New function. (grub_raid_register): Likewise. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (GRUB_MOD_INIT): Don't iterate device here. (GRUB_MOD_FINI): Use free_array to release resource. * include/grub/raid.h: Remove macro and structure specific to mdraid. (grub_raid5_recover_func_t): New function variable type. (grub_raid6_recover_func_t): Likewise. (grub_raid5_recover_func): New variable. (grub_raid6_recover_func): Likewise. (grub_raid_register): New function. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (grub_raid_block_xor): Likewise. * util/grub-fstest.c: Add #include <grub/raid.h> and <grub/lib/crc.h>. (CMD_CRC): New macro. (part): Removed. (read_file): Handle device as well as file. (cmd_crc): New function. (fstest): Handle multiple disks. (options): Remove part, raw and long, add root and diskcount. (usage): Add crc, remove -p, -r, -l, add -r and -c. (main): Find the first non option entry and ignore subsequence options, add handling for the new options, support multiple disks. * util/grub-probe.c (probe): Add mdraid to abstraction_name.
2008-08-23 14:51:19 +00:00
}
#ifdef MODE_BIGENDIAN
GRUB_MOD_FINI (mdraid09_be)
#else
GRUB_MOD_FINI (mdraid09)
#endif
2008-08-23 Bean <bean123ch@gmail.com> * conf/common.rmk (grub_probe_SOURCES): Add disk/mdraid_linux.c. (grub_fstest_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c and lib/crc.c. (pkglib_MODULES): Add raid5rec.mod, raid6rec.mod, mdraid.mod and dm_nv.mod. (raid5rec_mod_SOURCES): New macro. (raid5rec_mod_CFLAGS): Likewise. (raid5rec_mod_LDFLAGS): Likewise. (raid6rec_mod_SOURCES): Likewise. (raid6rec_mod_CFLAGS): Likewise. (raid6rec_mod_LDFLAGS): Likewise. (mdraid_mod_SOURCES): Likewise. (mdraid_mod_CFLAGS): Likewise. (mdraid_mod_LDFLAGS): Likewise. (dm_nv_mod_SOURCES): Likewise. (dm_nv_mod_CFLAGS): Likewise. (dm_nv_mod_LDFLAGS): Likewise. * conf/i386-pc.rmk (grub_setup_SOURCES): Add disk/mdraid_linux.c. (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-coreboot.rmk (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-efi.rmk (grub_emu_SOURCES): Likewise. * conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise. * conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise. * disk/raid5_recover.c: New file. * disk/raid6_recover.c: Likewise. * disk/mdraid_linux.c: Likewise. * disk/dmraid_nvidia.c: Likewise. * disk/i386/pc/biosdisk.c: Set total_sectors of cdrom device to ULONG_MAX. * disk/raid.c (grub_raid_open): Use the size of the smallest disk to calculate the size of raid device. (grub_raid_read): Simplify raid0 code. Support raid4, raid6 and four different layout of raid5. (grub_raid_scan_device): Remove code specific to mdraid. (grub_raid_list): New variable. (free_array): New function. (grub_raid_register): Likewise. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (GRUB_MOD_INIT): Don't iterate device here. (GRUB_MOD_FINI): Use free_array to release resource. * include/grub/raid.h: Remove macro and structure specific to mdraid. (grub_raid5_recover_func_t): New function variable type. (grub_raid6_recover_func_t): Likewise. (grub_raid5_recover_func): New variable. (grub_raid6_recover_func): Likewise. (grub_raid_register): New function. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (grub_raid_block_xor): Likewise. * util/grub-fstest.c: Add #include <grub/raid.h> and <grub/lib/crc.h>. (CMD_CRC): New macro. (part): Removed. (read_file): Handle device as well as file. (cmd_crc): New function. (fstest): Handle multiple disks. (options): Remove part, raw and long, add root and diskcount. (usage): Add crc, remove -p, -r, -l, add -r and -c. (main): Find the first non option entry and ignore subsequence options, add handling for the new options, support multiple disks. * util/grub-probe.c (probe): Add mdraid to abstraction_name.
2008-08-23 14:51:19 +00:00
{
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.
2012-01-29 13:28:01 +00:00
grub_diskfilter_unregister (&grub_mdraid_dev);
2008-08-23 Bean <bean123ch@gmail.com> * conf/common.rmk (grub_probe_SOURCES): Add disk/mdraid_linux.c. (grub_fstest_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c and lib/crc.c. (pkglib_MODULES): Add raid5rec.mod, raid6rec.mod, mdraid.mod and dm_nv.mod. (raid5rec_mod_SOURCES): New macro. (raid5rec_mod_CFLAGS): Likewise. (raid5rec_mod_LDFLAGS): Likewise. (raid6rec_mod_SOURCES): Likewise. (raid6rec_mod_CFLAGS): Likewise. (raid6rec_mod_LDFLAGS): Likewise. (mdraid_mod_SOURCES): Likewise. (mdraid_mod_CFLAGS): Likewise. (mdraid_mod_LDFLAGS): Likewise. (dm_nv_mod_SOURCES): Likewise. (dm_nv_mod_CFLAGS): Likewise. (dm_nv_mod_LDFLAGS): Likewise. * conf/i386-pc.rmk (grub_setup_SOURCES): Add disk/mdraid_linux.c. (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-coreboot.rmk (grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c. * conf/i386-efi.rmk (grub_emu_SOURCES): Likewise. * conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise. * conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise. * disk/raid5_recover.c: New file. * disk/raid6_recover.c: Likewise. * disk/mdraid_linux.c: Likewise. * disk/dmraid_nvidia.c: Likewise. * disk/i386/pc/biosdisk.c: Set total_sectors of cdrom device to ULONG_MAX. * disk/raid.c (grub_raid_open): Use the size of the smallest disk to calculate the size of raid device. (grub_raid_read): Simplify raid0 code. Support raid4, raid6 and four different layout of raid5. (grub_raid_scan_device): Remove code specific to mdraid. (grub_raid_list): New variable. (free_array): New function. (grub_raid_register): Likewise. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (GRUB_MOD_INIT): Don't iterate device here. (GRUB_MOD_FINI): Use free_array to release resource. * include/grub/raid.h: Remove macro and structure specific to mdraid. (grub_raid5_recover_func_t): New function variable type. (grub_raid6_recover_func_t): Likewise. (grub_raid5_recover_func): New variable. (grub_raid6_recover_func): Likewise. (grub_raid_register): New function. (grub_raid_unregister): Likewise. (grub_raid_rescan): Likewise. (grub_raid_block_xor): Likewise. * util/grub-fstest.c: Add #include <grub/raid.h> and <grub/lib/crc.h>. (CMD_CRC): New macro. (part): Removed. (read_file): Handle device as well as file. (cmd_crc): New function. (fstest): Handle multiple disks. (options): Remove part, raw and long, add root and diskcount. (usage): Add crc, remove -p, -r, -l, add -r and -c. (main): Find the first non option entry and ignore subsequence options, add handling for the new options, support multiple disks. * util/grub-probe.c (probe): Add mdraid to abstraction_name.
2008-08-23 14:51:19 +00:00
}