]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
automatic raid members addition
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 22 Apr 2011 11:55:30 +0000 (13:55 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 22 Apr 2011 11:55:30 +0000 (13:55 +0200)
Makefile.util.def
grub-core/Makefile.core.def
grub-core/disk/lvm.c
grub-core/kern/emu/getroot.c
grub-core/kern/emu/raid.c [moved from util/raid.c with 84% similarity]
include/grub/emu/getroot.h
include/grub/util/raid.h [deleted file]
util/grub-setup.c

index 058572f065a2f4b49727869324a9dd0a2264fb88..40c67c2330cfd466b39fdb7a08d5720a15f4624c 100644 (file)
@@ -10,6 +10,7 @@ library = {
   common = grub-core/kern/device.c;
   common = grub-core/kern/disk.c;
   common = grub-core/kern/emu/getroot.c;
+  common = grub-core/kern/emu/raid.c;
   common = grub-core/kern/emu/hostdisk.c;
   common = grub-core/kern/emu/misc.c;
   common = grub-core/kern/emu/mm.c;
@@ -265,7 +266,6 @@ program = {
   installdir = sbin;
   mansection = 8;
   common = util/grub-setup.c;
-  common = util/raid.c;
   common = util/lvm.c;
   common = grub-core/lib/reed_solomon.c;
 
index f4d38149dfb24f00de8c544699c2446011c0b3ec..4146e3841c69d430c3d366901fa2da04b3509549 100644 (file)
@@ -165,6 +165,7 @@ kernel = {
   emu = kern/emu/cache.S;
   emu = kern/emu/console.c;
   emu = kern/emu/getroot.c;
+  emu = kern/emu/raid.c;
   emu = kern/emu/hostdisk.c;
   emu = kern/emu/hostfs.c;
   emu = kern/emu/main.c;
index d104be7508d36b3691e6ba8885c760ce184ad4e8..b86cd8023570729394973eeb64bf3495e0cc5a02 100644 (file)
@@ -198,16 +198,6 @@ grub_lvm_open (const char *name, grub_disk_t disk,
   if (! lv && !scan_depth &&
       pull == (explicit ? GRUB_DISK_PULL_RESCAN : GRUB_DISK_PULL_RESCAN_UNTYPED))
     {
-#ifdef GRUB_UTIL
-      if (explicit)
-       {
-         char buf[grub_strlen (name) + sizeof ("/dev/mapper/")];
-         grub_memcpy (buf, "/dev/mapper/", sizeof ("/dev/mapper/"));
-         grub_strcpy (buf + sizeof ("/dev/mapper/") - 1,
-                      name + sizeof ("lvm/") - 1);
-         grub_util_pull_device (buf);
-       }
-#endif
       scan_for = name;
       scan_depth++;
       grub_device_iterate (&grub_lvm_scan_device);
index 474bb42bcea7f2168ec75bcfa54602d0ea2f32ca..d9c1c9e082605f6553f4c2c973d1382a6b57671a 100644 (file)
@@ -854,9 +854,20 @@ grub_util_pull_device (const char *os_dev)
              grub_util_pull_device (subdev);
          }
        dm_tree_free (tree);
-       return;
       }
 #endif
+      return;
+    case GRUB_DEV_ABSTRACTION_RAID:
+#ifdef __linux__
+      {
+       char **devicelist = grub_util_raid_getmembers (os_dev, 0);
+       int i;
+       for (i = 0; devicelist[i];i++)
+         grub_util_pull_device (devicelist[i]);
+       free (devicelist);
+      }
+#endif
+      return;
 
     default:  /* GRUB_DEV_ABSTRACTION_NONE */
       grub_util_biosdisk_get_grub_dev (os_dev);
@@ -869,6 +880,8 @@ grub_util_get_grub_dev (const char *os_dev)
 {
   char *grub_dev = NULL;
 
+  grub_util_pull_device (os_dev);
+
   switch (grub_util_get_dev_abstraction (os_dev))
     {
     case GRUB_DEV_ABSTRACTION_LVM:
similarity index 84%
rename from util/raid.c
rename to grub-core/kern/emu/raid.c
index a6aa5f95e19dc79e4e267c3b5799d9f28d3d1830..1371117da97ad4146fa7c5f564f24d957f257d56 100644 (file)
@@ -21,7 +21,6 @@
 #ifdef __linux__
 #include <grub/emu/misc.h>
 #include <grub/util/misc.h>
-#include <grub/util/raid.h>
 #include <grub/emu/getroot.h>
 
 #include <string.h>
@@ -36,7 +35,7 @@
 #include <linux/raid/md_u.h>
 
 char **
-grub_util_raid_getmembers (const char *name)
+grub_util_raid_getmembers (const char *name, int bootable)
 {
   int fd, ret, i, j;
   char **devicelist;
@@ -53,7 +52,14 @@ grub_util_raid_getmembers (const char *name)
   if (ret != 0)
     grub_util_error ("ioctl RAID_VERSION error: %s", strerror (errno));
 
-  if (version.major != 0 || version.minor != 90)
+  if ((version.major != 0 || version.minor != 90)
+      && (version.major != 1 || version.minor != 0)
+      && (version.major != 1 || version.minor != 1)
+      && (version.major != 1 || version.minor != 2))
+    grub_util_error ("unsupported RAID version: %d.%d",
+                    version.major, version.minor);
+
+  if (bootable && (version.major != 0 || version.minor != 90))
     grub_util_error ("unsupported RAID version: %d.%d",
                     version.major, version.minor);
 
index 581ea8056822caeb710d36292dd9aae26777abcd..702903ee6681f837662188b3798ed755d3ff2c9f 100644 (file)
@@ -34,5 +34,8 @@ char *grub_util_get_grub_dev (const char *os_dev);
 char *grub_make_system_path_relative_to_its_root (const char *path);
 const char *grub_util_check_block_device (const char *blk_dev);
 const char *grub_util_check_char_device (const char *blk_dev);
+#ifdef __linux__
+char **grub_util_raid_getmembers (const char *name, int bootable);
+#endif
 
 #endif /* ! GRUB_UTIL_GETROOT_HEADER */
diff --git a/include/grub/util/raid.h b/include/grub/util/raid.h
deleted file mode 100644 (file)
index 4da5eaa..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/* raid.h - RAID support for GRUB utils.  */
-/*
- *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2006,2007  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 <http://www.gnu.org/licenses/>.
- */
-
-#ifndef GRUB_RAID_UTIL_HEADER
-#define GRUB_RAID_UTIL_HEADER  1
-
-#ifdef __linux__
-char** grub_util_raid_getmembers (const char *name);
-#endif
-
-#endif /* ! GRUB_RAID_UTIL_HEADER */
index 7d47fa6544baa041fd0454eed73e3f6c18567b50..8482e11c92c4040b2615b27eb7f3d4c0fec4a77b 100644 (file)
@@ -32,7 +32,6 @@
 #include <grub/machine/kernel.h>
 #include <grub/term.h>
 #include <grub/i18n.h>
-#include <grub/util/raid.h>
 #include <grub/util/lvm.h>
 #ifdef GRUB_MACHINE_IEEE1275
 #include <grub/util/ofpath.h>
@@ -972,12 +971,12 @@ main (int argc, char *argv[])
       int i;
 
       if (arguments.device[0] == '/')
-       devicelist = grub_util_raid_getmembers (arguments.device);
+       devicelist = grub_util_raid_getmembers (arguments.device, 1);
       else
        {
          char *devname;
          devname = xasprintf ("/dev/%s", dest_dev);
-         devicelist = grub_util_raid_getmembers (dest_dev);
+         devicelist = grub_util_raid_getmembers (dest_dev, 1);
          free (devname);
        }