dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

Blame SOURCES/0070-Fix-partmap-cryptodisk-and-abstraction-handling-in-g.patch

4fe85b
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
4fe85b
From: Colin Watson <cjwatson@ubuntu.com>
4fe85b
Date: Mon, 31 Mar 2014 14:48:33 +0100
4fe85b
Subject: [PATCH] Fix partmap, cryptodisk, and abstraction handling in
4fe85b
 grub-mkconfig.
4fe85b
4fe85b
Commit 588744d0dc655177d5883bdcb8f72ff5160109ed caused grub-mkconfig
4fe85b
no longer to be forgiving of trailing spaces on grub-probe output
4fe85b
lines, which among other things means that util/grub.d/10_linux.in
4fe85b
no longer detects LVM.  To fix this, make grub-probe's output
4fe85b
delimiting more consistent.  As a bonus, this improves the coverage
4fe85b
of the -0 option.
4fe85b
4fe85b
Fixes Debian bug #735935.
4fe85b
4fe85b
* grub-core/disk/cryptodisk.c
4fe85b
(grub_util_cryptodisk_get_abstraction): Add a user-data argument.
4fe85b
* grub-core/disk/diskfilter.c (grub_diskfilter_get_partmap):
4fe85b
Likewise.
4fe85b
* include/grub/cryptodisk.h (grub_util_cryptodisk_get_abstraction):
4fe85b
Update prototype.
4fe85b
* include/grub/diskfilter.h (grub_diskfilter_get_partmap): Likewise.
4fe85b
* util/grub-install.c (push_partmap_module, push_cryptodisk_module,
4fe85b
probe_mods): Adjust for extra user-data arguments.
4fe85b
* util/grub-probe.c (do_print, probe_partmap, probe_cryptodisk_uuid,
4fe85b
probe_abstraction): Use configured delimiter.  Update callers.
4fe85b
---
4fe85b
 grub-core/disk/cryptodisk.c | 19 ++++++++++---------
4fe85b
 grub-core/disk/diskfilter.c |  5 +++--
4fe85b
 util/grub-install.c         | 14 ++++++++++----
4fe85b
 util/grub-probe.c           | 46 ++++++++++++++++++++++-----------------------
4fe85b
 include/grub/cryptodisk.h   |  3 ++-
4fe85b
 include/grub/diskfilter.h   |  3 ++-
4fe85b
 ChangeLog                   | 25 ++++++++++++++++++++++++
4fe85b
 7 files changed, 74 insertions(+), 41 deletions(-)
4fe85b
4fe85b
diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c
4fe85b
index 75c6e1f91ac..f0e3a900ae3 100644
4fe85b
--- a/grub-core/disk/cryptodisk.c
4fe85b
+++ b/grub-core/disk/cryptodisk.c
4fe85b
@@ -762,25 +762,26 @@ grub_cryptodisk_cheat_insert (grub_cryptodisk_t newdev, const char *name,
4fe85b
 
4fe85b
 void
4fe85b
 grub_util_cryptodisk_get_abstraction (grub_disk_t disk,
4fe85b
-				      void (*cb) (const char *val))
4fe85b
+				      void (*cb) (const char *val, void *data),
4fe85b
+				      void *data)
4fe85b
 {
4fe85b
   grub_cryptodisk_t dev = (grub_cryptodisk_t) disk->data;
4fe85b
 
4fe85b
-  cb ("cryptodisk");
4fe85b
-  cb (dev->modname);
4fe85b
+  cb ("cryptodisk", data);
4fe85b
+  cb (dev->modname, data);
4fe85b
 
4fe85b
   if (dev->cipher)
4fe85b
-    cb (dev->cipher->cipher->modname);
4fe85b
+    cb (dev->cipher->cipher->modname, data);
4fe85b
   if (dev->secondary_cipher)
4fe85b
-    cb (dev->secondary_cipher->cipher->modname);
4fe85b
+    cb (dev->secondary_cipher->cipher->modname, data);
4fe85b
   if (dev->essiv_cipher)
4fe85b
-    cb (dev->essiv_cipher->cipher->modname);
4fe85b
+    cb (dev->essiv_cipher->cipher->modname, data);
4fe85b
   if (dev->hash)
4fe85b
-    cb (dev->hash->modname);
4fe85b
+    cb (dev->hash->modname, data);
4fe85b
   if (dev->essiv_hash)
4fe85b
-    cb (dev->essiv_hash->modname);
4fe85b
+    cb (dev->essiv_hash->modname, data);
4fe85b
   if (dev->iv_hash)
4fe85b
-    cb (dev->iv_hash->modname);
4fe85b
+    cb (dev->iv_hash->modname, data);
4fe85b
 }
