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:
Vladimir 'phcoder' Serbinenko 2010-09-13 13:09:58 +02:00
parent 53f0eb1f64
commit cf9827de73
4 changed files with 44 additions and 2 deletions

View file

@ -1,3 +1,16 @@
2010-09-13 Vladimir Serbinenko <phcoder@gmail.com>
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.
2010-09-13 Vladimir Serbinenko <phcoder@gmail.com>
Search hints support.

View file

@ -572,6 +572,10 @@ int
grub_util_get_dev_abstraction (const char *os_dev __attribute__((unused)))
{
#ifdef __linux__
/* User explicitly claims that this drive is visible by BIOS. */
if (grub_util_biosdisk_is_present (os_dev))
return GRUB_DEV_ABSTRACTION_NONE;
/* Check for LVM. */
if (!strncmp (os_dev, "/dev/mapper/", 12)
&& ! grub_util_is_dmraid (os_dev)

View file

@ -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,

View file

@ -26,5 +26,6 @@ void grub_util_biosdisk_init (const char *dev_map);
void grub_util_biosdisk_fini (void);
char *grub_util_biosdisk_get_grub_dev (const char *os_dev);
const char *grub_util_biosdisk_get_osdev (grub_disk_t disk);
int grub_util_biosdisk_is_present (const char *name);
#endif /* ! GRUB_BIOSDISK_MACHINE_UTIL_HEADER */