Make cryptodisk and diskfilter probe data retrievable programmatically
and not just printable.
This commit is contained in:
parent
24ca45125e
commit
bf25f87931
7 changed files with 40 additions and 19 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2013-10-04 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Make cryptodisk and diskfilter probe data retrievable programmatically
|
||||||
|
and not just printable.
|
||||||
|
|
||||||
2013-10-04 Vladimir Serbinenko <phcoder@gmail.com>
|
2013-10-04 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
Split random retrieving code into separate files.
|
Split random retrieving code into separate files.
|
||||||
|
|
|
@ -746,31 +746,33 @@ grub_cryptodisk_cheat_insert (grub_cryptodisk_t newdev, const char *name,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_util_cryptodisk_print_abstraction (grub_disk_t disk)
|
grub_util_cryptodisk_get_abstraction (grub_disk_t disk,
|
||||||
|
void (*cb) (const char *val))
|
||||||
{
|
{
|
||||||
grub_cryptodisk_t dev = (grub_cryptodisk_t) disk->data;
|
grub_cryptodisk_t dev = (grub_cryptodisk_t) disk->data;
|
||||||
|
|
||||||
grub_printf ("cryptodisk %s ", dev->modname);
|
cb ("cryptodisk");
|
||||||
|
cb (dev->modname);
|
||||||
|
|
||||||
if (dev->cipher)
|
if (dev->cipher)
|
||||||
grub_printf ("%s ", dev->cipher->cipher->modname);
|
cb (dev->cipher->cipher->modname);
|
||||||
if (dev->secondary_cipher)
|
if (dev->secondary_cipher)
|
||||||
grub_printf ("%s ", dev->secondary_cipher->cipher->modname);
|
cb (dev->secondary_cipher->cipher->modname);
|
||||||
if (dev->essiv_cipher)
|
if (dev->essiv_cipher)
|
||||||
grub_printf ("%s ", dev->essiv_cipher->cipher->modname);
|
cb (dev->essiv_cipher->cipher->modname);
|
||||||
if (dev->hash)
|
if (dev->hash)
|
||||||
grub_printf ("%s ", dev->hash->modname);
|
cb (dev->hash->modname);
|
||||||
if (dev->essiv_hash)
|
if (dev->essiv_hash)
|
||||||
grub_printf ("%s ", dev->essiv_hash->modname);
|
cb (dev->essiv_hash->modname);
|
||||||
if (dev->iv_hash)
|
if (dev->iv_hash)
|
||||||
grub_printf ("%s ", dev->iv_hash->modname);
|
cb (dev->iv_hash->modname);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
const char *
|
||||||
grub_util_cryptodisk_print_uuid (grub_disk_t disk)
|
grub_util_cryptodisk_get_uuid (grub_disk_t disk)
|
||||||
{
|
{
|
||||||
grub_cryptodisk_t dev = (grub_cryptodisk_t) disk->data;
|
grub_cryptodisk_t dev = (grub_cryptodisk_t) disk->data;
|
||||||
grub_printf ("%s ", dev->uuid);
|
return dev->uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -353,7 +353,8 @@ grub_diskfilter_memberlist (grub_disk_t disk)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_diskfilter_print_partmap (grub_disk_t disk)
|
grub_diskfilter_get_partmap (grub_disk_t disk,
|
||||||
|
void (*cb) (const char *pm))
|
||||||
{
|
{
|
||||||
struct grub_diskfilter_lv *lv = disk->data;
|
struct grub_diskfilter_lv *lv = disk->data;
|
||||||
struct grub_diskfilter_pv *pv;
|
struct grub_diskfilter_pv *pv;
|
||||||
|
@ -375,7 +376,7 @@ grub_diskfilter_print_partmap (grub_disk_t disk)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (s = 0; pv->partmaps[s]; s++)
|
for (s = 0; pv->partmaps[s]; s++)
|
||||||
grub_printf ("%s ", pv->partmaps[s]);
|
cb (pv->partmaps[s]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,9 @@ grub_err_t
|
||||||
grub_cryptodisk_cheat_insert (grub_cryptodisk_t newdev, const char *name,
|
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_print_abstraction (grub_disk_t disk);
|
grub_util_cryptodisk_get_abstraction (grub_disk_t disk,
|
||||||
|
void (*cb) (const char *val));
|
||||||
|
|
||||||
char *
|
char *
|
||||||
grub_util_get_geli_uuid (const char *dev);
|
grub_util_get_geli_uuid (const char *dev);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -201,7 +201,8 @@ struct grub_diskfilter_pv *
|
||||||
grub_diskfilter_get_pv_from_disk (grub_disk_t disk,
|
grub_diskfilter_get_pv_from_disk (grub_disk_t disk,
|
||||||
struct grub_diskfilter_vg **vg);
|
struct grub_diskfilter_vg **vg);
|
||||||
void
|
void
|
||||||
grub_diskfilter_print_partmap (grub_disk_t disk);
|
grub_diskfilter_get_partmap (grub_disk_t disk,
|
||||||
|
void (*cb) (const char *val));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* ! GRUB_RAID_H */
|
#endif /* ! GRUB_RAID_H */
|
||||||
|
|
|
@ -65,7 +65,8 @@ ssize_t grub_util_fd_read (grub_util_fd_t fd, char *buf, size_t len);
|
||||||
ssize_t grub_util_fd_write (grub_util_fd_t fd, const char *buf, size_t len);
|
ssize_t grub_util_fd_write (grub_util_fd_t fd, const char *buf, size_t len);
|
||||||
grub_err_t
|
grub_err_t
|
||||||
grub_cryptodisk_cheat_mount (const char *sourcedev, const char *cheat);
|
grub_cryptodisk_cheat_mount (const char *sourcedev, const char *cheat);
|
||||||
void grub_util_cryptodisk_print_uuid (grub_disk_t disk);
|
const char *
|
||||||
|
grub_util_cryptodisk_get_uuid (grub_disk_t disk);
|
||||||
char *
|
char *
|
||||||
grub_util_get_ldm (grub_disk_t disk, grub_disk_addr_t start);
|
grub_util_get_ldm (grub_disk_t disk, grub_disk_addr_t start);
|
||||||
int
|
int
|
||||||
|
|
|
@ -76,6 +76,12 @@ enum {
|
||||||
static int print = PRINT_FS;
|
static int print = PRINT_FS;
|
||||||
static unsigned int argument_is_device = 0;
|
static unsigned int argument_is_device = 0;
|
||||||
|
|
||||||
|
static void
|
||||||
|
do_print (const char *x)
|
||||||
|
{
|
||||||
|
grub_printf ("%s ", x);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
probe_partmap (grub_disk_t disk)
|
probe_partmap (grub_disk_t disk)
|
||||||
{
|
{
|
||||||
|
@ -91,7 +97,7 @@ probe_partmap (grub_disk_t disk)
|
||||||
printf ("%s ", part->partmap->name);
|
printf ("%s ", part->partmap->name);
|
||||||
|
|
||||||
if (disk->dev->id == GRUB_DISK_DEVICE_DISKFILTER_ID)
|
if (disk->dev->id == GRUB_DISK_DEVICE_DISKFILTER_ID)
|
||||||
grub_diskfilter_print_partmap (disk);
|
grub_diskfilter_get_partmap (disk, do_print);
|
||||||
|
|
||||||
/* 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)
|
||||||
|
@ -125,7 +131,10 @@ probe_cryptodisk_uuid (grub_disk_t disk)
|
||||||
list = tmp;
|
list = tmp;
|
||||||
}
|
}
|
||||||
if (disk->dev->id == GRUB_DISK_DEVICE_CRYPTODISK_ID)
|
if (disk->dev->id == GRUB_DISK_DEVICE_CRYPTODISK_ID)
|
||||||
grub_util_cryptodisk_print_uuid (disk);
|
{
|
||||||
|
const char *uu = grub_util_cryptodisk_get_uuid (disk);
|
||||||
|
grub_printf ("%s ", uu);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -303,7 +312,7 @@ probe_abstraction (grub_disk_t disk)
|
||||||
printf ("ldm ");
|
printf ("ldm ");
|
||||||
|
|
||||||
if (disk->dev->id == GRUB_DISK_DEVICE_CRYPTODISK_ID)
|
if (disk->dev->id == GRUB_DISK_DEVICE_CRYPTODISK_ID)
|
||||||
grub_util_cryptodisk_print_abstraction (disk);
|
grub_util_cryptodisk_get_abstraction (disk, do_print);
|
||||||
|
|
||||||
raid_level = probe_raid_level (disk);
|
raid_level = probe_raid_level (disk);
|
||||||
if (raid_level >= 0)
|
if (raid_level >= 0)
|
||||||
|
|
Loading…
Reference in a new issue