4fe85b
 
4fe85b
 const char *
4fe85b
diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c
4fe85b
index 28b70c666d4..e8a3bcbd138 100644
4fe85b
--- a/grub-core/disk/diskfilter.c
4fe85b
+++ b/grub-core/disk/diskfilter.c
4fe85b
@@ -354,7 +354,8 @@ grub_diskfilter_memberlist (grub_disk_t disk)
4fe85b
 
4fe85b
 void
4fe85b
 grub_diskfilter_get_partmap (grub_disk_t disk,
4fe85b
-			     void (*cb) (const char *pm))
4fe85b
+			     void (*cb) (const char *pm, void *data),
4fe85b
+			     void *data)
4fe85b
 {
4fe85b
   struct grub_diskfilter_lv *lv = disk->data;
4fe85b
   struct grub_diskfilter_pv *pv;
4fe85b
@@ -376,7 +377,7 @@ grub_diskfilter_get_partmap (grub_disk_t disk,
4fe85b
 	    continue;
4fe85b
 	  }
4fe85b
 	for (s = 0; pv->partmaps[s]; s++)
4fe85b
-	  cb (pv->partmaps[s]);
4fe85b
+	  cb (pv->partmaps[s], data);
4fe85b
       }
4fe85b
 }
4fe85b
 
4fe85b
diff --git a/util/grub-install.c b/util/grub-install.c
4fe85b
index 2e6226a3716..e9c6a4656ef 100644
4fe85b
--- a/util/grub-install.c
4fe85b
+++ b/util/grub-install.c
4fe85b
@@ -387,7 +387,7 @@ probe_raid_level (grub_disk_t disk)
4fe85b
 }
4fe85b
 
4fe85b
 static void
4fe85b
-push_partmap_module (const char *map)
4fe85b
+push_partmap_module (const char *map, void *data __attribute__ ((unused)))
4fe85b
 {
4fe85b
   char buf[50];
4fe85b
 
4fe85b
@@ -401,6 +401,12 @@ push_partmap_module (const char *map)
4fe85b
   grub_install_push_module (buf);
4fe85b
 }
4fe85b
 
4fe85b
+static void
4fe85b
+push_cryptodisk_module (const char *mod, void *data __attribute__ ((unused)))
4fe85b
+{
4fe85b
+  grub_install_push_module (mod);
4fe85b
+}
4fe85b
+
4fe85b
 static void
4fe85b
 probe_mods (grub_disk_t disk)
4fe85b
 {
4fe85b
@@ -412,11 +418,11 @@ probe_mods (grub_disk_t disk)
4fe85b
     grub_util_info ("no partition map found for %s", disk->name);
4fe85b
 
4fe85b
   for (part = disk->partition; part; part = part->parent)
4fe85b
-    push_partmap_module (part->partmap->name);
4fe85b
+    push_partmap_module (part->partmap->name, NULL);
4fe85b
 
4fe85b
   if (disk->dev->id == GRUB_DISK_DEVICE_DISKFILTER_ID)
4fe85b
     {
4fe85b
-      grub_diskfilter_get_partmap (disk, push_partmap_module);
4fe85b
+      grub_diskfilter_get_partmap (disk, push_partmap_module, NULL);
4fe85b
       have_abstractions = 1;
4fe85b
     }
4fe85b
 
4fe85b
@@ -432,7 +438,7 @@ probe_mods (grub_disk_t disk)
4fe85b
   if (disk->dev->id == GRUB_DISK_DEVICE_CRYPTODISK_ID)
4fe85b
     {
4fe85b
       grub_util_cryptodisk_get_abstraction (disk,
4fe85b
-					    grub_install_push_module);
4fe85b
+					    push_cryptodisk_module, NULL);
4fe85b
       have_abstractions = 1;
4fe85b
       have_cryptodisk = 1;
4fe85b
     }
