]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2011-10-09 Robert Millan <rmh@gnu.org>
authorRobert Millan <rmh@gnu.org>
Sun, 9 Oct 2011 19:13:00 +0000 (21:13 +0200)
committerRobert Millan <rmh@gnu.org>
Sun, 9 Oct 2011 19:13:00 +0000 (21:13 +0200)
        LVM support for FreeBSD and GNU/kFreeBSD.

        * util/lvm.c (grub_util_lvm_isvolume): Enable on FreeBSD and
        GNU/kFreeBSD.
        (LVM_DEV_MAPPER_STRING): Move from here ...
        * include/grub/util/lvm.h (LVM_DEV_MAPPER_STRING): ... to here.
        * util/getroot.c: Include `<grub/util/lvm.h>'.
        (grub_util_get_dev_abstraction): Enable
        grub_util_biosdisk_is_present() on FreeBSD and GNU/kFreeBSD.
        Check for LVM abstraction on FreeBSD and GNU/kFreeBSD.
        (grub_util_get_grub_dev): Replace "/dev/mapper/" with
        `LVM_DEV_MAPPER_STRING'.  Enable LVM and mdRAID only on platforms that
        support it.
        * util/grub-setup.c (main): Check for LVM also on FreeBSD and
        GNU/kFreeBSD.
        * util/grub.d/10_kfreebsd.in: Load `geom_linux_lvm' kernel module
        when LVM abstraction is required for ${GRUB_DEVICE}.

ChangeLog
include/grub/util/lvm.h
util/getroot.c
util/grub-setup.c
util/grub.d/10_kfreebsd.in
util/lvm.c

index 6484cf826f0df1492ac8363a80267cd6a5f7a5f2..19db47e04a3cadb8dabdca3ed81a4a759d398b80 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2011-10-09  Robert Millan  <rmh@gnu.org>
+
+       LVM support for FreeBSD and GNU/kFreeBSD.
+
+       * util/lvm.c (grub_util_lvm_isvolume): Enable on FreeBSD and
+       GNU/kFreeBSD.
+       (LVM_DEV_MAPPER_STRING): Move from here ...
+       * include/grub/util/lvm.h (LVM_DEV_MAPPER_STRING): ... to here.
+       * util/getroot.c: Include `<grub/util/lvm.h>'.
+       (grub_util_get_dev_abstraction): Enable
+       grub_util_biosdisk_is_present() on FreeBSD and GNU/kFreeBSD.
+       Check for LVM abstraction on FreeBSD and GNU/kFreeBSD.
+       (grub_util_get_grub_dev): Replace "/dev/mapper/" with
+       `LVM_DEV_MAPPER_STRING'.  Enable LVM and mdRAID only on platforms that
+       support it.
+       * util/grub-setup.c (main): Check for LVM also on FreeBSD and
+       GNU/kFreeBSD.
+       * util/grub.d/10_kfreebsd.in: Load `geom_linux_lvm' kernel module
+       when LVM abstraction is required for ${GRUB_DEVICE}.
+
 2011-10-06  Szymon Janc <szymon@janc.net.pl>
 
        Add support for LZO compression in GRUB:
index 7a4c76c6bbfe8cf1bc786b90142d681bddc31dab..ff268f83f190583fb534b62554f1fbed37624602 100644 (file)
@@ -1,7 +1,7 @@
 /* lvm.h - LVM support for GRUB utils.  */
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2006,2007  Free Software Foundation, Inc.
+ *  Copyright (C) 2006,2007,2011  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
 #ifndef GRUB_LVM_UTIL_HEADER
 #define GRUB_LVM_UTIL_HEADER   1
 
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+
 #ifdef __linux__
+#define LVM_DEV_MAPPER_STRING "/dev/mapper/"
+#else
+#define LVM_DEV_MAPPER_STRING "/dev/linux_lvm/"
+#endif
+
 int grub_util_lvm_isvolume (char *name);
 #endif
 
index 71064583f8e239efb93af26c4f3dc15bb0d575cd..7c5602e71ccb1333cef0438f53fe6889a637cabd 100644 (file)
@@ -1,7 +1,7 @@
 /* getroot.c - Get root device */
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 1999,2000,2001,2002,2003,2006,2007,2008,2009,2010  Free Software Foundation, Inc.
+ *  Copyright (C) 1999,2000,2001,2002,2003,2006,2007,2008,2009,2010,2011  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
@@ -33,6 +33,7 @@
 #include <stdlib.h>
 #include <stdint.h>
 #include <grub/util/misc.h>
+#include <grub/util/lvm.h>
 #include <grub/cryptodisk.h>
 
 #ifdef HAVE_DEVICE_MAPPER
