dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

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

39700a
From 0a65563c2b355c0eb7412b46f015556691f1b5d1 Mon Sep 17 00:00:00 2001
39700a
From: Colin Watson <cjwatson@ubuntu.com>
39700a
Date: Mon, 31 Mar 2014 14:48:33 +0100
39700a
Subject: [PATCH 070/143] 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
 ChangeLog                   | 25 ++++++++++++++++++++++++
39700a
 grub-core/disk/cryptodisk.c | 19 ++++++++++---------
39700a
 grub-core/disk/diskfilter.c |  5 +++--
39700a
 include/grub/cryptodisk.h   |  3 ++-
39700a
 include/grub/diskfilter.h   |  3 ++-
39700a
 util/grub-install.c         | 14 ++++++++++----
39700a
 util/grub-probe.c           | 46 ++++++++++++++++++++++-----------------------
39700a
 7 files changed, 74 insertions(+), 41 deletions(-)
39700a
39700a
diff --git a/ChangeLog b/ChangeLog
39700a
index efbed8c..1cb3b68 100644
39700a
--- a/ChangeLog
39700a
+++ b/ChangeLog
39700a
@@ -1,5 +1,30 @@
39700a
 2014-03-31  Colin Watson  <cjwatson@ubuntu.com>
39700a
 
39700a
+	Fix partmap, cryptodisk, and abstraction handling in 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
+2014-03-31  Colin Watson  <cjwatson@ubuntu.com>
39700a
+
39700a
 	* util/grub-probe,c (options): Make -0 work again (broken by
39700a
 	conversion to argp).
39700a
 	(main): Simplify logic.
39700a
diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c
39700a
index 75c6e1f..f0e3a90 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
39700a
index 28b70c6..e8a3bcb 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/include/grub/cryptodisk.h b/include/grub/cryptodisk.h
39700a
index 66f3e1e..f2ad2a7 100644
39700a
--- a/include/grub/cryptodisk.h
39700a
+++ b/include/grub/cryptodisk.h
39700a
@@ -145,7 +145,8 @@ grub_cryptodisk_cheat_insert (grub_cryptodisk_t newdev, const char *name,
39700a
 			      grub_disk_t source, const char *cheat);
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
 char *
39700a
 grub_util_get_geli_uuid (const char *dev);
39700a
diff --git a/include/grub/diskfilter.h b/include/grub/diskfilter.h
39700a
index 042fe04..1aedcd3 100644
39700a
--- a/include/grub/diskfilter.h
39700a
+++ b/include/grub/diskfilter.h
39700a
@@ -202,7 +202,8 @@ grub_diskfilter_get_pv_from_disk (grub_disk_t disk,
39700a
 				  struct grub_diskfilter_vg **vg);
39700a
 void
39700a
 grub_diskfilter_get_partmap (grub_disk_t disk,
39700a
-			     void (*cb) (const char *val));
39700a
+			     void (*cb) (const char *val, void *data),
39700a
+			     void *data);
39700a
 #endif
39700a
 
39700a
 #endif /* ! GRUB_RAID_H */
39700a
diff --git a/util/grub-install.c b/util/grub-install.c
39700a
index 2e6226a..e9c6a46 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
 
39700a
@@ -402,6 +402,12 @@ push_partmap_module (const char *map)
39700a
 }
39700a
 
39700a
 static void
39700a
+push_cryptodisk_module (const char *mod, void *data __attribute__ ((unused)))
39700a
+{
39700a
+  grub_install_push_module (mod);
39700a
+}
39700a
+
39700a
+static void
39700a
 probe_mods (grub_disk_t disk)
39700a
 {
39700a
   grub_partition_t part;
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
39700a
index 80509be..ecb7b6b 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
 	}
39700a
-- 
39700a
1.9.3
39700a