tags 310689 + patch
thanks
Hallo,
now I run into the same problem and traced it back to a too touchy
condition/success handling in the scan method. It simply threats open
failures (caused by locking, like on mounted hard disks) the same way as
SCSI hardware failures.
The attached patch modifes the open method a bit so it a) does not
display confusing messages, b) does not need 10 seconds per devices, and
also opens the device scanning loop to continue rather than break.
I cannot see why this "return(0)" explicitely in the device-name-method
was needed whatsoever, looks like a dirty trick to make the life
non-SCSI users harder.
Any comments to that? I would apply it RSN unless someone objects with
good arguments.
Eduard.
--
<weasel> Smur: du brauchst nen Level 9 Analyzer
<Smur> weasel: fällt dir da konkret n name ein?
#! /bin/sh /usr/share/dpatch/dpatch-run
## 35_ignore_failures_while_scanning.dpatch by Eduard Bloch <[EMAIL PROTECTED]>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.
@DPATCH@
diff -urNad cdrtools-2.01+01a03~/libscg/scsi-linux-sg.c
cdrtools-2.01+01a03/libscg/scsi-linux-sg.c
--- cdrtools-2.01+01a03~/libscg/scsi-linux-sg.c 2006-01-08 02:43:33.000000000
+0100
+++ cdrtools-2.01+01a03/libscg/scsi-linux-sg.c 2006-01-08 02:43:41.000000000
+0100
@@ -240,21 +240,23 @@
#endif
LOCAL void sg_settimeout __PR((int f, int timeout));
-int sg_open_excl __PR((char *device, int mode));
+int sg_open_excl __PR((char *device, int mode, int quickAndQuiet));
int
-sg_open_excl(device, mode)
+sg_open_excl(device, mode, quickAndQuiet)
char *device;
int mode;
+ int quickAndQuiet;
{
int f;
int i;
- f = open(device, mode|O_EXCL);
- for (i = 0; (i < 10) && (f == -1 && (errno == EACCES || errno ==
EBUSY)); i++) {
- fprintf(stderr, "Error trying to open %s exclusively (%s)...
retrying in 1 second.\n", device, strerror(errno));
- usleep(1000000 + 100000.0 * rand()/(RAND_MAX+1.0));
- f = open(device, mode|O_EXCL);
- }
+ f = open(device, mode|O_EXCL);
+ if(!quickAndQuiet)
+ for (i = 0; (i < 10) && (f == -1 && (errno == EACCES || errno ==
EBUSY)); i++) {
+ fprintf(stderr, "Error trying to open %s exclusively (%s)...
retrying in 1 second.\n", device, strerror(errno));
+ usleep(1000000 + 100000.0 * rand()/(RAND_MAX+1.0));
+ f = open(device, mode|O_EXCL);
+ }
if (f == -1 && errno != EACCES && errno != EBUSY) {
f = open(device, mode);
}
@@ -442,7 +444,7 @@
if (use_ata) for (i=2*busno+tgt >= 0 ? 2*busno+tgt:0; i <= 25; i++) {
js_snprintf(devname, sizeof (devname), "/dev/hd%c", i+'a');
/* O_NONBLOCK is dangerous */
- f = sg_open_excl(devname, O_RDWR | O_NONBLOCK);
+ f = sg_open_excl(devname, O_RDWR | O_NONBLOCK, 1);
if (f < 0) {
/*
* Set up error string but let us clear it later
@@ -455,7 +457,8 @@
if (scgp->errstr)
js_snprintf(scgp->errstr,
SCSI_ERRSTR_SIZE,
"Cannot open '%s'",
devname);
- return (0);
+ /* return (0); */
+ continue;
}
} else {
int iparm;
@@ -482,7 +485,7 @@
if (nopen == 0) for (i = 0; i < 32; i++) {
js_snprintf(devname, sizeof (devname), "/dev/sg%d", i);
/* O_NONBLOCK is dangerous */
- f = sg_open_excl(devname, O_RDWR | O_NONBLOCK);
+ f = sg_open_excl(devname, O_RDWR | O_NONBLOCK, 0);
if (f < 0) {
/*
* Set up error string but let us clear it later
@@ -511,7 +514,7 @@
if (nopen == 0) for (i = 0; i <= 25; i++) {
js_snprintf(devname, sizeof (devname), "/dev/sg%c", i+'a');
/* O_NONBLOCK is dangerous */
- f = sg_open_excl(devname, O_RDWR | O_NONBLOCK);
+ f = sg_open_excl(devname, O_RDWR | O_NONBLOCK, 0);
if (f < 0) {
/*
* Set up error string but let us clear it later
@@ -559,7 +562,7 @@
"Warning: Open by 'devname' is unintentional and not
supported.\n");
}
/* O_NONBLOCK is dangerous */
- f = sg_open_excl(device, O_RDWR | O_NONBLOCK);
+ f = sg_open_excl(device, O_RDWR | O_NONBLOCK, 0);
/* if (f < 0 && errno == ENOENT)*/
/* goto openpg;*/