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

Re: [PATCH] Sleep if the kickstart file read fails.



On 11/11/2009 11:32 AM, Jeffrey Bastian wrote:
>  int getFileFromBlockDevice(char *device, char *path, char * dest) {
> -    int rc;
> +    int rc, s, 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, s = 1; rc && i < 5; ++i) {
> +        logMessage(DEBUGLVL, "sleeping to wait for USB storage devices");
> +        sleep(s);
> +        s = 1 << (i+1);
> +        rc = doPwMount(device, "/tmp/mnt", "auto", "ro", NULL);
> +    }
> +    if (rc) {
>          logMessage(ERROR, "failed to mount /dev/%s: %m", device);
>          return 2;
>      }

What's the point of defining "s" this way at all?  Why not just do

for (i = 0; rc && i < 5; i++) {
    logMessage(INFO, "sleeping to wait for USB storage devices");
    sleep(1 << i);
    rc = doPwMount(device, "/tmp/mnt", "auto", "ro", NULL);
}

(note that I also switch logMessage to INFO there, which I think it
probably should be...)

-- 
        Peter

Power corrupts.  Absolute power is kind of neat.
		-- John Lehman, Secretary of the Navy, 1981-1987


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