Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1GSx36-00069G-On for mharc-grub-devel@gnu.org; Thu, 28 Sep 2006 10:39:40 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GSx35-00066c-76 for grub-devel@gnu.org; Thu, 28 Sep 2006 10:39:39 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GSx34-00064w-AJ for grub-devel@gnu.org; Thu, 28 Sep 2006 10:39:38 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GSx34-00064i-2n for grub-devel@gnu.org; Thu, 28 Sep 2006 10:39:38 -0400 Received: from [69.60.117.155] (helo=aybabtu.com) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1GSx8A-0004cp-0s for grub-devel@gnu.org; Thu, 28 Sep 2006 10:44:54 -0400 Received: from 138.red-62-57-141.user.auna.net ([62.57.141.138] helo=khazad.dyndns.org) by aybabtu.com with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.63) (envelope-from ) id 1GSx2y-0004LS-0i for grub-devel@gnu.org; Thu, 28 Sep 2006 16:39:34 +0200 Received: from rmh by khazad.dyndns.org with local (Exim 4.63) (envelope-from ) id 1GSx3M-0007DW-Be for grub-devel@gnu.org; Thu, 28 Sep 2006 16:39:56 +0200 Date: Thu, 28 Sep 2006 16:39:56 +0200 From: Robert Millan To: The development of GRUB 2 Message-ID: <20060928143955.GA27513@khazad.dyndns.org> References: <20060922163313.GA29160@khazad.dyndns.org> <200609230520.37732.okuji@enbug.org> <20060923072605.GA10850@khazad.dyndns.org> <4519637D.6050600@nic.fi> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Qxx1br4bt0+wmkIi" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4519637D.6050600@nic.fi> Organization: free as in freedom X-Message-Flag: Microsoft discourages use of Outlook. User-Agent: Mutt/1.5.13 (2006-08-11) Subject: Re: [PATCH] grub-probefs --root-device 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: Thu, 28 Sep 2006 14:39:39 -0000 --Qxx1br4bt0+wmkIi Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Tue, Sep 26, 2006 at 08:29:33PM +0300, Vesa Jääskeläinen wrote: > Hi, > > Here are some comments about your patch. As requested :) Thanks for the corrections. Some of them make me ashamed, I should have looked better at all those grub-probefs instances... ;) > Robert Millan wrote: > > 2006-09-23 Robert Millan > > > > * util/i386/pc/getroot.c (grub_guess_root_device): Stop using > > grub_util_biosdisk_get_grub_dev to convert system device to GRUB device. > > * util/grub-emu.c: Use grub_util_biosdisk_get_grub_dev with the string > > returned by grub_guess_root_device. > > Method name missing from grub-emu. Ok (main). > > * util/i386/pc/grub-setup.c: Ditto. > > * util/i386/pc/grub-probefs.c: Ditto. > > > > * util/i386/pc/grub-probefs.c: Rename to ... > > * util/i386/pc/grub-probe.c: ... this. > > * DISTLIST: Update reference to grub-probefs. > > * conf/i386-efi.mk: Ditto. > > * conf/i386-efi.rmk: Ditto. > > * conf/i386-pc.mk: Ditto. > > * conf/i386-pc.rmk: Ditto. > > * util/i386/pc/grub-install.in: Ditto. > > Describe what changed in terms of source code not in terms of "english". > Eg. DISTLIST: Removed grub-probefs. Added grub-probe. > > I am not sure is "ditto" a good term.. I have seen "Likewise." in other > entries and used that myself too. > > And no need to inform about changes to .mk as they are generated files. > Just make sure on commit they are there. Ok. I'm also omitting .mk files from my patch. I'll take care of regenerating later. > > * util/i386/pc/grub-probe.c: Add --target=(fs|device|drive) option to > > choose which information we want to print. > > Method... This change applies in various places of the file (main, probe, options..) > Should be grub_probe as name changes... May need changes to other places > too. Checked them all this time. > > --no-floppy do not probe any floppy drive > > --recheck probe a device map even if it already exists > > > > @@ -92,8 +92,8 @@ > > grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;; > > --grub-mkdevicemap=*) > > grub_mkdevicemap=`echo "$option" | sed 's/--grub-mkdevicemap=//'` ;; > > - --grub-probefs=*) > > - grub_probefs=`echo "$option" | sed 's/--grub-probefs=//'` ;; > > + --grub-probe=*) > > + grub_probefs=`echo "$option" | sed 's/--grub-probe=//'` ;; > > Needs change here at least... Done. Also added an explicit --target=fs option in grub-install (better be safe). Please let me know if it's ok now: 2006-09-28 Robert Millan * util/i386/pc/getroot.c (grub_guess_root_device): Stop using grub_util_biosdisk_get_grub_dev to convert system device to GRUB device. * util/grub-emu.c (main): Use grub_util_biosdisk_get_grub_dev with the string returned by grub_guess_root_device. * util/i386/pc/grub-setup.c: Likewise. * util/i386/pc/grub-probefs.c: Likewise. * util/i386/pc/grub-probefs.c: Rename to ... * util/i386/pc/grub-probe.c: ... this. * DISTLIST: Remove grub-probefs, add grub-probe. * conf/i386-efi.rmk: Likewise. * conf/i386-pc.rmk: Likewise. * util/i386/pc/grub-install.in: Likewise. * util/i386/pc/grub-probe.c: Add --target=(fs|device|drive) option to choose which information we want to print. -- 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. --Qxx1br4bt0+wmkIi Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="print_paths.diff" 2006-09-28 Robert Millan * util/i386/pc/getroot.c (grub_guess_root_device): Stop using grub_util_biosdisk_get_grub_dev to convert system device to GRUB device. * util/grub-emu.c (main): Use grub_util_biosdisk_get_grub_dev with the string returned by grub_guess_root_device. * util/i386/pc/grub-setup.c: Likewise. * util/i386/pc/grub-probefs.c: Likewise. * util/i386/pc/grub-probefs.c: Rename to ... * util/i386/pc/grub-probe.c: ... this. * DISTLIST: Remove grub-probefs, add grub-probe. * conf/i386-efi.rmk: Likewise. * conf/i386-pc.rmk: Likewise. * util/i386/pc/grub-install.in: Likewise. * util/i386/pc/grub-probe.c: Add --target=(fs|device|drive) option to choose which information we want to print. Index: DISTLIST =================================================================== RCS file: /sources/grub/grub2/DISTLIST,v retrieving revision 1.36 diff -u -r1.36 DISTLIST --- DISTLIST 4 Jun 2006 12:59:19 -0000 1.36 +++ DISTLIST 28 Sep 2006 14:11:04 -0000 @@ -253,7 +253,7 @@ util/i386/pc/grub-install.in util/i386/pc/grub-mkdevicemap.c util/i386/pc/grub-mkimage.c -util/i386/pc/grub-probefs.c +util/i386/pc/grub-probe.c util/i386/pc/grub-setup.c util/i386/pc/misc.c util/powerpc/ieee1275/grub-install.in Index: conf/i386-efi.rmk =================================================================== RCS file: /sources/grub/grub2/conf/i386-efi.rmk,v retrieving revision 1.10 diff -u -r1.10 i386-efi.rmk --- conf/i386-efi.rmk 22 Sep 2006 19:36:32 -0000 1.10 +++ conf/i386-efi.rmk 28 Sep 2006 14:11:04 -0000 @@ -6,7 +6,7 @@ # Utilities. bin_UTILITIES = grub-mkimage -#sbin_UTILITIES = grub-setup grub-emu grub-mkdevicemap grub-probefs +#sbin_UTILITIES = grub-setup grub-emu grub-mkdevicemap grub-probe # For grub-mkimage. grub_mkimage_SOURCES = util/i386/efi/grub-mkimage.c util/misc.c \ @@ -23,8 +23,8 @@ # For grub-mkdevicemap. #grub_mkdevicemap_SOURCES = util/i386/pc/grub-mkdevicemap.c util/misc.c -# For grub-probefs. -#grub_probefs_SOURCES = util/i386/pc/grub-probefs.c \ +# For grub-probe. +#grub_probe_SOURCES = util/i386/pc/grub-probe.c \ # util/i386/pc/biosdisk.c util/misc.c util/i386/pc/getroot.c \ # kern/device.c kern/disk.c kern/err.c kern/misc.c fs/fat.c \ # fs/ext2.c kern/parser.c kern/partition.c partmap/pc.c fs/ufs.c \ Index: conf/i386-pc.rmk =================================================================== RCS file: /sources/grub/grub2/conf/i386-pc.rmk,v retrieving revision 1.70 diff -u -r1.70 i386-pc.rmk --- conf/i386-pc.rmk 22 Sep 2006 21:09:14 -0000 1.70 +++ conf/i386-pc.rmk 28 Sep 2006 14:11:05 -0000 @@ -51,7 +51,7 @@ # Utilities. bin_UTILITIES = grub-mkimage -sbin_UTILITIES = grub-setup grub-emu grub-mkdevicemap grub-probefs +sbin_UTILITIES = grub-setup grub-emu grub-mkdevicemap grub-probe # For grub-mkimage. grub_mkimage_SOURCES = util/i386/pc/grub-mkimage.c util/misc.c \ @@ -69,8 +69,8 @@ # For grub-mkdevicemap. grub_mkdevicemap_SOURCES = util/i386/pc/grub-mkdevicemap.c util/misc.c -# For grub-probefs. -grub_probefs_SOURCES = util/i386/pc/grub-probefs.c \ +# For grub-probe. +grub_probe_SOURCES = util/i386/pc/grub-probe.c \ util/i386/pc/biosdisk.c util/misc.c util/i386/pc/getroot.c \ kern/device.c kern/disk.c kern/err.c kern/misc.c fs/fat.c \ fs/ext2.c kern/parser.c kern/partition.c partmap/pc.c fs/ufs.c \ Index: util/grub-emu.c =================================================================== RCS file: /sources/grub/grub2/util/grub-emu.c,v retrieving revision 1.30 diff -u -r1.30 grub-emu.c --- util/grub-emu.c 13 Jun 2006 22:50:01 -0000 1.30 +++ util/grub-emu.c 28 Sep 2006 14:11:06 -0000 @@ -185,7 +185,7 @@ /* Make sure that there is a root device. */ if (! args.root_dev) { - args.root_dev = grub_guess_root_device (args.dir ? : DEFAULT_DIRECTORY); + args.root_dev = grub_util_biosdisk_get_grub_dev (grub_guess_root_device (args.dir ? : DEFAULT_DIRECTORY)); if (! args.root_dev) { grub_util_info ("guessing the root device failed, because of `%s'", Index: util/i386/pc/getroot.c =================================================================== RCS file: /sources/grub/grub2/util/i386/pc/getroot.c,v retrieving revision 1.5 diff -u -r1.5 getroot.c --- util/i386/pc/getroot.c 14 Sep 2006 18:52:50 -0000 1.5 +++ util/i386/pc/getroot.c 28 Sep 2006 14:11:06 -0000 @@ -223,5 +223,5 @@ if (! os_dev) return 0; - return grub_util_biosdisk_get_grub_dev (os_dev); + return os_dev; } Index: util/i386/pc/grub-install.in =================================================================== RCS file: /sources/grub/grub2/util/i386/pc/grub-install.in,v retrieving revision 1.9 diff -u -r1.9 grub-install.in --- util/i386/pc/grub-install.in 14 Sep 2006 18:52:50 -0000 1.9 +++ util/i386/pc/grub-install.in 28 Sep 2006 14:11:06 -0000 @@ -33,7 +33,7 @@ grub_setup=${sbindir}/grub-setup grub_mkimage=${bindir}/grub-mkimage grub_mkdevicemap=${sbindir}/grub-mkdevicemap -grub_probefs=${sbindir}/grub-probefs +grub_probe=${sbindir}/grub-probe rootdir= grub_prefix=/boot/grub modules= @@ -59,7 +59,7 @@ --grub-setup=FILE use FILE as grub-setup --grub-mkimage=FILE use FILE as grub-mkimage --grub-mkdevicemap=FILE use FILE as grub-mkdevicemap - --grub-probefs=FILE use FILE as grub-probefs + --grub-probe=FILE use FILE as grub-probe --no-floppy do not probe any floppy drive --recheck probe a device map even if it already exists @@ -92,8 +92,8 @@ grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;; --grub-mkdevicemap=*) grub_mkdevicemap=`echo "$option" | sed 's/--grub-mkdevicemap=//'` ;; - --grub-probefs=*) - grub_probefs=`echo "$option" | sed 's/--grub-probefs=//'` ;; + --grub-probe=*) + grub_probe=`echo "$option" | sed 's/--grub-probe=//'` ;; --no-floppy) no_floppy="--no-floppy" ;; --recheck) @@ -207,7 +207,7 @@ done # Create the core image. First, auto-detect the filesystem module. -fs_module=`$grub_probefs --device-map=${device_map} ${grubdir}` +fs_module=`$grub_probe --target=fs --device-map=${device_map} ${grubdir}` if test "x$fs_module" = x -a "x$modules" = x; then echo "Auto-detection of a filesystem module failed." 1>&2 echo "Please specify the module with the option \`--modules' explicitly." 1>&2 Index: util/i386/pc/grub-probefs.c =================================================================== RCS file: /sources/grub/grub2/util/i386/pc/grub-probefs.c,v retrieving revision 1.3 diff -u -r1.3 grub-probefs.c --- util/i386/pc/grub-probefs.c 23 Apr 2006 13:37:36 -0000 1.3 +++ util/i386/pc/grub-probefs.c 28 Sep 2006 14:11:06 -0000 @@ -1,4 +1,4 @@ -/* grub-probefs.c - probe a filesystem module for a given path */ +/* grub-probe.c - probe device information for a given path */ /* * GRUB -- GRand Unified Bootloader * Copyright (C) 2005,2006 Free Software Foundation, Inc. @@ -47,6 +47,12 @@ #define DEFAULT_DEVICE_MAP DEFAULT_DIRECTORY "/device.map" +#define PRINT_FS 0 +#define PRINT_DRIVE 1 +#define PRINT_DEVICE 2 + +int print = PRINT_FS; + void grub_putchar (int c) { @@ -74,13 +80,33 @@ probe (const char *path) { char *device_name; + char *drive_name; grub_device_t dev; grub_fs_t fs; device_name = grub_guess_root_device (path); if (! device_name) { - fprintf (stderr, "cannot find a GRUB device for %s.\n", path); + fprintf (stderr, "cannot find a device for %s.\n", path); + return; + } + + if (print == PRINT_DEVICE) + { + printf ("%s\n", device_name); + return; + } + + drive_name = grub_util_biosdisk_get_grub_dev (device_name); + if (! drive_name) + { + fprintf (stderr, "cannot find a GRUB drive for %s.\n", drive_name); + return; + } + + if (print == PRINT_DRIVE) + { + printf ("(%s)\n", drive_name); return; } @@ -102,6 +128,7 @@ static struct option options[] = { {"device-map", required_argument, 0, 'm'}, + {"target", required_argument, 0, 't'}, {"help", no_argument, 0, 'h'}, {"version", no_argument, 0, 'V'}, {"verbose", no_argument, 0, 'v'}, @@ -113,14 +140,15 @@ { if (status) fprintf (stderr, - "Try ``grub-probefs --help'' for more information.\n"); + "Try ``grub-probe --help'' for more information.\n"); else printf ("\ -Usage: grub-probefs [OPTION]... PATH\n\ +Usage: grub-probe [OPTION]... PATH\n\ \n\ -Probe a filesystem module for a given 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\ -h, --help display this message and exit\n\ -V, --version print version information and exit\n\ -v, --verbose print verbose messages\n\ @@ -138,12 +166,12 @@ char *dev_map = 0; char *path; - progname = "grub-probefs"; + progname = "grub-probe"; /* Check for options. */ while (1) { - int c = getopt_long (argc, argv, "m:hVv", options, 0); + int c = getopt_long (argc, argv, "m:t:hVv", options, 0); if (c == -1) break; @@ -157,6 +185,17 @@ dev_map = xstrdup (optarg); break; + case 't': + if (!strcmp (optarg, "fs")) + print = PRINT_FS; + else if (!strcmp (optarg, "drive")) + print = PRINT_DRIVE; + else if (!strcmp (optarg, "device")) + print = PRINT_DEVICE; + else + usage (1); + break; + case 'h': usage (0); break; Index: util/i386/pc/grub-setup.c =================================================================== RCS file: /sources/grub/grub2/util/i386/pc/grub-setup.c,v retrieving revision 1.18 diff -u -r1.18 grub-setup.c --- util/i386/pc/grub-setup.c 4 Jun 2006 15:56:55 -0000 1.18 +++ util/i386/pc/grub-setup.c 28 Sep 2006 14:11:06 -0000 @@ -669,7 +669,7 @@ } else { - root_dev = grub_guess_root_device (dir ? : DEFAULT_DIRECTORY); + root_dev = grub_util_biosdisk_get_grub_dev (grub_guess_root_device (dir ? : DEFAULT_DIRECTORY)); if (! root_dev) { grub_util_info ("guessing the root device failed, because of `%s'", --Qxx1br4bt0+wmkIi--