Fix partmap, cryptodisk, and abstraction handling in grub-mkconfig.

Commit 588744d0dc 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.
This commit is contained in:
Colin Watson 2014-03-31 14:48:33 +01:00
parent 9b35fe819f
commit 24024dac7f
7 changed files with 74 additions and 41 deletions

View file

@ -1,3 +1,28 @@
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> 2014-03-31 Colin Watson <cjwatson@ubuntu.com>
* util/grub-probe,c (options): Make -0 work again (broken by * util/grub-probe,c (options): Make -0 work again (broken by

View file

@ -762,25 +762,26 @@ grub_cryptodisk_cheat_insert (grub_cryptodisk_t newdev, const char *name,
void void
grub_util_cryptodisk_get_abstraction (grub_disk_t disk, 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; grub_cryptodisk_t dev = (grub_cryptodisk_t) disk->data;
cb ("cryptodisk"); cb ("cryptodisk", data);
cb (dev->modname); cb (dev->modname, data);
if (dev->cipher) if (dev->cipher)
cb (dev->cipher->cipher->modname); cb (dev->cipher->cipher->modname, data);
if (dev->secondary_cipher) if (dev->secondary_cipher)
cb (dev->secondary_cipher->cipher->modname); cb (dev->secondary_cipher->cipher->modname, data);
if (dev->essiv_cipher) if (dev->essiv_cipher)
cb (dev->essiv_cipher->cipher->modname); cb (dev->essiv_cipher->cipher->modname, data);
if (dev->hash) if (dev->hash)
cb (dev->hash->modname); cb (dev->hash->modname, data);
if (dev->essiv_hash) if (dev->essiv_hash)
cb (dev->essiv_hash->modname); cb (dev->essiv_hash->modname, data);
if (dev->iv_hash) if (dev->iv_hash)
cb (dev->iv_hash->modname); cb (dev->iv_hash->modname, data);
} }
const char * const char *

View file

@ -354,7 +354,8 @@ grub_diskfilter_memberlist (grub_disk_t disk)
void void
grub_diskfilter_get_partmap (grub_disk_t disk, 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_lv *lv = disk->data;
struct grub_diskfilter_pv *pv; struct grub_diskfilter_pv *pv;
@ -376,7 +377,7 @@ grub_diskfilter_get_partmap (grub_disk_t disk,
continue; continue;
} }
for (s = 0; pv->partmaps[s]; s++) for (s = 0; pv->partmaps[s]; s++)
cb (pv->partmaps[s]); cb (pv->partmaps[s], data);
} }
} }

View file

@ -145,7 +145,8 @@ grub_cryptodisk_cheat_insert (grub_cryptodisk_t newdev, const char *name,
grub_disk_t source, const char *cheat); grub_disk_t source, const char *cheat);
void void
grub_util_cryptodisk_get_abstraction (grub_disk_t disk, grub_util_cryptodisk_get_abstraction (grub_disk_t disk,
void (*cb) (const char *val)); void (*cb) (const char *val, void *data),
void *data);
char * char *
grub_util_get_geli_uuid (const char *dev); grub_util_get_geli_uuid (const char *dev);

View file

@ -202,7 +202,8 @@ grub_diskfilter_get_pv_from_disk (grub_disk_t disk,
struct grub_diskfilter_vg **vg); struct grub_diskfilter_vg **vg);
void void
grub_diskfilter_get_partmap (grub_disk_t disk, grub_diskfilter_get_partmap (grub_disk_t disk,
void (*cb) (const char *val)); void (*cb) (const char *val, void *data),
void *data);
#endif #endif
#endif /* ! GRUB_RAID_H */ #endif /* ! GRUB_RAID_H */

View file

@ -387,7 +387,7 @@ probe_raid_level (grub_disk_t disk)
} }
static void static void
push_partmap_module (const char *map) push_partmap_module (const char *map, void *data __attribute__ ((unused)))
{ {
char buf[50]; char buf[50];
@ -401,6 +401,12 @@ push_partmap_module (const char *map)
grub_install_push_module (buf); grub_install_push_module (buf);
} }
static void
push_cryptodisk_module (const char *mod, void *data __attribute__ ((unused)))
{
grub_install_push_module (mod);
}
static void static void
probe_mods (grub_disk_t disk) probe_mods (grub_disk_t disk)
{ {
@ -412,11 +418,11 @@ probe_mods (grub_disk_t disk)
grub_util_info ("no partition map found for %s", disk->name); grub_util_info ("no partition map found for %s", disk->name);
for (part = disk->partition; part; part = part->parent) 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) 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; have_abstractions = 1;
} }
@ -432,7 +438,7 @@ probe_mods (grub_disk_t disk)
if (disk->dev->id == GRUB_DISK_DEVICE_CRYPTODISK_ID) if (disk->dev->id == GRUB_DISK_DEVICE_CRYPTODISK_ID)
{ {
grub_util_cryptodisk_get_abstraction (disk, grub_util_cryptodisk_get_abstraction (disk,
grub_install_push_module); push_cryptodisk_module, NULL);
have_abstractions = 1; have_abstractions = 1;
have_cryptodisk = 1; have_cryptodisk = 1;
} }

