* grub-core/disk/efi/efidisk.c (grub_efidisk_get_device_name):
Handle CD-ROMs.
This commit is contained in:
parent
6de9ee86bf
commit
44016e527a
2 changed files with 75 additions and 62 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2013-10-14 Andrey Borzenkov <arvidjaar@gmail.com>
|
||||||
|
|
||||||
|
* grub-core/disk/efi/efidisk.c (grub_efidisk_get_device_name):
|
||||||
|
Handle CD-ROMs.
|
||||||
|
|
||||||
2013-10-14 Vladimir Serbinenko <phcoder@gmail.com>
|
2013-10-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
Pass-through unknown E820 types. It required reorganisation of mmap
|
Pass-through unknown E820 types. It required reorganisation of mmap
|
||||||
|
|
|
@ -799,72 +799,80 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
|
||||||
if (! ldp)
|
if (! ldp)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE
|
if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE)
|
||||||
&& (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp)
|
|
||||||
== GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE))
|
|
||||||
{
|
{
|
||||||
struct grub_efidisk_get_device_name_ctx ctx;
|
int is_cdrom = 0;
|
||||||
char *dev_name;
|
|
||||||
grub_efi_device_path_t *dup_dp, *dup_ldp;
|
|
||||||
grub_disk_t parent = 0;
|
|
||||||
|
|
||||||
/* It is necessary to duplicate the device path so that GRUB
|
switch (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp))
|
||||||
can overwrite it. */
|
{
|
||||||
dup_dp = duplicate_device_path (dp);
|
case GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE:
|
||||||
if (! dup_dp)
|
is_cdrom = 1;
|
||||||
return 0;
|
/* Intentionally fall through */
|
||||||
|
case GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE:
|
||||||
|
{
|
||||||
|
struct grub_efidisk_get_device_name_ctx ctx;
|
||||||
|
char *dev_name;
|
||||||
|
grub_efi_device_path_t *dup_dp, *dup_ldp;
|
||||||
|
grub_disk_t parent = 0;
|
||||||
|
|
||||||
dup_ldp = find_last_device_path (dup_dp);
|
/* It is necessary to duplicate the device path so that GRUB
|
||||||
dup_ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
|
can overwrite it. */
|
||||||
dup_ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
|
dup_dp = duplicate_device_path (dp);
|
||||||
dup_ldp->length[0] = sizeof (*dup_ldp);
|
if (! dup_dp)
|
||||||
dup_ldp->length[1] = 0;
|
|
||||||
|
|
||||||
if (!get_diskname_from_path (dup_dp, device_name))
|
|
||||||
{
|
|
||||||
grub_free (dup_dp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
parent = grub_disk_open (device_name);
|
|
||||||
grub_free (dup_dp);
|
|
||||||
|
|
||||||
if (! parent)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* Find a partition which matches the hard drive device path. */
|
|
||||||
ctx.partition_name = NULL;
|
|
||||||
grub_memcpy (&ctx.hd, ldp, sizeof (ctx.hd));
|
|
||||||
if (ctx.hd.partition_start == 0
|
|
||||||
&& (ctx.hd.partition_size << (parent->log_sector_size
|
|
||||||
- GRUB_DISK_SECTOR_BITS))
|
|
||||||
== grub_disk_get_size (parent))
|
|
||||||
{
|
|
||||||
dev_name = grub_strdup (parent->name);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
grub_partition_iterate (parent, grub_efidisk_get_device_name_iter,
|
|
||||||
&ctx);
|
|
||||||
|
|
||||||
if (! ctx.partition_name)
|
|
||||||
{
|
|
||||||
grub_disk_close (parent);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
dev_name = grub_xasprintf ("%s,%s", parent->name,
|
dup_ldp = find_last_device_path (dup_dp);
|
||||||
ctx.partition_name);
|
dup_ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
|
||||||
grub_free (ctx.partition_name);
|
dup_ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
|
||||||
}
|
dup_ldp->length[0] = sizeof (*dup_ldp);
|
||||||
grub_disk_close (parent);
|
dup_ldp->length[1] = 0;
|
||||||
|
|
||||||
return dev_name;
|
if (!get_diskname_from_path (dup_dp, device_name))
|
||||||
}
|
{
|
||||||
else
|
grub_free (dup_dp);
|
||||||
{
|
return 0;
|
||||||
/* This should be an entire disk. */
|
}
|
||||||
if (!get_diskname_from_path (dp, device_name))
|
parent = grub_disk_open (device_name);
|
||||||
return 0;
|
grub_free (dup_dp);
|
||||||
return grub_strdup (device_name);
|
|
||||||
|
if (! parent)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Find a partition which matches the hard drive device path. */
|
||||||
|
ctx.partition_name = NULL;
|
||||||
|
grub_memcpy (&ctx.hd, ldp, sizeof (ctx.hd));
|
||||||
|
if (ctx.hd.partition_start == 0
|
||||||
|
&& (ctx.hd.partition_size << (parent->log_sector_size
|
||||||
|
- GRUB_DISK_SECTOR_BITS))
|
||||||
|
== grub_disk_get_size (parent))
|
||||||
|
{
|
||||||
|
dev_name = grub_strdup (parent->name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
grub_partition_iterate (parent, grub_efidisk_get_device_name_iter,
|
||||||
|
&ctx);
|
||||||
|
|
||||||
|
if (! ctx.partition_name)
|
||||||
|
{
|
||||||
|
grub_disk_close (parent);
|
||||||
|
if (is_cdrom)
|
||||||
|
return grub_strdup (device_name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
dev_name = grub_xasprintf ("%s,%s", parent->name,
|
||||||
|
ctx.partition_name);
|
||||||
|
grub_free (ctx.partition_name);
|
||||||
|
}
|
||||||
|
grub_disk_close (parent);
|
||||||
|
|
||||||
|
return dev_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
/* This may be guessed device - floppy, cdrom or entire disk. */
|
||||||
|
if (!get_diskname_from_path (dp, device_name))
|
||||||
|
return 0;
|
||||||
|
return grub_strdup (device_name);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue