]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2008-01-12 Robert Millan <rmh@aybabtu.com>
authorrobertmh <robertmh@localhost>
Sat, 12 Jan 2008 15:11:57 +0000 (15:11 +0000)
committerrobertmh <robertmh@localhost>
Sat, 12 Jan 2008 15:11:57 +0000 (15:11 +0000)
        * include/grub/util/getroot.h (grub_dev_abstraction_types): New enum.
        (grub_util_get_dev_abstraction): New function prototype.

        * util/getroot.c: Include `<grub/util/getroot.h>'
        (grub_util_get_grub_dev): Move detection of abstraction type to ...
        (grub_util_get_dev_abstraction): ... here (new function).

        * util/grub-probe.c: Convert PRINT_* to an enum.  Add
        `PRINT_ABSTRACTION'.
        (probe): Probe for abstraction type when requested.
        (main): Understand `--target=abstraction'.

        * util/i386/efi/grub-install.in: Add abstraction module to core
        image when it is found to be necessary.
        * util/i386/pc/grub-install.in: Likewise.
        * util/powerpc/ieee1275/grub-install.in: Likewise.

        * util/update-grub_lib.in (font_path): Return system path without
        converting to GRUB path.
        * util/update-grub.in: Convert system path returned by font_path()
        to a GRUB path.  Use `grub-probe -t abstraction' to determine what
        abstraction module is needed for loading fonts (if any).  Export
        that as `GRUB_PRELOAD_MODULES'.
        * util/grub.d/00_header.in: Process `GRUB_PRELOAD_MODULES' (print
        insmod commands).

ChangeLog
include/grub/util/getroot.h
util/getroot.c
util/grub-probe.c
util/grub.d/00_header.in
util/i386/efi/grub-install.in
util/i386/pc/grub-install.in
util/powerpc/ieee1275/grub-install.in
util/update-grub.in
util/update-grub_lib.in

index 6968544f6ccac320e94dc97249466696081462d7..a82d18965e16e843116b134526027a536153515a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,31 @@
+2008-01-12  Robert Millan  <rmh@aybabtu.com>
+
+       * include/grub/util/getroot.h (grub_dev_abstraction_types): New enum.
+       (grub_util_get_dev_abstraction): New function prototype.
+
+       * util/getroot.c: Include `<grub/util/getroot.h>'
+       (grub_util_get_grub_dev): Move detection of abstraction type to ...
+       (grub_util_get_dev_abstraction): ... here (new function).
+
+       * util/grub-probe.c: Convert PRINT_* to an enum.  Add
+       `PRINT_ABSTRACTION'.
+       (probe): Probe for abstraction type when requested.
+       (main): Understand `--target=abstraction'.
+
+       * util/i386/efi/grub-install.in: Add abstraction module to core
+       image when it is found to be necessary.
+       * util/i386/pc/grub-install.in: Likewise.
+       * util/powerpc/ieee1275/grub-install.in: Likewise.
+
+       * util/update-grub_lib.in (font_path): Return system path without
+       converting to GRUB path.
+       * util/update-grub.in: Convert system path returned by font_path()
+       to a GRUB path.  Use `grub-probe -t abstraction' to determine what
+       abstraction module is needed for loading fonts (if any).  Export
+       that as `GRUB_PRELOAD_MODULES'.
+       * util/grub.d/00_header.in: Process `GRUB_PRELOAD_MODULES' (print
+       insmod commands).
+
 2008-01-12  Yoshinori K. Okuji  <okuji@enbug.org>
 
        Remove some unused code from reiserfs.
index d2624e6f902f5a0c6644b3abe506dca17dbf1805..45b66880b3ee8bfb33cedb45552b81a8b92d3c41 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2003, 2007  Free Software Foundation, Inc.
+ *  Copyright (C) 2003, 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
 #ifndef GRUB_UTIL_GETROOT_HEADER
 #define GRUB_UTIL_GETROOT_HEADER       1
 
+enum grub_dev_abstraction_types {
+  GRUB_DEV_ABSTRACTION_NONE,
+  GRUB_DEV_ABSTRACTION_LVM,
+  GRUB_DEV_ABSTRACTION_RAID,
+};
+
 char *grub_guess_root_device (const char *dir);
 char *grub_get_prefix (const char *dir);
