]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2007-05-07 Robert Millan <rmh@aybabtu.com>
authorrobertmh <robertmh@localhost>
Mon, 7 May 2007 19:54:46 +0000 (19:54 +0000)
committerrobertmh <robertmh@localhost>
Mon, 7 May 2007 19:54:46 +0000 (19:54 +0000)
* util/i386/pc/grub-probe.c: Add `grub-probe -t partmap' parameter to
determine partition map module.
* util/i386/pc/grub-install.in: Use this feature to decide which
partition module to load, instead of hardcoding pc and gpt.

ChangeLog
util/i386/pc/grub-install.in
util/i386/pc/grub-probe.c

index 9d4b8d52d6845734f54d6396cd7f066fa0bf3f5e..7b43ed08561cd6a6ab9d5e959f8e352e5fc9f074 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-05-07  Robert Millan  <rmh@aybabtu.com>
+
+       * util/i386/pc/grub-probe.c: Add `grub-probe -t partmap' parameter to
+       determine partition map module.
+       * util/i386/pc/grub-install.in: Use this feature to decide which
+       partition module to load, instead of hardcoding pc and gpt.
+
 2007-05-07  Robert Millan  <rmh@aybabtu.com>
 
        * Makefile.in: Fix assumption that $(srcdir) has a trailing slash when
index 4620270660a2dc11c377267c739f05e44342d1d3..97c8761faf6489c7b614118201bbc6dbe19e5e6c 100644 (file)
@@ -216,8 +216,16 @@ if test "x$fs_module" = x -a "x$modules" = x; then
     exit 1
 fi
 
-# Typically, _chain, pc and gpt are required.
-modules="$modules $fs_module _chain pc gpt"
+# Then the partition map module.
+partmap_module=`$grub_probe --target=partmap --device-map=${device_map} ${grubdir}`
+if test "x$partmap_module" = x -a "x$modules" = x; then
+    echo "Auto-detection of a partition map module failed." 1>&2
+    echo "Please specify the module with the option \`--modules' explicitly." 1>&2
+    exit 1
+fi
+
+# _chain is often useful
+modules="$modules $fs_module $partmap_module _chain"
 
 $grub_mkimage --output=${grubdir}/core.img $modules || exit 1
 
index 971ede8b0fd07f7f1ca4c722068123f23d7beeca..8ee1225af5a162fcb1916c485f793eb8615248e5 100644 (file)
@@ -50,6 +50,7 @@
 #define PRINT_FS       0
 #define PRINT_DRIVE    1
 #define PRINT_DEVICE   2
+#define PRINT_PARTMAP  3
 
 int print = PRINT_FS;
 
@@ -123,6 +124,23 @@ probe (const char *path)
   if (! dev)
     grub_util_error ("%s", grub_errmsg);
 
+  if (print == PRINT_PARTMAP)
+    {
+      if (strcmp (dev->disk->partition->partmap->name, "amiga_partition_map") == 0)
+        printf ("amiga\n");
+      else if (strcmp (dev->disk->partition->partmap->name, "apple_partition_map") == 0)
+        printf ("apple\n");
+      else if (strcmp (dev->disk->partition->partmap->name, "gpt_partition_map") == 0)
+        printf ("gpt\n");
+      else if (strcmp (dev->disk->partition->partmap->name, "pc_partition_map") == 0)
+        printf ("pc\n");
+      else if (strcmp (dev->disk->partition->partmap->name, "sun_partition_map") == 0)
+        printf ("sun\n");
+      else
+        grub_util_error ("Unknown partition map %s", dev->disk->partition->partmap->name);
+      goto end;
+    }
+
   fs = grub_fs_probe (dev);
   if (! fs)
     grub_util_error ("%s", grub_errmsg);
@@ -160,7 +178,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)  print filesystem module, GRUB drive or system device [default=fs]\n\
+  -t, --target=(fs|drive|device|partmap)\n\
+                            print filesystem module, GRUB drive, system device or partition map 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\
@@ -204,6 +223,8 @@ main (int argc, char *argv[])
              print = PRINT_DRIVE;
            else if (!strcmp (optarg, "device"))
              print = PRINT_DEVICE;
+           else if (!strcmp (optarg, "partmap"))
+             print = PRINT_PARTMAP;
            else
              usage (1);
            break;