All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Mierswa <impulze@impulze.org>
To: grub-devel@gnu.org
Subject: [PATCH] Caseless UUID comparsion in search command
Date: Mon, 06 Jul 2009 09:57:30 +0200	[thread overview]
Message-ID: <4A51AE6A.6060708@impulze.org> (raw)


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

Just like some time ago in search_fs_uuid() the search_fs() function of
search also needs to be caseless when comparing UUIDs, for some reason
GRUB2 didn't find my UUID although I entered it as reported by blkid. To
be on the safe side, just use strncasecmp. :) Patch against git master
and ChangeLog attached. I await your feedback. :-)

-- 
Mierswa, Daniel

If you still don't like it, that's ok: that's why I'm boss. I simply
know better than you do.
               --- Linus Torvalds, comp.os.linux.advocacy, 1996/07/22

[-- Attachment #1.2: ChangeLog --]
[-- Type: text/plain, Size: 123 bytes --]

2009-07-06  Daniel Mierswa  <impulze@impulze.org>

	* commands/search.c (search_fs): use `strcasecmp' for UUID comparsion.

[-- Attachment #1.3: grub2.patch --]
[-- Type: text/plain, Size: 1116 bytes --]

From 02d806fe1e7603c38f2c885680007b6d14edeefa Mon Sep 17 00:00:00 2001
From: Daniel Mierswa <impulze@impulze.org>
Date: Mon, 6 Jul 2009 09:35:17 +0200
Subject: [PATCH] ignore case for uuid comparison in search

---
 commands/search.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/commands/search.c b/commands/search.c
index 647f408..52b5fd6 100644
--- a/commands/search.c
+++ b/commands/search.c
@@ -70,6 +70,13 @@ search_fs (const char *key, const char *var, int no_floppy, int is_uuid)
 
 	  fs = grub_fs_probe (dev);
 
+	  int (*compare_fn)(const char *s1, const char *s2);
+	  if (is_uuid) {
+	    compare_fn = grub_strcasecmp;
+	  } else {
+	    compare_fn = grub_strcmp;
+	  }
+
 #define QUID(x)	(is_uuid ? (x)->uuid : (x)->label)
 
 	  if (fs && QUID(fs))
@@ -79,7 +86,7 @@ search_fs (const char *key, const char *var, int no_floppy, int is_uuid)
 	      (QUID(fs)) (dev, &quid);
 	      if (grub_errno == GRUB_ERR_NONE && quid)
 		{
-		  if (grub_strcmp (quid, key) == 0)
+		  if (compare_fn (quid, key) == 0)
 		    {
 		      /* Found!  */
 		      count++;
-- 
1.6.3.3


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

             reply	other threads:[~2009-07-06  7:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-06  7:57 Daniel Mierswa [this message]
2009-07-06 20:14 ` [PATCH] Caseless UUID comparsion in search command Pavel Roskin
2009-07-06 20:16 ` Arthur Marsh
2009-07-07  0:38   ` Pavel Roskin
2009-07-07  1:11     ` Arthur Marsh
2009-07-07  1:43       ` Arthur Marsh
2009-07-07  1:58       ` Pavel Roskin
2009-07-07  3:38         ` Arthur Marsh
2009-07-07  4:23           ` Pavel Roskin
2009-07-07  4:40             ` Arthur Marsh
2009-07-07  6:51               ` Arthur Marsh
2009-07-08  6:26                 ` Pavel Roskin
2009-07-08  8:26                   ` Arthur Marsh

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=4A51AE6A.6060708@impulze.org \
    --to=impulze@impulze.org \
    --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.