grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Caseless UUID comparsion in search command


From: Daniel Mierswa
Subject: [PATCH] Caseless UUID comparsion in search command
Date: Mon, 06 Jul 2009 09:57:30 +0200
User-agent: Thunderbird 2.0.0.22 (X11/20090628)

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
2009-07-06  Daniel Mierswa  <address@hidden>

        * commands/search.c (search_fs): use `strcasecmp' for UUID comparsion.
From 02d806fe1e7603c38f2c885680007b6d14edeefa Mon Sep 17 00:00:00 2001
From: Daniel Mierswa <address@hidden>
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: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]