]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2009-06-04 Robert Millan <rmh.grub@aybabtu.com>
authorrobertmh <robertmh@localhost>
Thu, 4 Jun 2009 11:37:44 +0000 (11:37 +0000)
committerrobertmh <robertmh@localhost>
Thu, 4 Jun 2009 11:37:44 +0000 (11:37 +0000)
        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.

ChangeLog
commands/search.c
conf/common.rmk
util/grub-mkconfig_lib.in

index d79342f8e6649c100f633bf1e0b143167fd183f1..30d9c796975fede8fad8951d5aca18451cc4eff5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
index 5f8d1b51ddc3b0ebc996baa1fe3d353be0854028..301b663e5d191dc3815e067a55fe6728d7d04ce9 100644 (file)
 
 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;
 }
index 1b9a6cdb48555d15d5b767b168fbf5af7e533d3d..ca18c534a52554e4a75d204f13566134611ff1b8 100644 (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.
index 0c5c456212cb15258bb0768342ce112ab1f01063..9afbd3b1f1501784c7f836c986abad270c93fd94 100644 (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
 }