dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

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

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