All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] simplify partmap probe
@ 2008-02-06 16:43 Robert Millan
  2008-02-06 21:07 ` Robert Millan
  0 siblings, 1 reply; 2+ messages in thread
From: Robert Millan @ 2008-02-06 16:43 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 192 bytes --]


Simplification for partmap probing function.

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)

[-- Attachment #2: simplify_partmap_probe.diff --]
[-- Type: text/x-diff, Size: 1651 bytes --]


	* util/grub-probe.c (probe): Simplify partmap probing (with the
	assumption that the first word up to the underscore equals to
	the module name).

diff -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/util/grub-probe.c ./util/grub-probe.c
--- ../grub2/util/grub-probe.c	2008-01-25 23:33:57.000000000 +0100
+++ ./util/grub-probe.c	2008-02-06 17:32:28.000000000 +0100
@@ -133,21 +133,22 @@ probe (const char *path)
 
   if (print == PRINT_PARTMAP)
     {
+      char *name;
+      char *underscore;
+      
       if (dev->disk->partition == NULL)
         grub_util_error ("Cannot detect partition map for %s", drive_name);
 
-      if (strcmp (dev->disk->partition->partmap->name, "amiga_partition_map") == 0)
-        printf ("amiga\n");
-      else if (strcmp (dev->disk->partition->partmap->name, "apple_partition_map") == 0)
-        printf ("apple\n");
-      else if (strcmp (dev->disk->partition->partmap->name, "gpt_partition_map") == 0)
-        printf ("gpt\n");
-      else if (strcmp (dev->disk->partition->partmap->name, "pc_partition_map") == 0)
-        printf ("pc\n");
-      else if (strcmp (dev->disk->partition->partmap->name, "sun_partition_map") == 0)
-        printf ("sun\n");
-      else
-        grub_util_error ("Unknown partition map %s", dev->disk->partition->partmap->name);
+      name = strdup (dev->disk->partition->partmap->name);
+      if (! name)
+	grub_util_error ("not enough memory");
+
+      underscore = strchr (name, '_');
+      if (! underscore)
+	grub_util_error ("Invalid partition map %s", name);
+
+      *underscore = '\0';
+      printf ("%s\n", name);
       goto end;
     }
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] simplify partmap probe
  2008-02-06 16:43 [PATCH] simplify partmap probe Robert Millan
@ 2008-02-06 21:07 ` Robert Millan
  0 siblings, 0 replies; 2+ messages in thread
From: Robert Millan @ 2008-02-06 21:07 UTC (permalink / raw)
  To: grub-devel

On Wed, Feb 06, 2008 at 05:43:21PM +0100, Robert Millan wrote:
> 
> Simplification for partmap probing function.

Committed.

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-02-06 21:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-06 16:43 [PATCH] simplify partmap probe Robert Millan
2008-02-06 21:07 ` Robert Millan

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.