4fe85b
diff --git a/util/grub-probe.c b/util/grub-probe.c
4fe85b
index 80509be8aa7..ecb7b6bbdf2 100644
4fe85b
--- a/util/grub-probe.c
4fe85b
+++ b/util/grub-probe.c
4fe85b
@@ -130,13 +130,14 @@ get_targets_string (void)
4fe85b
 }
4fe85b
 
4fe85b
 static void
4fe85b
-do_print (const char *x)
4fe85b
+do_print (const char *x, void *data)
4fe85b
 {
4fe85b
-  grub_printf ("%s ", x);
4fe85b
+  char delim = *(const char *) data;
4fe85b
+  grub_printf ("%s%c", x, delim);
4fe85b
 }
4fe85b
 
4fe85b
 static void
4fe85b
-probe_partmap (grub_disk_t disk)
4fe85b
+probe_partmap (grub_disk_t disk, char delim)
4fe85b
 {
4fe85b
   grub_partition_t part;
4fe85b
   grub_disk_memberlist_t list = NULL, tmp;
4fe85b
@@ -147,10 +148,10 @@ probe_partmap (grub_disk_t disk)
4fe85b
     }
4fe85b
 
4fe85b
   for (part = disk->partition; part; part = part->parent)
4fe85b
-    printf ("%s ", part->partmap->name);
4fe85b
+    printf ("%s%c", part->partmap->name, delim);
4fe85b
 
4fe85b
   if (disk->dev->id == GRUB_DISK_DEVICE_DISKFILTER_ID)
4fe85b
-    grub_diskfilter_get_partmap (disk, do_print);
4fe85b
+    grub_diskfilter_get_partmap (disk, do_print, &delim);
4fe85b
 
4fe85b
   /* In case of LVM/RAID, check the member devices as well.  */
4fe85b
   if (disk->dev->memberlist)
4fe85b
@@ -159,7 +160,7 @@ probe_partmap (grub_disk_t disk)
4fe85b
     }
4fe85b
   while (list)
4fe85b
     {
4fe85b
-      probe_partmap (list->disk);
4fe85b
+      probe_partmap (list->disk, delim);
4fe85b
       tmp = list->next;
4fe85b
       free (list);
4fe85b
       list = tmp;
4fe85b
@@ -167,7 +168,7 @@ probe_partmap (grub_disk_t disk)
4fe85b
 }
4fe85b
 
4fe85b
 static void
4fe85b
-probe_cryptodisk_uuid (grub_disk_t disk)
4fe85b
+probe_cryptodisk_uuid (grub_disk_t disk, char delim)
4fe85b
 {
4fe85b
   grub_disk_memberlist_t list = NULL, tmp;
4fe85b
 
4fe85b
@@ -178,7 +179,7 @@ probe_cryptodisk_uuid (grub_disk_t disk)
4fe85b
     }
4fe85b
   while (list)
4fe85b
     {
4fe85b
-      probe_cryptodisk_uuid (list->disk);
4fe85b
+      probe_cryptodisk_uuid (list->disk, delim);
4fe85b
       tmp = list->next;
4fe85b
       free (list);
4fe85b
       list = tmp;
4fe85b
@@ -186,7 +187,7 @@ probe_cryptodisk_uuid (grub_disk_t disk)
4fe85b
   if (disk->dev->id == GRUB_DISK_DEVICE_CRYPTODISK_ID)
4fe85b
     {
4fe85b
       const char *uu = grub_util_cryptodisk_get_uuid (disk);
4fe85b
-      grub_printf ("%s ", uu);
4fe85b
+      grub_printf ("%s%c", uu, delim);
4fe85b
     }
4fe85b
 }
4fe85b
 
4fe85b
@@ -210,7 +211,7 @@ probe_raid_level (grub_disk_t disk)
4fe85b
 }
4fe85b
 
4fe85b
 static void
