diff options
| author | Ales Kozumplik <akozumpl@redhat.com> | 2009-11-19 10:14:30 +0100 |
|---|---|---|
| committer | Ales Kozumplik <akozumpl@redhat.com> | 2009-11-19 10:16:34 +0100 |
| commit | 436da6753f80dfafcfc242a2b08fccb81bf83ab9 (patch) | |
| tree | a8271fc3c4fadfa4f388c4b05244f3e3a0488840 /loader/method.c | |
| parent | 46312dc05b61d7fd18fe9710461eb9b0a9118607 (diff) | |
Sleep if the kickstart file read fails (#537361)
If a read from a block device (like USB key) or a cdrom (USB cdrom) fails, sleep
a bit to give the device some time to initialize. Return status of the mount
command is checked so waiting occurs only if there is a reasonable chance that
the device might eventually come online. This required extending our existing
mounting methods to report the correct mount error code.
I tested that
* the installer still runs
* reading the kickstart from a usb works
* starting the installer with no USB key inserted but a command line argument pointing to a USB drive will trigger the waiting cycle and that when the key is inserted while waiting the kickstart is eventually found on the key.
Diffstat (limited to 'loader/method.c')
| -rw-r--r-- | loader/method.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/loader/method.c b/loader/method.c index ebfe557d5..90f06873a 100644 --- a/loader/method.c +++ b/loader/method.c @@ -466,12 +466,21 @@ int copyFileAndLoopbackMount(int fd, char * dest, char * device, char * mntpoint 3 - file named path not there */ int getFileFromBlockDevice(char *device, char *path, char * dest) { - int rc; + int rc, i; char file[4096]; logMessage(INFO, "getFileFromBlockDevice(%s, %s)", device, path); - if (doPwMount(device, "/tmp/mnt", "auto", "ro", NULL)) { + /* some USB thumb drives and hard drives are slow to initialize */ + /* retry up to 5 times or 31 seconds */ + rc = doPwMount(device, "/tmp/mnt", "auto", "ro", NULL); + for (i = 0; mountMightSucceedLater(rc) && i < 5; ++i) { + logMessage(INFO, "sleeping to wait for USB storage devices"); + sleep(1 << i); + rc = doPwMount(device, "/tmp/mnt", "auto", "ro", NULL); + logMessage(ERROR, "error code: %d", rc); + } + if (rc) { logMessage(ERROR, "failed to mount /dev/%s: %m", device); return 2; } |
