All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: [PATCH] Search hinting support
Date: Mon, 28 Dec 2009 14:04:18 +0100	[thread overview]
Message-ID: <4B38ACD2.8030507@gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 58 bytes --]


-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: hints.diff --]
[-- Type: text/x-diff; name="hints.diff", Size: 4079 bytes --]

=== modified file 'commands/search.c'
--- commands/search.c	2009-12-25 23:50:59 +0000
+++ commands/search.c	2009-12-28 13:02:23 +0000
@@ -30,7 +30,8 @@
 #include <grub/i18n.h>
 
 void
-FUNC_NAME (const char *key, const char *var, int no_floppy)
+FUNC_NAME (const char *key, const char *var, int no_floppy,
+	   const char **hints, unsigned nhints)
 {
   int count = 0;
   char *buf = NULL;
@@ -118,22 +119,32 @@
     return (found && var);
   }
 
+  auto void try (void);
+  void try (void)    
+  {
+    unsigned i;
+    for (i = 0; i < nhints; i++)
+      if (iterate_device (hints[i]))
+	return;
+    grub_device_iterate (iterate_device);
+  }
+
   /* First try without autoloading if we're setting variable. */
   if (var)
     {
       saved_autoload = grub_fs_autoload_hook;
       grub_fs_autoload_hook = 0;
-      grub_device_iterate (iterate_device);
+      try ();
 
       /* Restore autoload hook.  */
       grub_fs_autoload_hook = saved_autoload;
 
       /* Retry with autoload if nothing found.  */
       if (grub_errno == GRUB_ERR_NONE && count == 0)
-	grub_device_iterate (iterate_device);
+	try ();
     }
   else
-    grub_device_iterate (iterate_device);
+    try ();
 
   grub_free (buf);
 
@@ -148,7 +159,8 @@
   if (argc == 0)
     return grub_error (GRUB_ERR_BAD_ARGUMENT, "no argument specified");
 
-  FUNC_NAME (args[0], argc == 1 ? 0 : args[1], 0);
+  FUNC_NAME (args[0], argc == 1 ? 0 : args[1], 0, (const char **) (args + 2),
+	     argc > 2 ? argc - 2 : 0);
 
   return grub_errno;
 }
@@ -165,7 +177,7 @@
 {
   cmd =
     grub_register_command (COMMAND_NAME, grub_cmd_do_search,
-			   "NAME [VARIABLE]",
+			   "NAME [VARIABLE] [HINTS]",
 			   "Search devices by " SEARCH_TARGET "."
 			   " If VARIABLE is specified, "
 			   "the first device found is set to a variable.");

=== modified file 'commands/search_wrap.c'
--- commands/search_wrap.c	2009-12-25 22:06:52 +0000
+++ commands/search_wrap.c	2009-12-28 13:02:23 +0000
@@ -62,11 +62,14 @@
     var = state[SEARCH_SET].arg ? state[SEARCH_SET].arg : "root";
 
   if (state[SEARCH_LABEL].set)
-    grub_search_label (args[0], var, state[SEARCH_NO_FLOPPY].set);
+    grub_search_label (args[0], var, state[SEARCH_NO_FLOPPY].set, 
+		       (const char **) (args + 1), argc - 1);
   else if (state[SEARCH_FS_UUID].set)
-    grub_search_fs_uuid (args[0], var, state[SEARCH_NO_FLOPPY].set);
+    grub_search_fs_uuid (args[0], var, state[SEARCH_NO_FLOPPY].set,
+			 (const char **) (args + 1), argc - 1);
   else if (state[SEARCH_FILE].set)
-    grub_search_fs_file (args[0], var, state[SEARCH_NO_FLOPPY].set);
+    grub_search_fs_file (args[0], var, state[SEARCH_NO_FLOPPY].set, 
+			 (const char **) (args + 1), argc - 1);
   else
     return grub_error (GRUB_ERR_INVALID_COMMAND, "unspecified search type");
 
@@ -80,7 +83,7 @@
   cmd =
     grub_register_extcmd ("search", grub_cmd_search,
 			  GRUB_COMMAND_FLAG_BOTH,
-			  N_("search [-f|-l|-u|-s|-n] NAME"),
+			  N_("[-f|-l|-u|-s|-n] NAME [HINTS]"),
 			  N_("Search devices by file, filesystem label"
 			     " or filesystem UUID."
 			     " If --set is specified, the first device found is"

=== modified file 'include/grub/search.h'
--- include/grub/search.h	2009-11-23 20:15:44 +0000
+++ include/grub/search.h	2009-12-28 13:02:23 +0000
@@ -19,8 +19,11 @@
 #ifndef GRUB_SEARCH_HEADER
 #define GRUB_SEARCH_HEADER 1
 
-void grub_search_fs_file (const char *key, const char *var, int no_floppy);
-void grub_search_fs_uuid (const char *key, const char *var, int no_floppy);
-void grub_search_label (const char *key, const char *var, int no_floppy);
+void grub_search_fs_file (const char *key, const char *var, int no_floppy,
+			  const char **hints, unsigned nhints);
+void grub_search_fs_uuid (const char *key, const char *var, int no_floppy,
+			  const char **hints, unsigned nhints);
+void grub_search_label (const char *key, const char *var, int no_floppy,
+			const char **hints, unsigned nhints);
 
 #endif


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 293 bytes --]

             reply	other threads:[~2009-12-28 13:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-28 13:04 Vladimir 'φ-coder/phcoder' Serbinenko [this message]
2010-01-08 13:38 ` [PATCH] Search hinting support Robert Millan
2010-02-06 15:19   ` Vladimir 'φ-coder/phcoder' Serbinenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B38ACD2.8030507@gmail.com \
    --to=phcoder@gmail.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.