[Debburn-changes] r720 - in cdrkit/trunk: libusal wodim
Eduard Bloch
blade at alioth.debian.org
Sun Apr 1 14:57:56 UTC 2007
Author: blade
Date: 2007-04-01 14:57:55 +0000 (Sun, 01 Apr 2007)
New Revision: 720
Modified:
cdrkit/trunk/libusal/scsi-linux-sg.c
cdrkit/trunk/libusal/scsiopen.c
cdrkit/trunk/wodim/wodim.c
Log:
Do device scanning on /dev/sr first and fallback to /dev/sg only then
Modified: cdrkit/trunk/libusal/scsi-linux-sg.c
===================================================================
--- cdrkit/trunk/libusal/scsi-linux-sg.c 2007-04-01 13:20:10 UTC (rev 719)
+++ cdrkit/trunk/libusal/scsi-linux-sg.c 2007-04-01 14:57:55 UTC (rev 720)
@@ -276,6 +276,8 @@
return f;
}
+#if 0
+// Dead code, that sysfs parts may become deprecated soon
void map_sg_to_block(char *device, int len) {
char globpat[100];
glob_t globbuf;
@@ -287,6 +289,7 @@
}
globfree(&globbuf);
}
+#endif
/*
* Return version information for the low level SCSI transport code.
@@ -464,13 +467,51 @@
if(nopen==0)
return(0);
}
+ else {
+ fprintf(stderr, "ATAPI devices not scanned.\n"
+ "wodim: HINT : To surely see all drives try option: --devices\n"
+ "wodim: HINT : Or try options: dev=ATA -scanbus\n"
+ );
+ }
if (nopen > 0 && usalp->errstr)
usalp->errstr[0] = '\0';
if (nopen == 0) {
for (i = 0; i < 32; i++) {
+ snprintf(devname, sizeof (devname), "/dev/sr%d", i);
+ /* O_NONBLOCK is dangerous */
+ f = sg_open_excl(devname, O_RDWR | O_NONBLOCK);
+ if (f < 0) {
+ /*
+ * Set up error string but let us clear it later
+ * if at least one open succeeded.
+ */
+ if (usalp->errstr)
+ snprintf(usalp->errstr, SCSI_ERRSTR_SIZE,
+ "Cannot open '%s'", devname);
+ if(errno == EACCES || errno==EPERM)
+ continue;
+ if (errno != ENOENT && errno != ENXIO && errno != ENODEV) {
+ if (usalp->errstr)
+ snprintf(usalp->errstr, SCSI_ERRSTR_SIZE,
+ "Cannot open '%s'", devname);
+ return (0);
+ }
+ } else {
+ sg_clearnblock(f); /* Be very proper about this */
+ if (sg_setup(usalp, f, busno, tgt, tlun, -1))
+ return (++nopen);
+ if (busno < 0 && tgt < 0 && tlun < 0)
+ nopen++;
+ }
+ }
+ }
+ if (nopen > 0 && usalp->errstr)
+ usalp->errstr[0] = '\0';
+
+ if (nopen == 0) { /* don't do it if sr driver is workin */
+ for (i = 0; i < 32; i++) {
snprintf(devname, sizeof (devname), "/dev/sg%d", i);
- map_sg_to_block(devname, sizeof(devname));
/* O_NONBLOCK is dangerous */
f = sg_open_excl(devname, O_RDWR | O_NONBLOCK);
if (f < 0) {
@@ -542,14 +583,16 @@
if (strlen(device) == 8 && strncmp(device, "/dev/hd", 7) == 0) {
b = device[7] - 'a';
if (b < 0 || b > 25)
- b = -1;
- }
+ b = -1;
+ }
/* O_NONBLOCK is dangerous */
- if(0==strncmp(device, "/dev/sg", 7)) {
- strncpy(buf, device, sizeof(buf)-1);
- map_sg_to_block(buf, sizeof(buf));
- device=buf;
- }
+ /* Let the user open what he wants this time, the mapping is sysfs depending anyway and may be unreliable
+ if(0==strncmp(device, "/dev/sg", 7)) {
+ strncpy(buf, device, sizeof(buf)-1);
+ map_sg_to_block(buf, sizeof(buf));
+ device=buf;
+ }
+ * */
f = sg_open_excl(device, O_RDWR | O_NONBLOCK);
/* if (f < 0 && errno == ENOENT)*/
/* goto openpg;*/
@@ -692,6 +735,9 @@
sg_mapdev(usalp, f, &Bus, &Target, &Lun, &Chan, &Ino, ataidx);
+ /*if(usallocal(usalp)) // skip it, already set up
+ return TRUE;
+*/
/*
* For old kernels try to make the best guess.
*/
Modified: cdrkit/trunk/libusal/scsiopen.c
===================================================================
--- cdrkit/trunk/libusal/scsiopen.c 2007-04-01 13:20:10 UTC (rev 719)
+++ cdrkit/trunk/libusal/scsiopen.c 2007-04-01 14:57:55 UTC (rev 720)
@@ -147,6 +147,7 @@
"It is recommended to mount sysfs to allow better device configuration\n");
sleep(5);
}
+ /* some bitching about old style, ATA:b,t,l warning was displayed already. */
if(sscanf(scsidev, "%d,%d,%d", &tmp, &tmp, &tmp)>1) {
fprintf(stderr, "\nWarning, the deprecated pseudo SCSI syntax found as device specification.\n"
"Support for that may cease in the future versions of wodim. For now,\n"
Modified: cdrkit/trunk/wodim/wodim.c
===================================================================
--- cdrkit/trunk/wodim/wodim.c 2007-04-01 13:20:10 UTC (rev 719)
+++ cdrkit/trunk/wodim/wodim.c 2007-04-01 14:57:55 UTC (rev 720)
@@ -409,11 +409,17 @@
if(!usalp && dev) {
char *dalt;
int len=5+strlen(dev);
+
dalt=calloc(len, sizeof(char));
strcat(dalt, "ATA:");
strcat(dalt+4, dev);
usalp = usal_open(dalt, errstr, sizeof (errstr),
debug, lverbose);
+#ifdef __linux__
+ if(usalp && sscanf(dev, "%d,%d,%d", dalt, dalt, dalt)>1)
+ fprintf(stderr, "WARNING: mapped the pseudo SCSI syntax to ATA:%s. This method is considered"
+ "deprecated. Please specify the device by native path, run \"wodim --devices\".");
+#endif
}
if(!usalp)
More information about the Debburn-changes
mailing list