From 3be3b0be12c8055109cdfbf69789a35b5bfb68dd Mon Sep 17 00:00:00 2001 From: Michael Roitzsch Date: Sun, 4 Jul 2004 21:01:26 +0000 Subject: better error checking when testing cdrom and dvd devices, not being able to open the device does not mean it's not accessible, there might just be no disk inside (closes bug #984594) CVS patchset: 6768 CVS date: 2004/07/04 21:01:26 --- src/xine-utils/xine_check.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/xine-utils/xine_check.c b/src/xine-utils/xine_check.c index 91fb40186..14fb424ac 100644 --- a/src/xine-utils/xine_check.c +++ b/src/xine-utils/xine_check.c @@ -220,10 +220,17 @@ xine_health_check_t* _x_health_check_cdrom (xine_health_check_t* hc) { } if ( (fd = open(hc->cdrom_dev, O_RDWR)) < 0) { - set_hc_result (hc, XINE_HEALTH_CHECK_FAIL, "FAILED - %s permissions are not sufficient\n.", hc->cdrom_dev); - return hc; - } - close(fd); + switch (errno) { + case EACCES: + set_hc_result (hc, XINE_HEALTH_CHECK_FAIL, "FAILED - %s permissions are not sufficient\n.", hc->cdrom_dev); + return hc; + case ENXIO: + case ENODEV: + set_hc_result (hc, XINE_HEALTH_CHECK_FAIL, "FAILED - there is no device behind %s\n.", hc->cdrom_dev); + return hc; + } + } else + close(fd); hc->status = XINE_HEALTH_CHECK_OK; return hc; @@ -249,10 +256,17 @@ xine_health_check_t* _x_health_check_dvdrom(xine_health_check_t* hc) { } if ( (fd = open(hc->dvd_dev, O_RDWR)) < 0) { - set_hc_result (hc, XINE_HEALTH_CHECK_FAIL, "FAILED - %s permissions are not sufficient\n.", hc->cdrom_dev); - return hc; - } - close(fd); + switch (errno) { + case EACCES: + set_hc_result (hc, XINE_HEALTH_CHECK_FAIL, "FAILED - %s permissions are not sufficient\n.", hc->dvd_dev); + return hc; + case ENXIO: + case ENODEV: + set_hc_result (hc, XINE_HEALTH_CHECK_FAIL, "FAILED - there is no device behind %s\n.", hc->dvd_dev); + return hc; + } + } else + close(fd); hc->status = XINE_HEALTH_CHECK_OK; return hc; -- cgit v1.2.3