Updated PCI IDs to latest snapshot.
[tangerine.git] / arch / common / boot / grub2 / disk / raid5_recover.c
blob31cef88b13f6f2a15c6b8a9a11d2dea36dab2233
1 /* raid5_recover.c - module to recover from faulty RAID4/5 arrays. */
2 /*
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/>.
20 #include <grub/dl.h>
21 #include <grub/disk.h>
22 #include <grub/mm.h>
23 #include <grub/err.h>
24 #include <grub/misc.h>
25 #include <grub/raid.h>
27 static grub_err_t
28 grub_raid5_recover (struct grub_raid_array *array, int disknr,
29 char *buf, grub_disk_addr_t sector, int size)
31 char *buf2;
32 int i;
34 size <<= GRUB_DISK_SECTOR_BITS;
35 buf2 = grub_malloc (size);
36 if (!buf2)
37 return grub_errno;
39 grub_memset (buf, 0, size);
41 for (i = 0; i < (int) array->total_devs; i++)
43 grub_err_t err;
45 if (i == disknr)
46 continue;
48 err = grub_disk_read (array->device[i], sector, 0, size, buf2);
50 if (err)
52 grub_free (buf2);
53 return err;
56 grub_raid_block_xor (buf, buf2, size);
59 grub_free (buf2);
61 return GRUB_ERR_NONE;
64 GRUB_MOD_INIT(raid5rec)
66 grub_raid5_recover_func = grub_raid5_recover;
69 GRUB_MOD_FINI(raid5rec)
71 grub_raid5_recover_func = 0;