2006-10-14 Robert Millan <rmh@aybabtu.com>
* 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.
This commit is contained in:
parent
2b00217369
commit
ddd5cee9a9
9 changed files with 80 additions and 22 deletions
|
@ -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 @@ static void
|
|||
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 @@ probe (const char *path)
|
|||
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 @@ usage (int status)
|
|||
{
|
||||
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 @@ main (int argc, char *argv[])
|
|||
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 @@ main (int argc, char *argv[])
|
|||
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue