* grub-core/disk/ieee1275/ofdisk.c: Fix CD-ROM and boot device

detection.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-04-15 00:38:39 +02:00
parent 25092d2922
commit 21aecce0f9
2 changed files with 24 additions and 2 deletions

View file

@ -1,3 +1,8 @@
2013-04-15 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/disk/ieee1275/ofdisk.c: Fix CD-ROM and boot device
detection.
2013-04-14 Vladimir Serbinenko <phcoder@gmail.com> 2013-04-14 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/lib/posix_wrap/sys/types.h: Make WORDS_BIGENDIAN definition * grub-core/lib/posix_wrap/sys/types.h: Make WORDS_BIGENDIAN definition

View file

@ -32,6 +32,7 @@ struct ofdisk_hash_ent
{ {
char *devpath; char *devpath;
int is_boot; int is_boot;
int is_cdrom;
/* Pointer to shortest available name on nodes representing canonical names, /* Pointer to shortest available name on nodes representing canonical names,
otherwise NULL. */ otherwise NULL. */
const char *shortest; const char *shortest;
@ -80,6 +81,18 @@ ofdisk_hash_add_real (char *devpath)
return p; return p;
} }
static int
check_string_cdrom (const char *str)
{
const char *ptr = grub_strrchr (str, '/');
if (ptr)
ptr++;
else
ptr = str;
return (grub_strncmp (ptr, "cdrom", 5) == 0);
}
static struct ofdisk_hash_ent * static struct ofdisk_hash_ent *
ofdisk_hash_add (char *devpath, char *curcan) ofdisk_hash_add (char *devpath, char *curcan)
{ {
@ -92,6 +105,8 @@ ofdisk_hash_add (char *devpath, char *curcan)
if (!curcan) if (!curcan)
{ {
p->shortest = devpath; p->shortest = devpath;
if (check_string_cdrom (devpath))
p->is_cdrom = 1;
return p; return p;
} }
@ -101,6 +116,9 @@ ofdisk_hash_add (char *devpath, char *curcan)
else else
grub_free (curcan); grub_free (curcan);
if (check_string_cdrom (devpath) || check_string_cdrom (curcan))
pcan->is_cdrom = 1;
if (!pcan) if (!pcan)
grub_errno = GRUB_ERR_NONE; grub_errno = GRUB_ERR_NONE;
else else
@ -267,8 +285,7 @@ grub_ofdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
} }
} }
if (grub_strncmp (ent->shortest, "cdrom", 5) == 0 if (!ent->is_boot && ent->is_cdrom)
|| ent->is_boot)
continue; continue;
{ {