[rhel5-branch] Sleep if the kickstart file read fails.

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

 



BZ #460566, if a read from a block device (like USB key) or a cdrom (USB cdrom) fails, sleep to give the device some time to initialize. The patch was proposed by Jeffrey Bastian <jbastian@xxxxxxxxxx>.
---
 loader2/cdinstall.c |   10 +++++++++-
 loader2/method.c    |   20 ++++++++++++++++----
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/loader2/cdinstall.c b/loader2/cdinstall.c
index 3aeb1e1..2694e82 100644
--- a/loader2/cdinstall.c
+++ b/loader2/cdinstall.c
@@ -438,13 +438,21 @@ void setKickstartCD(struct loaderData_s * loaderData, int argc, char ** argv) {
 }
 
 int kickstartFromCD(char *kssrc) {
-    int rc, i;
+    int i = 0, rc;
     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 */
+    while (!devices && (i++ < 10)) {
+        sleep(2);
+        logMessage(DEBUGLVL, "sleeping to wait for a USB CD-ROM");
+        devices = probeDevices(CLASS_CDROM, BUS_UNSPEC, 0);
+    }
     if (!devices) {
         logMessage(ERROR, "No CDROM devices found!");
         return 1;
diff --git a/loader2/method.c b/loader2/method.c
index 1905f9f..a874d98 100644
--- a/loader2/method.c
+++ b/loader2/method.c
@@ -644,8 +644,11 @@ int copyFileAndLoopbackMount(int fd, char * dest,
       2 - could not mount device as ext2, vfat, or iso9660
       3 - file named path not there
 */
+#define TRYMOUNT(fs) \
+    (doPwMount("/tmp/srcdev", "/tmp/mnt", (fs), IMOUNT_RDONLY, NULL))
+
 int getFileFromBlockDevice(char *device, char *path, char * dest) {
-    int rc;
+    int i = 0, s = 1, rc;
     char file[4096];
 
     logMessage(INFO, "getFileFromBlockDevice(%s, %s)", device, path);
@@ -655,9 +658,16 @@ int getFileFromBlockDevice(char *device, char *path, char * dest) {
         return 1;
     }
 
-    if (doPwMount("/tmp/srcdev", "/tmp/mnt", "vfat", IMOUNT_RDONLY, NULL) &&
-        doPwMount("/tmp/srcdev", "/tmp/mnt", "ext2", IMOUNT_RDONLY, NULL) && 
-        doPwMount("/tmp/srcdev", "/tmp/mnt", "iso9660", IMOUNT_RDONLY, NULL)) {
+    /* some USB thumb drives and hard drives are slow to initialize */
+    /* retry up to 5 times or 31 seconds */
+    rc = TRYMOUNT("vfat") && TRYMOUNT("ext2") && TRYMOUNT("iso9660");
+    while (rc && (i++ < 5)) {
+        sleep(s);
+        s <<= 1;
+        logMessage(DEBUGLVL, "sleeping to wait for USB storage devices");
+        rc = TRYMOUNT("vfat") && TRYMOUNT("ext2") && TRYMOUNT("iso9660");
+    }
+    if (rc) {
         logMessage(ERROR, "failed to mount /dev/%s: %s", device,
                    strerror(errno));
         return 2;
@@ -680,6 +690,8 @@ int getFileFromBlockDevice(char *device, char *path, char * dest) {
     return rc;
 }
 
+#undef TRYMOUNT
+
 void setMethodFromCmdline(char * arg, struct loaderData_s * ld) {
     char * c, * dup;
 
-- 
1.6.2.5

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux