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

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