raid.h revision 2
1N/A/* raid.h - On disk structures for RAID. */
1N/A/*
1N/A * GRUB -- GRand Unified Bootloader
1N/A * Copyright (C) 2006,2007,2008,2010 Free Software Foundation, Inc.
1N/A *
1N/A * GRUB is free software: you can redistribute it and/or modify
1N/A * it under the terms of the GNU General Public License as published by
1N/A * the Free Software Foundation, either version 3 of the License, or
1N/A * (at your option) any later version.
1N/A *
1N/A * GRUB is distributed in the hope that it will be useful,
1N/A * but WITHOUT ANY WARRANTY; without even the implied warranty of
1N/A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1N/A * GNU General Public License for more details.
1N/A *
1N/A * You should have received a copy of the GNU General Public License
1N/A * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
1N/A */
1N/A
1N/A#ifndef GRUB_RAID_H
1N/A#define GRUB_RAID_H 1
1N/A
1N/A#include <grub/types.h>
1N/A
1N/A#define GRUB_RAID_LAYOUT_LEFT_ASYMMETRIC 0
1N/A#define GRUB_RAID_LAYOUT_RIGHT_ASYMMETRIC 1
1N/A#define GRUB_RAID_LAYOUT_LEFT_SYMMETRIC 2
1N/A#define GRUB_RAID_LAYOUT_RIGHT_SYMMETRIC 3
1N/A
1N/A#define GRUB_RAID_LAYOUT_RIGHT_MASK 1
1N/A#define GRUB_RAID_LAYOUT_SYMMETRIC_MASK 2
1N/A
1N/Astruct grub_raid_member
1N/A{
1N/A grub_disk_t device; /* Array of total_devs devices. */
1N/A grub_disk_addr_t start_sector;
1N/A /* Start of each device, in 512 byte sectors. */
1N/A};
1N/A
1N/Astruct grub_raid_array
1N/A{
1N/A int number; /* The device number, taken from md_minor so we
1N/A are consistent with the device name in
1N/A Linux. */
1N/A int became_readable_at;
1N/A int level; /* RAID levels, only 0, 1 or 5 at the moment. */
1N/A int layout; /* Layout for RAID 5/6. */
1N/A unsigned int total_devs; /* Total number of devices in the array. */
1N/A grub_size_t chunk_size; /* The size of a chunk, in 512 byte sectors. */
1N/A grub_uint64_t disk_size; /* Size of an individual disk, in 512 byte
1N/A sectors. */
1N/A unsigned int index; /* Index of current device. */
1N/A int uuid_len; /* The length of uuid. */
1N/A char *uuid; /* The UUID of the device. */
1N/A
1N/A /* The following field is setup by the caller. */
1N/A char *name; /* That will be "md<number>". */
1N/A unsigned int nr_devs; /* The number of devices we've found so far. */
1N/A unsigned int allocated_devs;
1N/A struct grub_raid_member *members;
1N/A struct grub_raid_array *next;
1N/A
1N/A#ifdef GRUB_UTIL
1N/A struct grub_raid *driver;
1N/A#endif
1N/A};
1N/A
1N/Astruct grub_raid
1N/A{
1N/A const char *name;
1N/A
1N/A grub_err_t (*detect) (grub_disk_t disk, struct grub_raid_array *array,
1N/A grub_disk_addr_t *start_sector);
1N/A
1N/A struct grub_raid *next;
1N/A};
1N/Atypedef struct grub_raid *grub_raid_t;
1N/A
1N/Avoid grub_raid_register (grub_raid_t raid);
1N/Avoid grub_raid_unregister (grub_raid_t raid);
1N/A
1N/Avoid grub_raid_block_xor (char *buf1, const char *buf2, int size);
1N/A
1N/Atypedef grub_err_t (*grub_raid5_recover_func_t) (struct grub_raid_array *array,
1N/A int disknr, char *buf,
1N/A grub_disk_addr_t sector,
1N/A int size);
1N/A
1N/Atypedef grub_err_t (*grub_raid6_recover_func_t) (struct grub_raid_array *array,
1N/A int disknr, int p, char *buf,
1N/A grub_disk_addr_t sector,
1N/A int size);
1N/A
1N/Aextern grub_raid5_recover_func_t grub_raid5_recover_func;
1N/Aextern grub_raid6_recover_func_t grub_raid6_recover_func;
1N/A
1N/A#endif /* ! GRUB_RAID_H */
1N/A