4fe85b
-probe_abstraction (grub_disk_t disk)
4fe85b
+probe_abstraction (grub_disk_t disk, char delim)
4fe85b
 {
4fe85b
   grub_disk_memberlist_t list = NULL, tmp;
4fe85b
   int raid_level;
4fe85b
@@ -219,7 +220,7 @@ probe_abstraction (grub_disk_t disk)
4fe85b
     list = disk->dev->memberlist (disk);
4fe85b
   while (list)
4fe85b
     {
4fe85b
-      probe_abstraction (list->disk);
4fe85b
+      probe_abstraction (list->disk, delim);
4fe85b
 
4fe85b
       tmp = list->next;
4fe85b
       free (list);
4fe85b
@@ -229,26 +230,26 @@ probe_abstraction (grub_disk_t disk)
4fe85b
   if (disk->dev->id == GRUB_DISK_DEVICE_DISKFILTER_ID
4fe85b
       && (grub_memcmp (disk->name, "lvm/", sizeof ("lvm/") - 1) == 0 ||
4fe85b
 	  grub_memcmp (disk->name, "lvmid/", sizeof ("lvmid/") - 1) == 0))
4fe85b
-    printf ("lvm ");
4fe85b
+    printf ("lvm%c", delim);
4fe85b
 
4fe85b
   if (disk->dev->id == GRUB_DISK_DEVICE_DISKFILTER_ID
4fe85b
       && grub_memcmp (disk->name, "ldm/", sizeof ("ldm/") - 1) == 0)
4fe85b
-    printf ("ldm ");
4fe85b
+    printf ("ldm%c", delim);
4fe85b
 
4fe85b
   if (disk->dev->id == GRUB_DISK_DEVICE_CRYPTODISK_ID)
4fe85b
-    grub_util_cryptodisk_get_abstraction (disk, do_print);
4fe85b
+    grub_util_cryptodisk_get_abstraction (disk, do_print, &delim);
4fe85b
 
4fe85b
   raid_level = probe_raid_level (disk);
4fe85b
   if (raid_level >= 0)
4fe85b
     {
4fe85b
-      printf ("diskfilter ");
4fe85b
+      printf ("diskfilter%c", delim);
4fe85b
       if (disk->dev->raidname)
4fe85b
-	printf ("%s ", disk->dev->raidname (disk));
4fe85b
+	printf ("%s%c", disk->dev->raidname (disk), delim);
4fe85b
     }
4fe85b
   if (raid_level == 5)
4fe85b
-    printf ("raid5rec ");
4fe85b
+    printf ("raid5rec%c", delim);
4fe85b
   if (raid_level == 6)
4fe85b
-    printf ("raid6rec ");
4fe85b
+    printf ("raid6rec%c", delim);
4fe85b
 }
4fe85b
 
4fe85b
 static void
4fe85b
@@ -630,16 +631,14 @@ probe (const char *path, char **device_names, char delim)
4fe85b
 
4fe85b
       if (print == PRINT_ABSTRACTION)
4fe85b
 	{
4fe85b
-	  probe_abstraction (dev->disk);
4fe85b
-	  putchar (delim);
4fe85b
+	  probe_abstraction (dev->disk, delim);
4fe85b
 	  grub_device_close (dev);
4fe85b
 	  continue;
4fe85b
 	}
4fe85b
 
4fe85b
       if (print == PRINT_CRYPTODISK_UUID)
4fe85b
 	{
4fe85b
-	  probe_cryptodisk_uuid (dev->disk);
4fe85b
-	  putchar (delim);
4fe85b
+	  probe_cryptodisk_uuid (dev->disk, delim);
4fe85b
 	  grub_device_close (dev);
4fe85b
 	  continue;
4fe85b
 	}
4fe85b
@@ -647,8 +646,7 @@ probe (const char *path, char **device_names, char delim)
4fe85b
       if (print == PRINT_PARTMAP)
4fe85b
 	{
4fe85b
 	  /* Check if dev->disk itself is contained in a partmap.  */
4fe85b
-	  probe_partmap (dev->disk);
4fe85b
-	  putchar (delim);
4fe85b
+	  probe_partmap (dev->disk, delim);
4fe85b
 	  grub_device_close (dev);
4fe85b
 	  continue;
4fe85b
 	}
4fe85b
diff --git a/include/grub/cryptodisk.h b/include/grub/cryptodisk.h
4fe85b
index 66f3e1e221b..f2ad2a79ab2 100644
4fe85b
--- a/include/grub/cryptodisk.h
4fe85b
+++ b/include/grub/cryptodisk.h
4fe85b
@@ -145,7 +145,8 @@ grub_cryptodisk_cheat_insert (grub_cryptodisk_t newdev, const char *name,
4fe85b
 			      grub_disk_t source, const char *cheat);
4fe85b
 void
4fe85b
 grub_util_cryptodisk_get_abstraction (grub_disk_t disk,
4fe85b
-				      void (*cb) (const char *val));
4fe85b
+				      void (*cb) (const char *val, void *data),
4fe85b
+				      void *data);
4fe85b
 
