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

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