1 /* raid5_recover.c - module to recover from faulty RAID4/5 arrays. */
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2006,2007,2008 Free Software Foundation, Inc.
6 * GRUB is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GRUB is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
21 #include <grub/disk.h>
24 #include <grub/misc.h>
25 #include <grub/diskfilter.h>
26 #include <grub/crypto.h>
28 GRUB_MOD_LICENSE ("GPLv3+");
31 grub_raid5_recover (struct grub_diskfilter_segment
*array
, int disknr
,
32 char *buf
, grub_disk_addr_t sector
, grub_size_t size
)
37 size
<<= GRUB_DISK_SECTOR_BITS
;
38 buf2
= grub_malloc (size
);
42 grub_memset (buf
, 0, size
);
44 for (i
= 0; i
< (int) array
->node_count
; i
++)
51 err
= grub_diskfilter_read_node (&array
->nodes
[i
], sector
,
52 size
>> GRUB_DISK_SECTOR_BITS
, buf2
);
60 grub_crypto_xor (buf
, buf
, buf2
, size
);
68 GRUB_MOD_INIT(raid5rec
)
70 grub_raid5_recover_func
= grub_raid5_recover
;
73 GRUB_MOD_FINI(raid5rec
)
75 grub_raid5_recover_func
= 0;