4fe85b
 char *
4fe85b
 grub_util_get_geli_uuid (const char *dev);
4fe85b
diff --git a/include/grub/diskfilter.h b/include/grub/diskfilter.h
4fe85b
index 042fe04a5a4..1aedcd3dffb 100644
4fe85b
--- a/include/grub/diskfilter.h
4fe85b
+++ b/include/grub/diskfilter.h
4fe85b
@@ -202,7 +202,8 @@ grub_diskfilter_get_pv_from_disk (grub_disk_t disk,
4fe85b
 				  struct grub_diskfilter_vg **vg);
4fe85b
 void
4fe85b
 grub_diskfilter_get_partmap (grub_disk_t disk,
4fe85b
-			     void (*cb) (const char *val));
4fe85b
+			     void (*cb) (const char *val, void *data),
4fe85b
+			     void *data);
4fe85b
 #endif
4fe85b
 
4fe85b
 #endif /* ! GRUB_RAID_H */
4fe85b
diff --git a/ChangeLog b/ChangeLog
4fe85b
index efbed8ccbf6..1cb3b683fcf 100644
4fe85b
--- a/ChangeLog
4fe85b
+++ b/ChangeLog
4fe85b
@@ -1,3 +1,28 @@
4fe85b
+2014-03-31  Colin Watson  <cjwatson@ubuntu.com>
4fe85b
+
4fe85b
+	Fix partmap, cryptodisk, and abstraction handling in grub-mkconfig.
4fe85b
+
4fe85b
+	Commit 588744d0dc655177d5883bdcb8f72ff5160109ed caused grub-mkconfig
4fe85b
+	no longer to be forgiving of trailing spaces on grub-probe output
4fe85b
+	lines, which among other things means that util/grub.d/10_linux.in
4fe85b
+	no longer detects LVM.  To fix this, make grub-probe's output
4fe85b
+	delimiting more consistent.  As a bonus, this improves the coverage
4fe85b
+	of the -0 option.
4fe85b
+
4fe85b
+	Fixes Debian bug #735935.
4fe85b
+
4fe85b
+	* grub-core/disk/cryptodisk.c
4fe85b
+	(grub_util_cryptodisk_get_abstraction): Add a user-data argument.
4fe85b
+	* grub-core/disk/diskfilter.c (grub_diskfilter_get_partmap):
4fe85b
+	Likewise.
4fe85b
+	* include/grub/cryptodisk.h (grub_util_cryptodisk_get_abstraction):
4fe85b
+	Update prototype.
4fe85b
+	* include/grub/diskfilter.h (grub_diskfilter_get_partmap): Likewise.
4fe85b
+	* util/grub-install.c (push_partmap_module, push_cryptodisk_module,
4fe85b
+	probe_mods): Adjust for extra user-data arguments.
4fe85b
+	* util/grub-probe.c (do_print, probe_partmap, probe_cryptodisk_uuid,
4fe85b
+	probe_abstraction): Use configured delimiter.  Update callers.
4fe85b
+
4fe85b
 2014-03-31  Colin Watson  <cjwatson@ubuntu.com>
4fe85b
 
4fe85b
 	* util/grub-probe,c (options): Make -0 work again (broken by