From 9216e0e742ec8027ec82bd4203a3a24c53ba4f16 Mon Sep 17 00:00:00 2001 From: robertmh Date: Wed, 6 Feb 2008 21:06:34 +0000 Subject: [PATCH] 2008-02-06 Robert Millan * util/grub-probe.c (probe): Simplify partmap probing (with the assumption that the first word up to the underscore equals to the module name). --- ChangeLog | 6 ++++++ util/grub-probe.c | 26 ++++++++++++++------------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index e69d6332d..d826595ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-02-06 Robert Millan + + * util/grub-probe.c (probe): Simplify partmap probing (with the + assumption that the first word up to the underscore equals to + the module name). + 2008-02-06 Christian Franke * fs/cpio.c (grub_cpio_find_file): Return GRUB_ERR_NONE diff --git a/util/grub-probe.c b/util/grub-probe.c index 0681d9f59..062889ca9 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -133,21 +133,23 @@ 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); + free (name); goto end; }