Попал мне в руки код GRUB'а.
grub_device_iterate (int (*hook) (const char *name))
{
auto int iterate_disk (const char *disk_name);
struct part_ent
{
struct part_ent *next;
char *name;
} *ents;
int iterate_disk (const char *disk_name)
{
grub_device_t dev;
if (hook (disk_name))
return 1;
dev = grub_device_open (disk_name);
if (! dev)
return 0;
.................
}
................
}