2008-02-09 Robert Millan <rmh@aybabtu.com>
* disk/lvm.c [GRUB_UTIL] (grub_lvm_memberlist): New function. Construct and return a grub_diskmemberlist_t composed of LVM physical volumes. [GRUB_UTIL] (grub_lvm_dev): Add `memberlist' member. * disk/raid.c [GRUB_UTIL] (grub_raid_memberlist): New function. Construct and return a grub_diskmemberlist_t composed of physical array members. [GRUB_UTIL] (grub_raid_dev): Add `memberlist' member. * include/grub/disk.h [GRUB_UTIL] (grub_disk_memberlist): New struct prototype. [GRUB_UTIL] (struct grub_disk_dev): Add `memberlist' function pointer. [GRUB_UTIL] (struct grub_disk_memberlist): New struct declaration. [GRUB_UTIL] (grub_disk_memberlist_t): New typedef. * util/grub-probe.c (probe): Move partmap probing code from here ... (probe_partmap): ... to here. (probe): Use probe_partmap() once for the disk we're probing, and additionally, when such disk contains a memberlist() struct member, once for each disk that is contained in the structure returned by memberlist().
This commit is contained in:
parent
91a4bf68ff
commit
b92f0c1843
5 changed files with 123 additions and 15 deletions
|
@ -74,6 +74,31 @@ grub_refresh (void)
|
|||
{
|
||||
}
|
||||
|
||||
static void
|
||||
probe_partmap (grub_disk_t disk)
|
||||
{
|
||||
char *name;
|
||||
char *underscore;
|
||||
|
||||
if (disk->partition == NULL)
|
||||
{
|
||||
grub_util_info ("No partition map found for %s", disk->name);
|
||||
return;
|
||||
}
|
||||
|
||||
name = strdup (disk->partition->partmap->name);
|
||||
if (! name)
|
||||
grub_util_error ("Not enough memory");
|
||||
|
||||
underscore = strchr (name, '_');
|
||||
if (! underscore)
|
||||
grub_util_error ("Invalid partition map %s", name);
|
||||
|
||||
*underscore = '\0';
|
||||
printf ("%s\n", name);
|
||||
free (name);
|
||||
}
|
||||
|
||||
static void
|
||||
probe (const char *path)
|
||||
{
|
||||
|
@ -133,23 +158,21 @@ probe (const char *path)
|
|||
|
||||
if (print == PRINT_PARTMAP)
|
||||
{
|
||||
char *name;
|
||||
char *underscore;
|
||||
|
||||
if (dev->disk->partition == NULL)
|
||||
grub_util_error ("Cannot detect partition map for %s", drive_name);
|
||||
grub_disk_memberlist_t list = NULL, tmp;
|
||||
|
||||
name = strdup (dev->disk->partition->partmap->name);
|
||||
if (! name)
|
||||
grub_util_error ("not enough memory");
|
||||
/* Check if dev->disk itself is contained in a partmap. */
|
||||
probe_partmap (dev->disk);
|
||||
|
||||
underscore = strchr (name, '_');
|
||||
if (! underscore)
|
||||
grub_util_error ("Invalid partition map %s", name);
|
||||
|
||||
*underscore = '\0';
|
||||
printf ("%s\n", name);
|
||||
free (name);
|
||||
/* In case of LVM/RAID, check the member devices as well. */
|
||||
if (dev->disk->dev->memberlist)
|
||||
list = dev->disk->dev->memberlist (dev->disk);
|
||||
while (list)
|
||||
{
|
||||
probe_partmap (list->disk);
|
||||
tmp = list->next;
|
||||
free (list);
|
||||
list = tmp;
|
||||
}
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue