2009-06-04 Robert Millan <rmh.grub@aybabtu.com>

Prevent GRUB from probing floppies during boot.

        * conf/common.rmk (search_mod_CFLAGS): Use `-Werror -Wall'.
        * commands/search.c (options): Add --no-floppy.
        (search_fs, search_file, grub_cmd_search): Support --no-floppy.
        * util/grub-mkconfig_lib.in (prepare_grub_to_access_device): Use
        --no-floppy when searching for UUIDs.
This commit is contained in:
robertmh 2009-06-04 11:37:44 +00:00
parent 2bf5885a3d
commit f4448a0792
4 changed files with 34 additions and 11 deletions

View File

@ -1,3 +1,13 @@
2009-06-04 Robert Millan <rmh.grub@aybabtu.com>
Prevent GRUB from probing floppies during boot.
* conf/common.rmk (search_mod_CFLAGS): Use `-Werror -Wall'.
* commands/search.c (options): Add --no-floppy.
(search_fs, search_file, grub_cmd_search): Support --no-floppy.
* util/grub-mkconfig_lib.in (prepare_grub_to_access_device): Use
--no-floppy when searching for UUIDs.
2009-06-04 Robert Millan <rmh.grub@aybabtu.com>
Simplify the code duplication in commands/search.c.

View File

@ -29,15 +29,16 @@
static const struct grub_arg_option options[] =
{
{"file", 'f', 0, "search devices by a file (default)", 0, 0},
{"label", 'l', 0, "search devices by a filesystem label", 0, 0},
{"fs-uuid", 'u', 0, "search devices by a filesystem UUID", 0, 0},
{"set", 's', GRUB_ARG_OPTION_OPTIONAL, "set a variable to the first device found", "VAR", ARG_TYPE_STRING},
{"file", 'f', 0, "search devices by a file (default)", 0, 0},
{"label", 'l', 0, "search devices by a filesystem label", 0, 0},
{"fs-uuid", 'u', 0, "search devices by a filesystem UUID", 0, 0},
{"set", 's', GRUB_ARG_OPTION_OPTIONAL, "set a variable to the first device found", "VAR", ARG_TYPE_STRING},
{"no-floppy", 'n', 0, "do not probe any floppy drive", 0, 0},
{0, 0, 0, 0, 0, 0}
};
static void
search_fs (const char *key, const char *var, int is_uuid)
search_fs (const char *key, const char *var, int no_floppy, int is_uuid)
{
int count = 0;
auto int iterate_device (const char *name);
@ -46,6 +47,12 @@ search_fs (const char *key, const char *var, int is_uuid)
{
grub_device_t dev;
int abort = 0;
/* Skip floppy drives when requested. */
if (no_floppy &&
name[0] == 'f' && name[1] == 'd' &&
name[2] >= '0' && name[2] <= '9')
return 0;
dev = grub_device_open (name);
if (dev)
@ -94,7 +101,7 @@ search_fs (const char *key, const char *var, int is_uuid)
}
static void
search_file (const char *key, const char *var)
search_file (const char *key, const char *var, int no_floppy)
{
int count = 0;
char *buf = 0;
@ -107,6 +114,12 @@ search_file (const char *key, const char *var)
grub_file_t file;
int abort = 0;
/* Skip floppy drives when requested. */
if (no_floppy &&
name[0] == 'f' && name[1] == 'd' &&
name[2] >= '0' && name[2] <= '9')
return 0;
len = grub_strlen (name) + 2 + grub_strlen (key) + 1;
p = grub_realloc (buf, len);
if (! p)
@ -156,11 +169,11 @@ grub_cmd_search (grub_extcmd_t cmd, int argc, char **args)
var = state[3].arg ? state[3].arg : "root";
if (state[1].set)
search_fs (args[0], var, 0);
search_fs (args[0], var, state[4].set, 0);
else if (state[2].set)
search_fs (args[0], var, 1);
search_fs (args[0], var, state[4].set, 1);
else
search_file (args[0], var);
search_file (args[0], var, state[4].set);
return grub_errno;
}

View File

@ -413,7 +413,7 @@ help_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For search.mod.
search_mod_SOURCES = commands/search.c
search_mod_CFLAGS = $(COMMON_CFLAGS)
search_mod_CFLAGS = $(COMMON_CFLAGS) -Werror -Wall
search_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For test.mod.

View File

@ -144,7 +144,7 @@ prepare_grub_to_access_device ()
# otherwise set root as per value in device.map.
echo "set root=`${grub_probe} --device ${device} --target=drive`"
if fs_uuid="`${grub_probe} --device ${device} --target=fs_uuid 2> /dev/null`" ; then
echo "search --fs-uuid --set ${fs_uuid}"
echo "search --no-floppy --fs-uuid --set ${fs_uuid}"
fi
}