+int grub_util_get_dev_abstraction (const char *os_dev);
 char *grub_util_get_grub_dev (const char *os_dev);
 
 #endif /* ! GRUB_UTIL_GETROOT_HEADER */
index dc0a972f7cff7f94440aff261d4a88e84c55f19c..74ee6d6677fe7e1104d9fb62d888a1c7cda41f28 100644 (file)
@@ -1,7 +1,7 @@
 /* getroot.c - Get root device */
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 1999,2000,2001,2002,2003,2006,2007  Free Software Foundation, Inc.
+ *  Copyright (C) 1999,2000,2001,2002,2003,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
@@ -24,6 +24,7 @@
 
 #include <grub/util/misc.h>
 #include <grub/util/biosdisk.h>
+#include <grub/util/getroot.h>
 
 static void
 strip_extra_slashes (char *dir)
@@ -239,27 +240,42 @@ grub_guess_root_device (const char *dir)
   return os_dev;
 }
 
-char *
-grub_util_get_grub_dev (const char *os_dev)
+int
+grub_util_get_dev_abstraction (const char *os_dev)
 {
   /* Check for LVM.  */
   if (!strncmp (os_dev, "/dev/mapper/", 12))
-    {
-      char *grub_dev = xmalloc (strlen (os_dev) - 12 + 1);
-
-      strcpy (grub_dev, os_dev+12);
-
-      return grub_dev;
-    }
+    return GRUB_DEV_ABSTRACTION_LVM;
 
   /* Check for RAID.  */
   if (!strncmp (os_dev, "/dev/md", 7))
+    return GRUB_DEV_ABSTRACTION_RAID;
+
+  /* No abstraction found.  */
+  return GRUB_DEV_ABSTRACTION_NONE;
+}
+
+char *
+grub_util_get_grub_dev (const char *os_dev)
+{
+  char *grub_dev;
+
+  switch (grub_util_get_dev_abstraction (os_dev))
     {
-      const char *p;
-      char *grub_dev = xmalloc (20);
+    case GRUB_DEV_ABSTRACTION_LVM:
+      grub_dev = xmalloc (strlen (os_dev) - 12 + 1);
+
+      strcpy (grub_dev, os_dev + 12);
+
+      break;
+
+    case GRUB_DEV_ABSTRACTION_RAID:
+      grub_dev = xmalloc (20);
 
       if (os_dev[7] == '_' && os_dev[8] == 'd')
        {
+         const char *p;
+
          /* This a partitionable RAID device of the form /dev/md_dNNpMM. */
          int i;
 
@@ -297,17 +313,17 @@ grub_util_get_grub_dev (const char *os_dev)
        }
       else if (os_dev[7] >= '0' && os_dev[7] <= '9')
        {
-         p = os_dev + 5;
-         memcpy (grub_dev, p, 7);
+         memcpy (grub_dev, os_dev + 5, 7);
          grub_dev[7] = '\0';
        }
       else
        grub_util_error ("Unknown kind of RAID device `%s'", os_dev);
 
+      break;
 
-      return grub_dev;
+    default:  /* GRUB_DEV_ABSTRACTION_NONE */
+      grub_dev = grub_util_biosdisk_get_grub_dev (os_dev);
     }
 
-  /* If it's not RAID or LVM, it should be a biosdisk.  */
-  return grub_util_biosdisk_get_grub_dev (os_dev);
+  return grub_dev;
 }
index d7eb9c457bb4a3ec17ca5f921c8c7b4587e6964c..60d530f94e71a846577c71f9eb04290c9a61b54b 100644 (file)
@@ -1,7 +1,7 @@
 /* grub-probe.c - probe device information for a given path */
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2005,2006,2007 Free Software Foundation, Inc.
+ *  Copyright (C) 2005,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
 #define _GNU_SOURCE    1
 #include <getopt.h>
 
-#define PRINT_FS       0
-#define PRINT_DRIVE    1
-#define PRINT_DEVICE   2
-#define PRINT_PARTMAP  3
+enum {
+  PRINT_FS,
+  PRINT_DRIVE,
+  PRINT_DEVICE,
+  PRINT_PARTMAP,
+  PRINT_ABSTRACTION,
+};
 
 int print = PRINT_FS;
 
@@ -74,6 +77,7 @@ probe (const char *path)
 {
   char *device_name;
   char *drive_name = NULL;
+  int abstraction_type;
   grub_device_t dev;
   grub_fs_t fs;
   
@@ -87,6 +91,28 @@ probe (const char *path)
       goto end;
     }
 
