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>
|
||||
|
||||
Split random retrieving code into separate files.
|
||||
|
|
|
@ -746,31 +746,33 @@ grub_cryptodisk_cheat_insert (grub_cryptodisk_t newdev, const char *name,
|
|||
}
|
||||
|
||||
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_printf ("cryptodisk %s ", dev->modname);
|
||||
cb ("cryptodisk");
|
||||
cb (dev->modname);
|
||||
|
||||
if (dev->cipher)
|
||||
grub_printf ("%s ", dev->cipher->cipher->modname);
|
||||
cb (dev->cipher->cipher->modname);
|
||||
if (dev->secondary_cipher)
|
||||
grub_printf ("%s ", dev->secondary_cipher->cipher->modname);
|
||||
cb (dev->secondary_cipher->cipher->modname);
|
||||
if (dev->essiv_cipher)
|
||||
grub_printf ("%s ", dev->essiv_cipher->cipher->modname);
|
||||
cb (dev->essiv_cipher->cipher->modname);
|
||||
if (dev->hash)
|
||||
grub_printf ("%s ", dev->hash->modname);
|
||||
cb (dev->hash->modname);
|
||||
if (dev->essiv_hash)
|
||||
grub_printf ("%s ", dev->essiv_hash->modname);
|
||||
cb (dev->essiv_hash->modname);
|
||||
if (dev->iv_hash)
|
||||
grub_printf ("%s ", dev->iv_hash->modname);
|
||||
cb (dev->iv_hash->modname);
|
||||
}
|
||||
|
||||
void
|
||||
grub_util_cryptodisk_print_uuid (grub_disk_t disk)
|
||||
const char *
|
||||
grub_util_cryptodisk_get_uuid (grub_disk_t disk)
|
||||
{
|
||||
grub_cryptodisk_t dev = (grub_cryptodisk_t) disk->data;
|
||||
grub_printf ("%s ", dev->uuid);
|
||||
return dev->uuid;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -353,7 +353,8 @@ grub_diskfilter_memberlist (grub_disk_t disk)
|
|||
}
|
||||
|
||||
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_pv *pv;
|
||||
|
@ -375,7 +376,7 @@ grub_diskfilter_print_partmap (grub_disk_t disk)
|
|||
continue;
|
||||
}
|
||||
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_disk_t source, const char *cheat);
|
||||
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 *
|
||||
grub_util_get_geli_uuid (const char *dev);
|
||||
#endif
|
||||
|
|
|
@ -201,7 +201,8 @@ struct grub_diskfilter_pv *
|
|||
grub_diskfilter_get_pv_from_disk (grub_disk_t disk,
|
||||
struct grub_diskfilter_vg **vg);
|
||||
void
|
||||
grub_diskfilter_print_partmap (grub_disk_t disk);
|
||||
grub_diskfilter_get_partmap (grub_disk_t disk,
|
||||
void (*cb) (const char *val));
|
||||
#endif
|
||||
|
||||
#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);
|
||||
grub_err_t
|
||||
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 *
|
||||
grub_util_get_ldm (grub_disk_t disk, grub_disk_addr_t start);
|
||||
int
|
||||
|
|
|
@ -76,6 +76,12 @@ enum {
|
|||
static int print = PRINT_FS;
|
||||
static unsigned int argument_is_device = 0;
|
||||
|
||||
static void
|
||||
do_print (const char *x)
|
||||
{
|
||||
grub_printf ("%s ", x);
|
||||
}
|
||||
|
||||
static void
|
||||
probe_partmap (grub_disk_t disk)
|
||||
{
|
||||
|
@ -91,7 +97,7 @@ probe_partmap (grub_disk_t disk)
|
|||
printf ("%s ", part->partmap->name);
|
||||
|
||||
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. */
|
||||
if (disk->dev->memberlist)
|
||||
|
@ -125,7 +131,10 @@ probe_cryptodisk_uuid (grub_disk_t disk)
|
|||
list = tmp;
|
||||
}
|
||||
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
|
||||
|
@ -303,7 +312,7 @@ probe_abstraction (grub_disk_t disk)
|
|||
printf ("ldm ");
|
||||
|
||||
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);
|
||||
if (raid_level >= 0)
|
||||
|
|
Loading…
Reference in a new issue