Support explicit user claim that a device is BIOS-visible.
* grub-core/kern/emu/getroot.c (grub_util_get_dev_abstraction): Return GRUB_DEV_ABSTRACTION_NONE if device is in device.map. * grub-core/kern/emu/hostdisk.c (convert_system_partition_to_system_disk): Support mdX. (find_system_device): New parameter add. All users updated. (grub_util_biosdisk_is_present): New function. * include/grub/emu/hostdisk.h (grub_util_biosdisk_is_present): New proto.
This commit is contained in:
parent
53f0eb1f64
commit
cf9827de73
4 changed files with 44 additions and 2 deletions
|
@ -1117,6 +1117,16 @@ convert_system_partition_to_system_disk (const char *os_dev, struct stat *st)
|
|||
return path;
|
||||
}
|
||||
|
||||
if (strncmp ("md", p, 2) == 0
|
||||
&& p[2] >= '0' && p[2] <= '9')
|
||||
{
|
||||
char *ptr = p + 2;
|
||||
while (*ptr >= '0' && *ptr <= '9')
|
||||
ptr++;
|
||||
*ptr = 0;
|
||||
return path;
|
||||
}
|
||||
|
||||
/* If this is an IDE, SCSI or Virtio disk. */
|
||||
if (strncmp ("vdisk", p, 5) == 0
|
||||
&& p[5] >= 'a' && p[5] <= 'z')
|
||||
|
@ -1334,7 +1344,7 @@ device_is_wholedisk (const char *os_dev)
|
|||
#endif /* defined(__NetBSD__) */
|
||||
|
||||
static int
|
||||
find_system_device (const char *os_dev, struct stat *st)
|
||||
find_system_device (const char *os_dev, struct stat *st, int add)
|
||||
{
|
||||
unsigned int i;
|
||||
char *os_disk;
|
||||
|
@ -1352,6 +1362,9 @@ find_system_device (const char *os_dev, struct stat *st)
|
|||
return i;
|
||||
}
|
||||
|
||||
if (!add)
|
||||
return -1;
|
||||
|
||||
if (i == ARRAY_SIZE (map))
|
||||
grub_util_error (_("device count exceeds limit"));
|
||||
|
||||
|
@ -1361,6 +1374,17 @@ find_system_device (const char *os_dev, struct stat *st)
|
|||
return i;
|
||||
}
|
||||
|
||||
int
|
||||
grub_util_biosdisk_is_present (const char *os_dev)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
if (stat (os_dev, &st) < 0)
|
||||
return 0;
|
||||
|
||||
return find_system_device (os_dev, &st, 0) != -1;
|
||||
}
|
||||
|
||||
char *
|
||||
grub_util_biosdisk_get_grub_dev (const char *os_dev)
|
||||
{
|
||||
|
@ -1373,7 +1397,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
drive = find_system_device (os_dev, &st);
|
||||
drive = find_system_device (os_dev, &st, 1);
|
||||
if (drive < 0)
|
||||
{
|
||||
grub_error (GRUB_ERR_UNKNOWN_DEVICE,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue