[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[rhel5-branch] Fix waiting for a cdrom with a ks file to come up. (#658398)



To make sure probeDevices() returned an actual device, we have to check
that devices is not null, but also that at least one member of the array
has a non-null 'device' member.

The solution was suggested by Sandeep K Shandilya from cisco.
---
 loader2/cdinstall.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/loader2/cdinstall.c b/loader2/cdinstall.c
index ee837ad..79bbb84 100644
--- a/loader2/cdinstall.c
+++ b/loader2/cdinstall.c
@@ -443,20 +443,28 @@ void setKickstartCD(struct loaderData_s * loaderData, int argc, char ** argv) {
 }
 
 int kickstartFromCD(char *kssrc) {
-    int rc, i;
+    int rc, i, j, found = 0;
     char *p, *kspath;
     struct device ** devices;
 
     logMessage(INFO, "getting kickstart file from first CDROM");
 
-    devices = probeDevices(CLASS_CDROM, BUS_UNSPEC, 0);
     /* usb can take some time to settle, even with the various hacks we
      * have in place.  some systems use portable USB CD-ROM drives, try to
      * make sure there really isn't one before bailing */
-    for (i = 0; !devices && i < 10; ++i) {
-        logMessage(DEBUGLVL, "sleeping to wait for a USB CD-ROM");
-        sleep(2);
+    for (i = 0; i < 10; ++i) {
         devices = probeDevices(CLASS_CDROM, BUS_UNSPEC, 0);
+
+        for (j = 0; devices && devices[j]; ++j) {
+            if (devices[j]->device)
+                found = 1;
+        }
+        if (found)
+            break;
+        else {
+            logMessage(DEBUGLVL, "sleeping to wait for a USB CD-ROM");
+            sleep(2);
+        }
     }
 
     if (!devices) {
-- 
1.7.3.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]