[Debburn-changes] r656 - in cdrkit/trunk: . doc/plattforms libusal libusal/usal wodim

Eduard Bloch blade at alioth.debian.org
Fri Dec 29 15:37:17 CET 2006


Author: blade
Date: 2006-12-29 15:37:17 +0100 (Fri, 29 Dec 2006)
New Revision: 656

Modified:
   cdrkit/trunk/Changelog
   cdrkit/trunk/doc/plattforms/README.win32
   cdrkit/trunk/libusal/scsi-wnt.c
   cdrkit/trunk/libusal/usal/scsitransp.h
   cdrkit/trunk/wodim/scsi_scan.c
   cdrkit/trunk/wodim/wodim.1
Log:
Open-By-Device-Letter on cygwin and manpage update

Modified: cdrkit/trunk/Changelog
===================================================================
--- cdrkit/trunk/Changelog	2006-12-29 08:46:32 UTC (rev 655)
+++ cdrkit/trunk/Changelog	2006-12-29 14:37:17 UTC (rev 656)
@@ -6,7 +6,9 @@
   * more verbose abort message if track is specified with some maintainance
     command (#369677)
   * Added more DVD related fixes from SuSE's wodim-1.0pre5cvs-6.src.rpm
-  * --devices option for wodim (modeled after cdrskin's output)
+  * --devices option for wodim (modeled after cdrskin's output), working on
+    Linux and Cygwin
+  * Open-By-Device-Letter mode on Cygwin
   * -msifile=... option to store -msinfo output reliably in a dedicated file
   * clear profile names printing (using code from libburnia)
   * cleanup with unused embedded CVS revision strings from Schilling and

Modified: cdrkit/trunk/doc/plattforms/README.win32
===================================================================
--- cdrkit/trunk/doc/plattforms/README.win32	2006-12-29 08:46:32 UTC (rev 655)
+++ cdrkit/trunk/doc/plattforms/README.win32	2006-12-29 14:37:17 UTC (rev 656)
@@ -7,8 +7,8 @@
 and many mirrors.
 
 To compile on Cygwin, execute setup.exe to install it. You will need to select
-cmake, make, gcc compiler in the package selection. Also choose subversion if
-you wish to fetch the latest development version.
+cmake, make, libiconv and gcc compiler in the package selection. Also choose
+subversion if you wish to fetch the latest development version.
 
 When done, you can start the Cygwin Shell by the new icon in the Start menu or
 on the desktop. Visit cdrkit.org and download a tarball of a recent version and store it under <cygwin_directory>\home\your_user_name.

Modified: cdrkit/trunk/libusal/scsi-wnt.c
===================================================================
--- cdrkit/trunk/libusal/scsi-wnt.c	2006-12-29 08:46:32 UTC (rev 655)
+++ cdrkit/trunk/libusal/scsi-wnt.c	2006-12-29 14:37:17 UTC (rev 656)
@@ -102,7 +102,7 @@
 static	BOOL	(*pfnFreeASPI32Buffer)(PASPI32BUFF)		= NULL;
 static	BOOL	(*pfnTranslateASPI32Address)(PDWORD, PDWORD)	= NULL;
 
-static	int	AspiLoaded			= 0;    /* ASPI or SPTI */
+static	int	DriverLoaded			= 0;    /* ASPI or SPTI */
 static	HANDLE	hAspiLib			= NULL;	/* Used for Loadlib */
 
 #define	MAX_DMA_WNT	(63L*1024L) /* ASPI-Driver  allows up to 64k ??? */
@@ -171,7 +171,7 @@
 	DRIVE	drive[NUM_MAX_NTSCSI_DRIVES];
 } SPTIGLOBAL;
 
-static	int	InitSCSIPT(void);
+static	int	InitSCSIPT(SCSI *usalp);
 static	int	DeinitSCSIPT(void);
 static	void	GetDriveInformation(BYTE i, DRIVE *pDrive);
 static	BYTE	SPTIGetNumAdapters(void);
@@ -182,8 +182,8 @@
 
 static	BOOL	bSCSIPTInit = FALSE;
 static	SPTIGLOBAL sptiglobal;
-static	BOOL	bUsingSCSIPT = FALSE;
-static	BOOL	bForceAccess = FALSE;
+static	BOOL	UsingSPTI = FALSE;
+static	BOOL	ForceAccess = FALSE;
 static	int	sptihamax;
 static	USHORT	sptihasortarr[NUM_MAX_NTSCSI_HA];
 
@@ -195,9 +195,7 @@
  * send CDB with the INQUIRY command to it -- NT will automagically fill in
  * the PathId, TargetId, and Lun for us.
  */
-static int
-InitSCSIPT(void)
-{
+static int InitSCSIPT(SCSI *usalp) {
 	BYTE	i;
 	BYTE	j;
 	char	buf[4];
@@ -211,6 +209,7 @@
 	char	InquiryBuffer[2048];
 	PSCSI_ADAPTER_BUS_INFO	ai;
 	BYTE	bus;
+	int explicite_number=-1;
 
 	if (bSCSIPTInit)
 		return (0);
@@ -263,6 +262,7 @@
 		if (TRUE) {
 #endif
 			GetDriveInformation(i, &sptiglobal.drive[i]);
+
 			if (sptiglobal.drive[i].bUsed) {
 				retVal++;
 				hasortval = (sptiglobal.drive[i].PortNumber<<8) | sptiglobal.drive[i].PathId;
@@ -278,9 +278,17 @@
 					sptihasortarr[j] = hasortval;
 					sptihamax++;
 				}
+
+				/* shortcut for device names */
+				if(uDriveType==DRIVE_CDROM && usalp->device && ('A'+i)==toupper(usalp->device[0]))
+					explicite_number=i;
 			}
 		}
 	}
+		/* looks like a workaround for diverging ASPI and SPTI hostadapter numbers,
+		   most likely an attempt to keep the world of fake numbers
+		   consistent;
+		   EB */
 	if (sptihamax > 0) {
 		for (i = NUM_FLOPPY_DRIVES; i < NUM_MAX_NTSCSI_DRIVES; i++)
 			if (sptiglobal.drive[i].bUsed)
@@ -294,9 +302,25 @@
 	sptiglobal.numAdapters = SPTIGetNumAdapters();
 
 	bSCSIPTInit = TRUE;
+	if(explicite_number>0) {
+		usal_scsibus(usalp)=sptiglobal.drive[explicite_number].ha;
+		usal_target(usalp) =sptiglobal.drive[explicite_number].tgt;
+		usal_lun(usalp)    =sptiglobal.drive[explicite_number].lun;
+		/* now unset it to avoid further confusion */
+		usalp->device[0]='\0';
 
+		#ifdef _DEBUG_SCSIPT
+		fprintf(stderr, "named SCSIPT drive type %d found as %c, choosing %d, %d, %d\n", 
+				uDriveType,
+				'A'+explicite_number, 
+				usal_scsibus(usalp), 
+				usal_target(usalp), 
+				usal_lun(usalp));
+		#endif
+	}
+
 	if (retVal > 0)
-		bUsingSCSIPT = TRUE;
+		UsingSPTI = TRUE;
 
 	return (retVal);
 }
@@ -485,8 +509,7 @@
  * fills in a pDrive structure with information from a SCSI_INQUIRY
  * and obtains the ha:tgt:lun values via IOCTL_SCSI_GET_ADDRESS
  */
-static void
-GetDriveInformation(BYTE i, DRIVE *pDrive)
+static void GetDriveInformation(BYTE i, DRIVE *pDrive)
 {
 	HANDLE		fh;
 	BOOL		status;
@@ -633,7 +656,8 @@
 	BYTE	i;
 
 #ifdef _DEBUG_SCSIPT
-	fprintf(usalp_errfile,  "SPTI: SPTIGetDeviceIndex\n");
+	fprintf(usalp_errfile,  "SPTI: SPTIGetDeviceIndex, %d, %d, %d\n", ha,
+			tgt, lun);
 #endif
 
 	for (i = NUM_FLOPPY_DRIVES; i < NUM_MAX_NTSCSI_DRIVES; i++) {
@@ -778,7 +802,7 @@
 		switch (what) {
 
 		case SCG_VERSION:
-			if (bUsingSCSIPT)
+			if (UsingSPTI)
 				return (_usal_itrans_version);
 			return (_usal_trans_version);
 		/*
@@ -811,6 +835,8 @@
 	int	tgt	= usal_target(usalp);
 	int	tlun	= usal_lun(usalp);
 
+	usalp->device = NULL;
+
 	if (busno >= MAX_SCG || tgt >= MAX_TGT || tlun >= MAX_LUN) {
 		errno = EINVAL;
 		if (usalp->errstr)
@@ -820,44 +846,55 @@
 		return (-1);
 	}
 
-	if (device != NULL &&
-	    (strcmp(device, "SPTI") == 0 || strcmp(device, "ASPI") == 0))
+	if (device != NULL && (strcmp(device, "SPTI") == 0 || strcmp(device, "ASPI") == 0))
 		goto devok;
 
 	if ((device != NULL && *device != '\0') || (busno == -2 && tgt == -2)) {
+/*
 		errno = EINVAL;
 		if (usalp->errstr)
 			snprintf(usalp->errstr, SCSI_ERRSTR_SIZE,
 				"Open by 'devname' not supported on this OS");
 		return (-1);
+*/
+
+		UsingSPTI = TRUE;
+		usalp->device = device;
+
+		/* not the finest solution but prevents breaking on various
+		 * places for no good reasons... */
+		usal_scsibus(usalp)=0;
+		usal_target(usalp)=0;
+		usal_lun(usalp)=0;
+		goto openbydev;
 	}
 devok:
-	if (AspiLoaded <= 0) {	/* do not change access method on open driver */
-		bForceAccess = FALSE;
+	if (DriverLoaded <= 0) {	/* do not change access method on open driver */
+		ForceAccess = FALSE;
 #ifdef PREFER_SPTI
-		bUsingSCSIPT = TRUE;
+		UsingSPTI = TRUE;
 #else
-		bUsingSCSIPT = FALSE;
+		UsingSPTI = FALSE;
 #endif
 		if (!w2k_or_newer())
-			bUsingSCSIPT = FALSE;
+			UsingSPTI = FALSE;
 
 		if (usalp->debug > 0) {
 			fprintf((FILE *)usalp->errfile,
 				"usalo_open: Prefered SCSI transport: %s\n",
-					bUsingSCSIPT ? "SPTI":"ASPI");
+					UsingSPTI ? "SPTI":"ASPI");
 		}
 		if (device != NULL && strcmp(device, "SPTI") == 0) {
-			bUsingSCSIPT = TRUE;
-			bForceAccess = TRUE;
+			UsingSPTI = TRUE;
+			ForceAccess = TRUE;
 		} else if (device != NULL && strcmp(device, "ASPI") == 0) {
-			bUsingSCSIPT = FALSE;
-			bForceAccess = TRUE;
+			UsingSPTI = FALSE;
+			ForceAccess = TRUE;
 		}
 		if (device != NULL && usalp->debug > 0) {
 			fprintf((FILE *)usalp->errfile,
 				"usalo_open: Selected SCSI transport: %s\n",
-					bUsingSCSIPT ? "SPTI":"ASPI");
+					UsingSPTI ? "SPTI":"ASPI");
 		}
 	}
 
@@ -880,6 +917,7 @@
 		return (-1);
 	}
 
+openbydev:
 	if (usalp->local == NULL) {
 		usalp->local = malloc(sizeof (struct usal_local));
 		if (usalp->local == NULL)
@@ -913,6 +951,7 @@
 static int
 usalo_close(SCSI *usalp)
 {
+	//printf("closing\n");
 	exit_func();
 	return (0);
 }
@@ -996,7 +1035,7 @@
 	SRB_BusDeviceReset	s;
 
 	if (what == SCG_RESET_NOP) {
-		if (bUsingSCSIPT)
+		if (UsingSPTI)
 			return (-1);
 		else
 			return (0);  /* Can ASPI really reset? */
@@ -1005,7 +1044,7 @@
 		errno = EINVAL;
 		return (-1);
 	}
-	if (bUsingSCSIPT) {
+	if (UsingSPTI) {
 		fprintf((FILE *)usalp->errfile,
 					"Reset SCSI device not implemented with SPTI\n");
 		return (-1);
@@ -1022,7 +1061,7 @@
 	/*
 	 * Check if ASPI library is loaded
 	 */
-	if (AspiLoaded <= 0) {
+	if (DriverLoaded <= 0) {
 		fprintf((FILE *)usalp->errfile,
 				"error in usalo_reset: ASPI driver not loaded !\n");
 		return (-1);
@@ -1252,7 +1291,7 @@
 	/*
 	 * Check if ASPI library is loaded
 	 */
-	if (AspiLoaded <= 0) {
+	if (DriverLoaded <= 0) {
 		errmsgno(EX_BAD, "error in usalo_send: ASPI driver not loaded.\n");
 		sp->error = SCG_FATAL;
 		return (0);
@@ -1302,7 +1341,7 @@
 	s->SRB_BufPointer = sp->addr;			/* pointer to data buffer	*/
 	s->SRB_CDBLen	 = sp->cdb_len;			/* SCSI command length		*/
 	s->SRB_PostProc	 = Event;			/* Post proc event		*/
-	if (bUsingSCSIPT)
+	if (UsingSPTI)
 		s->SRB_SenseLen	= SENSE_LEN_SPTI;	/* Length of sense buffer, SPTI returns SenseInfoLength */
 	else
 		s->SRB_SenseLen	= SENSE_LEN;		/* fixed length 14 for ASPI */
@@ -1334,7 +1373,7 @@
 	 */
 
 	ResetEvent(Event);			/* Clear event handle	    */
-	if (bUsingSCSIPT) {
+	if (UsingSPTI) {
 #ifdef _DEBUG_SCSIPT
 		usalp_errfile = (FILE *)usalp->errfile;
 #endif
@@ -1419,8 +1458,8 @@
 	/*
 	 * Check if ASPI library is already loaded yet
 	 */
-	if (AspiLoaded > 0) {
-		AspiLoaded++;
+	if (DriverLoaded > 0) {
+		DriverLoaded++;
 		return (TRUE);
 	}
 
@@ -1431,37 +1470,37 @@
 	usalp_errfile = (FILE *)usalp->errfile;
 #endif
 #ifdef	PREFER_SPTI
-	if (bUsingSCSIPT)
-		if (InitSCSIPT() > 0) AspiLoaded++;
+	if (UsingSPTI)
+		if (InitSCSIPT(usalp) > 0) DriverLoaded++;
 #endif
 #ifdef	PREFER_SPTI
-	if ((!bUsingSCSIPT || !bForceAccess) && AspiLoaded <= 0) {
+	if ((!UsingSPTI || !ForceAccess) && DriverLoaded <= 0) {
 #else
-	if (!bUsingSCSIPT || !bForceAccess) {
+	if (!UsingSPTI || !ForceAccess) {
 #endif
 		if (load_aspi(usalp)) {
-			AspiLoaded++;
-			bUsingSCSIPT = FALSE;
+			DriverLoaded++;
+			UsingSPTI = FALSE;
 		}
 	}
 
 #ifndef	PREFER_SPTI
-	if ((bUsingSCSIPT || !bForceAccess) && AspiLoaded <= 0)
-		if (InitSCSIPT() > 0)
-			AspiLoaded++;
+	if ((UsingSPTI || !ForceAccess) && DriverLoaded <= 0)
+		if (InitSCSIPT(usalp) > 0)
+			DriverLoaded++;
 #endif	/*PREFER_SPTI*/
 
-	if (AspiLoaded <= 0) {
-		if (bUsingSCSIPT) {
+	if (DriverLoaded <= 0) {
+		if (UsingSPTI) {
 			if (errno == 0)
 				errno = ENOSYS;
 		}
 		fprintf((FILE *)usalp->errfile, "Can not load %s driver! ",
-						bUsingSCSIPT ? "SPTI":"ASPI");
+						UsingSPTI ? "SPTI":"ASPI");
 		return (FALSE);
 	}
 
-	if (bUsingSCSIPT) {
+	if (UsingSPTI) {
 		if (usalp->debug > 0)
 			fprintf((FILE *)usalp->errfile, "using SPTI Transport\n");
 
@@ -1573,7 +1612,7 @@
 static BOOL
 close_driver()
 {
-	if (--AspiLoaded > 0)
+	if (--DriverLoaded > 0)
 		return (TRUE);
 	/*
 	 * If library is loaded
@@ -1616,7 +1655,7 @@
 	ip->SRB_Flags	 = 0;
 	ip->SRB_Hdr_Rsvd = 0;
 
-	if (bUsingSCSIPT)
+	if (UsingSPTI)
 		Status = SPTIHandleHaInquiry(ip);
 	else
 		Status = pfnSendASPI32Command((LPSRB)ip);
@@ -1642,7 +1681,7 @@
 	HANDLE			Event;
 	SRB_BusDeviceReset	s;
 
-	if (bUsingSCSIPT) {
+	if (UsingSPTI) {
 		fprintf((FILE *)usalp->errfile,
 					"Reset SCSI bus not implemented with SPTI\n");
 		return (FALSE);
@@ -1710,7 +1749,7 @@
 	DWORD			Status = 0;
 	SRB_Abort		s;
 
-	if (bUsingSCSIPT) {
+	if (UsingSPTI) {
 		fprintf((FILE *)usalp->errfile,
 					"Abort SCSI not implemented with SPTI\n");
 		return (FALSE);
@@ -1724,7 +1763,7 @@
 	/*
 	 * Check if ASPI library is loaded
 	 */
-	if (AspiLoaded <= 0) {
+	if (DriverLoaded <= 0) {
 		fprintf((FILE *)usalp->errfile,
 				"error in scsiabort: ASPI driver not loaded !\n");
 		return (FALSE);

Modified: cdrkit/trunk/libusal/usal/scsitransp.h
===================================================================
--- cdrkit/trunk/libusal/usal/scsitransp.h	2006-12-29 08:46:32 UTC (rev 655)
+++ cdrkit/trunk/libusal/usal/scsitransp.h	2006-12-29 14:37:17 UTC (rev 656)
@@ -56,6 +56,7 @@
 	usal_ops_t *ops;		/* Ptr to low level SCSI transport ops	*/
 	int	fd;		/* File descriptor for next I/O		*/
 	usal_addr_t	addr;	/* SCSI address for next I/O		*/
+	char	*device;	/* plain text device name, optional	*/
 	int	flags;		/* Libusal flags (see below)		*/
 	int	dflags;		/* Drive specific flags (see below)	*/
 	int	kdebug;		/* Kernel debug value for next I/O	*/

Modified: cdrkit/trunk/wodim/scsi_scan.c
===================================================================
--- cdrkit/trunk/wodim/scsi_scan.c	2006-12-29 08:46:32 UTC (rev 655)
+++ cdrkit/trunk/wodim/scsi_scan.c	2006-12-29 14:37:17 UTC (rev 656)
@@ -80,8 +80,8 @@
 	int i, ndevs=0;
 	BOOL have_tgt;
 
-    fprintf(stderr, "Beginning native device scan. This may take a while if devices are busy...\n");
 #ifdef linux
+	fprintf(stderr, "Beginning native device scan. This may take a while if devices are busy...\n");
 	for(i=0;i<MAXDEVCOUNT;i++) {
 		if(i<26)
 			snprintf(devname, sizeof (devname), "/dev/hd%c", 'a'+i);
@@ -141,6 +141,63 @@
 
 #endif
 
+#ifdef __CYGWIN32__
+	fprintf(stderr, "Beginning native device scan. This may take a while if devices are busy...\n");
+	devname[1]='\0';
+	for(i=2;i<26;i++) {
+		devname[0]='A'+i;
+		usalp = usal_open(devname, buf, sizeof (buf), 0, 0);
+		if(!usalp) continue;
+		if('\0' != usalp->device[0]) // must have been consumed by the pickup code!
+		{
+			usal_close(usalp);
+			continue;
+		}
+		usalp->silent++;
+		//usalp->verbose=3;
+		have_tgt = unit_ready(usalp) || usalp->scmd->error != SCG_FATAL;
+
+		strcpy(perms,"------");
+		if(statbuf.st_mode&S_IRUSR) perms[0]= 'r';
+		if(statbuf.st_mode&S_IWUSR) perms[1]= 'w';
+		if(statbuf.st_mode&S_IRGRP) perms[2]= 'r';
+		if(statbuf.st_mode&S_IWGRP) perms[3]= 'w';
+		if(statbuf.st_mode&S_IROTH) perms[4]= 'r';
+		if(statbuf.st_mode&S_IWOTH) perms[5]= 'w';
+
+		if(have_tgt) {
+			char *p;
+
+			getdev(usalp, FALSE);
+			for(p=usalp->inq->vendor_info + 7 ; p >= usalp->inq->vendor_info; p--) {
+				if(isspace((unsigned char)*p))
+					*p='\0';
+				else
+					break;
+			}
+			for(p=usalp->inq->prod_ident + 15 ; p >= usalp->inq->prod_ident; p--) {
+				if(isspace((unsigned char)*p))
+					*p='\0';
+				else
+					break;
+			}
+			snprintf(buf, sizeof(buf), "%d    dev='%s'   %s :  '%.8s'  '%.16s'\n", ndevs, devname, perms, usalp->inq->vendor_info, usalp->inq->prod_ident);
+			lines[ndevs++]=strdup(buf);
+			usal_close(usalp);
+		}
+	}
+	fprintf(stdout, "%s: Overview of accessible drives (%d found) :\n"
+			"----------------------------------------------------------------------\n",
+			get_progname(), ndevs);
+	for(i=0;i<ndevs;i++)
+		fprintf(stdout, "%s", lines[i]);
+	fprintf(stdout,	"----------------------------------------------------------------------\n");
+
+	return 0;
+
+
+#endif
+
     fprintf(stderr, "Native device scanning is not supported on this plattform. Please use -scanbus.\n");
 	return 0;
 }

Modified: cdrkit/trunk/wodim/wodim.1
===================================================================
--- cdrkit/trunk/wodim/wodim.1	2006-12-29 08:46:32 UTC (rev 655)
+++ cdrkit/trunk/wodim/wodim.1	2006-12-29 14:37:17 UTC (rev 656)
@@ -711,10 +711,9 @@
 A typical device specification is
 .BI dev= 6,0
 \&.
-If a filename must be provided together with the numerical target 
-specification, the filename is implementation specific.
-The correct filename in this case can be found in the system specific
-manuals of the target operating system.
+A filename or virtual device name can be passed instead of the symbolic SCSI
+numbers.  The correct device/filename in this case can be found in the system
+specific manuals of the target operating system.
 On a 
 .I FreeBSD
 system without 
@@ -725,9 +724,9 @@
 .BI dev= /dev/rcd0.ctl:@
 \&.
 .sp
-On Linux, drives connected to a parallel port adapter are mapped
-to a virtual SCSI bus. Different adapters are mapped to different
-targets on this virtual SCSI bus.
+On Linux and Windows 2000/XP, drives are accessible with their device (or
+drive) names or with the symbolic SCSI numbers (not recommended, mapping is not
+stable and could be completely removed in the future).
 .sp
 If no 
 .I dev




More information about the Debburn-changes mailing list