2008-01-12 Robert Millan <rmh@aybabtu.com>

* include/grub/util/getroot.h (grub_dev_abstraction_types): New enum.
        (grub_util_get_dev_abstraction): New function prototype.

        * util/getroot.c: Include `<grub/util/getroot.h>'
        (grub_util_get_grub_dev): Move detection of abstraction type to ...
        (grub_util_get_dev_abstraction): ... here (new function).

        * util/grub-probe.c: Convert PRINT_* to an enum.  Add
        `PRINT_ABSTRACTION'.
        (probe): Probe for abstraction type when requested.
        (main): Understand `--target=abstraction'.

        * util/i386/efi/grub-install.in: Add abstraction module to core
        image when it is found to be necessary.
        * util/i386/pc/grub-install.in: Likewise.
        * util/powerpc/ieee1275/grub-install.in: Likewise.

        * util/update-grub_lib.in (font_path): Return system path without
        converting to GRUB path.
        * util/update-grub.in: Convert system path returned by font_path()
        to a GRUB path.  Use `grub-probe -t abstraction' to determine what
        abstraction module is needed for loading fonts (if any).  Export
        that as `GRUB_PRELOAD_MODULES'.
        * util/grub.d/00_header.in: Process `GRUB_PRELOAD_MODULES' (print
        insmod commands).
This commit is contained in:
robertmh 2008-01-12 15:11:57 +00:00
parent 52bd3de956
commit 1eb8c80241
10 changed files with 135 additions and 43 deletions

View file

@ -1,7 +1,7 @@
/* grub-probe.c - probe device information for a given path */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2005,2006,2007 Free Software Foundation, Inc.
* Copyright (C) 2005,2006,2007,2008 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -39,10 +39,13 @@
#define _GNU_SOURCE 1
#include <getopt.h>
#define PRINT_FS 0
#define PRINT_DRIVE 1
#define PRINT_DEVICE 2
#define PRINT_PARTMAP 3
enum {
PRINT_FS,
PRINT_DRIVE,
PRINT_DEVICE,
PRINT_PARTMAP,
PRINT_ABSTRACTION,
};
int print = PRINT_FS;
@ -74,6 +77,7 @@ probe (const char *path)
{
char *device_name;
char *drive_name = NULL;
int abstraction_type;
grub_device_t dev;
grub_fs_t fs;
@ -87,6 +91,28 @@ probe (const char *path)
goto end;
}
abstraction_type = grub_util_get_dev_abstraction (device_name);
/* No need to check for errors; lack of abstraction is permissible. */
if (print == PRINT_ABSTRACTION)
{
char *abstraction_name;
switch (abstraction_type)
{
case GRUB_DEV_ABSTRACTION_NONE:
grub_util_info ("did not find LVM/RAID in %s, assuming raw device", device_name);
goto end;
case GRUB_DEV_ABSTRACTION_LVM:
abstraction_name = "lvm";
break;
case GRUB_DEV_ABSTRACTION_RAID:
abstraction_name = "raid";
break;
}
printf ("%s\n", abstraction_name);
goto end;
}
drive_name = grub_util_get_grub_dev (device_name);
if (! drive_name)
grub_util_error ("cannot find a GRUB drive for %s.\n", device_name);
@ -159,8 +185,8 @@ Usage: grub-probe [OPTION]... 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|partmap)\n\
print filesystem module, GRUB drive, system device or partition map module [default=fs]\n\
-t, --target=(fs|drive|device|partmap|abstraction)\n\
print filesystem module, GRUB drive, system device, partition map module or abstraction 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\
@ -206,6 +232,8 @@ main (int argc, char *argv[])
print = PRINT_DEVICE;
else if (!strcmp (optarg, "partmap"))
print = PRINT_PARTMAP;
else if (!strcmp (optarg, "abstraction"))
print = PRINT_ABSTRACTION;
else
usage (1);
break;