From 436bd62edb35525dd1d149ee1c5ad72b687cbbae Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Thu, 23 Oct 2008 12:05:25 -0400 Subject: Fix "looking for installation images" when there's no disc at all. Don't check for ENOMEDIUM on opening the device right after we got a real drive status from it. Instead, just consider the actual drive status from waitForCdromTrayClose(). --- loader/cdinstall.c | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) (limited to 'loader') diff --git a/loader/cdinstall.c b/loader/cdinstall.c index 0b03a6dfa..f3c55b8fa 100644 --- a/loader/cdinstall.c +++ b/loader/cdinstall.c @@ -307,7 +307,6 @@ static char *setupCdrom(char *location, struct loaderData_s *loaderData, do { for (i = 0; devices[i]; i++) { char *tmp = NULL; - int j; int fd; if (!devices[i]->device) @@ -332,23 +331,29 @@ static char *setupCdrom(char *location, struct loaderData_s *loaderData, printf(_("Looking for installation images on CD device %s"), devices[i]->device); fd = open(devices[i]->device, O_RDONLY | O_NONBLOCK); - if (fd >= 0) { - waitForCdromTrayClose(fd); - close(fd); - } - - for (j = 0; j < 450; j++) { - fd = open(devices[i]->device, O_RDONLY); - if (fd >= 0) { - close(fd); - break; - } else if (errno == ENOMEDIUM) { - logMessage(DEBUGLVL, "%s reported %m", devices[i]->device); - usleep(100000); - } else { - break; - } - } + if (fd < 0) { + logMessage(ERROR, "Couldn't open %s: %m", devices[i]->device); + if (!FL_CMDLINE(flags)) + newtPopWindow(); + continue; + } + + rc = waitForCdromTrayClose(fd); + close(fd); + switch (rc) { + case CDS_NO_INFO: + logMessage(ERROR, "Drive tray reports CDS_NO_INFO"); + break; + case CDS_NO_DISC: + if (!FL_CMDLINE(flags)) + newtPopWindow(); + continue; + case CDS_TRAY_OPEN: + logMessage(ERROR, "Drive tray reports open when it should be closed"); + break; + default: + break; + } if (!FL_CMDLINE(flags)) newtPopWindow(); -- cgit