a5bd9f6
From f0efb6d6b3660d99f2dbb55b1b12525ef4255368 Mon Sep 17 00:00:00 2001
a5bd9f6
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
a5bd9f6
Date: Mon, 15 Apr 2013 00:38:39 +0200
a5bd9f6
Subject: [PATCH 312/364] 	* grub-core/disk/ieee1275/ofdisk.c: Fix CD-ROM
a5bd9f6
 and boot device 	detection.
a5bd9f6
a5bd9f6
---
a5bd9f6
 ChangeLog                        |  5 +++++
a5bd9f6
 grub-core/disk/ieee1275/ofdisk.c | 21 +++++++++++++++++++--
a5bd9f6
 2 files changed, 24 insertions(+), 2 deletions(-)
a5bd9f6
a5bd9f6
diff --git a/ChangeLog b/ChangeLog
a5bd9f6
index a4d9555..b372668 100644
a5bd9f6
--- a/ChangeLog
a5bd9f6
+++ b/ChangeLog
a5bd9f6
@@ -1,3 +1,8 @@
a5bd9f6
+2013-04-15  Vladimir Serbinenko  <phcoder@gmail.com>
a5bd9f6
+
a5bd9f6
+	* grub-core/disk/ieee1275/ofdisk.c: Fix CD-ROM and boot device
a5bd9f6
+	detection.
a5bd9f6
+
a5bd9f6
 2013-04-14  Vladimir Serbinenko  <phcoder@gmail.com>
a5bd9f6
 
a5bd9f6
 	* grub-core/lib/posix_wrap/sys/types.h: Make WORDS_BIGENDIAN definition
a5bd9f6
diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c
a5bd9f6
index bebf777..ec92c4d 100644
a5bd9f6
--- a/grub-core/disk/ieee1275/ofdisk.c
a5bd9f6
+++ b/grub-core/disk/ieee1275/ofdisk.c
a5bd9f6
@@ -32,6 +32,7 @@ struct ofdisk_hash_ent
a5bd9f6
 {
a5bd9f6
   char *devpath;
a5bd9f6
   int is_boot;
a5bd9f6
+  int is_cdrom;
a5bd9f6
   /* Pointer to shortest available name on nodes representing canonical names,
a5bd9f6
      otherwise NULL.  */
a5bd9f6
   const char *shortest;
a5bd9f6
@@ -80,6 +81,18 @@ ofdisk_hash_add_real (char *devpath)
a5bd9f6
   return p;
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
+static int
a5bd9f6
+check_string_cdrom (const char *str)
a5bd9f6
+{
a5bd9f6
+  const char *ptr = grub_strrchr (str, '/');
a5bd9f6
+
a5bd9f6
+  if (ptr)
a5bd9f6
+    ptr++;
a5bd9f6
+  else
a5bd9f6
+    ptr = str;
a5bd9f6
+  return (grub_strncmp (ptr, "cdrom", 5) == 0);
a5bd9f6
+}
a5bd9f6
+
a5bd9f6
 static struct ofdisk_hash_ent *
a5bd9f6
 ofdisk_hash_add (char *devpath, char *curcan)
a5bd9f6
 {
a5bd9f6
@@ -92,6 +105,8 @@ ofdisk_hash_add (char *devpath, char *curcan)
a5bd9f6
   if (!curcan)
a5bd9f6
     {
a5bd9f6
       p->shortest = devpath;
a5bd9f6
+      if (check_string_cdrom (devpath))
a5bd9f6
+	p->is_cdrom = 1;  
a5bd9f6
       return p;
a5bd9f6
     }
a5bd9f6
 
a5bd9f6
@@ -101,6 +116,9 @@ ofdisk_hash_add (char *devpath, char *curcan)
a5bd9f6
   else
a5bd9f6
     grub_free (curcan);
a5bd9f6
 
a5bd9f6
+  if (check_string_cdrom (devpath) || check_string_cdrom (curcan))
a5bd9f6
+    pcan->is_cdrom = 1;
a5bd9f6
+
a5bd9f6
   if (!pcan)
a5bd9f6
     grub_errno = GRUB_ERR_NONE;
a5bd9f6
   else
a5bd9f6
@@ -267,8 +285,7 @@ grub_ofdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
a5bd9f6
 		}
a5bd9f6
 	    }
a5bd9f6
 
a5bd9f6
-	  if (grub_strncmp (ent->shortest, "cdrom", 5) == 0
a5bd9f6
-	      || ent->is_boot)
a5bd9f6
+	  if (!ent->is_boot && ent->is_cdrom)
a5bd9f6
 	    continue;
a5bd9f6
 
a5bd9f6
 	  {
a5bd9f6
-- 
a5bd9f6
1.8.1.4
a5bd9f6