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

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