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