@@ -856,12 +857,14 @@ grub_util_get_geom_abstraction (const char *dev)
 int
 grub_util_get_dev_abstraction (const char *os_dev __attribute__((unused)))
 {
-#ifdef __linux__
-  enum grub_dev_abstraction_types ret;
-
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
   /* User explicitly claims that this drive is visible by BIOS.  */
   if (grub_util_biosdisk_is_present (os_dev))
     return GRUB_DEV_ABSTRACTION_NONE;
+#endif
+
+#ifdef __linux__
+  enum grub_dev_abstraction_types ret;
 
   /* Check for LVM and LUKS.  */
   ret = grub_util_get_dm_abstraction (os_dev);
@@ -880,6 +883,10 @@ grub_util_get_dev_abstraction (const char *os_dev __attribute__((unused)))
   grub_util_info ("abstraction of %s is %s", os_dev, abs);
   if (abs && grub_strcasecmp (abs, "eli") == 0)
     return GRUB_DEV_ABSTRACTION_GELI;
+
+  /* Check for LVM.  */
+  if (!strncmp (os_dev, LVM_DEV_MAPPER_STRING, sizeof(LVM_DEV_MAPPER_STRING)-1))
+    return GRUB_DEV_ABSTRACTION_LVM;
 #endif
 
   /* No abstraction found.  */
@@ -1111,11 +1118,12 @@ grub_util_get_grub_dev (const char *os_dev)
 
   switch (grub_util_get_dev_abstraction (os_dev))
     {
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
     case GRUB_DEV_ABSTRACTION_LVM:
 
       {
        unsigned short i, len;
-       grub_size_t offset = sizeof ("/dev/mapper/") - 1;
+       grub_size_t offset = sizeof (LVM_DEV_MAPPER_STRING) - 1;
 
        len = strlen (os_dev) - offset + 1;
        grub_dev = xmalloc (len + sizeof ("lvm/"));
@@ -1191,7 +1199,9 @@ grub_util_get_grub_dev (const char *os_dev)
       }
 #endif
       break;
+#endif
 
+#ifdef __linux__
     case GRUB_DEV_ABSTRACTION_RAID:
 
       if (os_dev[7] == '_' && os_dev[8] == 'd')
@@ -1267,7 +1277,6 @@ grub_util_get_grub_dev (const char *os_dev)
       else
        grub_util_error ("unknown kind of RAID device `%s'", os_dev);
 
-#ifdef __linux__
       {
        char *mdadm_name = get_mdadm_uuid (os_dev);
        struct stat st;
@@ -1292,9 +1301,8 @@ grub_util_get_grub_dev (const char *os_dev)
            free (mdadm_name);
          }
       }
-#endif /* __linux__ */
-
       break;
+#endif /* __linux__ */
 
     default:  /* GRUB_DEV_ABSTRACTION_NONE */
       grub_dev = grub_util_biosdisk_get_grub_dev (os_dev);
index 2505c03a436ae895166680cfc085953e96e86883..b3a6c5c763bdbca78a60b00d6a9f8685f9cba79d 100644 (file)
@@ -1,7 +1,7 @@
 /* grub-setup.c - make GRUB usable */
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010  Free Software Foundation, Inc.
+ *  Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011  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
@@ -954,10 +954,12 @@ main (int argc, char *argv[])
                       arguments.dir ? : DEFAULT_DIRECTORY);
     }
 
-#ifdef __linux__
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
   if (grub_util_lvm_isvolume (root_dev))
     must_embed = 1;
+#endif
 
+#ifdef __linux__
   if (root_dev[0] == 'm' && root_dev[1] == 'd'
       && ((root_dev[2] >= '0' && root_dev[2] <= '9') || root_dev[2] == '/'))
     {
index 2ade4ea35d58f80e8632022bc859a822f5d36e50..e4bfc06cb5a892976ffbf339970754ed6e29e5e2 100644 (file)
@@ -2,7 +2,7 @@
 set -e
 
 # grub-mkconfig helper script.
-# Copyright (C) 2006,2007,2008,2009,2010  Free Software Foundation, Inc.
+# Copyright (C) 2006,2007,2008,2009,2010,2011  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
@@ -98,6 +98,12 @@ EOF
 
   load_kfreebsd_module acpi true
 
+  for abstraction in dummy $(grub-probe -t abstraction --device ${GRUB_DEVICE}) ; do
+    case $abstraction in
+      lvm) load_kfreebsd_module geom_linux_lvm false ;;
+    esac
+  done
+
   case "${kfreebsd_fs}" in
     zfs)
       load_kfreebsd_module opensolaris false
index bb2c19fe31de401db25063fef19e606e568fcfbf..0bc271e465b498799801908bfca679fb64528268 100644 (file)
@@ -1,7 +1,7 @@
 /* lvm.c - LVM support for GRUB utils.  */
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2006,2007,2008  Free Software Foundation, Inc.
+ *  Copyright (C) 2006,2007,2008,2011  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
@@ -17,8 +17,7 @@
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-/* We only support LVM on Linux.  */
-#ifdef __linux__
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #include <grub/emu/misc.h>
 #include <grub/util/misc.h>
 #include <grub/util/lvm.h>
@@ -26,8 +25,6 @@
 #include <string.h>
 #include <sys/stat.h>
 
-#define LVM_DEV_MAPPER_STRING "/dev/mapper/"
-
 int
 grub_util_lvm_isvolume (char *name)
 {
@@ -49,4 +46,4 @@ grub_util_lvm_isvolume (char *name)
     return 1;
 }
 
-#endif /* ! __linux__ */
+#endif