Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1GQsK5-0000lO-Je for mharc-grub-devel@gnu.org; Fri, 22 Sep 2006 17:12:37 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GQsK4-0000ho-AL for grub-devel@gnu.org; Fri, 22 Sep 2006 17:12:36 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GQsK0-0000X9-UX for grub-devel@gnu.org; Fri, 22 Sep 2006 17:12:35 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GQsK0-0000W1-Is for grub-devel@gnu.org; Fri, 22 Sep 2006 17:12:32 -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 1GQsNp-0003Zb-1q for grub-devel@gnu.org; Fri, 22 Sep 2006 17:16:29 -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 1GQsJj-0005AP-34 for grub-devel@gnu.org; Fri, 22 Sep 2006 23:12:15 +0200 Received: from rmh by khazad.dyndns.org with local (Exim 4.63) (envelope-from ) id 1GQsJw-0005iK-TS for grub-devel@gnu.org; Fri, 22 Sep 2006 23:12:28 +0200 Date: Fri, 22 Sep 2006 23:12:23 +0200 From: Robert Millan To: grub-devel@gnu.org Message-ID: <20060922211223.GA21836@khazad.dyndns.org> References: <20060922163313.GA29160@khazad.dyndns.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Dxnq1zWXvFF0Q93v" Content-Disposition: inline In-Reply-To: <20060922163313.GA29160@khazad.dyndns.org> 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: Fri, 22 Sep 2006 21:12:36 -0000 --Dxnq1zWXvFF0Q93v Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Sep 22, 2006 at 06:33:13PM +0200, Robert Millan wrote: > > This would be very useful to get rid of ugly kludges in Debian, such as this > one: > http://svn.debian.org/wsvn/pkg-grub/grub2/trunk/debian/update-grub?op=file&rev=0&sc=0 > (look for convert() here) > > Fortunately grub-probefs is already doing what we need, we just need a way to > tell it to print the information. Uhm it seems I need the system device name as well. Please look at this new patch with an additional option (I had to rework the grub_guess_root_device interface to get the info yet unprocessed by grub_util_biosdisk_get_grub_dev). 2006-09-22 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. * util/i386/pc/grub-setup.c: Ditto. * util/i386/pc/grub-probefs.c: Ditto. * util/i386/pc/grub-probefs.c: Add two options (--grub-root-device and --root-device) to print GRUB or system device and exit. -- 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. --Dxnq1zWXvFF0Q93v Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="print_paths.diff" 2006-09-22 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. * util/i386/pc/grub-setup.c: Ditto. * util/i386/pc/grub-probefs.c: Ditto. * util/i386/pc/grub-probefs.c: Add two options (--grub-root-device and --root-device) to print GRUB or system device and exit. 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 22 Sep 2006 21:00:09 -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 22 Sep 2006 21:00:09 -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-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 22 Sep 2006 21:00:09 -0000 @@ -47,6 +47,9 @@ #define DEFAULT_DEVICE_MAP DEFAULT_DIRECTORY "/device.map" +int print_root = 0; +int print_grub_root = 0; + void grub_putchar (int c) { @@ -74,13 +77,33 @@ probe (const char *path) { char *device_name; + char *grub_device_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; + } + + grub_device_name = grub_util_biosdisk_get_grub_dev (device_name); + if (! grub_device_name) + { + fprintf (stderr, "cannot find a GRUB device for %s.\n", device_name); + return; + } + + if (print_root) + { + printf ("%s\n", device_name); + return; + } + + if (print_grub_root) + { + printf ("(%s)\n", grub_device_name); return; } @@ -102,6 +125,8 @@ static struct option options[] = { {"device-map", required_argument, 0, 'm'}, + {"root-device", no_argument, 0, 'r'}, + {"grub-root-device", no_argument, 0, 'g'}, {"help", no_argument, 0, 'h'}, {"version", no_argument, 0, 'V'}, {"verbose", no_argument, 0, 'v'}, @@ -121,6 +146,8 @@ Probe a filesystem module for a given path.\n\ \n\ -m, --device-map=FILE use FILE as the device map [default=%s]\n\ + -r, --root-device print guessed root device and exit\n\ + -g, --grub-root-device print guessed GRUB root device and exit\n\ -h, --help display this message and exit\n\ -V, --version print version information and exit\n\ -v, --verbose print verbose messages\n\ @@ -143,7 +170,7 @@ /* Check for options. */ while (1) { - int c = getopt_long (argc, argv, "m:hVv", options, 0); + int c = getopt_long (argc, argv, "m:rghVv", options, 0); if (c == -1) break; @@ -157,6 +184,14 @@ dev_map = xstrdup (optarg); break; + case 'r': + print_root=1; + break; + + case 'g': + print_grub_root=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 22 Sep 2006 21:00:09 -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'", --Dxnq1zWXvFF0Q93v--