From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HkzRt-0006eZ-ID for mharc-grub-devel@gnu.org; Mon, 07 May 2007 05:24:05 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HkzRr-0006ZA-8N for grub-devel@gnu.org; Mon, 07 May 2007 05:24:03 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HkzRp-0006Tg-H2 for grub-devel@gnu.org; Mon, 07 May 2007 05:24:02 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HkzRp-0006TB-Ds for grub-devel@gnu.org; Mon, 07 May 2007 05:24:01 -0400 Received: from aybabtu.com ([69.60.117.155]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HkzKp-0003wv-EJ for grub-devel@gnu.org; Mon, 07 May 2007 05:16:48 -0400 Received: from [192.168.10.6] (helo=aragorn) by aybabtu.com with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1HkzKY-00087J-GU for grub-devel@gnu.org; Mon, 07 May 2007 11:16:31 +0200 Received: from rmh by aragorn with local (Exim 4.63) (envelope-from ) id 1HkzLl-0000xh-VB for grub-devel@gnu.org; Mon, 07 May 2007 11:17:45 +0200 Date: Mon, 7 May 2007 11:17:45 +0200 From: Robert Millan To: The development of GRUB 2 Message-ID: <20070507091745.GA3628@aragorn> References: <20070501191808.GA19766@aragorn> <871whxouby.fsf@xs4all.nl> <20070504230555.GA17479@aragorn> <87fy6bo17h.fsf@xs4all.nl> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="9jxsPFA5p3P2qPhR" Content-Disposition: inline In-Reply-To: <87fy6bo17h.fsf@xs4all.nl> Organization: free as in freedom X-Message-Flag: Microsoft discourages use of Outlook. X-Debbugs-No-Ack: true User-Agent: Mutt/1.5.13 (2006-08-11) X-detected-kernel: Genre and OS details not recognized. Subject: Re: GPT on PC/BIOS computers X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 May 2007 09:24:03 -0000 --9jxsPFA5p3P2qPhR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. --9jxsPFA5p3P2qPhR Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="ptable.diff" 2007-05-07 Robert Millan * 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; --9jxsPFA5p3P2qPhR--