/* raid5_recover.c - module to recover from faulty RAID4/5 arrays. */ /* * VAS_EBOOT -- GRand Unified Bootloader * Copyright (C) 2006,2007,2008 Free Software Foundation, Inc. * * VAS_EBOOT 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. * * VAS_EBOOT 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 VAS_EBOOT. If not, see . */ #include #include #include #include #include #include #include VAS_EBOOT_MOD_LICENSE ("GPLv3+"); static VasEBoot_err_t VasEBoot_raid5_recover (struct VasEBoot_diskfilter_segment *array, int disknr, char *buf, VasEBoot_disk_addr_t sector, VasEBoot_size_t size) { char *buf2; int i; size <<= VAS_EBOOT_DISK_SECTOR_BITS; buf2 = VasEBoot_malloc (size); if (!buf2) return VasEBoot_errno; VasEBoot_memset (buf, 0, size); for (i = 0; i < (int) array->node_count; i++) { VasEBoot_err_t err; if (i == disknr) continue; err = VasEBoot_diskfilter_read_node (&array->nodes[i], sector, size >> VAS_EBOOT_DISK_SECTOR_BITS, buf2); if (err) { VasEBoot_free (buf2); return err; } VasEBoot_crypto_xor (buf, buf, buf2, size); } VasEBoot_free (buf2); return VAS_EBOOT_ERR_NONE; } VAS_EBOOT_MOD_INIT(raid5rec) { VasEBoot_raid5_recover_func = VasEBoot_raid5_recover; } VAS_EBOOT_MOD_FINI(raid5rec) { VasEBoot_raid5_recover_func = 0; }