[Debburn-changes] r717 - cdrkit/trunk/libusal
Eduard Bloch
blade at alioth.debian.org
Sat Mar 31 15:37:53 UTC 2007
Author: blade
Date: 2007-03-31 15:37:53 +0000 (Sat, 31 Mar 2007)
New Revision: 717
Modified:
cdrkit/trunk/libusal/scsi-linux-sg.c
cdrkit/trunk/libusal/scsiopen.c
Log:
Mapping from sg to block devices and some bitching about missing sysfs etc.
Modified: cdrkit/trunk/libusal/scsi-linux-sg.c
===================================================================
--- cdrkit/trunk/libusal/scsi-linux-sg.c 2007-03-26 20:42:04 UTC (rev 716)
+++ cdrkit/trunk/libusal/scsi-linux-sg.c 2007-03-31 15:37:53 UTC (rev 717)
@@ -247,9 +247,7 @@
static BOOL get_max_secs(char *dirpath, int *outval);
-int
-sg_open_excl(char *device, int mode)
-
+int sg_open_excl(char *device, int mode)
{
int f;
int i=0;
@@ -278,6 +276,17 @@
return f;
}
+void map_sg_to_block(char *device, int len) {
+ char globpat[100];
+ glob_t globbuf;
+ snprintf(globpat, 100, "/sys/class/scsi_generic/%s/device/block:*", device+5);
+ memset(&globbuf, 0, sizeof(glob_t));
+ if(0==glob(globpat, GLOB_DOOFFS | GLOB_NOSORT, NULL, &globbuf)) {
+ char *p = strrchr(globbuf.gl_pathv[0], ':');
+ if(p) snprintf(device, len, "/dev/%s", p+1);
+ }
+ globfree(&globbuf);
+}
/*
* Return version information for the low level SCSI transport code.
@@ -461,6 +470,8 @@
if (nopen == 0) {
for (i = 0; i < 32; i++) {
snprintf(devname, sizeof (devname), "/dev/sg%d", i);
+ map_sg_to_block(devname, sizeof(devname));
+ printf("verwende %s\n", devname);
/* O_NONBLOCK is dangerous */
f = sg_open_excl(devname, O_RDWR | O_NONBLOCK);
if (f < 0) {
Modified: cdrkit/trunk/libusal/scsiopen.c
===================================================================
--- cdrkit/trunk/libusal/scsiopen.c 2007-03-26 20:42:04 UTC (rev 716)
+++ cdrkit/trunk/libusal/scsiopen.c 2007-03-31 15:37:53 UTC (rev 717)
@@ -127,19 +127,37 @@
usalp->overbose = be_verbose;
#ifdef __linux__
- struct utsname buf;
- if(scsidev) {
- if(0==strncmp(scsidev, "ATAPI:", 6) &&
- 0==uname( &buf ) &&
- 0==strncmp(buf.release, "2.6", 3) ) {
- scsidev+=6;
- fprintf(stderr, "\nWarning, the ATAPI: method is considered deprecated on modern kernels!\n"
- "Mapping device specification to dev=%s now.\n"
- "To force the old ATAPI: method, replace ATAPI: with OLDATAPI:\n", scsidev);
- }
- else if(0==strncmp(scsidev, "OLDATAPI:", 9))
- scsidev+=3;
- }
+ struct utsname buf;
+ if(scsidev) {
+ int gen, tmp;
+ struct stat statbuf;
+ if( 0==uname( &buf ) &&
+ sscanf(buf.release, "%d.%d", &gen, &tmp)>1 &&
+ tmp>=6)
+ {
+ if(0==strncmp(scsidev, "ATAPI:", 6))
+ {
+ scsidev+=6;
+ fprintf(stderr, "\nWarning, the ATAPI: method is considered deprecated on modern kernels!\n"
+ "Mapping device specification to dev=%s now.\n"
+ "To force the old ATAPI: method, replace ATAPI: with OLDATAPI:\n", scsidev);
+ }
+ if(0!=stat("/sys/kernel", &statbuf)) {
+ fprintf(stderr, "\nWarning, sysfs is not mounted on /sys!\n"
+ "It is recommended to mount sysfs to allow better device configuration\n");
+ sleep(5);
+ }
+ 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"
+ "the device will be mapped to a block device file where possible.\n"
+ "Run \"wodim --devices\" for details.\n" );
+ sleep(5);
+ }
+ }
+ if(0==strncmp(scsidev, "OLDATAPI:", 9))
+ scsidev+=3;
+ }
#endif
devname[0] = '\0';
More information about the Debburn-changes
mailing list