[2243] 2009-06-04 Robert Millan <[email protected]>

Robert Millan <[email protected]>
Newsgroups gmane.comp.boot-loaders.grub.cvs
Message-ID <[email protected]>
Revision: 2243
          http://svn.sv.gnu.org/viewvc/?view=rev&root=grub&revision=2243
Author:   robertmh
Date:     2009-06-04 11:37:44 +0000 (Thu, 04 Jun 2009)
Log Message:
-----------
2009-06-04  Robert Millan  <[email protected]>

        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.

Modified Paths:
--------------
    trunk/grub2/ChangeLog
    trunk/grub2/commands/search.c
    trunk/grub2/conf/common.rmk
    trunk/grub2/util/grub-mkconfig_lib.in

Modified: trunk/grub2/ChangeLog
===================================================================
--- trunk/grub2/ChangeLog	2009-06-04 11:18:18 UTC (rev 2242)
+++ trunk/grub2/ChangeLog	2009-06-04 11:37:44 UTC (rev 2243)
@@ -1,5 +1,15 @@
 2009-06-04  Robert Millan  <[email protected]>
 
+	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  <[email protected]>
+
 	Simplify the code duplication in commands/search.c.
 
 	* commands/search.c (search_label, search_fs_uuid): Merge into ...

Modified: trunk/grub2/commands/search.c
===================================================================
--- trunk/grub2/commands/search.c	2009-06-04 11:18:18 UTC (rev 2242)
+++ trunk/grub2/commands/search.c	2009-06-04 11:37:44 UTC (rev 2243)
@@ -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 @@
     {
       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 @@
 }
 
 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 @@
       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 @@
     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;
 }

Modified: trunk/grub2/conf/common.rmk
===================================================================
--- trunk/grub2/conf/common.rmk	2009-06-04 11:18:18 UTC (rev 2242)
+++ trunk/grub2/conf/common.rmk	2009-06-04 11:37:44 UTC (rev 2243)
@@ -413,7 +413,7 @@
 
 # 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.

Modified: trunk/grub2/util/grub-mkconfig_lib.in
===================================================================
--- trunk/grub2/util/grub-mkconfig_lib.in	2009-06-04 11:18:18 UTC (rev 2242)
+++ trunk/grub2/util/grub-mkconfig_lib.in	2009-06-04 11:37:44 UTC (rev 2243)
@@ -144,7 +144,7 @@
   # 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
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.