From 041d1ea37802bf7178a31a53f96c26efa6b8fb7b Mon Sep 17 00:00:00 2001 From: James Date: Fri, 16 Nov 2012 10:41:01 +0000 Subject: fish --- util/raid.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 util/raid.c (limited to 'util/raid.c') diff --git a/util/raid.c b/util/raid.c new file mode 100644 index 0000000..a6aa5f9 --- /dev/null +++ b/util/raid.c @@ -0,0 +1,86 @@ +/* raid.c - RAID support for GRUB utils. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2006,2007,2008 Free Software Foundation, Inc. + * + * 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 . + */ + +/* We only support RAID on Linux. */ +#ifdef __linux__ +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +char ** +grub_util_raid_getmembers (const char *name) +{ + int fd, ret, i, j; + char **devicelist; + mdu_version_t version; + mdu_array_info_t info; + mdu_disk_info_t disk; + + fd = open (name, O_RDONLY); + + if (fd == -1) + grub_util_error ("can't open %s: %s", name, strerror (errno)); + + ret = ioctl (fd, RAID_VERSION, &version); + if (ret != 0) + grub_util_error ("ioctl RAID_VERSION error: %s", strerror (errno)); + + if (version.major != 0 || version.minor != 90) + grub_util_error ("unsupported RAID version: %d.%d", + version.major, version.minor); + + ret = ioctl (fd, GET_ARRAY_INFO, &info); + if (ret != 0) + grub_util_error ("ioctl GET_ARRAY_INFO error: %s", strerror (errno)); + + devicelist = xmalloc ((info.nr_disks + 1) * sizeof (char *)); + + for (i = 0, j = 0; i