+  abstraction_type = grub_util_get_dev_abstraction (device_name);
+  /* No need to check for errors; lack of abstraction is permissible.  */
+  
+  if (print == PRINT_ABSTRACTION)
+    {
+      char *abstraction_name;
+      switch (abstraction_type)
+       {
+       case GRUB_DEV_ABSTRACTION_NONE:
+         grub_util_info ("did not find LVM/RAID in %s, assuming raw device", device_name);
+         goto end;
+       case GRUB_DEV_ABSTRACTION_LVM:
+         abstraction_name = "lvm";
+         break;
+       case GRUB_DEV_ABSTRACTION_RAID:
+         abstraction_name = "raid";
+         break;
+       }
+      printf ("%s\n", abstraction_name);
+      goto end;
+    }
+
   drive_name = grub_util_get_grub_dev (device_name);
   if (! drive_name)
     grub_util_error ("cannot find a GRUB drive for %s.\n", device_name);
@@ -159,8 +185,8 @@ Usage: grub-probe [OPTION]... PATH\n\
 Probe device information for a given path.\n\
 \n\
   -m, --device-map=FILE     use FILE as the device map [default=%s]\n\
-  -t, --target=(fs|drive|device|partmap)\n\
-                            print filesystem module, GRUB drive, system device or partition map module [default=fs]\n\
+  -t, --target=(fs|drive|device|partmap|abstraction)\n\
+                            print filesystem module, GRUB drive, system device, partition map module or abstraction module [default=fs]\n\
   -h, --help                display this message and exit\n\
   -V, --version             print version information and exit\n\
   -v, --verbose             print verbose messages\n\
@@ -206,6 +232,8 @@ main (int argc, char *argv[])
              print = PRINT_DEVICE;
            else if (!strcmp (optarg, "partmap"))
              print = PRINT_PARTMAP;
+           else if (!strcmp (optarg, "abstraction"))
+             print = PRINT_ABSTRACTION;
            else
              usage (1);
            break;
index 520a6fc60472cd292b302f2cec0c090a3473e6a8..01e92eda0e041eb4e3a0c6fc4ecdd3fe26fb0be5 100644 (file)
@@ -1,7 +1,7 @@
 #! /bin/sh -e
 
 # update-grub helper script.
-# Copyright (C) 2006,2007  Free Software Foundation, Inc.
+# 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
@@ -24,6 +24,12 @@ platform=@platform@
 # for convert_system_path_to_grub_path()
 . ${libdir}/grub/update-grub_lib
 
+# Do this as early as possible, since other commands might depend on it.
+# (e.g. the `font' command might need lvm or raid modules)
+for i in ${GRUB_PRELOAD_MODULES} ; do
+  echo "insmod $i"
+done
+
 if [ "x${GRUB_DEFAULT}" = "x" ] ; then GRUB_DEFAULT=0 ; fi
 if [ "x${GRUB_TIMEOUT}" = "x" ] ; then GRUB_TIMEOUT=5 ; fi
 
index 63ff61e084af138822e3e69f8fbeb2899aed0eeb..fae15172f67c44e4c5845f4e4b547042d137f92e 100644 (file)
@@ -1,7 +1,7 @@
 #! /bin/sh
 
 # Install GRUB on your EFI partition.
-# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007  Free Software Foundation, Inc.
+# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,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
@@ -190,8 +190,11 @@ fi
 # filesystem will be accessible).
 partmap_module=`$grub_probe --target=partmap --device-map=${device_map} ${grubdir} 2> /dev/null`
 
+# Device abstraction module, if any (lvm, raid).
+devabstraction_module=`$grub_probe --target=abstraction --device-map=${device_map} ${grubdir}`
+
 # _chain is often useful
-modules="$modules $fs_module $partmap_module _chain"
+modules="$modules $fs_module $partmap_module $devabstraction_module _chain"
 
 $grub_mkimage --output=${grubdir}/grub.efi $modules || exit 1
 
index e705086c62087d0a978d0ceccbaf3b358341d1e6..4428816fa5f8e729650dae888d505ab41000041f 100644 (file)
@@ -1,7 +1,7 @@
 #! /bin/sh
 
 # Install GRUB on your drive.
-# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007  Free Software Foundation, Inc.
+# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,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
@@ -223,8 +223,11 @@ fi
 # filesystem will be accessible).
 partmap_module=`$grub_probe --target=partmap --device-map=${device_map} ${grubdir} 2> /dev/null`
 
+# Device abstraction module, if any (lvm, raid).
+devabstraction_module=`$grub_probe --target=abstraction --device-map=${device_map} ${grubdir}`
+
 # _chain is often useful
-modules="$modules $fs_module $partmap_module biosdisk _chain"
+modules="$modules $fs_module $partmap_module biosdisk $devabstraction_module _chain"
 
 $grub_mkimage --output=${grubdir}/core.img --prefix=`make_system_path_relative_to_its_root ${grubdir}` $modules || exit 1
 
index 827b827f90cd126453b96826b4367c5cbbaf8207..490da97922415659f8c88e243a08ab347ffe01cb 100644 (file)
@@ -1,7 +1,7 @@
 #! /bin/sh
 
 # Install GRUB on your drive.
-# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007  Free Software Foundation, Inc.
+# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,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
@@ -176,7 +176,10 @@ fi
 # filesystem will be accessible).
 partmap_module=`$grub_probe --target=partmap --device-map=${device_map} ${grubdir} 2> /dev/null`
 
-modules="$modules $fs_module $partmap_module"
+# Device abstraction module, if any (lvm, raid).
+devabstraction_module=`$grub_probe --target=abstraction --device-map=${device_map} ${grubdir}`
+
+modules="$modules $fs_module $partmap_module $devabstraction_module"
 
 # Now perform the installation.
 "$grub_mkimage" --output=${grubdir}/grub $modules || exit 1
index 7e33eee1166aab648fad0961f5c54de388ac5525..ed8864529889568f88a0e96d040e150c56abc90b 100644 (file)
@@ -103,7 +103,10 @@ esac
 # check for terminals that require fonts
 case ${GRUB_TERMINAL} in
   gfxterm)
-    if GRUB_FONT_PATH=`font_path` ; then : ; else
+    if path=`font_path` ; then
+      GRUB_FONT_PATH="`convert_system_path_to_grub_path ${path}`"
+      GRUB_PRELOAD_MODULES="`${GRUB_PRELOAD_MODULES} ${grub_probe} -t abstraction ${path}`"
+    else
       # fallback to console
       GRUB_TERMINAL=console
     fi
@@ -121,7 +124,7 @@ esac
 
 # These are defined in this script, export them here so that user can
 # override them.
-export GRUB_DEVICE GRUB_FS GRUB_DRIVE GRUB_DRIVE_BOOT GRUB_DRIVE_BOOT_GRUB GRUB_FONT_PATH
+export GRUB_DEVICE GRUB_FS GRUB_DRIVE GRUB_DRIVE_BOOT GRUB_DRIVE_BOOT_GRUB GRUB_FONT_PATH GRUB_PRELOAD_MODULES
 
 # These are optional, user-defined variables.
 export GRUB_DEFAULT GRUB_TIMEOUT GRUB_DISTRIBUTOR GRUB_CMDLINE_LINUX GRUB_TERMINAL GRUB_SERIAL_COMMAND
index 7e5d4393f259f626f95195df1a9ecdeb4afa84c7..8b20867b8003fdce8206221257b60d825b950e31 100644 (file)
@@ -1,5 +1,5 @@
 # Helper library for update-grub
-# Copyright (C) 2007  Free Software Foundation, Inc.
+# Copyright (C) 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
@@ -93,19 +93,14 @@ convert_system_path_to_grub_path ()
 
 font_path ()
 {
-  if [ "x${GRUB_FONT_PATH}" = "x" ] ; then : ; else
-    echo "${GRUB_FONT_PATH}"
-    return 0
-  fi
-
   # Prefer system path for space reasons (/boot/grub might be a very small
   # partition in case of OpenFirmware, etc).
   for dir in ${pkgdatadir} /usr/share/grub /boot/grub ; do
     # Prefer complete fonts over incomplete ones.
     for basename in unicode unifont ascii ; do
-      if path=`convert_system_path_to_grub_path ${dir}/${basename}.pff` ; then
-        GRUB_FONT_PATH="${path}"
-        echo "${GRUB_FONT_PATH}"
+      path="${dir}/${basename}.pff"
+      if convert_system_path_to_grub_path ${path} > /dev/null ; then
+        echo "${path}"
         return 0
       fi
     done