View file

@ -130,13 +130,14 @@ get_targets_string (void)
} }
static 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 static void
probe_partmap (grub_disk_t disk) probe_partmap (grub_disk_t disk, char delim)
{ {
grub_partition_t part; grub_partition_t part;
grub_disk_memberlist_t list = NULL, tmp; 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) 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) 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. */ /* In case of LVM/RAID, check the member devices as well. */
if (disk->dev->memberlist) if (disk->dev->memberlist)
@ -159,7 +160,7 @@ probe_partmap (grub_disk_t disk)
} }
while (list) while (list)
{ {
probe_partmap (list->disk); probe_partmap (list->disk, delim);
tmp = list->next; tmp = list->next;
free (list); free (list);
list = tmp; list = tmp;
@ -167,7 +168,7 @@ probe_partmap (grub_disk_t disk)
} }
static void 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; grub_disk_memberlist_t list = NULL, tmp;
@ -178,7 +179,7 @@ probe_cryptodisk_uuid (grub_disk_t disk)
} }
while (list) while (list)
{ {
probe_cryptodisk_uuid (list->disk); probe_cryptodisk_uuid (list->disk, delim);
tmp = list->next; tmp = list->next;
free (list); free (list);
list = tmp; list = tmp;
@ -186,7 +187,7 @@ probe_cryptodisk_uuid (grub_disk_t disk)
if (disk->dev->id == GRUB_DISK_DEVICE_CRYPTODISK_ID) if (disk->dev->id == GRUB_DISK_DEVICE_CRYPTODISK_ID)
{ {
const char *uu = grub_util_cryptodisk_get_uuid (disk); 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 static void
probe_abstraction (grub_disk_t disk) probe_abstraction (grub_disk_t disk, char delim)
{ {
grub_disk_memberlist_t list = NULL, tmp; grub_disk_memberlist_t list = NULL, tmp;
int raid_level; int raid_level;
@ -219,7 +220,7 @@ probe_abstraction (grub_disk_t disk)
list = disk->dev->memberlist (disk); list = disk->dev->memberlist (disk);
while (list) while (list)
{ {
probe_abstraction (list->disk); probe_abstraction (list->disk, delim);
tmp = list->next; tmp = list->next;
free (list); free (list);
@ -229,26 +230,26 @@ probe_abstraction (grub_disk_t disk)
if (disk->dev->id == GRUB_DISK_DEVICE_DISKFILTER_ID if (disk->dev->id == GRUB_DISK_DEVICE_DISKFILTER_ID
&& (grub_memcmp (disk->name, "lvm/", sizeof ("lvm/") - 1) == 0 || && (grub_memcmp (disk->name, "lvm/", sizeof ("lvm/") - 1) == 0 ||
grub_memcmp (disk->name, "lvmid/", sizeof ("lvmid/") - 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 if (disk->dev->id == GRUB_DISK_DEVICE_DISKFILTER_ID
&& grub_memcmp (disk->name, "ldm/", sizeof ("ldm/") - 1) == 0) && grub_memcmp (disk->name, "ldm/", sizeof ("ldm/") - 1) == 0)
printf ("ldm "); printf ("ldm%c", delim);
if (disk->dev->id == GRUB_DISK_DEVICE_CRYPTODISK_ID) 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); raid_level = probe_raid_level (disk);
if (raid_level >= 0) if (raid_level >= 0)
{ {
printf ("diskfilter "); printf ("diskfilter%c", delim);
if (disk->dev->raidname) if (disk->dev->raidname)
printf ("%s ", disk->dev->raidname (disk)); printf ("%s%c", disk->dev->raidname (disk), delim);
} }
if (raid_level == 5) if (raid_level == 5)
printf ("raid5rec "); printf ("raid5rec%c", delim);
if (raid_level == 6) if (raid_level == 6)
printf ("raid6rec "); printf ("raid6rec%c", delim);
} }
static void static void
@ -630,16 +631,14 @@ probe (const char *path, char **device_names, char delim)
if (print == PRINT_ABSTRACTION) if (print == PRINT_ABSTRACTION)
{ {
probe_abstraction (dev->disk); probe_abstraction (dev->disk, delim);
putchar (delim);
grub_device_close (dev); grub_device_close (dev);
continue; continue;
} }
if (print == PRINT_CRYPTODISK_UUID) if (print == PRINT_CRYPTODISK_UUID)
{ {
probe_cryptodisk_uuid (dev->disk); probe_cryptodisk_uuid (dev->disk, delim);
putchar (delim);
grub_device_close (dev); grub_device_close (dev);
continue; continue;
} }
@ -647,8 +646,7 @@ probe (const char *path, char **device_names, char delim)
if (print == PRINT_PARTMAP) if (print == PRINT_PARTMAP)
{ {
/* Check if dev->disk itself is contained in a partmap. */ /* Check if dev->disk itself is contained in a partmap. */
probe_partmap (dev->disk); probe_partmap (dev->disk, delim);
putchar (delim);
grub_device_close (dev); grub_device_close (dev);
continue; continue;
} }