From: Robert Millan <rmh@aybabtu.com>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: GPT on PC/BIOS computers
Date: Mon, 7 May 2007 11:17:45 +0200 [thread overview]
Message-ID: <20070507091745.GA3628@aragorn> (raw)
In-Reply-To: <87fy6bo17h.fsf@xs4all.nl>
[-- Attachment #1: Type: text/plain, Size: 788 bytes --]
On Sat, May 05, 2007 at 03:21:38PM +0200, Marco Gerards wrote:
> > I've looked into this, but I need some advice. What's the simplest way to
> > obtain the corresponding grub_partition_t structure for a partition by knowing
> > its drive name?
>
> You can use grub_partition_iterate. Or open the disk and use
> ->partition. You can read the name of the partitioning scheme. The
> is also done in grub-setup.c, in the code you altered.
Patch attached. Let me know if it's correct (I had my doubts about hardcoding
the the whole partition_map list in grub-probe.c, but then again I think safety
is more important).
--
Robert Millan
My spam trap is honeypot@aybabtu.com. Note: this address is only intended
for spam harvesters. Writing to it will get you added to my black list.
[-- Attachment #2: ptable.diff --]
[-- Type: text/x-diff, Size: 3371 bytes --]
2007-05-07 Robert Millan <rmh@aybabtu.com>
* util/i386/pc/grub-probe.c: Add `grub-probe -t ptable' parameter to
determine partition table module.
* util/i386/pc/grub-install.in: Use this feature to decide which
partition module to load, instead of hardcoding pc and gpt.
diff -ur grub2-1.95+20070505.1.old/util/i386/pc/grub-install.in grub2-1.95+20070505.1/util/i386/pc/grub-install.in
--- grub2-1.95+20070505.1.old/util/i386/pc/grub-install.in 2007-05-07 10:53:25.000000000 +0200
+++ grub2-1.95+20070505.1/util/i386/pc/grub-install.in 2007-05-07 10:54:27.000000000 +0200
@@ -216,8 +216,16 @@
exit 1
fi
-# Typically, _chain, pc and gpt are required.
-modules="$modules $fs_module _chain pc gpt"
+# Then the partition table module.
+ptable_module=`$grub_probe --target=ptable --device-map=${device_map} ${grubdir}`
+if test "x$ptable_module" = x -a "x$modules" = x; then
+ echo "Auto-detection of a partition table 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 $ptable_module _chain"
$grub_mkimage --output=${grubdir}/core.img $modules || exit 1
diff -ur grub2-1.95+20070505.1.old/util/i386/pc/grub-probe.c grub2-1.95+20070505.1/util/i386/pc/grub-probe.c
--- grub2-1.95+20070505.1.old/util/i386/pc/grub-probe.c 2007-05-07 10:53:26.000000000 +0200
+++ grub2-1.95+20070505.1/util/i386/pc/grub-probe.c 2007-05-07 10:55:44.000000000 +0200
@@ -50,6 +50,7 @@
#define PRINT_FS 0
#define PRINT_DRIVE 1
#define PRINT_DEVICE 2
+#define PRINT_PTABLE 3
int print = PRINT_FS;
@@ -123,6 +124,23 @@
if (! dev)
grub_util_error ("%s", grub_errmsg);
+ if (print == PRINT_PTABLE)
+ {
+ 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 table %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 @@
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|ptable)\n\
+ print filesystem module, GRUB drive, system device or partition table 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 @@
print = PRINT_DRIVE;
else if (!strcmp (optarg, "device"))
print = PRINT_DEVICE;
+ else if (!strcmp (optarg, "ptable"))
+ print = PRINT_PTABLE;
else
usage (1);
break;
next prev parent reply other threads:[~2007-05-07 9:24 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-01 19:18 GPT on PC/BIOS computers Robert Millan
2007-05-03 13:33 ` Javier Rodríguez Sánchez
2007-05-03 14:17 ` Robert Millan
2007-05-03 14:27 ` Javier Rodríguez Sánchez
2007-05-04 20:32 ` Javier Rodríguez Sánchez
2007-05-04 22:15 ` Robert Millan
2007-05-05 13:13 ` Marco Gerards
2007-05-06 7:02 ` Javier Rodríguez Sánchez
2007-05-04 8:40 ` Marco Gerards
2007-05-04 23:05 ` Robert Millan
2007-05-05 13:21 ` Marco Gerards
2007-05-07 9:17 ` Robert Millan [this message]
2007-05-07 19:23 ` Yoshinori K. Okuji
2007-05-07 19:58 ` Robert Millan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070507091745.GA3628@aragorn \
--to=rmh@aybabtu.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.