* grub-core/disk/efi/efidisk.c (grub_efidisk_get_device_name): Handle

CD-ROM in case when it's declared as having subpartitions.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-10-19 02:23:08 +02:00
parent 29013cba15
commit 0f7c00c1c6
2 changed files with 75 additions and 65 deletions

View file

@ -1,3 +1,8 @@
2013-10-18 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/disk/efi/efidisk.c (grub_efidisk_get_device_name): Handle
CD-ROM in case when it's declared as having subpartitions.
2013-10-18 Vladimir Serbinenko <phcoder@gmail.com> 2013-10-18 Vladimir Serbinenko <phcoder@gmail.com>
Don't add -lm on haiku. Don't add -lm on haiku.

View file

@ -799,20 +799,14 @@ 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_CDROM_DEVICE_PATH_SUBTYPE
|| GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) == GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE))
{ {
int is_cdrom = 0; int is_cdrom = 0;
switch (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp))
{
case GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE:
is_cdrom = 1;
/* Intentionally fall through */
case GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE:
{
struct grub_efidisk_get_device_name_ctx ctx; struct grub_efidisk_get_device_name_ctx ctx;
char *dev_name; char *dev_name;
grub_efi_device_path_t *dup_dp, *dup_ldp; grub_efi_device_path_t *dup_dp;
grub_disk_t parent = 0; grub_disk_t parent = 0;
/* It is necessary to duplicate the device path so that GRUB /* It is necessary to duplicate the device path so that GRUB
@ -821,17 +815,30 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
if (! dup_dp) if (! dup_dp)
return 0; return 0;
while (1)
{
grub_efi_device_path_t *dup_ldp;
dup_ldp = find_last_device_path (dup_dp); dup_ldp = find_last_device_path (dup_dp);
if (!(GRUB_EFI_DEVICE_PATH_TYPE (dup_ldp) == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE
&& (GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE
|| GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE)))
break;
if (GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE)
is_cdrom = 1;
dup_ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE; dup_ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
dup_ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; dup_ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
dup_ldp->length[0] = sizeof (*dup_ldp); dup_ldp->length[0] = sizeof (*dup_ldp);
dup_ldp->length[1] = 0; dup_ldp->length[1] = 0;
}
if (!get_diskname_from_path (dup_dp, device_name)) if (!get_diskname_from_path (dup_dp, device_name))
{ {
grub_free (dup_dp); grub_free (dup_dp);
return 0; return 0;
} }
parent = grub_disk_open (device_name); parent = grub_disk_open (device_name);
grub_free (dup_dp); grub_free (dup_dp);
@ -869,8 +876,6 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
return dev_name; return dev_name;
} }
}
}
/* This may be guessed device - floppy, cdrom or entire disk. */ /* This may be guessed device - floppy, cdrom or entire disk. */
if (!get_diskname_from_path (dp, device_name)) if (!get_diskname_from_path (dp, device_name))
return 0; return 0;