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

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

 



Ack.

On 11/11/2009 02:20 PM, Ales Kozumplik wrote:
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>.

I verified that with the patch I can still load kickstart from a block device (USB key in my case).
---
  loader2/cdinstall.c |    9 +++++++++
  loader2/method.c    |   28 ++++++++++++++++++++++++----
  2 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/loader2/cdinstall.c b/loader2/cdinstall.c
index 90afdfb..0b47b6a 100644
--- a/loader2/cdinstall.c
+++ b/loader2/cdinstall.c
@@ -434,6 +434,15 @@ int kickstartFromCD(char *kssrc) {
      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);
+        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..f709110 100644
--- a/loader2/method.c
+++ b/loader2/method.c
@@ -50,6 +50,19 @@
  /* boot flags */
  extern uint64_t flags;

+/* Mount src to dest attempting different filesystem. */
+/* This is a rhel5-only thing, in later releases "auto" option can be */
+/* passed to doPwMount() instead. */
+static int tryMounts(char *src, char *dest, int flags)
+{
+    char *fstypes[] = {"vfat","ext2","iso9660", NULL};
+    int i, rc;
+    for (i = 0, rc = 1; rc&&  fstypes[i] != NULL; i++)
+        rc = doPwMount(src, dest, fstypes[i], flags, NULL);
+    return rc;
+}
+
+
  int umountLoopback(char * mntpoint, char * device) {
      int loopfd;

@@ -645,7 +658,7 @@ int copyFileAndLoopbackMount(int fd, char * dest,
        3 - file named path not there
  */
  int getFileFromBlockDevice(char *device, char *path, char * dest) {
-    int rc;
+    int s = 1, rc, i;
      char file[4096];

      logMessage(INFO, "getFileFromBlockDevice(%s, %s)", device, path);
@@ -655,9 +668,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 = tryMounts("/tmp/srcdev", "/tmp/mnt", IMOUNT_RDONLY);
+    for (i = 0; rc&&  i<  5; ++i) {
+        logMessage(DEBUGLVL, "sleeping to wait for USB storage devices");
+        sleep(s);
+        s<<= 1;
+        rc = tryMounts("/tmp/srcdev", "/tmp/mnt", IMOUNT_RDONLY);
+    }
+    if (rc) {
          logMessage(ERROR, "failed to mount /dev/%s: %s", device,
                     strerror(errno));
          return 2;

_______________________________________________
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