[Debburn-changes] r401 - in nonameyet/branches/surgery: . cdrecord debian include libhfs_iso libscg mkisofs

Eduard Bloch blade at alioth.debian.org
Sun Nov 19 18:41:44 CET 2006


Author: blade
Date: 2006-11-19 18:41:44 +0100 (Sun, 19 Nov 2006)
New Revision: 401

Removed:
   nonameyet/branches/surgery/cdrecord/cdrecord.c
   nonameyet/branches/surgery/libscg/scsitransp.c
Modified:
   nonameyet/branches/surgery/CMakeLists.txt
   nonameyet/branches/surgery/Changelog
   nonameyet/branches/surgery/debian/control
   nonameyet/branches/surgery/include/AddScgBits.cmake
   nonameyet/branches/surgery/libhfs_iso/CMakeLists.txt
   nonameyet/branches/surgery/mkisofs/CMakeLists.txt
Log:
Removal of the most offensive parts

Modified: nonameyet/branches/surgery/CMakeLists.txt
===================================================================
--- nonameyet/branches/surgery/CMakeLists.txt	2006-11-19 17:32:55 UTC (rev 400)
+++ nonameyet/branches/surgery/CMakeLists.txt	2006-11-19 17:41:44 UTC (rev 401)
@@ -1,5 +1,6 @@
 PROJECT (cdrkit)
-SUBDIRS(cdda2wav cdrecord libdeflt libedc libhfs_iso libparanoia libscg libschily libunls mkisofs readcd rscsi 3rd-party/dirsplit include)
+SUBDIRS(libdeflt libedc libhfs_iso libschily libunls mkisofs 3rd-party/dirsplit include)
+#SUBDIRS(cdda2wav cdrecord libdeflt libedc libhfs_iso libparanoia libscg libschily libunls mkisofs readcd rscsi 3rd-party/dirsplit include)
 
 #ADD_DEFINITIONS(-DSHUT_UP)
 

Modified: nonameyet/branches/surgery/Changelog
===================================================================
--- nonameyet/branches/surgery/Changelog	2006-11-19 17:32:55 UTC (rev 400)
+++ nonameyet/branches/surgery/Changelog	2006-11-19 17:41:44 UTC (rev 401)
@@ -3,6 +3,7 @@
   [ Eduard Bloch ]
   * replacement of libdeflt and config parser rewrite; more user-friendly,
     flexibel, tolerant now
+  * removed non-free source parts
 
   [ Christian Fromme ]
   * big cleanup, phase I, getting rid from Cstyle function definitions in

Deleted: nonameyet/branches/surgery/cdrecord/cdrecord.c
===================================================================
--- nonameyet/branches/surgery/cdrecord/cdrecord.c	2006-11-19 17:32:55 UTC (rev 400)
+++ nonameyet/branches/surgery/cdrecord/cdrecord.c	2006-11-19 17:41:44 UTC (rev 401)
@@ -1,4839 +0,0 @@
-/*
- * This file has been modified for the cdrkit suite.
- *
- * The behaviour and appearence of the program code below can differ to a major
- * extent from the version distributed by the original author(s).
- *
- * For details, see Changelog file distributed with the cdrkit package. If you
- * received this file from another source then ask the distributing person for
- * a log of modifications.
- *
- */
-
-/*
- *
- * Modified by Eduard Bloch in 08/2006
- */
-
-/* @(#)cdrecord.c	1.310 06/02/09 Copyright 1995-2006 J. Schilling */
-#ifndef lint
-static	char sccsid[] =
-	"@(#)cdrecord.c	1.310 06/02/09 Copyright 1995-2006 J. Schilling";
-#endif
-/*
- *	Record data on a CD/CVD-Recorder
- *
- *	Copyright (c) 1995-2006 J. Schilling
- */
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; see the file COPYING.  If not, write to the Free Software
- * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <mconfig.h>
-#include <stdio.h>
-#include <standard.h>
-#include <stdxlib.h>
-#include <fctldefs.h>
-#include <errno.h>
-#include <timedefs.h>
-#ifdef	HAVE_SYS_RESOURCE_H
-#include <sys/resource.h>	/* for rlimit */
-#endif
-#include <statdefs.h>
-#include <unixstd.h>
-#ifdef	HAVE_SYS_MMAN_H
-#include <sys/mman.h>
-#endif
-#include <strdefs.h>
-#include <utypes.h>
-#include <intcvt.h>
-#include <signal.h>
-#include <schily.h>
-#include <getargs.h>
-#ifdef	HAVE_PRIV_H
-#include <priv.h>
-#endif
-
-#include "xio.h"
-
-#include <scg/scsireg.h>	/* XXX wegen SC_NOT_READY */
-#include <scg/scsitransp.h>
-#include <scg/scgcmd.h>		/* XXX fuer read_buffer */
-#include "scsi_scan.h"
-
-#include "auheader.h"
-#include "cdrecord.h"
-#include "defaults.h"
-#include "movesect.h"
-
-#ifdef __linux__
-#include <sys/capability.h> 	/* for rawio capability */
-#endif
-
-#define cdr_version "1.0pre1"
-
-#if defined(_POSIX_PRIORITY_SCHEDULING) && _POSIX_PRIORITY_SCHEDULING -0 >= 0
-#ifdef  HAVE_SYS_PRIOCNTL_H	/* The preferred SYSvR4 schduler */
-#else
-#define	USE_POSIX_PRIORITY_SCHEDULING
-#endif
-#endif
-
-/*
- * Map toc/track types into names.
- */
-char	*toc2name[] = {
-		"CD-DA",
-		"CD-ROM",
-		"CD-ROM XA mode 1",
-		"CD-ROM XA mode 2",
-		"CD-I",
-		"Illegal toc type 5",
-		"Illegal toc type 6",
-		"Illegal toc type 7",
-};
-
-/*
- * Map sector types into names.
- */
-char	*st2name[] = {
-		"Illegal sector type 0",
-		"CD-ROM mode 1",
-		"CD-ROM mode 2",
-		"Illegal sector type 3",
-		"CD-DA without preemphasis",
-		"CD-DA with preemphasis",
-		"Illegal sector type 6",
-		"Illegal sector type 7",
-};
-
-/*
- * Map data block types into names.
- */
-char	*db2name[] = {
-		"Raw (audio)",
-		"Raw (audio) with P/Q sub channel",
-		"Raw (audio) with P/W packed sub channel",
-		"Raw (audio) with P/W raw sub channel",
-		"Reserved mode 4",
-		"Reserved mode 5",
-		"Reserved mode 6",
-		"Vendor unique mode 7",
-		"CD-ROM mode 1",
-		"CD-ROM mode 2",
-		"CD-ROM XA mode 2 form 1",
-		"CD-ROM XA mode 2 form 1 (with subheader)",
-		"CD-ROM XA mode 2 form 2",
-		"CD-ROM XA mode 2 form 1/2/mix",
-		"Reserved mode 14",
-		"Vendor unique mode 15",
-};
-
-/*
- * Map write modes into names.
- */
-static	char	wm_none[] = "unknown";
-static	char	wm_ill[]  = "illegal";
-
-char	*wm2name[] = {
-		wm_none,
-		"BLANK",
-		"FORMAT",
-		wm_ill,
-		"PACKET",
-		wm_ill,
-		wm_ill,
-		wm_ill,
-		"TAO",
-		wm_ill,
-		wm_ill,
-		wm_ill,
-		"SAO",
-		"SAO/RAW16",	/* Most liklely not needed */
-		"SAO/RAW96P",
-		"SAO/RAW96R",
-		"RAW",
-		"RAW/RAW16",
-		"RAW/RAW96P",
-		"RAW/RAW96R",
-};
-
-int		debug;		/* print debug messages */
-static	int	kdebug;		/* print kernel debug messages */
-static	int	scsi_verbose;	/* SCSI verbose flag */
-static	int	silent;		/* SCSI silent flag */
-int		lverbose;	/* static verbose flag */
-int		xdebug;		/* extended debug flag */
-
-char	*buf;			/* The transfer buffer */
-long	bufsize = -1;		/* The size of the transfer buffer */
-
-static	int	gracetime = GRACE_TIME;
-static	int	raw_speed = -1;
-static	int	dma_speed = -1;
-static	int	dminbuf = -1;	/* XXX Hack for now drive min buf fill */
-BOOL	isgui;
-static	int	didintr;
-char	*driveropts;
-static	char	*cuefilename;
-static	uid_t	oeuid = (uid_t)-1;
-
-struct timeval	starttime;
-struct timeval	wstarttime;
-struct timeval	stoptime;
-struct timeval	fixtime;
-
-static	long	fs = -1L;	/* fifo (ring buffer) size */
-
-static	int	gracewait(cdr_t *dp, BOOL *didgracep);
-static	void	cdrstats(cdr_t *dp);
-static	void	susage(int);
-static	void	usage(int);
-static	void	blusage(int);
-static	void	formattypeusage(int);
-static	void	intr(int sig);
-static	void	catchsig(int sig);
-static	int	scsi_cb(void *arg);
-static	void	intfifo(int sig);
-static	void	exscsi(int excode, void *arg);
-static	void	excdr(int excode, void *arg);
-int	read_buf(int f, char *bp, int size);
-int	fill_buf(int f, track_t *trackp, long secno, char *bp, int size);
-int	get_buf(int f, track_t *trackp, long secno, char **bpp, int size);
-int	write_secs(SCSI *scgp, cdr_t *dp, char *bp, long startsec, int bytespt,
-					  int secspt, BOOL islast);
-static	int	write_track_data(SCSI *scgp, cdr_t *, track_t *);
-int	pad_track(SCSI *scgp, cdr_t *dp, track_t *trackp, long startsec, 
-					 Llong amt, BOOL dolast, Llong *bytesp);
-int	write_buf(SCSI *scgp, cdr_t *dp, track_t *trackp, char *bp, 
-					 long startsec, Llong amt, int secsize, BOOL dolast, 
-					 Llong *bytesp);
-static	void	printdata(int, track_t *);
-static	void	printaudio(int, track_t *);
-static	void	checkfile(int, track_t *);
-static	int	checkfiles(int, track_t *);
-static	void	setleadinout(int, track_t *);
-static	void	setpregaps(int, track_t *);
-static	long	checktsize(int, track_t *);
-static	void	opentracks(track_t *);
-static	void	checksize(track_t *);
-static	BOOL	checkdsize(SCSI *scgp, cdr_t *dp, long tsize, int flags);
-static	void	raise_fdlim(void);
-static	void	raise_memlock(void);
-static	int	gargs(int, char **, int *, track_t *, char **, int *, cdr_t **,
-							int *, long *, int *, int *);
-static	void	set_trsizes(cdr_t *, int, track_t *);
-void		load_media(SCSI *scgp, cdr_t *, BOOL);
-void		unload_media(SCSI *scgp, cdr_t *, int);
-void		reload_media(SCSI *scgp, cdr_t *);
-void		set_secsize(SCSI *scgp, int secsize);
-static	int	get_dmaspeed(SCSI *scgp, cdr_t *);
-static	BOOL	do_opc(SCSI *scgp, cdr_t *, int);
-static	void	check_recovery(SCSI *scgp, cdr_t *, int);
-void		audioread(SCSI *scgp, cdr_t *, int);
-static	void	print_msinfo(SCSI *scgp, cdr_t *);
-static	void	print_toc(SCSI *scgp, cdr_t *);
-static	void	print_track(int, long, struct msf *, int, int, int);
-#if !defined(HAVE_SYS_PRIOCNTL_H)
-static	int	rt_raisepri(int);
-#endif
-void		raisepri(int);
-static	void	wait_input(void);
-static	void	checkgui(void);
-static	int	getbltype(char *optstr, long *typep);
-static	int	getformattype(char *optstr, long *typep);
-static	void	print_drflags(cdr_t *dp);
-static	void	print_wrmodes(cdr_t *dp);
-static	BOOL	check_wrmode(cdr_t *dp, int wmode, int tflags);
-static	void	set_wrmode(cdr_t *dp, int wmode, int tflags);
-static	void	linuxcheck(void);
-
-#ifdef __linux__
-static int get_cap(cap_value_t cap_array);
-#endif
-
-struct exargs {
-	SCSI	*scgp;
-	cdr_t	*dp;
-	int	old_secsize;
-	int	flags;
-	int	exflags;
-} exargs;
-
-void fifo_cleanup(void) {
-   kill_faio();
-}
-
-int main(int argc, char *argv[])
-{
-	char	*dev = NULL;
-	int	timeout = 40;	/* Set default timeout to 40s CW-7502 is slow*/
-	int	speed = -1;
-	long	flags = 0L;
-	int	blanktype = 0;
-	int	formattype = 0;
-	int	i;
-	int	tracks = 0;
-	int	trackno;
-	long	tsize;
-	track_t	track[MAX_TRACK+2];	/* Max tracks + track 0 + track AA */
-	cdr_t	*dp = (cdr_t *)0;
-	long	startsec = 0L;
-	int	errs = 0;
-	SCSI	*scgp = NULL;
-	char	errstr[80];
-	BOOL	gracedone = FALSE;
-	int     ispacket;
-	BOOL	is_cdwr = FALSE;
-	BOOL	is_dvdwr = FALSE;
-
-
-	/* workaround for k3b */
-	int acpos;
-	for(acpos=0;acpos<argc;acpos++) {
-	   if(!strcmp(argv[acpos],"-version") || !strcmp(argv[acpos],"--version"))
-	      fprintf(stderr, "Cdrecord-yelling-line-to-tell-frontends-to-use-it-like-version 2.01.01a03-dvd \n");
-	}
-
-#ifndef SHUT_UP
-
-	fprintf(stderr,
-			"This is wodim, not cdrecord. Don't expect it to behave like cdrecord in any\n"
-			"way, don't refer to it as \"cdrecord\". Send problem reports to\n"
-			"debburn-devel at lists.alioth.debian.org, don't bother Joerg Schilling with any\n"
-			"problems caused by this application.\n"
-			"Copyright (C) 2006 cdrkit maintainers, (C) 1994-2006 Joerg Schilling\n\n" );
-	fprintf(stderr,
-			"WARNING WARNING WARNING:\n\n"
-			"If you are annoyed by the messages below about unofficial status or about\n"
-			"non-Schily-Makefilesystem or if your GUI/script breaks because of them,\n"
-      "please don't send your complaints to cdrkit maintainers; they already know.\n"
-			"They are not allowed to remove them by Joerg Schilling's license\n"
-			"modifications (restrictions), hidden in the source. Correcting the contents\n"
-      "of the messages is forbidden as well, so don't believe everything said there.\n"
-      "See http://svn.debian.org/wsvn/debburn/nonameyet/trunk/FAQ?op=file&rev=0&sc=0\n"
-      "for details.\n\n" );
-
-  if(strcmp(argv[0], "cdrecord") == 0)
-     strcpy(argv[0], "wodim");
-#endif /* SHUT_UP */
-
-#ifdef __EMX__
-	/* This gives wildcard expansion with Non-Posix shells with EMX */
-	_wildcard(&argc, &argv);
-#endif
-	save_args(argc, argv);
-	oeuid = geteuid();		/* Remember saved set uid	*/
-
-	fillbytes(track, sizeof (track), '\0');
-	for (i = 0; i < MAX_TRACK+2; i++)
-		track[i].track = track[i].trackno = i;
-	track[0].tracktype = TOC_MASK;
-	raise_fdlim();
-	ispacket = gargs(argc, argv, &tracks, track, &dev, &timeout, &dp, &speed, &flags,
-							&blanktype, &formattype);
-	if ((track[0].tracktype & TOC_MASK) == TOC_MASK)
-		comerrno(EX_BAD, "Internal error: Bad TOC type.\n");
-
-	if (flags & F_VERSION) {
-	   fprintf(stderr,
-		 "Wodim " cdr_version "\n"
-		 "Copyright (C) 2006 Cdrkit suite contributors\n"
-		 "Based on works from Joerg Schilling, Copyright (C) 1995-2006, J. Schilling\n"
-		 );
-	   /*exit(0);*/
-	}
-
-#ifndef SHUT_UP
-
-#define HOST_CPU "HOST_CPU-just-a-fake-string-to-make-Schilling's-invariant-section-compile-because-cdrkit-does-not-need-it-anymore"
-#define HOST_VENDOR "HOST_VENDOR-just-a-fake-string-to-make-Schilling's-invariant-section-compile-because-cdrkit-does-not-need-it-anymore"
-#define HOST_OS HOST_SYSTEM
-
-	/*
-	 * Begin restricted code for quality assurance.
-	 *
-	 * Warning: you are not allowed to modify or to remove the
-	 * Copyright and version printing code below!
-	 * See also GPL § 2 subclause c)
-	 *
-	 * If you modify cdrecord you need to include additional version
-	 * printing code that:
-	 *
-	 *	-	Clearly states that the current version is an
-	 *		inofficial (modified) version and thus may have bugs
-	 *		that are not present in the original.
-	 *
-	 *	-	Print your support e-mail address and tell people that
-	 *		you will do complete support for this version of
-	 *		cdrecord.
-	 *
-	 *		Or clearly state that there is absolutely no support
-	 *		for the modified version you did create.
-	 *
-	 *	-	Tell the users not to ask the original author for
-	 *		help.
-	 *
-	 * This limitation definitely also applies when you use any other
-	 * cdrecord release together with libscg-0.6 or later, or when you
-	 * use any amount of code from cdrecord-1.11a17 or later.
-	 * In fact, it applies to any version of cdrecord, see also
-	 * GPL Preamble, subsection 6.
-	 *
-	 * I am sorry for the inconvenience but I am forced to do this because
-	 * some people create inofficial branches. These branches create
-	 * problems but the initiators do not give support and thus cause the
-	 * development of the official cdrecord versions to slow down because
-	 * I am loaded with unneeded work.
-	 *
-	 * Please note that this is a memorandum on how I interpret the GPL.
-	 * If you use/modify/redistribute cdrecord, you need to accept it
-	 * this way.
-	 *
-	 *
-	 * The above statement is void if there has been neither a new version
-	 * of cdrecord nor a new version of star from the original author
-	 * within more then a year.
-	 */
-
-	/*
-	 * Ugly, but Linux incude files violate POSIX and #define printf
-	 * so we cannot include the #ifdef inside the printf() arg list.
-	 */
-#	define	PRODVD_TITLE	""
-#ifdef	CLONE_WRITE
-#	define	CLONE_TITLE	"-Clone"
-#else
-#	define	CLONE_TITLE	""
-#endif
-	if ((flags & F_MSINFO) == 0 || lverbose || flags & F_VERSION) {
-		printf("Cdrecord%s%s %s (%s-%s-%s) Copyright (C) 1995-2006 Jörg Schilling\n",
-								PRODVD_TITLE,
-								CLONE_TITLE,
-								cdr_version,
-								HOST_CPU, HOST_VENDOR, HOST_OS);
-
-#if	defined(SOURCE_MODIFIED) || !defined(IS_SCHILY_XCONFIG)
-#define	INSERT_YOUR_EMAIL_ADDRESS_HERE
-#define	NO_SUPPORT	0
-		printf("NOTE: this version of cdrecord is an inofficial (modified) release of cdrecord\n");
-		printf("      and thus may have bugs that are not present in the original version.\n");
-#if	NO_SUPPORT
-		printf("      The author of the modifications decided not to provide a support e-mail\n");
-		printf("      address so there is absolutely no support for this version.\n");
-#else
-		printf("      Please send bug reports and support requests to <%s>.\n", "debburn-devel at lists.alioth.debian.org");
-#endif
-		printf("      The original author should not be bothered with problems of this version.\n");
-		printf("\n");
-#endif
-#if	!defined(IS_SCHILY_XCONFIG)
-		printf("\nWarning: This version of cdrecord has not been configured via the standard\n");
-		printf("autoconfiguration method of the Schily makefile system. There is a high risk\n");
-		printf("that the code is not configured correctly and for this reason will not behave\n");
-		printf("as expected.\n");
-#endif
-
-
-	/*
-	 * I am sorry that even for version 1.310 of cdrecord.c, I am forced to do
-	 * things like this, but defective versions of cdrecord cause a lot of
-	 * work load to me and it seems to be impossible to otherwise convince
-	 * SuSE to cooperate.
-	 * As people contact me and bother me with the related problems,
-	 * it is obvious that SuSE is violating subsection 6 in the preamble of
-	 * the GPL.
-	 *
-	 * The reason for including a test against SuSE's private
-	 * distribution environment is only that SuSE violates the GPL for
-	 * a long time and seems not to be willing to follow the requirements
-	 * imposed by the GPL. If SuSE starts to ship non defective versions
-	 * of cdrecord or informs their customers that they would need to
-	 * compile cdrecord themselves in order to get a working cdrecord,
-	 * they should contact me for a permission to change the related test.
-	 *
-	 * Note that although the SuSE test is effective only for SuSE, the
-	 * intention to have non bastardized versions out is not limited
-	 * to SuSE. It is bad to see that in special in the "Linux" business,
-	 * companies prefer a model with many proprietary differing programs
-	 * instead of cooperating with the program authors.
-	 */
-
-	if (flags & F_VERSION)
-		exit(0);
-	/*
-	 * End restricted code for quality assurance.
-	 */
-        }
-#else
-	if (flags & F_VERSION)
-		exit(0);
-#endif /* SHUT_UP */
-
-	checkgui();
-
-	if (debug || lverbose) {
-		printf("TOC Type: %d = %s\n",
-			track[0].tracktype & TOC_MASK,
-			toc2name[track[0].tracktype & TOC_MASK]);
-	}
-
-	if ((flags & (F_MSINFO|F_TOC|F_PRATIP|F_FIX|F_VERSION|F_CHECKDRIVE|F_INQUIRY|F_SCANBUS|F_RESET)) == 0) {
-		/*
-		 * Try to lock us im memory (will only work for root)
-		 * but you need access to root anyway to send SCSI commands.
-		 * We need to be root to open /dev/scg? or similar devices
-		 * on other OS variants and we need to be root to be able
-		 * to send SCSI commands at least on AIX and
-		 * Solaris (USCSI only) regardless of the permissions for
-		 * opening files
-		 *
-		 * XXX The folowing test used to be
-		 * XXX #if defined(HAVE_MLOCKALL) || defined(_POSIX_MEMLOCK)
-		 * XXX but the definition for _POSIX_MEMLOCK did change during
-		 * XXX the last 8 years and the autoconf test is better for
-		 * XXX the static case. sysconf() only makes sense if we like
-		 * XXX to check dynamically.
-		 */
-		raise_memlock();
-#if defined(HAVE_MLOCKALL)
-		/*
-		 * XXX mlockall() needs root privilleges.
-		 */
-		if (mlockall(MCL_CURRENT|MCL_FUTURE) < 0) {
-			errmsg("WARNING: Cannot do mlockall(2).\n");
-			errmsgno(EX_BAD, "WARNING: This causes a high risk for buffer underruns.\n");
-		}
-#endif
-
-		/*
-		 * XXX raisepri() needs root privilleges.
-		 */
-		raisepri(0); /* max priority */
-		/*
-		 * XXX shmctl(id, SHM_LOCK, 0) needs root privilleges.
-		 * XXX So if we use SysV shared memory, wee need to be root.
-		 *
-		 * Note that not being able to set up a FIFO bombs us
-		 * back to the DOS ages. Trying to run cdrecord without
-		 * root privillegs is extremely silly, it breaks most
-		 * of the advanced features. We need to be at least installed
-		 * suid root or called by RBACs pfexec.
-		 */
-		init_fifo(fs);	/* Attach shared memory (still one process) */
-	}
-
-	if ((flags & F_WAITI) != 0) {
-		if (lverbose)
-			printf("Waiting for data on stdin...\n");
-		wait_input();
-	}
-
-	/*
-	 * Call scg_remote() to force loading the remote SCSI transport library
-	 * code that is located in librscg instead of the dummy remote routines
-	 * that are located inside libscg.
-	 */
-	scg_remote();
-	if (dev != NULL &&
-	    ((strncmp(dev, "HELP", 4) == 0) ||
-	    (strncmp(dev, "help", 4) == 0))) {
-		scg_help(stderr);
-		exit(0);
-	}
-
-  scgp = scg_open(dev, errstr, sizeof (errstr),
-        debug, lverbose);
-  if(!scgp && dev) {
-     char *dalt;
-     int len=5+strlen(dev);
-     dalt=calloc(len, sizeof(char));
-     strcat(dalt, "ATA:");
-     strcat(dalt+4, dev);
-     scgp = scg_open(dalt, errstr, sizeof (errstr),
-           debug, lverbose);
-  }
-  if(!scgp)
-  {
-     errmsg("\nCannot open SCSI driver!\n"
-           "For possible targets try 'wodim -scanbus'.\n"
-           "For possible transport specifiers try 'wodim dev=help'.\n"
-           "For IDE/ATAPI devices configuration, see the file README.ATAPI.setup from\n"
-           "the wodim documentation.\n");
-     exit(EX_BAD);
-  }
-#ifdef	HAVE_PRIV_SET
-#ifdef	PRIV_DEBUG
-	fprintf(stderr, "file_dac_read: %d\n", priv_ineffect(PRIV_FILE_DAC_READ));
-#endif
-	/*
-	 * Give up privs we do not need anymore.
-	 * We no longer need:
-	 *	file_dac_read,proc_lock_memory,proc_priocntl,net_privaddr
-	 * We still need:
-	 *	sys_devices
-	 */
-	priv_set(PRIV_OFF, PRIV_EFFECTIVE,
-		PRIV_FILE_DAC_READ, PRIV_PROC_LOCK_MEMORY,
-		PRIV_PROC_PRIOCNTL, PRIV_NET_PRIVADDR, NULL);
-	priv_set(PRIV_OFF, PRIV_PERMITTED,
-		PRIV_FILE_DAC_READ, PRIV_PROC_LOCK_MEMORY,
-		PRIV_PROC_PRIOCNTL, PRIV_NET_PRIVADDR, NULL);
-	priv_set(PRIV_OFF, PRIV_INHERITABLE,
-		PRIV_FILE_DAC_READ, PRIV_PROC_LOCK_MEMORY,
-		PRIV_PROC_PRIOCNTL, PRIV_NET_PRIVADDR, PRIV_SYS_DEVICES, NULL);
-#endif
-	/*
-	 * This is only for OS that do not support fine grained privs.
-	 *
-	 * XXX Below this point we do not need root privilleges anymore.
-	 */
-	if (geteuid() != getuid()) {	/* AIX does not like to do this */
-					/* If we are not root		*/
-#ifdef	HAVE_SETREUID
-		if (setreuid(-1, getuid()) < 0)
-#else
-#ifdef	HAVE_SETEUID
-		if (seteuid(getuid()) < 0)
-#else
-		if (setuid(getuid()) < 0)
-#endif
-#endif
-			comerr("Panic cannot set back effective uid.\n");
-	}
-
-#ifdef __linux__
-	/* get the rawio capability */
-  if (get_cap(CAP_SYS_RAWIO) && (debug || lverbose)) 
-  {
-		perror("Warning: Cannot gain SYS_RAWIO capability");
-    fprintf(stderr, "Possible reason: wodim not installed SUID root.\n");
-  }
-#endif
-
-	/*
-	 * WARNING: We now are no more able to do any privilleged operation
-	 * unless we have been called by root.
-	 *
-	 * XXX It may be that we later get problems in init_faio() because
-	 * XXX this function calls raisepri() to lower the priority slightly.
-	 */
-	scg_settimeout(scgp, timeout);
-	scgp->verbose = scsi_verbose;
-	scgp->silent = silent;
-	scgp->debug = debug;
-	scgp->kdebug = kdebug;
-	scgp->cap->c_bsize = DATA_SEC_SIZE;
-
-#ifndef SHUT_UP
-
-	if ((flags & F_MSINFO) == 0 || lverbose) {
-		char	*vers;
-		char	*auth;
-
-		/*
-		 * Warning: you are not allowed to modify or to remove this
-		 * version checking code!
-		 */
-		vers = scg_version(0, SCG_VERSION);
-		auth = scg_version(0, SCG_AUTHOR);
-    printf("Using libscg version '%s-%s'.\n", auth, vers);
-		if (auth == 0 || strcmp("schily", auth) != 0) {
-			errmsgno(EX_BAD,
-			"Warning: using inofficial version of libscg (%s-%s '%s').\n",
-				auth, vers, scg_version(0, SCG_SCCS_ID));
-		}
-
-		vers = scg_version(scgp, SCG_VERSION);
-		auth = scg_version(scgp, SCG_AUTHOR);
-		if (lverbose > 1)
-			fprintf(stderr, "Using libscg transport code version '%s-%s'\n", auth, vers);
-		if (auth == 0 || strcmp("schily", auth) != 0) {
-			errmsgno(EX_BAD,
-			"Warning: using inofficial libscg transport code version (%s-%s '%s').\n",
-				auth, vers, scg_version(scgp, SCG_SCCS_ID));
-		}
-
-		vers = scg_version(scgp, SCG_RVERSION);
-		auth = scg_version(scgp, SCG_RAUTHOR);
-		if (lverbose > 1 && vers && auth)
-			fprintf(stderr, "Using remote transport code version '%s-%s'\n", auth, vers);
-		if (auth != 0 && strcmp("schily", auth) != 0) {
-			errmsgno(EX_BAD,
-			"Warning: using inofficial remote transport code version (%s-%s '%s').\n",
-				auth, vers, scg_version(scgp, SCG_RSCCS_ID));
-		}
-	}
-
-#endif /* SHUT_UP */
-
-	if (lverbose && driveropts)
-		printf("Driveropts: '%s'\n", driveropts);
-
-/*	bufsize = scg_bufsize(scgp, CDR_BUF_SIZE);*/
-	bufsize = scg_bufsize(scgp, bufsize);
-	if (lverbose || debug)
-		fprintf(stderr, "SCSI buffer size: %ld\n", bufsize);
-	if ((buf = scg_getbuf(scgp, bufsize)) == NULL)
-		comerr("Cannot get SCSI I/O buffer.\n");
-
-	if ((flags & F_SCANBUS) != 0) {
-		select_target(scgp, stdout);
-		exit(0);
-	}
-	if ((flags & F_RESET) != 0) {
-		if (scg_reset(scgp, SCG_RESET_NOP) < 0)
-			comerr("Cannot reset (OS does not implement reset).\n");
-		if (scg_reset(scgp, SCG_RESET_TGT) >= 0)
-			exit(0);
-		if (scg_reset(scgp, SCG_RESET_BUS) < 0)
-			comerr("Cannot reset target.\n");
-		exit(0);
-	}
-
-	/*
-	 * First try to check which type of SCSI device we
-	 * have.
-	 */
-	if (debug || lverbose)
-		printf("atapi: %d\n", scg_isatapi(scgp));
-	scgp->silent++;
-	test_unit_ready(scgp);	/* eat up unit attention */
-	scgp->silent--;
-	if (!do_inquiry(scgp, (flags & F_MSINFO) == 0 || lverbose)) {
-		errmsgno(EX_BAD, "Cannot do inquiry for CD/DVD-Recorder.\n");
-		if (unit_ready(scgp))
-			errmsgno(EX_BAD, "The unit seems to be hung and needs power cycling.\n");
-		exit(EX_BAD);
-	}
-#ifdef	GCONF
-/*
- * Debug only
- */
-{
-extern	void	gconf(SCSI *);
-
-if (lverbose > 2)
-	gconf(scgp);
-}
-#endif
-
-	if ((flags & F_PRCAP) != 0) {
-		print_capabilities(scgp);
-		print_capabilities_mmc4(scgp);
-		exit(0);
-	}
-	if ((flags & F_INQUIRY) != 0)
-		exit(0);
-
-	if (dp == (cdr_t *)NULL) {	/* No driver= option specified	*/
-		dp = get_cdrcmds(scgp);	/* Calls dp->cdr_identify()	*/
-	} else if (!is_unknown_dev(scgp) && dp != get_cdrcmds(scgp)) {
-		errmsgno(EX_BAD, "WARNING: Trying to use other driver on known device.\n");
-	}
-        is_mmc(scgp, &is_cdwr, &is_dvdwr);
-        if (ispacket) {
-	    if (is_dvdwr) {
-		track[0].flags |= TI_PACKET; 
-		/*XXX put here to only affect DVD writing, should be in gargs.
-		 * however if set in args for all mode, packet writing is then
-		 * broken for all disc as cdrecord assume that PACKET imply TAO which  
-		 * is not true at all???? */ 
-		track[0].flags &= ~TI_TAO;
-	    }
-	}
-
-	if (dp == (cdr_t *)0)
-		comerrno(EX_BAD, "Sorry, no supported CD/DVD-Recorder found on this target.\n");
-
-	/* DVD does not support TAO */
-	if (dp->is_dvd) {
-	        fprintf(stderr, "Using Session At Once (SAO) for DVD mode.\n");
-		dp->cdr_flags |= F_SAO;
-		for (i = 0; i <= MAX_TRACK; i++) {
-		    track[i].flags &= ~TI_TAO;
-		    track[i].flags |= TI_SAO;
-		}
-	}
-
-	if (!is_cddrive(scgp))
-		comerrno(EX_BAD, "Sorry, no CD/DVD-Drive found on this target.\n");
-	/*
-	 * The driver is known, set up data structures...
-	 */
-	{
-		cdr_t	*ndp;
-		dstat_t	*dsp;
-
-		ndp = malloc(sizeof (cdr_t));
-		dsp = malloc(sizeof (dstat_t));
-		if (ndp == NULL || dsp == NULL)
-			comerr("Cannot allocate memory for driver structure.\n");
-		movebytes(dp, ndp, sizeof (cdr_t));
-		dp = ndp;
-		dp->cdr_flags |= CDR_ALLOC;
-		dp->cdr_cmdflags = flags;
-
-		fillbytes(dsp, sizeof (*dsp), '\0');
-		dsp->ds_minbuf = 0xFFFF;
-		dp->cdr_dstat = dsp;
-	}
-
-	if ((flags & (F_MSINFO|F_TOC|F_LOAD|F_DLCK|F_EJECT)) == 0 ||
-	    tracks > 0 ||
-	    cuefilename != NULL) {
-
-
-		if ((dp->cdr_flags & CDR_ISREADER) != 0) {
-			errmsgno(EX_BAD,
-			"Sorry, no CD/DVD-Recorder or unsupported CD/DVD-Recorder found on this target.\n");
-		}
-
-		if (!is_mmc(scgp, &is_cdwr, &is_dvdwr))
-			is_cdwr = TRUE;			/* If it is not MMC, it must be a CD writer */
-
-		if (is_dvdwr && !set_cdrcmds("mmc_mdvd", (cdr_t **)NULL)) {
-			errmsgno(EX_BAD,
-			"Internal error, DVD driver failure. Please report to debburn-devel at lists.alioth.debian.org.\n");
-       /*
-			errmsgno(EX_BAD,
-			"This version of cdrecord does not include DVD-R/DVD-RW support code.\n");
-			errmsgno(EX_BAD,
- 			"See /usr/share/doc/cdrecord/README.DVD.Debian for details on DVD support.\n");
-      */
-		}
-		/*
-		 * Only exit if this is not the ProDVD test binary.
-		 */
-		if (!is_cdwr)
-			exit(EX_BAD);
-	}
-
-	/*
-	 * Set up data structures for current drive state.
-	 */
-	if ((*dp->cdr_attach)(scgp, dp) != 0)
-		comerrno(EX_BAD, "Cannot attach driver for CD/DVD-Recorder.\n");
-
-	if (lverbose > 1) {
-		printf("Drive current speed: %d\n", dp->cdr_dstat->ds_dr_cur_wspeed);
-		printf("Drive default speed: %d\n", dp->cdr_speeddef);
-		printf("Drive max speed    : %d\n", dp->cdr_speedmax);
-	}
-	if (speed > (int)dp->cdr_speedmax && (flags & F_FORCE) == 0)
-		speed = dp->cdr_speedmax;
-	if (speed < 0)
-		speed = dp->cdr_speeddef;
-
-	if (lverbose > 1) {
-		printf("Selected speed     : %d\n", speed);
-	}
-	dp->cdr_dstat->ds_wspeed = speed; /* XXX Remove 'speed' in future */
-
-	exargs.scgp	   = scgp;
-	exargs.dp	   = dp;
-	exargs.old_secsize = -1;
-	exargs.flags	   = flags;
-
-	if ((flags & F_MSINFO) == 0 || lverbose) {
-		printf("Using %s (%s).\n", dp->cdr_drtext, dp->cdr_drname);
-		print_drflags(dp);
-		print_wrmodes(dp);
-	}
-	scgp->silent++;
-	if ((debug || lverbose)) {
-		tsize = -1;
-		if ((*dp->cdr_buffer_cap)(scgp, &tsize, (long *)0) < 0 || tsize < 0) {
-			if (read_buffer(scgp, buf, 4, 0) >= 0)
-				tsize = a_to_u_4_byte(buf);
-		}
-		if (tsize > 0) {
-			printf("Drive buf size : %lu = %lu KB\n",
-						tsize, tsize >> 10);
-		}
-	}
-	scgp->silent--;
-
-	dma_speed = get_dmaspeed(scgp, dp);
-	if ((debug || lverbose) && dma_speed > 0) {
-		/*
-		 * We do not yet know what medium type is in...
-		 */
-		printf("Drive DMA Speed: %d kB/s %dx CD %dx DVD\n",
-			dma_speed, dma_speed/176, dma_speed/1385);
-	}
-	if ((tracks > 0 || cuefilename != NULL) && (debug || lverbose))
-		printf("FIFO size      : %lu = %lu KB\n", fs, fs >> 10);
-
-#ifdef	HAVE_LIB_EDC_ECC
-	if ((flags & F_RAW) != 0 && (dp->cdr_dstat->ds_flags & DSF_DVD) == 0)
-		raw_speed = encspeed(debug || lverbose);
-#endif
-
-	if ((flags & F_CHECKDRIVE) != 0)
-		exit(0);
-
-	if ((flags & F_ABORT) != 0) {
-		/*
-		 * flush cache is not supported by CD-ROMs avoid prob with -toc
-		 */
-		scgp->silent++;
-		scsi_flush_cache(scgp, FALSE);
-		(*dp->cdr_abort_session)(scgp, dp);
-		scgp->silent--;
-		exit(0);
-	}
-
-	if (tracks == 0 && cuefilename == NULL &&
-	    (flags & (F_FIX|F_BLANK)) == 0 && (flags & F_EJECT) != 0) {
-		/*
-		 * Do not check if the unit is ready here to allow to open
-		 * an empty unit too.
-		 */
-		unload_media(scgp, dp, flags);
-		exit(0);
-	}
-	flush();
-
-	if (cuefilename) {
-		parsecue(cuefilename, track);
-		tracks = track[0].tracks;
-	} else {
-		opentracks(track);
-	}
-
-	if (tracks > 1)
-		sleep(2);	/* Let the user watch the inquiry messages */
-
-	if (tracks > 0 && !check_wrmode(dp, flags, track[1].flags))
-		comerrno(EX_BAD, "Illegal write mode for this drive.\n");
-
-	if ((track[0].flags & TI_TEXT) == 0 &&	/* CD-Text not yet processed */
-	    (track[MAX_TRACK+1].flags & TI_TEXT) != 0) {
-		/*
-		 * CD-Text from textfile= or from CUE CDTEXTFILE will win
-		 * over CD-Text from *.inf files and over CD-Text from
-		 * CUE SONGWRITER, ...
-		 */
-		packtext(tracks, track);
-		track[0].flags |= TI_TEXT;
-	}
-#ifdef	CLONE_WRITE
-	if (flags & F_CLONE) {
-		clone_toc(track);
-		clone_tracktype(track);
-	}
-#endif
-	setleadinout(tracks, track);
-	set_trsizes(dp, tracks, track);
-	setpregaps(tracks, track);
-	checkfiles(tracks, track);
-	tsize = checktsize(tracks, track);
-
-	/*
-	 * Make wm2name[wrmode] work.
-	 * This must be done after the track flags have been set up
-	 * by the functions above.
-	 */
-	if (tracks == 0 && (flags & F_BLANK) != 0)
-		dp->cdr_dstat->ds_wrmode = WM_BLANK;
-	else if (tracks == 0 && (flags & F_FORMAT) != 0)
-		dp->cdr_dstat->ds_wrmode = WM_FORMAT;
-	else
-		set_wrmode(dp, flags, track[1].flags);
-
-	/*
-	 * Debug only
-	 */
-	{
-		void	*cp = NULL;
-
-		(*dp->cdr_gen_cue)(track, &cp, FALSE);
-		if (cp)
-			free(cp);
-	}
-
-	/*
-	 * Create Lead-in data. Only needed in RAW mode.
-	 */
-	do_leadin(track);
-
-
-	/*
-	 * Install exit handler before we change the drive status.
-	 */
-	on_comerr(exscsi, &exargs);
-
-	if ((flags & F_FORCE) == 0)
-		load_media(scgp, dp, TRUE);
-
-	if ((flags & (F_LOAD|F_DLCK)) != 0) {
-		if ((flags & F_DLCK) == 0) {
-			scgp->silent++;		/* silently		*/
-			scsi_prevent_removal(
-				scgp, 0);	/* allow manual open	*/
-			scgp->silent--;		/* if load failed...	*/
-		}
-		exit(0);			/* we did not change status */
-	}
-	exargs.old_secsize = sense_secsize(scgp, 1);
-	if (exargs.old_secsize < 0)
-		exargs.old_secsize = sense_secsize(scgp, 0);
-	if (debug)
-		printf("Current Secsize: %d\n", exargs.old_secsize);
-	scgp->silent++;
-	if (read_capacity(scgp) < 0) {
-		if (exargs.old_secsize > 0)
-			scgp->cap->c_bsize = exargs.old_secsize;
-	}
-	scgp->silent--;
-	if (exargs.old_secsize < 0)
-		exargs.old_secsize = scgp->cap->c_bsize;
-	if (exargs.old_secsize != scgp->cap->c_bsize)
-		errmsgno(EX_BAD, "Warning: blockdesc secsize %d differs from cap secsize %d\n",
-				exargs.old_secsize, scgp->cap->c_bsize);
-
-	if (lverbose)
-		printf("Current Secsize: %d\n", exargs.old_secsize);
-
-	if (exargs.old_secsize > 0 && exargs.old_secsize != DATA_SEC_SIZE) {
-		/*
-		 * Some drives (e.g. Plextor) don't like to write correctly
-		 * in SAO mode if the sector size is set to 512 bytes.
-		 * In addition, cdrecord -msinfo will not work properly
-		 * if the sector size is not 2048 bytes.
-		 */
-		set_secsize(scgp, DATA_SEC_SIZE);
-	}
-
-	/*
-	 * Is this the right place to do this ?
-	 */
-	check_recovery(scgp, dp, flags);
-
-/*audioread(dp, flags);*/
-/*unload_media(scgp, dp, flags);*/
-/*return 0;*/
-	if (flags & F_WRITE)
-		dp->cdr_dstat->ds_cdrflags |= RF_WRITE;
-	if (flags & F_BLANK)
-		dp->cdr_dstat->ds_cdrflags |= RF_BLANK;
-	if (flags & F_PRATIP || lverbose > 0) {
-		dp->cdr_dstat->ds_cdrflags |= RF_PRATIP;
-	}
-	if (flags & F_IMMED || dminbuf > 0) {
-		if (dminbuf <= 0)
-			dminbuf = 50;
-		if (lverbose <= 0)	/* XXX Hack needed for now */
-			lverbose++;
-		dp->cdr_dstat->ds_cdrflags |= RF_WR_WAIT;
-	}
-	if ((*dp->cdr_getdisktype)(scgp, dp) < 0) {
-		errmsgno(EX_BAD, "Cannot get disk type.\n");
-		if ((flags & F_FORCE) == 0)
-			comexit(EX_BAD);
-	}
-	if (flags & F_PRATIP) {
-		comexit(0);
-	}
-	/*
-	 * The next actions should depend on the disk type.
-	 */
-	if (dma_speed > 0) {
-		if ((dp->cdr_dstat->ds_flags & DSF_DVD) == 0)
-			dma_speed /= 176;
-		else
-			dma_speed /= 1385;
-	}
-
-	/*
-	 * Init drive to default modes:
-	 *
-	 * We set TAO unconditionally to make checkdsize() work
-	 * currectly in SAO mode too.
-	 *
-	 * At least MMC drives will not return the next writable
-	 * address we expect when the drive's write mode is set
-	 * to SAO. We need this address for mkisofs and thus
-	 * it must be the first user accessible sector and not the
-	 * first sector of the pregap.
-	 *
-	 * XXX The ACER drive:
-	 * XXX Vendor_info    : 'ATAPI   '
-	 * XXX Identifikation : 'CD-R/RW 8X4X32  '
-	 * XXX Revision       : '5.EW'
-	 * XXX Will not return from -dummy to non-dummy without
-	 * XXX opening the tray.
-	 */
-	scgp->silent++;
-	if ((*dp->cdr_init)(scgp, dp) < 0)
-		comerrno(EX_BAD, "Cannot init drive.\n");
-	scgp->silent--;
-
-	if (flags & F_SETDROPTS) {
-		/*
-		 * Note that the set speed function also contains
-		 * drive option processing for speed related drive options.
-		 */
-		if ((*dp->cdr_opt1)(scgp, dp) < 0) {
-			errmsgno(EX_BAD, "Cannot set up 1st set of driver options.\n");
-		}
-		if ((*dp->cdr_set_speed_dummy)(scgp, dp, &speed) < 0) {
-			errmsgno(EX_BAD, "Cannot set speed/dummy.\n");
-		}
-		dp->cdr_dstat->ds_wspeed = speed; /* XXX Remove 'speed' in future */
-		if ((*dp->cdr_opt2)(scgp, dp) < 0) {
-			errmsgno(EX_BAD, "Cannot set up 2nd set of driver options.\n");
-		}
-		comexit(0);
-	}
-	/*
-	 * XXX If dp->cdr_opt1() ever affects the result for
-	 * XXX the multi session info we would need to move it here.
-	 */
-	if (flags & F_MSINFO) {
-		print_msinfo(scgp, dp);
-		comexit(0);
-	}
-	if (flags & F_TOC) {
-		print_toc(scgp, dp);
-		comexit(0);
-	}
-#ifdef	XXX
-	if ((*dp->cdr_check_session)() < 0) {
-		comexit(EX_BAD);
-	}
-#endif
-	{
-		Int32_t omb = dp->cdr_dstat->ds_maxblocks;
-
-		if ((*dp->cdr_opt1)(scgp, dp) < 0) {
-			errmsgno(EX_BAD, "Cannot set up 1st set of driver options.\n");
-		}
-		if (tsize > 0 && omb != dp->cdr_dstat->ds_maxblocks) {
-			printf("Disk size changed by user options.\n");
-			printf("Checking disk capacity according to new values.\n");
-		}
-	}
-	if (tsize == 0) {
-		if (tracks > 0) {
-			errmsgno(EX_BAD,
-			"WARNING: Total disk size unknown. Data may not fit on disk.\n");
-		}
-	} else if (tracks > 0) {
-		/*
-		 * XXX How do we let the user check the remaining
-		 * XXX disk size witout starting the write process?
-		 */
-		if (!checkdsize(scgp, dp, tsize, flags))
-			comexit(EX_BAD);
-	}
-	if (tracks > 0 && fs > 0l) {
-#if defined(USE_POSIX_PRIORITY_SCHEDULING) && defined(HAVE_SETREUID)
-		/*
-		 * Hack to work around the POSIX design bug in real time
-		 * priority handling: we need to be root even to lower
-		 * our priority.
-		 * Note that we need to find a more general way that works
-		 * even on OS that do not support getreuid() which is *BSD
-		 * and SUSv3 only.
-		 */
-		if (oeuid != getuid()) {
-			if (setreuid(-1, oeuid) < 0)
-				errmsg("Could set back effective uid.\n");
-		}
-
-#endif
-		/*
-		 * fork() here to start the extra process needed for
-		 * improved buffering.
-		 */
-		if (!init_faio(track, bufsize))
-			fs = 0L;
-		else
-			on_comerr(excdr, &exargs);
-
-    atexit(fifo_cleanup);
-
-#if defined(USE_POSIX_PRIORITY_SCHEDULING) && defined(HAVE_SETREUID)
-		/*
-		 * XXX Below this point we never need root privilleges anymore.
-		 */
-		if (geteuid() != getuid()) {	/* AIX does not like to do this */
-						/* If we are not root		*/
-			if (setreuid(-1, getuid()) < 0)
-				comerr("Panic cannot set back effective uid.\n");
-		}
-#ifdef __linux__
-		if (get_cap(CAP_SYS_RAWIO) && (debug || lverbose))
-			perror("Error: Cannot gain SYS_RAWIO capability, is wodim installed SUID root? Reason");
-#endif
-
-#endif
-	}
-	if ((*dp->cdr_set_speed_dummy)(scgp, dp, &speed) < 0) {
-		errmsgno(EX_BAD, "Cannot set speed/dummy.\n");
-		if ((flags & F_FORCE) == 0)
-			comexit(EX_BAD);
-	}
-	dp->cdr_dstat->ds_wspeed = speed; /* XXX Remove 'speed' in future */
-	if ((flags & F_WRITE) != 0 && raw_speed >= 0) {
-		int	max_raw = (flags & F_FORCE) != 0 ? raw_speed:raw_speed/2;
-
-		if (getenv("CDR_FORCERAWSPEED"))
-			max_raw = raw_speed;
-
-		for (i = 1; i <= MAX_TRACK; i++) {
-			/*
-			 * Check for Clone tracks
-			 */
-			if ((track[i].sectype & ST_MODE_RAW) != 0)
-				continue;
-			/*
-			 * Check for non-data tracks
-			 */
-			if ((track[i].sectype & ST_MODE_MASK) == ST_MODE_AUDIO)
-				continue;
-
-			if (speed > max_raw) {
-				errmsgno(EX_BAD,
-				"Processor too slow. Cannot write RAW data at speed %d.\n",
-				speed);
-				comerrno(EX_BAD, "Max RAW data speed on this processor is %d.\n",
-				max_raw);
-			}
-			break;
-		}
-	}
-	if (tracks > 0 && (flags & F_WRITE) != 0 && dma_speed > 0) {
-		int	max_dma = (flags & F_FORCE) != 0 ? dma_speed:(dma_speed+1)*4/5;
-
-		if (getenv("CDR_FORCESPEED"))
-			max_dma = dma_speed;
-
-		if (speed > max_dma) {
-			errmsgno(EX_BAD,
-			"DMA speed too slow (OK for %dx). Cannot write at speed %dx.\n",
-					max_dma, speed);
-			if ((dp->cdr_dstat->ds_cdrflags & RF_BURNFREE) == 0) {
-				errmsgno(EX_BAD, "Max DMA data speed is %d.\n", max_dma);
-				comerrno(EX_BAD, "Try to use 'driveropts=burnfree'.\n");
-			}
-		}
-	}
-	if ((flags & (F_WRITE|F_BLANK)) != 0 &&
-				(dp->cdr_dstat->ds_flags & DSF_ERA) != 0) {
-		if (xdebug) {
-			printf("Current speed %d, medium low speed: %d medium high speed: %d\n",
-				speed,
-				dp->cdr_dstat->ds_at_min_speed,
-				dp->cdr_dstat->ds_at_max_speed);
-		}
-		if (dp->cdr_dstat->ds_at_max_speed > 0 &&
-				speed <= 8 &&
-				speed > (int)dp->cdr_dstat->ds_at_max_speed) {
-			/*
-			 * Be careful here: 10x media may be written faster.
-			 * The current code will work as long as there is no
-			 * writer that can only write faster than 8x
-			 */
-			if ((flags & F_FORCE) == 0) {
-				errmsgno(EX_BAD,
-				"Write speed %d of medium not sufficient for this writer.\n",
-					dp->cdr_dstat->ds_at_max_speed);
-				comerrno(EX_BAD,
-				"You may have used an ultra low speed medium on a high speed writer.\n");
-			}
-		}
-
-		if ((dp->cdr_dstat->ds_flags & DSF_ULTRASPP_ERA) != 0 &&
-		    (speed < 16 || (dp->cdr_cdrw_support & CDR_CDRW_ULTRAP) == 0)) {
-			if ((dp->cdr_cdrw_support & CDR_CDRW_ULTRAP) == 0) {
-				comerrno(EX_BAD,
-				"Trying to use ultra high speed+ medium on a writer which is not\ncompatible with ultra high speed+ media.\n");
-			} else if ((flags & F_FORCE) == 0) {
-				comerrno(EX_BAD,
-				"Probably trying to use ultra high speed+ medium on improper writer.\n");
-			}
-		} else if ((dp->cdr_dstat->ds_flags & DSF_ULTRASP_ERA) != 0 &&
-		    (speed < 16 || (dp->cdr_cdrw_support & CDR_CDRW_ULTRA) == 0)) {
-			if ((dp->cdr_cdrw_support & CDR_CDRW_ULTRA) == 0) {
-				comerrno(EX_BAD,
-				"Trying to use ultra high speed medium on a writer which is not\ncompatible with ultra high speed media.\n");
-			} else if ((flags & F_FORCE) == 0) {
-				comerrno(EX_BAD,
-				"Probably trying to use ultra high speed medium on improper writer.\n");
-			}
-		}
-		if (dp->cdr_dstat->ds_at_min_speed >= 4 &&
-				dp->cdr_dstat->ds_at_max_speed > 4 &&
-				dp->cdr_dstat->ds_dr_max_wspeed <= 4) {
-			if ((flags & F_FORCE) == 0) {
-				comerrno(EX_BAD,
-				"Trying to use high speed medium on low speed writer.\n");
-			}
-		}
-		if ((int)dp->cdr_dstat->ds_at_min_speed > speed) {
-			if ((flags & F_FORCE) == 0) {
-				errmsgno(EX_BAD,
-				"Write speed %d of writer not sufficient for this medium.\n",
-					speed);
-				errmsgno(EX_BAD,
-				"You did use a %s speed medium on an improper writer or\n",
-				dp->cdr_dstat->ds_flags & DSF_ULTRASP_ERA ?
-				"ultra high": "high");
-				comerrno(EX_BAD,
-				"you used a speed=# option with a speed too low for this medium.\n");
-			}
-		}
-	}
-	if ((flags & (F_BLANK|F_FORCE)) == (F_BLANK|F_FORCE)) {
-		printf("Waiting for drive to calm down.\n");
-		wait_unit_ready(scgp, 120);
-		if (gracewait(dp, &gracedone) < 0) {
-			/*
-			 * In case kill() did not work ;-)
-			 */
-			errs++;
-			goto restore_it;
-		}
-		scsi_blank(scgp, 0L, blanktype, FALSE);
-	}
-
-	/*
-	 * Last chance to quit!
-	 */
-	if (gracewait(dp, &gracedone) < 0) {
-		/*
-		 * In case kill() did not work ;-)
-		 */
-		errs++;
-		goto restore_it;
-	}
- 	
- 	if (dp->profile == 0x2B && flags & F_SAO && tsize > 0) {
- 	    printf("Preparing middle zone location for this DVD+R dual layer disc\n");
- 	    if (!dp->cdr_layer_split(scgp, dp, tsize)) {
- 		errmsgno(EX_BAD, "Cannot send structure for middle zone location.\n");
- 		comexit(EX_BAD);
- 	    }
- 	}
-
-	if (tracks > 0 && fs > 0l) {
-		/*
-		 * Wait for the read-buffer to become full.
-		 * This should be take no extra time if the input is a file.
-		 * If the input is a pipe (e.g. mkisofs) this can take a
-		 * while. If mkisofs dumps core before it starts writing,
-		 * we abort before the writing process started.
-		 */
-		if (!await_faio()) {
-			comerrno(EX_BAD, "Input buffer error, aborting.\n");
-		}
-	}
-	wait_unit_ready(scgp, 120);
-
-	starttime.tv_sec = 0;
-	wstarttime.tv_sec = 0;
-	stoptime.tv_sec = 0;
-	fixtime.tv_sec = 0;
-	if (gettimeofday(&starttime, (struct timezone *)0) < 0)
-		errmsg("Cannot get start time\n");
-
-	/*
-	 * Blank the media if we were requested to do so
-	 */
-	if (flags & F_BLANK) {
-		/*
-		 * Do not abort if OPC failes. Just give it a chance
-		 * for better laser power calibration than without OPC.
-		 *
-		 * Ricoh drives return with a vendor unique sense code.
-		 * This is most likely because they refuse to do OPC
-		 * on a non blank media.
-		 */
-		scgp->silent++;
-		do_opc(scgp, dp, flags);
-		scgp->silent--;
-		wait_unit_ready(scgp, 120);
-		if (gettimeofday(&starttime, (struct timezone *)0) < 0)
-			errmsg("Cannot get start time\n");
-
-		if ((*dp->cdr_blank)(scgp, dp, 0L, blanktype) < 0) {
-			errmsgno(EX_BAD, "Cannot blank disk, aborting.\n");
-			if (blanktype != BLANK_DISC) {
-				errmsgno(EX_BAD, "Some drives do not support all blank types.\n");
-				errmsgno(EX_BAD, "Try again with wodim blank=all.\n");
-			}
-			comexit(EX_BAD);
-		}
-		if (gettimeofday(&fixtime, (struct timezone *)0) < 0)
-			errmsg("Cannot get blank time\n");
-		if (lverbose)
-			prtimediff("Blanking time: ", &starttime, &fixtime);
-
-		/*
-		 * XXX Erst blank und dann format?
-		 * XXX Wenn ja, dann hier (flags & F_FORMAT) testen
-		 */
-		if (!wait_unit_ready(scgp, 240) || tracks == 0) {
-			comexit(0);
-		}
-      if (flags & F_FORMAT) {
-         printf("wodim: media format asked\n");
-         /*
-          * Do not abort if OPC failes. Just give it a chance
-          * for better laser power calibration than without OPC.
-          *
-          * Ricoh drives return with a vendor unique sense code.
-          * This is most likely because they refuse to do OPC
-          * on a non blank media.
-          */
-         scgp->silent++;
-         do_opc(scgp, dp, flags);
-         scgp->silent--;
-         wait_unit_ready(scgp, 120);
-         if (gettimeofday(&starttime, (struct timezone *)0) < 0)
-            errmsg("Cannot get start time\n");
-
-         if ((*dp->cdr_format)(scgp, dp, formattype) < 0) {
-            errmsgno(EX_BAD, "Cannot format disk, aborting.\n");
-            comexit(EX_BAD);
-         }
-         if (gettimeofday(&fixtime, (struct timezone *)0) < 0)
-            errmsg("Cannot get format time\n");
-         if (lverbose)
-            prtimediff("Formatting time: ", &starttime, &fixtime);
-
-         if (!wait_unit_ready(scgp, 240) || tracks == 0) {
-            comexit(0);
-         }
-         if (gettimeofday(&starttime, (struct timezone *)0) < 0)
-            errmsg("Cannot get start time\n");
-      }
-		/*
-		 * Reset start time so we will not see blanking time and
-		 * writing time counted together.
-		 */
-		if (gettimeofday(&starttime, (struct timezone *)0) < 0)
-			errmsg("Cannot get start time\n");
-	}
-	if (tracks == 0 && (flags & F_FIX) == 0)
-		comerrno(EX_BAD, "No tracks found.\n");
-	/*
-	 * Get the number of the next recordable track by reading the TOC and
-	 * use the number the last current track number.
-	 */
-	scgp->silent++;
-	if (read_tochdr(scgp, dp, NULL, &trackno) < 0) {
-		trackno = 0;
-	}
-	scgp->silent--;
-      
-   /* If it is DVD, the information in TOC is fabricated :)
-   The real information is from read disk info command*/
-   if((dp->cdr_dstat->ds_disktype&DT_DVD) && (dp->cdr_dstat->ds_trlast>0)){
-      trackno=dp->cdr_dstat->ds_trlast-1;
-	  if (lverbose > 2)
-		  printf("trackno=%d\n",trackno);
-   }
-
-	if ((tracks + trackno) > MAX_TRACK) {
-		/*
-		 * XXX How many tracks are allowed on a DVD?
-		 */
-		comerrno(EX_BAD, "Too many tracks for this disk, last track number is %d.\n",
-				tracks + trackno);
-	}
-
-	for (i = 0; i <= tracks+1; i++) {	/* Lead-in ... Lead-out */
-		track[i].trackno = i + trackno;	/* Set up real track #	*/
-	}
-
-	if ((*dp->cdr_opt2)(scgp, dp) < 0) {
-		errmsgno(EX_BAD, "Cannot set up 2nd set of driver options.\n");
-	}
-
-	/*
-	 * Now we actually start writing to the CD/DVD.
-	 * XXX Check total size of the tracks and remaining size of disk.
-	 */
-	if ((*dp->cdr_open_session)(scgp, dp, track) < 0) {
-		comerrno(EX_BAD, "Cannot open new session.\n");
-	}
-	if (!do_opc(scgp, dp, flags))
-		comexit(EX_BAD);
-
-	/*
-	 * As long as open_session() will do nothing but
-	 * set up parameters, we may leave fix_it here.
-	 * I case we have to add an open_session() for a drive
-	 * that wants to do something that modifies the disk
-	 * We have to think about a new solution.
-	 */
-	if (flags & F_FIX)
-		goto fix_it;
-
-	/*
-	 * This call may modify trackp[i].trackstart for all tracks.
-	 */
-	if ((*dp->cdr_write_leadin)(scgp, dp, track) < 0)
-		comerrno(EX_BAD, "Could not write Lead-in.\n");
-
-	if (lverbose && (dp->cdr_dstat->ds_cdrflags & RF_LEADIN) != 0) {
-
-		if (gettimeofday(&fixtime, (struct timezone *)0) < 0)
-			errmsg("Cannot get lead-in write time\n");
-		prtimediff("Lead-in write time: ", &starttime, &fixtime);
-	}
-
-	if (gettimeofday(&wstarttime, (struct timezone *)0) < 0)
-		errmsg("Cannot get start time\n");
-	for (i = 1; i <= tracks; i++) {
-		startsec = 0L;
-
-		if ((*dp->cdr_open_track)(scgp, dp, &track[i]) < 0) {
-			errmsgno(EX_BAD, "Cannot open next track.\n");
-			errs++;
-			break;
-		}
-
-		if ((flags & (F_SAO|F_RAW)) == 0) {
-			if ((*dp->cdr_next_wr_address)(scgp, &track[i], &startsec) < 0) {
-				errmsgno(EX_BAD, "Cannot get next writable address.\n");
-				errs++;
-				break;
-			}
-			track[i].trackstart = startsec;
-		}
-		if (debug || lverbose) {
-			printf("Starting new track at sector: %ld\n",
-						track[i].trackstart);
-			flush();
-		}
-		if (write_track_data(scgp, dp, &track[i]) < 0) {
-			if (cdr_underrun(scgp)) {
-				errmsgno(EX_BAD,
-				"The current problem looks like a buffer underrun.\n");
-				if ((dp->cdr_dstat->ds_cdrflags & RF_BURNFREE) == 0)
-					errmsgno(EX_BAD,
-				"Try to use 'driveropts=burnfree'.\n");
-				else {
-					errmsgno(EX_BAD,
-				"It looks like 'driveropts=burnfree' does not work for this drive.\n");
-					errmsgno(EX_BAD, "Please report.\n");
-				}
-
-				errmsgno(EX_BAD,
-				"Make sure that you are root, enable DMA and check your HW/OS set up.\n");
-			} else {
-				errmsgno(EX_BAD, "A write error occured.\n");
-				errmsgno(EX_BAD, "Please properly read the error message above.\n");
-			}
-			errs++;
-			sleep(5);
-			unit_ready(scgp);
-			(*dp->cdr_close_track)(scgp, dp, &track[i]);
-			break;
-		}
-		if ((*dp->cdr_close_track)(scgp, dp, &track[i]) < 0) {
-			/*
-			 * Check for "Dummy blocks added" message first.
-			 */
-			if (scg_sense_key(scgp) != SC_ILLEGAL_REQUEST ||
-					scg_sense_code(scgp) != 0xB5) {
-				errmsgno(EX_BAD, "Cannot close track.\n");
-				errs++;
-				break;
-			}
-		}
-	}
-fix_it:
-	if (gettimeofday(&stoptime, (struct timezone *)0) < 0)
-		errmsg("Cannot get stop time\n");
-	cdrstats(dp);
-
-	if (flags & F_RAW) {
-		if (lverbose) {
-			printf("Writing Leadout...\n");
-			flush();
-		}
-		write_leadout(scgp, dp, track);
-	}
-	if ((flags & F_NOFIX) == 0) {
-		if (lverbose) {
-			printf("Fixating...\n");
-			flush();
-		}
-		if ((*dp->cdr_fixate)(scgp, dp, track) < 0) {
-			/*
-			 * Ignore fixating errors in dummy mode.
-			 */
-			if ((flags & F_DUMMY) == 0) {
-				errmsgno(EX_BAD, "Cannot fixate disk.\n");
-				errs++;
-			}
-		}
-		if (gettimeofday(&fixtime, (struct timezone *)0) < 0)
-			errmsg("Cannot get fix time\n");
-		if (lverbose)
-			prtimediff("Fixating time: ", &stoptime, &fixtime);
-	}
-	if ((dp->cdr_dstat->ds_cdrflags & RF_DID_CDRSTAT) == 0) {
-		dp->cdr_dstat->ds_cdrflags |= RF_DID_CDRSTAT;
-		(*dp->cdr_stats)(scgp, dp);
-	}
-	if ((flags & (F_RAW|F_EJECT)) == F_RAW) {
-		/*
-		 * Most drives seem to forget to reread the TOC from disk
-		 * if they are in RAW mode.
-		 */
-		scgp->silent++;
-		if (read_tochdr(scgp, dp, NULL, NULL) < 0) {
-			scgp->silent--;
-			if ((flags & F_DUMMY) == 0)
-				reload_media(scgp, dp);
-		} else {
-			scgp->silent--;
-		}
-	}
-
-restore_it:
-	/*
-	 * Try to restore the old sector size and stop FIFO.
-	 */
-	kill_faio();
-	comexit(errs?-2:0);
-	return (0);
-}
-
-static int 
-gracewait(cdr_t *dp, BOOL *didgracep)
-{
-	int	i;
-	BOOL	didgrace = FALSE;
-
-	if (didgracep)
-		didgrace = *didgracep;
-
-	if (gracetime < MIN_GRACE_TIME)
-		gracetime = MIN_GRACE_TIME;
-	if (gracetime > 999)
-		gracetime = 999;
-
-   printf("Starting to write CD/DVD at speed %5.1f in %s%s %s mode for %s session.\n",
-         (float)dp->cdr_dstat->ds_wspeed,
-		(dp->cdr_cmdflags & F_DUMMY) ? "dummy" : "real",
-		(dp->cdr_cmdflags & F_FORCE) ? " force" : "",
-		wm2name[dp->cdr_dstat->ds_wrmode],
-		(dp->cdr_cmdflags & F_MULTI) ? "multi" : "single");
-	if (didgrace) {
-		printf("No chance to quit anymore.");
-		goto grace_done;
-	}
-	printf("Last chance to quit, starting %s write in %d seconds.",
-		(dp->cdr_cmdflags & F_DUMMY)?"dummy":"real", gracetime);
-	flush();
-	signal(SIGINT, intr);
-	signal(SIGHUP, intr);
-	signal(SIGTERM, intr);
-
-	for (i = gracetime; --i >= 0; ) {
-		sleep(1);
-		if (didintr) {
-			printf("\n");
-			excdr(SIGINT, &exargs);
-			signal(SIGINT, SIG_DFL);
-			kill(getpid(), SIGINT);
-			/*
-			 * In case kill() did not work ;-)
-			 */
-			if (didgracep)
-				*didgracep = FALSE;
-			return (-1);
-		}
-		printf("\b\b\b\b\b\b\b\b\b\b\b\b\b%4d seconds.", i);
-		flush();
-	}
-grace_done:
-	printf(" Operation starts.");
-	flush();
-	signal(SIGINT, SIG_DFL);
-	signal(SIGHUP, SIG_DFL);
-	signal(SIGTERM, SIG_DFL);
-	signal(SIGINT, intfifo);
-	signal(SIGHUP, intfifo);
-	signal(SIGTERM, intfifo);
-	printf("\n");
-
-	if (didgracep)
-		*didgracep = TRUE;
-	return (0);
-}
-
-static void 
-cdrstats(cdr_t *dp)
-{
-	float	secsps = 75.0;
-	int	nsecs;
-	float	fspeed;
-	struct timeval	tcur;
-	struct timeval	tlast;
-	BOOL	nostop = FALSE;
-
-	if (starttime.tv_sec == 0)
-		return;
-
-	if (stoptime.tv_sec == 0) {
-		gettimeofday(&stoptime, (struct timezone *)0);
-		nostop = TRUE;
-	}
-
-	if ((dp->cdr_dstat->ds_cdrflags & RF_DID_STAT) != 0)
-		return;
-	dp->cdr_dstat->ds_cdrflags |= RF_DID_STAT;
-
-	if (lverbose == 0)
-		return;
-
-	if (dp->cdr_cmdflags & F_FIX)
-		return;
-
-	if ((dp->cdr_cmdflags & (F_WRITE|F_BLANK)) == F_BLANK)
-		return;
-
-	tlast = wstarttime;
-	tcur = stoptime;
-
-	prtimediff("Writing  time: ", &starttime, &stoptime);
-
-	nsecs = dp->cdr_dstat->ds_endsec - dp->cdr_dstat->ds_startsec;
-
-	if (dp->cdr_dstat->ds_flags & DSF_DVD)
-		secsps = 676.27;
-
-	tlast.tv_sec = tcur.tv_sec - tlast.tv_sec;
-	tlast.tv_usec = tcur.tv_usec - tlast.tv_usec;
-	while (tlast.tv_usec < 0) {
-		tlast.tv_usec += 1000000;
-		tlast.tv_sec -= 1;
-	}
-	if (!nostop && nsecs != 0 && dp->cdr_dstat->ds_endsec > 0) {
-		/*
-		 * May not be known (e.g. cdrecord -)
-		 *
-		 * XXX if we later allow this code to know how much has
-		 * XXX actually been written, then we may remove the
-		 * XXX dependance from nostop & nsecs != 0
-		 */
-		fspeed = (nsecs / secsps) /
-			(tlast.tv_sec * 1.0 + tlast.tv_usec * 0.000001);
-		if (fspeed > 999.0)
-			fspeed = 999.0;
-      if (dp->is_dvd) fspeed /= 9;
-		printf("Average write speed %5.1fx.\n", fspeed);
-	}
-
-	if (dp->cdr_dstat->ds_minbuf <= 100) {
-		printf("Min drive buffer fill was %u%%\n",
-			(unsigned int)dp->cdr_dstat->ds_minbuf);
-	}
-	if (dp->cdr_dstat->ds_buflow > 0) {
-		printf("Total of %ld possible drive buffer underruns predicted.\n",
-			(long)dp->cdr_dstat->ds_buflow);
-	}
-}
-
-/*
- * Short usage
- */
-static void
-susage(int ret)
-{
-	fprintf(stderr, "Usage: %s [options] track1...trackn\n", get_progname());
-	fprintf(stderr, "\nUse\t%s -help\n", get_progname());
-	fprintf(stderr, "to get a list of valid options.\n");
-	fprintf(stderr, "\nUse\t%s blank=help\n", get_progname());
-	fprintf(stderr, "to get a list of valid blanking options.\n");
-	fprintf(stderr, "\nUse\t%s dev=b,t,l driveropts=help -checkdrive\n", get_progname());
-	fprintf(stderr, "to get a list of drive specific options.\n");
-	fprintf(stderr, "\nUse\t%s dev=help\n", get_progname());
-	fprintf(stderr, "to get a list of possible SCSI transport specifiers.\n");
-	exit(ret);
-	/* NOTREACHED */
-}
-
-static void 
-usage(int excode)
-{
-	fprintf(stderr, "Usage: %s [options] track1...trackn\n", get_progname());
-	fprintf(stderr, "Options:\n");
-	fprintf(stderr, "\t-version	print version information and exit\n");
-	fprintf(stderr, "\tdev=target	SCSI target to use as CD/DVD-Recorder\n");
-	fprintf(stderr, "\tgracetime=#	set the grace time before starting to write to #.\n");
-	fprintf(stderr, "\ttimeout=#	set the default SCSI command timeout to #.\n");
-	fprintf(stderr, "\tdebug=#,-d	Set to # or increment misc debug level\n");
-	fprintf(stderr, "\tkdebug=#,kd=#	do Kernel debugging\n");
-	fprintf(stderr, "\t-verbose,-v	increment general verbose level by one\n");
-	fprintf(stderr, "\t-Verbose,-V	increment SCSI command transport verbose level by one\n");
-	fprintf(stderr, "\t-silent,-s	do not print status of failed SCSI commands\n");
-	fprintf(stderr, "\tdriver=name	user supplied driver name, use with extreme care\n");
-	fprintf(stderr, "\tdriveropts=opt	a comma separated list of driver specific options\n");
-	fprintf(stderr, "\t-setdropts	set driver specific options and exit\n");
-	fprintf(stderr, "\t-checkdrive	check if a driver for the drive is present\n");
-	fprintf(stderr, "\t-prcap		print drive capabilities for MMC compliant drives\n");
-	fprintf(stderr, "\t-inq		do an inquiry for the drive and exit\n");
- 	fprintf(stderr, "\t-scanbus	scan the SCSI and IDE buses and exit\n");
-	fprintf(stderr, "\t-reset		reset the SCSI bus with the cdrecorder (if possible)\n");
-	fprintf(stderr, "\t-abort		send an abort sequence to the drive (may help if hung)\n");
-	fprintf(stderr, "\t-overburn	allow to write more than the official size of a medium\n");
-	fprintf(stderr, "\t-ignsize	ignore the known size of a medium (may cause problems)\n");
-	fprintf(stderr, "\t-useinfo	use *.inf files to overwrite audio options.\n");
-	fprintf(stderr, "\tspeed=#		set speed of drive\n");
-	fprintf(stderr, "\tblank=type	blank a CD-RW disc (see blank=help)\n");
-	fprintf(stderr, "\t-format		format a CD-RW/DVD-RW/DVD+RW disc\n");
-   fprintf(stderr, "\tformattype=#	select the format method for DVD+RW disc\n");
-#ifdef	FIFO
-	fprintf(stderr, "\tfs=#		Set fifo size to # (0 to disable, default is %ld MB)\n",
-							DEFAULT_FIFOSIZE/(1024L*1024L));
-#endif
-	fprintf(stderr, "\tts=#		set maximum transfer size for a single SCSI command\n");
-	fprintf(stderr, "\t-load		load the disk and exit (works only with tray loader)\n");
-	fprintf(stderr, "\t-lock		load and lock the disk and exit (works only with tray loader)\n");
-	fprintf(stderr, "\t-eject		eject the disk after doing the work\n");
-	fprintf(stderr, "\t-dummy		do everything with laser turned off\n");
-	fprintf(stderr, "\t-msinfo		retrieve multi-session info for mkisofs >= 1.10\n");
-	fprintf(stderr, "\t-toc		retrieve and print TOC/PMA data\n");
-	fprintf(stderr, "\t-atip		retrieve and print ATIP data\n");
-	fprintf(stderr, "\t-multi		generate a TOC that allows multi session\n");
-	fprintf(stderr, "\t		In this case default track type is CD-ROM XA mode 2 form 1 - 2048 bytes\n");
-	fprintf(stderr, "\t-fix		fixate a corrupt or unfixated disk (generate a TOC)\n");
-	fprintf(stderr, "\t-nofix		do not fixate disk after writing tracks\n");
-	fprintf(stderr, "\t-waiti		wait until input is available before opening SCSI\n");
-	fprintf(stderr, "\t-immed		Try to use the SCSI IMMED flag with certain long lasting commands\n");
-	fprintf(stderr, "\t-force		force to continue on some errors to allow blanking bad disks\n");
-	fprintf(stderr, "\t-tao		Write disk in TAO mode. This option will be replaced in the future.\n");
-	fprintf(stderr, "\t-dao		Write disk in SAO mode. This option will be replaced in the future.\n");
-	fprintf(stderr, "\t-sao		Write disk in SAO mode. This option will be replaced in the future.\n");
-	fprintf(stderr, "\t-raw		Write disk in RAW mode. This option will be replaced in the future.\n");
-	fprintf(stderr, "\t-raw96r		Write disk in RAW/RAW96R mode. This option will be replaced in the future.\n");
-	fprintf(stderr, "\t-raw96p		Write disk in RAW/RAW96P mode. This option will be replaced in the future.\n");
-	fprintf(stderr, "\t-raw16		Write disk in RAW/RAW16 mode. This option will be replaced in the future.\n");
-#ifdef	CLONE_WRITE
-	fprintf(stderr, "\t-clone		Write disk in clone write mode.\n");
-#endif
-	fprintf(stderr, "\ttsize=#		Length of valid data in next track\n");
-	fprintf(stderr, "\tpadsize=#	Amount of padding for next track\n");
-	fprintf(stderr, "\tpregap=#	Amount of pre-gap sectors before next track\n");
-	fprintf(stderr, "\tdefpregap=#	Amount of pre-gap sectors for all but track #1\n");
-	fprintf(stderr, "\tmcn=text	Set the media catalog number for this CD to 'text'\n");
-	fprintf(stderr, "\tisrc=text	Set the ISRC number for the next track to 'text'\n");
-	fprintf(stderr, "\tindex=list	Set the index list for the next track to 'list'\n");
-	fprintf(stderr, "\t-text		Write CD-Text from information from *.inf or *.cue files\n");
-	fprintf(stderr, "\ttextfile=name	Set the file with CD-Text data to 'name'\n");
-	fprintf(stderr, "\tcuefile=name	Set the file with CDRWIN CUE data to 'name'\n");
-
-	fprintf(stderr, "\t-audio		Subsequent tracks are CD-DA audio tracks\n");
-	fprintf(stderr, "\t-data		Subsequent tracks are CD-ROM data mode 1 - 2048 bytes (default)\n");
-	fprintf(stderr, "\t-mode2		Subsequent tracks are CD-ROM data mode 2 - 2336 bytes\n");
-	fprintf(stderr, "\t-xa		Subsequent tracks are CD-ROM XA mode 2 form 1 - 2048 bytes\n");
-	fprintf(stderr, "\t-xa1		Subsequent tracks are CD-ROM XA mode 2 form 1 - 2056 bytes\n");
-	fprintf(stderr, "\t-xa2		Subsequent tracks are CD-ROM XA mode 2 form 2 - 2324 bytes\n");
-	fprintf(stderr, "\t-xamix		Subsequent tracks are CD-ROM XA mode 2 form 1/2 - 2332 bytes\n");
-	fprintf(stderr, "\t-cdi		Subsequent tracks are CDI tracks\n");
-	fprintf(stderr, "\t-isosize	Use iso9660 file system size for next data track\n");
-	fprintf(stderr, "\t-preemp		Audio tracks are mastered with 50/15 µs preemphasis\n");
-	fprintf(stderr, "\t-nopreemp	Audio tracks are mastered with no preemphasis (default)\n");
-	fprintf(stderr, "\t-copy		Audio tracks have unlimited copy permission\n");
-	fprintf(stderr, "\t-nocopy		Audio tracks may only be copied once for personal use (default)\n");
-	fprintf(stderr, "\t-scms		Audio tracks will not have any copy permission at all\n");
-	fprintf(stderr, "\t-pad		Pad data tracks with %d zeroed sectors\n", PAD_SECS);
-	fprintf(stderr, "\t		Pad audio tracks to a multiple of %d bytes\n", AUDIO_SEC_SIZE);
-	fprintf(stderr, "\t-nopad		Do not pad data tracks (default)\n");
-	fprintf(stderr, "\t-shorttrack	Subsequent tracks may be non Red Book < 4 seconds if in SAO or RAW mode\n");
-	fprintf(stderr, "\t-noshorttrack	Subsequent tracks must be >= 4 seconds\n");
-	fprintf(stderr, "\t-swab		Audio data source is byte-swapped (little-endian/Intel)\n");
-	fprintf(stderr, "The type of the first track is used for the toc type.\n");
-	fprintf(stderr, "Currently only form 1 tracks are supported.\n");
-	exit(excode);
-}
-
-static void 
-blusage(int ret)
-{
-	fprintf(stderr, "Blanking options:\n");
-	fprintf(stderr, "\tall\t\tblank the entire disk\n");
-	fprintf(stderr, "\tdisc\t\tblank the entire disk\n");
-	fprintf(stderr, "\tdisk\t\tblank the entire disk\n");
-	fprintf(stderr, "\tfast\t\tminimally blank the entire disk (PMA, TOC, pregap)\n");
-	fprintf(stderr, "\tminimal\t\tminimally blank the entire disk (PMA, TOC, pregap)\n");
-	fprintf(stderr, "\ttrack\t\tblank a track\n");
-	fprintf(stderr, "\tunreserve\tunreserve a track\n");
-	fprintf(stderr, "\ttrtail\t\tblank a track tail\n");
-	fprintf(stderr, "\tunclose\t\tunclose last session\n");
-	fprintf(stderr, "\tsession\t\tblank last session\n");
-
-	exit(ret);
-	/* NOTREACHED */
-}
-
-static void 
-formattypeusage(int ret)
-{
-	fprintf(stderr, "Formating options:\n");
-	fprintf(stderr, "\tfull\t\tstandard formating\n");
-	fprintf(stderr, "\tbackground\t\tbackground formating\n");
-	fprintf(stderr, "\tforce\t\tforce reformat\n");
-
-	exit(ret);
-	/* NOTREACHED */
-}
-
-/* ARGSUSED */
-static void
-intr(int sig)
-{
-	sig = 0;	/* Fake usage for gcc */
-
-	signal(SIGINT, intr);
-
-	didintr++;
-}
-
-static void 
-catchsig(int sig)
-{
-	signal(sig, catchsig);
-}
-
-static int 
-scsi_cb(void *arg)
-{
-	comexit(EX_BAD);
-	/* NOTREACHED */
-	return (0);	/* Keep lint happy */
-}
-
-static void 
-intfifo(int sig)
-{
-	errmsgno(EX_BAD, "Caught interrupt.\n");
-	if (exargs.scgp) {
-		SCSI	*scgp = exargs.scgp;
-
-		if (scgp->running) {
-			if (scgp->cb_fun != NULL) {
-				comerrno(EX_BAD, "Second interrupt. Doing hard abort.\n");
-				/* NOTREACHED */
-			}
-			scgp->cb_fun = scsi_cb;
-			scgp->cb_arg = &exargs;
-			return;
-		}
-	}
-	comexit(sig);
-}
-
-/* ARGSUSED */
-static void 
-exscsi(int excode, void *arg)
-{
-	struct exargs	*exp = (struct exargs *)arg;
-
-	/*
-	 * Try to restore the old sector size.
-	 */
-	if (exp != NULL && exp->exflags == 0) {
-		if (exp->scgp->running) {
-			return;
-		}
-		/*
-		 * flush cache is not supported by CD-ROMs avoid prob with -toc
-		 */
-		exp->scgp->silent++;
-		scsi_flush_cache(exp->scgp, FALSE);
-		(*exp->dp->cdr_abort_session)(exp->scgp, exp->dp);
-		exp->scgp->silent--;
-		set_secsize(exp->scgp, exp->old_secsize);
-		unload_media(exp->scgp, exp->dp, exp->flags);
-
-		exp->exflags++;	/* Make sure that it only get called once */
-	}
-}
-
-static void 
-excdr(int excode, void *arg)
-{
-	struct exargs	*exp = (struct exargs *)arg;
-
-	exscsi(excode, arg);
-
-	cdrstats(exp->dp);
-	if ((exp->dp->cdr_dstat->ds_cdrflags & RF_DID_CDRSTAT) == 0) {
-		exp->dp->cdr_dstat->ds_cdrflags |= RF_DID_CDRSTAT;
-		(*exp->dp->cdr_stats)(exp->scgp, exp->dp);
-	}
-
-#ifdef	FIFO
-	kill_faio();
-	wait_faio();
-	if (debug || lverbose)
-		fifo_stats();
-#endif
-}
-
-int 
-read_buf(int f, char *bp, int size)
-{
-	char	*p = bp;
-	int	amount = 0;
-	int	n;
-
-	do {
-		do {
-			n = read(f, p, size-amount);
-		} while (n < 0 && (geterrno() == EAGAIN || geterrno() == EINTR));
-		if (n < 0)
-			return (n);
-		amount += n;
-		p += n;
-
-	} while (amount < size && n > 0);
-	return (amount);
-}
-
-int 
-fill_buf(int f, track_t *trackp, long secno, char *bp, int size)
-{
-	int	amount = 0;
-	int	nsecs;
-	int	rsize;
-	int	rmod;
-	int	readoffset = 0;
-
-	nsecs = size / trackp->secsize;
-	if (nsecs < trackp->secspt) {
-		/*
-		 * Clear buffer to prepare for last transfer.
-		 * Make sure that a partial sector ends with NULs
-		 */
-		fillbytes(bp, trackp->secspt * trackp->secsize, '\0');
-	}
-
-	if (!is_raw(trackp)) {
-		amount = read_buf(f, bp, size);
-		if (amount != size) {
-			if (amount < 0)
-				return (amount);
-			/*
-			 * We got less than expected, clear rest of buf.
-			 */
-			fillbytes(&bp[amount], size-amount, '\0');
-		}
-		if (is_swab(trackp))
-			swabbytes(bp, amount);
-		return (amount);
-	}
-
-	rsize = nsecs * trackp->isecsize;
-	rmod  = size % trackp->secsize;
-	if (rmod > 0) {
-		rsize += rmod;
-		nsecs++;
-	}
-
-	readoffset = trackp->dataoff;
-	amount = read_buf(f, bp + readoffset, rsize);
-	if (is_swab(trackp))
-		swabbytes(bp + readoffset, amount);
-
-	if (trackp->isecsize == 2448 && trackp->secsize == 2368)
-		subrecodesecs(trackp, (Uchar *)bp, secno, nsecs);
-
-	scatter_secs(trackp, bp + readoffset, nsecs);
-
-	if (amount != rsize) {
-		if (amount < 0)
-			return (amount);
-		/*
-		 * We got less than expected, clear rest of buf.
-		 */
-		fillbytes(&bp[amount], rsize-amount, '\0');
-		nsecs = amount / trackp->isecsize;
-		rmod  = amount % trackp->isecsize;
-		amount = nsecs * trackp->secsize;
-		if (rmod > 0) {
-			nsecs++;
-			amount += rmod;
-		}
-	} else {
-		amount = size;
-	}
-	if ((trackp->sectype & ST_MODE_RAW) == 0) {
-		encsectors(trackp, (Uchar *)bp, secno, nsecs);
-		fillsubch(trackp, (Uchar *)bp, secno, nsecs);
-	} else {
-		scrsectors(trackp, (Uchar *)bp, secno, nsecs);
-	}
-	return (amount);
-}
-
-int 
-get_buf(int f, track_t *trackp, long secno, char **bpp, int size)
-{
-	if (fs > 0) {
-/*		return (faio_read_buf(f, *bpp, size));*/
-		return (faio_get_buf(f, bpp, size));
-	} else {
-		return (fill_buf(f, trackp, secno, *bpp, size));
-	}
-}
-
-int 
-write_secs(SCSI *scgp, cdr_t *dp, char *bp, long startsec, int bytespt, 
-        		int secspt, BOOL islast)
-{
-	int	amount;
-
-again:
-	scgp->silent++;
-	amount = (*dp->cdr_write_trackdata)(scgp, bp, startsec, bytespt, secspt, islast);
-	scgp->silent--;
-	if (amount < 0) {
-		if (scsi_in_progress(scgp)) {
-			/*
-			 * If we sleep too long, the drive buffer is empty
-			 * before we start filling it again. The max. CD speed
-			 * is ~ 10 MB/s (52x RAW writing). The max. DVD speed
-			 * is ~ 25 MB/s (18x DVD 1385 kB/s).
-			 * With 10 MB/s, a 1 MB buffer empties within 100ms.
-			 * With 25 MB/s, a 1 MB buffer empties within 40ms.
-			 */
-			if ((dp->cdr_dstat->ds_flags & DSF_DVD) == 0) {
-				usleep(60000);
-			} else {
-#ifndef	_SC_CLK_TCK
-				usleep(20000);
-#else
-				if (sysconf(_SC_CLK_TCK) < 100)
-					usleep(20000);
-				else
-					usleep(10000);
-
-#endif
-			}
-			goto again;
-		}
-		return (-1);
-	}
-	return (amount);
-}
-
-static int 
-write_track_data(SCSI *scgp, cdr_t *dp, track_t *trackp)
-{
-	int	track = trackp->trackno;
-	int	f = -1;
-	int	isaudio;
-	long	startsec;
-	Llong	bytes_read = 0;
-	Llong	bytes	= 0;
-	Llong	savbytes = 0;
-	int	count;
-	Llong	tracksize;
-	int	secsize;
-	int	secspt;
-	int	bytespt;
-	int	bytes_to_read;
-	long	amount;
-	int	pad;
-	BOOL	neednl	= FALSE;
-	BOOL	islast	= FALSE;
-	char	*bp	= buf;
-	struct timeval tlast;
-	struct timeval tcur;
-	float	secsps = 75.0;
-long bsize;
-long bfree;
-#define	BCAP
-#ifdef	BCAP
-int per = 0;
-#ifdef	XBCAP
-int oper = -1;
-#endif
-#endif
-
-	if (dp->cdr_dstat->ds_flags & DSF_DVD)
-		secsps = 676.27;
-
-	scgp->silent++;
-	if ((*dp->cdr_buffer_cap)(scgp, &bsize, &bfree) < 0)
-		bsize = -1L;
-	if (bsize == 0)		/* If we have no (known) buffer, we cannot */
-		bsize = -1L;	/* retrieve the buffer fill ratio	   */
-	scgp->silent--;
-
-
-	if (is_packet(trackp))	/* XXX Ugly hack for now */
-		return (write_packet_data(scgp, dp, trackp));
-
-	if (trackp->xfp != NULL)
-		f = xfileno(trackp->xfp);
-
-	isaudio = is_audio(trackp);
-	tracksize = trackp->tracksize;
-	startsec = trackp->trackstart;
-
-	secsize = trackp->secsize;
-	secspt = trackp->secspt;
-	bytespt = secsize * secspt;
-
-	pad = !isaudio && is_pad(trackp);	/* Pad only data tracks */
-
-	if (debug) {
-		printf("secsize:%d secspt:%d bytespt:%d audio:%d pad:%d\n",
-			secsize, secspt, bytespt, isaudio, pad);
-	}
-
-	if (lverbose) {
-		if (tracksize > 0)
-			printf("\rTrack %02d:    0 of %4lld MB written.",
-				track, tracksize >> 20);
-		else
-			printf("\rTrack %02d:    0 MB written.", track);
-		flush();
-		neednl = TRUE;
-	}
-
-	gettimeofday(&tlast, (struct timezone *)0);
-	do {
-		bytes_to_read = bytespt;
-		if (tracksize > 0) {
-			if ((tracksize - bytes_read) > bytespt)
-				bytes_to_read = bytespt;
-			else
-				bytes_to_read = tracksize - bytes_read;
-		}
-		count = get_buf(f, trackp, startsec, &bp, bytes_to_read);
-
-		if (count < 0)
-			comerr("read error on input file\n");
-		if (count == 0)
-			break;
-		bytes_read += count;
-		if (tracksize >= 0 && bytes_read >= tracksize) {
-			count -= bytes_read - tracksize;
-			/*
-			 * Paranoia: tracksize is known (trackp->tracksize >= 0)
-			 * At this point, trackp->padsize should alway be set
-			 * if the tracksize is less than 300 sectors.
-			 */
-			if (trackp->padsecs == 0 &&
-			    (is_shorttrk(trackp) || (bytes_read/secsize) >= 300))
-				islast = TRUE;
-		}
-
-		if (count < bytespt) {
-			if (debug) {
-				printf("\nNOTICE: reducing block size for last record.\n");
-				neednl = FALSE;
-			}
-
-			if ((amount = count % secsize) != 0) {
-				amount = secsize - amount;
-				count += amount;
-				printf("\nWARNING: padding up to secsize.\n");
-				neednl = FALSE;
-			}
-			bytespt = count;
-			secspt = count / secsize;
-			/*
-			 * If tracksize is not known (trackp->tracksize < 0)
-			 * we may need to set trackp->padsize
-			 * if the tracksize is less than 300 sectors.
-			 */
-			if (trackp->padsecs == 0 &&
-			    (is_shorttrk(trackp) || (bytes_read/secsize) >= 300))
-				islast = TRUE;
-		}
-
-		amount = write_secs(scgp, dp, bp, startsec, bytespt, secspt, islast);
-		if (amount < 0) {
-			printf("%swrite track data: error after %lld bytes\n",
-							neednl?"\n":"", bytes);
-			return (-1);
-		}
-		bytes += amount;
-		startsec += amount / secsize;
-
-		if (lverbose && (bytes >= (savbytes + 0x100000))) {
-			int	fper;
-			int	nsecs = (bytes - savbytes) / secsize;
-			float	fspeed;
-
-			gettimeofday(&tcur, (struct timezone *)0);
-			printf("\rTrack %02d: %4lld", track, bytes >> 20);
-			if (tracksize > 0)
-				printf(" of %4lld MB", tracksize >> 20);
-			else
-				printf(" MB");
-			printf(" written");
-			fper = fifo_percent(TRUE);
-			if (fper >= 0)
-				printf(" (fifo %3d%%)", fper);
-#ifdef	BCAP
-			if (bsize > 0) {			/* buffer size known */
-				scgp->silent++;
-				per = (*dp->cdr_buffer_cap)(scgp, (long *)0, &bfree);
-				scgp->silent--;
-				if (per >= 0) {
-					per = 100*(bsize - bfree) / bsize;
-					if ((bsize - bfree) <= amount || per <= 5)
-						dp->cdr_dstat->ds_buflow++;
-					if (per < (int)dp->cdr_dstat->ds_minbuf &&
-					    (startsec*secsize) > bsize) {
-						dp->cdr_dstat->ds_minbuf = per;
-					}
-					printf(" [buf %3d%%]", per);
-#ifdef	BCAPDBG
-					printf(" %3ld %3ld", bsize >> 10, bfree >> 10);
-#endif
-				}
-			}
-#endif
-
-			tlast.tv_sec = tcur.tv_sec - tlast.tv_sec;
-			tlast.tv_usec = tcur.tv_usec - tlast.tv_usec;
-			while (tlast.tv_usec < 0) {
-				tlast.tv_usec += 1000000;
-				tlast.tv_sec -= 1;
-			}
-			fspeed = (nsecs / secsps) /
-				(tlast.tv_sec * 1.0 + tlast.tv_usec * 0.000001);
-			if (fspeed > 999.0)
-				fspeed = 999.0;
-#ifdef	BCAP
-			if (bsize > 0 && per > dminbuf &&
-			    dp->cdr_dstat->ds_cdrflags & RF_WR_WAIT) {
-				int	wsecs = (per-dminbuf)*(bsize/secsize)/100;
-				int	msecs = 0x100000/secsize;
-				int	wt;
-				int	mt;
-				int	s = dp->cdr_dstat->ds_dr_cur_wspeed;
-
-
-				if (s <= 0) {
-					if (dp->cdr_dstat->ds_flags & DSF_DVD)
-						s = 4;
-					else
-						s = 50;
-				}
-				if (wsecs > msecs)	/* Less that 1 MB */
-					wsecs = msecs;
-				wt = wsecs * 1000 / secsps / fspeed;
-				mt = (per-dminbuf)*(bsize/secsize)/100 * 1000 / secsps/s;
-
-				if (wt > mt)
-					wt = mt;
-				if (wt > 1000)		/* Max 1 second */
-					wt = 1000;
-				if (wt < 20)		/* Min 20 ms */
-					wt = 0;
-
-				if (xdebug)
-					printf(" |%3d %4dms %5dms|", wsecs, wt, mt);
-				else
-					printf(" |%3d %4dms|", wsecs, wt);
-				if (wt > 0)
-					usleep(wt*1000);
-			}
-#endif
-         if (dp->is_dvd) fspeed /= 9;
-			printf(" %5.1fx", fspeed);
-			printf(".");
-			savbytes = (bytes >> 20) << 20;
-			flush();
-			neednl = TRUE;
-			tlast = tcur;
-		}
-#ifdef	XBCAP
-		if (bsize > 0) {			/* buffer size known */
-			(*dp->cdr_buffer_cap)(scgp, (long *)0, &bfree);
-			per = 100*(bsize - bfree) / bsize;
-			if (per != oper)
-				printf("[buf %3d%%] %3ld %3ld\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b",
-					per, bsize >> 10, bfree >> 10);
-			oper = per;
-			flush();
-		}
-
-
-#endif
-	} while (tracksize < 0 || bytes_read < tracksize);
-
-	if (!is_shorttrk(trackp) && (bytes / secsize) < 300) {
-		/*
-		 * If tracksize is not known (trackp->tracksize < 0) or
-		 * for some strange reason we did not set padsecs properly
-		 * we may need to modify trackp->padsecs if
-		 * tracksize+padsecs is less than 300 sectors.
-		 */
-		if ((trackp->padsecs + (bytes / secsize)) < 300)
-			trackp->padsecs = 300 - (bytes / secsize);
-	}
-	if (trackp->padsecs > 0) {
-		Llong	padbytes;
-
-		/*
-		 * pad_track() is based on secsize. Compute the amount of bytes
-		 * assumed by pad_track().
-		 */
-		padbytes = (Llong)trackp->padsecs * secsize;
-
-		if (neednl) {
-			printf("\n");
-			neednl = FALSE;
-		}
-		if ((padbytes >> 20) > 0) {
-			neednl = TRUE;
-		} else if (lverbose) {
-			printf("Track %02d: writing %3lld KB of pad data.\n",
-					track, (Llong)(padbytes >> 10));
-			neednl = FALSE;
-		}
-		pad_track(scgp, dp, trackp, startsec, padbytes,
-					TRUE, &savbytes);
-		bytes += savbytes;
-		startsec += savbytes / secsize;
-	}
-	printf("%sTrack %02d: Total bytes read/written: %lld/%lld (%lld sectors).\n",
-		neednl?"\n":"", track, bytes_read, bytes, bytes/secsize);
-	flush();
-	return (0);
-}
-
-int 
-pad_track(SCSI *scgp, cdr_t	*dp, track_t *trackp, long startsec, Llong amt,
-				BOOL dolast, Llong *bytesp)
-{
-	int	track = trackp->trackno;
-	Llong	bytes	= 0;
-	Llong	savbytes = 0;
-	Llong	padsize = amt;
-	int	secsize;
-	int	secspt;
-	int	bytespt;
-	int	amount;
-	BOOL	neednl	= FALSE;
-	BOOL	islast	= FALSE;
-	struct timeval tlast;
-	struct timeval tcur;
-	float	secsps = 75.0;
-long bsize;
-long bfree;
-#define	BCAP
-#ifdef	BCAP
-int per;
-#ifdef	XBCAP
-int oper = -1;
-#endif
-#endif
-
-	if (dp->cdr_dstat->ds_flags & DSF_DVD)
-		secsps = 676.27;
-
-	scgp->silent++;
-	if ((*dp->cdr_buffer_cap)(scgp, &bsize, &bfree) < 0)
-		bsize = -1L;
-	if (bsize == 0)		/* If we have no (known) buffer, we cannot */
-		bsize = -1L;	/* retrieve the buffer fill ratio	   */
-	scgp->silent--;
-
-	secsize = trackp->secsize;
-	secspt = trackp->secspt;
-	bytespt = secsize * secspt;
-
-	fillbytes(buf, bytespt, '\0');
-
-	if ((amt >> 20) > 0) {
-		printf("\rTrack %02d:    0 of %4lld MB pad written.",
-						track, amt >> 20);
-		flush();
-	}
-	gettimeofday(&tlast, (struct timezone *)0);
-	do {
-		if (amt < bytespt) {
-			bytespt = roundup(amt, secsize);
-			secspt = bytespt / secsize;
-		}
-		if (dolast && (amt - bytespt) <= 0)
-			islast = TRUE;
-
-		if (is_raw(trackp)) {
-			encsectors(trackp, (Uchar *)buf, startsec, secspt);
-			fillsubch(trackp, (Uchar *)buf, startsec, secspt);
-		}
-
-		amount = write_secs(scgp, dp, buf, startsec, bytespt, secspt, islast);
-		if (amount < 0) {
-			printf("%swrite track pad data: error after %lld bytes\n",
-							neednl?"\n":"", bytes);
-			if (bytesp)
-				*bytesp = bytes;
-(*dp->cdr_buffer_cap)(scgp, (long *)0, (long *)0);
-			return (-1);
-		}
-		amt -= amount;
-		bytes += amount;
-		startsec += amount / secsize;
-
-		if (lverbose && (bytes >= (savbytes + 0x100000))) {
-			int	nsecs = (bytes - savbytes) / secsize;
-			float	fspeed;
-
-			gettimeofday(&tcur, (struct timezone *)0);
-			printf("\rTrack %02d: %4lld", track, bytes >> 20);
-			if (padsize > 0)
-				printf(" of %4lld MB", padsize >> 20);
-			else
-				printf(" MB");
-			printf(" pad written");
-			savbytes = (bytes >> 20) << 20;
-
-#ifdef	BCAP
-			if (bsize > 0) {			/* buffer size known */
-				scgp->silent++;
-				per = (*dp->cdr_buffer_cap)(scgp, (long *)0, &bfree);
-				scgp->silent--;
-				if (per >= 0) {
-					per = 100*(bsize - bfree) / bsize;
-					if ((bsize - bfree) <= amount || per <= 5)
-						dp->cdr_dstat->ds_buflow++;
-					if (per < (int)dp->cdr_dstat->ds_minbuf &&
-					    (startsec*secsize) > bsize) {
-						dp->cdr_dstat->ds_minbuf = per;
-					}
-					printf(" [buf %3d%%]", per);
-#ifdef	BCAPDBG
-					printf(" %3ld %3ld", bsize >> 10, bfree >> 10);
-#endif
-				}
-			}
-#endif
-			tlast.tv_sec = tcur.tv_sec - tlast.tv_sec;
-			tlast.tv_usec = tcur.tv_usec - tlast.tv_usec;
-			while (tlast.tv_usec < 0) {
-				tlast.tv_usec += 1000000;
-				tlast.tv_sec -= 1;
-			}
-			fspeed = (nsecs / secsps) /
-				(tlast.tv_sec * 1.0 + tlast.tv_usec * 0.000001);
-			if (fspeed > 999.0)
-				fspeed = 999.0;
-			printf(" %5.1fx", fspeed);
-			printf(".");
-			flush();
-			neednl = TRUE;
-			tlast = tcur;
-		}
-	} while (amt > 0);
-
-	if (bytesp)
-		*bytesp = bytes;
-	if (bytes == 0)
-		return (0);
-	return (bytes > 0 ? 1:-1);
-}
-
-#ifdef	USE_WRITE_BUF
-int 
-write_buf(SCSI *scgp, cdr_t *dp, track_t *trackp, char *bp, long startsec, 
-        	  Llong amt, int secsize, BOOL dolast, Llong *bytesp)
-{
-	int	track = trackp->trackno;
-	Llong	bytes	= 0;
-	Llong	savbytes = 0;
-/*	int	secsize;*/
-	int	secspt;
-	int	bytespt;
-	int	amount;
-	BOOL	neednl	= FALSE;
-	BOOL	islast	= FALSE;
-
-/*	secsize = trackp->secsize;*/
-/*	secspt = trackp->secspt;*/
-
-	secspt = bufsize/secsize;
-	secspt = min(255, secspt);
-	bytespt = secsize * secspt;
-
-/*	fillbytes(buf, bytespt, '\0');*/
-
-	if ((amt >> 20) > 0) {
-		printf("\rTrack %02d:   0 of %4ld MB pad written.",
-						track, amt >> 20);
-		flush();
-	}
-	do {
-		if (amt < bytespt) {
-			bytespt = roundup(amt, secsize);
-			secspt = bytespt / secsize;
-		}
-		if (dolast && (amt - bytespt) <= 0)
-			islast = TRUE;
-
-		amount = write_secs(scgp, dp, bp, startsec, bytespt, secspt, islast);
-		if (amount < 0) {
-			printf("%swrite track data: error after %ld bytes\n",
-							neednl?"\n":"", bytes);
-			if (bytesp)
-				*bytesp = bytes;
-(*dp->cdr_buffer_cap)(scgp, (long *)0, (long *)0);
-			return (-1);
-		}
-		amt -= amount;
-		bytes += amount;
-		startsec += amount / secsize;
-
-		if (lverbose && (bytes >= (savbytes + 0x100000))) {
-			printf("\rTrack %02d: %3ld", track, bytes >> 20);
-			savbytes = (bytes >> 20) << 20;
-			flush();
-			neednl = TRUE;
-		}
-	} while (amt > 0);
-
-	if (bytesp)
-		*bytesp = bytes;
-	return (bytes);
-}
-#endif	/* USE_WRITE_BUF */
-
-static void 
-printdata(int track, track_t *trackp)
-{
-	if (trackp->itracksize >= 0) {
-		printf("Track %02d: data  %4lld MB        ",
-					track, (Llong)(trackp->itracksize >> 20));
-	} else {
-		printf("Track %02d: data  unknown length",
-					track);
-	}
-	if (trackp->padsecs > 0) {
-		Llong	padbytes = (Llong)trackp->padsecs * trackp->isecsize;
-
-		if ((padbytes >> 20) > 0)
-			printf(" padsize: %4lld MB", (Llong)(padbytes >> 20));
-		else
-			printf(" padsize: %4lld KB", (Llong)(padbytes >> 10));
-	}
-	if (trackp->pregapsize != (trackp->flags & TI_DVD)? 0 : 150) {
-		printf(" pregapsize: %3ld", trackp->pregapsize);
-	}
-	if (xdebug)
-		printf(" START: %ld SECTORS: %ld INDEX0 %ld",
-			trackp->trackstart, trackp->tracksecs, trackp->index0start);
-	printf("\n");
-}
-
-static void 
-printaudio(int track, track_t *trackp)
-{
-	if (trackp->itracksize >= 0) {
-		printf("Track %02d: audio %4lld MB (%02d:%02d.%02d) %spreemp%s%s",
-			track, (Llong)(trackp->itracksize >> 20),
-			minutes(trackp->itracksize),
-			seconds(trackp->itracksize),
-			hseconds(trackp->itracksize),
-			is_preemp(trackp) ? "" : "no ",
-			is_swab(trackp) ? " swab":"",
-			((trackp->itracksize < 300L*trackp->isecsize) ||
-			(trackp->itracksize % trackp->isecsize)) &&
-			is_pad(trackp) ? " pad" : "");
-	} else {
-		printf("Track %02d: audio unknown length    %spreemp%s%s",
-			track, is_preemp(trackp) ? "" : "no ",
-			is_swab(trackp) ? " swab":"",
-			(trackp->itracksize % trackp->isecsize) && is_pad(trackp) ? " pad" : "");
-	}
-	if (is_scms(trackp))
-		printf(" scms");
-	else if (is_copy(trackp))
-		printf(" copy");
-	else
-		printf("     ");
-
-	if (trackp->padsecs > 0) {
-		Llong	padbytes = (Llong)trackp->padsecs * trackp->isecsize;
-
-		if ((padbytes >> 20) > 0)
-			printf(" padsize: %4lld MB", (Llong)(padbytes >> 20));
-		else
-			printf(" padsize: %4lld KB", (Llong)(padbytes >> 10));
-		printf(" (%02d:%02d.%02d)",
-			Sminutes(trackp->padsecs),
-			Sseconds(trackp->padsecs),
-			Shseconds(trackp->padsecs));
-	}
-	if (trackp->pregapsize != ((trackp->flags & TI_DVD)? 0 : 150) || xdebug > 0) {
-		printf(" pregapsize: %3ld", trackp->pregapsize);
-	}
-	if (xdebug)
-		printf(" START: %ld SECTORS: %ld INDEX0 %ld",
-			trackp->trackstart, trackp->tracksecs, trackp->index0start);
-	printf("\n");
-}
-
-static void 
-checkfile(int track, track_t *trackp)
-{
-	if (trackp->itracksize > 0 &&
-			is_audio(trackp) &&
-			((!is_shorttrk(trackp) &&
-			(trackp->itracksize < 300L*trackp->isecsize)) ||
-			(trackp->itracksize % trackp->isecsize)) &&
-						!is_pad(trackp)) {
-		errmsgno(EX_BAD, "Bad audio track size %lld for track %02d.\n",
-				(Llong)trackp->itracksize, track);
-		errmsgno(EX_BAD, "Audio tracks must be at least %ld bytes and a multiple of %d.\n",
-				300L*trackp->isecsize, trackp->isecsize);
-
-		if (!is_shorttrk(trackp) && (trackp->itracksize < 300L*trackp->isecsize))
-			comerrno(EX_BAD, "See -shorttrack option.\n");
-		if (!is_pad(trackp) && (trackp->itracksize % trackp->isecsize))
-			comerrno(EX_BAD, "See -pad option.\n");
-	}
-
-	if (lverbose == 0 && xdebug == 0)
-		return;
-
-	if (is_audio(trackp))
-		printaudio(track, trackp);
-	else
-		printdata(track, trackp);
-}
-
-static int 
-checkfiles(int tracks, track_t *trackp)
-{
-	int	i;
-	int	isaudio = 1;
-	int	starttrack = 1;
-	int	endtrack = tracks;
-
-	if (xdebug) {
-		/*
-		 * Include Lead-in & Lead-out.
-		 */
-		starttrack--;
-		endtrack++;
-	}
-	for (i = starttrack; i <= endtrack; i++) {
-		if (!is_audio(&trackp[i]))
-			isaudio = 0;
-		if (xdebug)
-			printf("SECTYPE %X ", trackp[i].sectype);
-		checkfile(i, &trackp[i]);
-	}
-	return (isaudio);
-}
-
-static void 
-setleadinout(int tracks, track_t *trackp)
-{
-	/*
-	 * Set some values for track 0 (the lead-in)
-	 */
-	if (!is_clone(&trackp[0])) {
-		trackp[0].sectype = trackp[1].sectype;
-		trackp[0].dbtype  = trackp[1].dbtype;
-		trackp[0].dataoff = trackp[1].dataoff;
-
-		/*
-		 * XXX Which other flags should be copied to Track 0 ?
-		 */
-		if (is_audio(&trackp[1]))
-			trackp[0].flags |= TI_AUDIO;
-	}
-
-	/*
-	 * Set some values for track 0xAA (the lead-out)
-	 */
-	trackp[tracks+1].pregapsize = 0;
-	trackp[tracks+1].isecsize   = trackp[tracks].isecsize;
-	trackp[tracks+1].secsize    = trackp[tracks].secsize;
-
-	if (!is_clone(&trackp[0])) {
-		trackp[tracks+1].tracktype = trackp[tracks].tracktype;
-		trackp[tracks+1].sectype   = trackp[tracks].sectype;
-		trackp[tracks+1].dbtype    = trackp[tracks].dbtype;
-		trackp[tracks+1].dataoff   = trackp[tracks].dataoff;
-	}
-
-	trackp[tracks+1].flags = trackp[tracks].flags;
-}
-
-static void 
-setpregaps(int tracks, track_t *trackp)
-{
-	int	i;
-	int	sectype;
-	long	pregapsize;
-	track_t	*tp;
-
-	sectype = trackp[1].sectype;
-	sectype &= ST_MASK;
-
-	for (i = 1; i <= tracks; i++) {
-		tp = &trackp[i];
-		if (tp->pregapsize == -1L) {
-			tp->pregapsize = 150;		/* Default CD Pre GAP*/
-			if (trackp->flags & TI_DVD) {
-				tp->pregapsize = 0;
-			} else if (sectype != (tp->sectype & ST_MASK)) {
-				tp->pregapsize = 255;	/* Pre GAP is 255 */
-				tp->flags &= ~TI_PREGAP;
-			}
-		}
-		sectype = tp->sectype & ST_MASK;	/* Save old sectype */
-	}
-	trackp[tracks+1].pregapsize = 0;
-	trackp[tracks+1].index0start = 0;
-
-	for (i = 1; i <= tracks; i++) {
-		/*
-		 * index0start is set below tracksecks if this track contains
-		 * the pregap (index 0) of the next track.
-		 */
-		trackp[i].index0start = trackp[i].tracksecs;
-
-		pregapsize = trackp[i+1].pregapsize;
-		if (is_pregap(&trackp[i+1]) && pregapsize > 0)
-			trackp[i].index0start -= pregapsize;
-	}
-}
-
-/*
- * Check total size of the medium
- */
-static long 
-checktsize(int tracks, track_t *trackp)
-{
-	int	i;
-	Llong	curr;
-	Llong	total = -150;	/* CD track #1 pregap compensation */
-	Ullong	btotal;
-	track_t	*tp;
-
-	if (trackp->flags & TI_DVD)
-		total = 0;
-	for (i = 1; i <= tracks; i++) {
-		tp = &trackp[i];
-		if (!is_pregap(tp))
-			total += tp->pregapsize;
-
-		if (lverbose > 1) {
-			printf("track: %d start: %lld pregap: %ld\n",
-					i, total, tp->pregapsize);
-		}
-		tp->trackstart = total;
-		if (tp->itracksize >= 0) {
-			curr = (tp->itracksize + (tp->isecsize-1)) / tp->isecsize;
-			curr += tp->padsecs;
-			/*
-			 * Minimum track size is 4s
-			 */
-			if (!is_shorttrk(tp) && curr < 300)
-				curr = 300;
-			if ((trackp->flags & TI_DVD) == 0) {
-				/*
-				 * XXX Was passiert hier bei is_packet() ???
-				 */
-				if (is_tao(tp) && !is_audio(tp)) {
-					curr += 2;
-				}
-			}
-			total += curr;
-		} else if (is_sao(tp) || is_raw(tp)) {
-			errmsgno(EX_BAD, "Track %d has unknown length.\n", i);
-			comerrno(EX_BAD,
-			"Use tsize= option in %s mode to specify track size.\n",
-			is_sao(tp) ? "SAO" : "RAW");
-		}
-	}
-	tp = &trackp[i];
-	tp->trackstart = total;
-	tp->tracksecs = 6750;		/* Size of first session Lead-Out */
-	if (!lverbose)
-		return (total);
-
-	if (trackp->flags & TI_DVD)
-		btotal = (Ullong)total * 2048;
-	else
-		btotal = (Ullong)total * 2352;
-/* XXX CD Sector Size ??? */
-	if (tracks > 0) {
-		if (trackp->flags & TI_DVD) {
-			printf("Total size:     %4llu MB = %lld sectors\n",
-				btotal >> 20, total);
-		} else {
-			printf("Total size:     %4llu MB (%02d:%02d.%02d) = %lld sectors\n",
-				btotal >> 20,
-				minutes(btotal),
-				seconds(btotal),
-				hseconds(btotal), total);
-			btotal += 150 * 2352;
-			printf("Lout start:     %4llu MB (%02d:%02d/%02d) = %lld sectors\n",
-				btotal >> 20,
-				minutes(btotal),
-				seconds(btotal),
-				frames(btotal), total);
-		}
-	}
-	return (total);
-}
-
-static void 
-opentracks(track_t *trackp)
-{
-	track_t	*tp;
-	int	i;
-	int	tracks = trackp[0].tracks;
-
-	Llong	tracksize;
-	int	secsize;
-
-	for (i = 1; i <= tracks; i++) {
-		tp = &trackp[i];
-
-		if (auinfosize(tp->filename, tp)) {
-			/*
-			 * open stdin
-			 */
-			tp->xfp = xopen(NULL, O_RDONLY|O_BINARY, 0);
-		} else if (strcmp("-", tp->filename) == 0) {
-			/*
-			 * open stdin
-			 */
-			tp->xfp = xopen(NULL, O_RDONLY|O_BINARY, 0);
-		} else {
-			if ((tp->xfp = xopen(tp->filename,
-					O_RDONLY|O_BINARY, 0)) == NULL) {
-				comerr("Cannot open '%s'.\n", tp->filename);
-			}
-		}
-
-		checksize(tp);
-		tracksize = tp->itracksize;
-		secsize = tp->isecsize;
-		if (!is_shorttrk(tp) &&
-		    tracksize > 0 && (tracksize / secsize) < 300) {
-
-			tracksize = roundup(tracksize, secsize);
-			if ((tp->padsecs +
-			    (tracksize / secsize)) < 300) {
-				tp->padsecs =
-					300 - tracksize / secsize;
-			}
-			if (xdebug) {
-				printf("TRACK %d SECTORS: %ld",
-					i, tp->tracksecs);
-				printf(" pasdize %lld (%ld sectors)\n",
-					(Llong)tp->padsecs * secsize,
-					tp->padsecs);
-			}
-		}
-#ifdef	AUINFO
-		if (tp->flags & TI_USEINFO) {
-			auinfo(tp->filename, i, trackp);
-			if (lverbose > 0 && i == 1)
-				printf("pregap1: %ld\n", trackp[1].pregapsize);
-		}
-#endif
-		/*
-		 * tracksecks is total numbers of sectors in track (starting from
-		 * index 0).
-		 */
-		if (tp->padsecs > 0)
-			tp->tracksecs += tp->padsecs;
-
-		if (debug) {
-			printf("File: '%s' itracksize: %lld isecsize: %d tracktype: %d = %s sectype: %X = %s dbtype: %s flags %X\n",
-				tp->filename, (Llong)tp->itracksize,
-				tp->isecsize,
-				tp->tracktype & TOC_MASK, toc2name[tp->tracktype & TOC_MASK],
-				tp->sectype, st2name[tp->sectype & ST_MASK], db2name[tp->dbtype], tp->flags);
-		}
-	}
-}
-
-static void 
-checksize(track_t *trackp)
-{
-	struct stat	st;
-	Llong		lsize;
-	int		f = -1;
-
-	if (trackp->xfp != NULL)
-		f = xfileno(trackp->xfp);
-
-	/*
-	 * If the current input file is a regular file and
-	 * 'padsize=' has not been specified,
-	 * use fstat() or file parser to get the size of the file.
-	 */
-	if (trackp->itracksize < 0 && (trackp->flags & TI_ISOSIZE) != 0) {
-		lsize = isosize(f);
-		trackp->itracksize = lsize;
-		if (trackp->itracksize != lsize)
-			comerrno(EX_BAD, "This OS cannot handle large ISO-9660 images.\n");
-	}
-	if (trackp->itracksize < 0 && (trackp->flags & TI_NOAUHDR) == 0) {
-		lsize = ausize(f);
-		trackp->itracksize = lsize;
-		if (trackp->itracksize != lsize)
-			comerrno(EX_BAD, "This OS cannot handle large audio images.\n");
-	}
-	if (trackp->itracksize < 0 && (trackp->flags & TI_NOAUHDR) == 0) {
-		lsize = wavsize(f);
-		trackp->itracksize = lsize;
-		if (trackp->itracksize != lsize)
-			comerrno(EX_BAD, "This OS cannot handle large WAV images.\n");
-		if (trackp->itracksize > 0)	/* Force little endian input */
-			trackp->flags |= TI_SWAB;
-	}
-	if (trackp->itracksize == AU_BAD_CODING) {
-		comerrno(EX_BAD, "Inappropriate audio coding in '%s'.\n",
-							trackp->filename);
-	}
-	if (trackp->itracksize < 0 &&
-			fstat(f, &st) >= 0 && S_ISREG(st.st_mode)) {
-		trackp->itracksize = st.st_size;
-	}
-	if (trackp->itracksize >= 0) {
-		/*
-		 * We do not allow cdrecord to start if itracksize is not
-		 * a multiple of isecsize or we are allowed to pad to secsize via -pad.
-		 * For this reason, we may safely always assume padding.
-		 */
-		trackp->tracksecs = (trackp->itracksize + trackp->isecsize -1) / trackp->isecsize;
-		trackp->tracksize = (trackp->itracksize / trackp->isecsize) * trackp->secsize
-					+ trackp->itracksize % trackp->isecsize;
-	} else {
-		trackp->tracksecs = -1L;
-	}
-}
-
-static BOOL 
-checkdsize(SCSI *scgp, cdr_t *dp, long tsize, int flags)
-{
-	long	startsec = 0L;
-	long	endsec = 0L;
-	dstat_t	*dsp = dp->cdr_dstat;
-	int	profile;
-
-	scgp->silent++;
-	(*dp->cdr_next_wr_address)(scgp, (track_t *)0, &startsec);
-	scgp->silent--;
-
-	/*
-	 * This only should happen when the drive is currently in SAO mode.
-	 * We rely on the drive being in TAO mode, a negative value for
-	 * startsec is not correct here it may be caused by bad firmware or
-	 * by a drive in SAO mode. In SAO mode the drive will report the
-	 * pre-gap as part of the writable area.
-	 */
-	if (startsec < 0)
-		startsec = 0;
-
-	/*
-	 * Size limitations (sectors) for CD's:
-	 *
-	 *		404850 == 90 min	Red book calls this the
-	 *					first negative time
-	 *					allows lead out start up to
-	 *					block 404700
-	 *
-	 *		449850 == 100 min	This is the first time that
-	 *					is no more representable
-	 *					in a two digit BCD number.
-	 *					allows lead out start up to
-	 *					block 449700
-	 *
-	 *		~540000 == 120 min	The largest CD ever made.
-	 *
-	 *		~650000 == 1.3 GB	a Double Density (DD) CD.
-	 */
-
-	endsec = startsec + tsize;
-	dsp->ds_startsec = startsec;
-	dsp->ds_endsec = endsec;
-
-
-	if (dsp->ds_maxblocks > 0) {
-		/*
-		 * dsp->ds_maxblocks > 0 (disk capacity is known).
-		 */
-		if (lverbose)
-			printf("Blocks total: %ld Blocks current: %ld Blocks remaining: %ld\n",
-					(long)dsp->ds_maxblocks,
-					(long)dsp->ds_maxblocks - startsec,
-					(long)dsp->ds_maxblocks - endsec);
-
-		if (endsec > dsp->ds_maxblocks) {
-			if (dsp->ds_flags & DSF_DVD) {	/* A DVD and not a CD */
-				/*
-				 * There is no overburning on DVD...
-				 */
-				errmsgno(EX_BAD,
-				"Data does not fit on current disk.\n");
-				goto toolarge;
-			}
-			errmsgno(EX_BAD,
-			"WARNING: Data may not fit on current disk.\n");
-
-			/* XXX Check for flags & CDR_NO_LOLIMIT */
-/*			goto toolarge;*/
-		}
-		if (lverbose && dsp->ds_maxrblocks > 0)
-			printf("RBlocks total: %ld RBlocks current: %ld RBlocks remaining: %ld\n",
-					(long)dsp->ds_maxrblocks,
-					(long)dsp->ds_maxrblocks - startsec,
-					(long)dsp->ds_maxrblocks - endsec);
-		if (dsp->ds_maxrblocks > 0 && endsec > dsp->ds_maxrblocks) {
-			errmsgno(EX_BAD,
-			"Data does not fit on current disk.\n");
-			goto toolarge;
-		}
-		if ((endsec > dsp->ds_maxblocks && endsec > 404700) ||
-		    (dsp->ds_maxrblocks > 404700 && 449850 > dsp->ds_maxrblocks)) {
-			/*
-			 * Assume that this must be a CD and not a DVD.
-			 * So this is a non Red Book compliant CD with a
-			 * capacity between 90 and 99 minutes.
-			 */
-			if (dsp->ds_maxrblocks > 404700)
-				printf("RedBook total: %ld RedBook current: %ld RedBook remaining: %ld\n",
-					404700L,
-					404700L - startsec,
-					404700L - endsec);
-			if (endsec > dsp->ds_maxblocks && endsec > 404700) {
-				if ((flags & (F_IGNSIZE|F_FORCE)) == 0) {
-					errmsgno(EX_BAD,
-					"Notice: Most recorders cannot write CD's >= 90 minutes.\n");
-					errmsgno(EX_BAD,
-					"Notice: Use -ignsize option to allow >= 90 minutes.\n");
-				}
-				goto toolarge;
-			}
-		}
-	} else {
-		/*
-		 * dsp->ds_maxblocks == 0 (disk capacity is unknown).
-		 */
-	        profile = dp->profile;
-	        if (endsec >= (4200000)) {
-		        errmsgno(EX_BAD,
-			"ERROR: Could not manage to find medium size, and more than 8.0 GB of data.\n");
-  		        goto toolarge;  
-		} else if (profile != 0x2B) { 
-		    if (endsec >= (2300000)) {
-			errmsgno(EX_BAD,
-				"ERROR: Could not manage to find medium size, and more than 4.3 GB of data for a non dual layer disc.\n");
-			goto toolarge;
-		    } else if (endsec >= (405000-300)) {            /*<90 min disk or DVD*/
-			errmsgno(EX_BAD,
-				"WARNING: Could not manage to find medium size, and more than 90 mins of data.\n");
-		    } else if (endsec >= (333000-150)) {		/* 74 min disk*/
-			errmsgno(EX_BAD,
-				"WARNING: Data may not fit on standard 74min disk.\n");
-		    }
-		}
-	}
-	if (dsp->ds_maxblocks <= 0 || endsec <= dsp->ds_maxblocks)
-		return (TRUE);
-	/* FALLTHROUGH */
-toolarge:
-	if (dsp->ds_maxblocks > 0 && endsec > dsp->ds_maxblocks) {
-		if ((flags & (F_OVERBURN|F_IGNSIZE|F_FORCE)) != 0) {
-			if (dsp->ds_flags & DSF_DVD) {	/* A DVD and not a CD */
-				errmsgno(EX_BAD,
-				"Notice: -overburn is not expected to work with DVD media.\n");
-			}
-			errmsgno(EX_BAD,
-				"Notice: Overburning active. Trying to write more than the official disk capacity.\n");
-			return (TRUE);
-		} else {
-			if ((dsp->ds_flags & DSF_DVD) == 0) {	/* A CD and not a DVD */
-				errmsgno(EX_BAD,
-				"Notice: Use -overburn option to write more than the official disk capacity.\n");
-				errmsgno(EX_BAD,
-				"Notice: Most CD-writers do overburning only on SAO or RAW mode.\n");
-			}
-			return (FALSE);
-		}
-	}
-	if (dsp->ds_maxblocks < 449850) {
-		if ((dsp->ds_flags & DSF_DVD) == 0) {	/* A CD and not a DVD */
-			if (endsec <= dsp->ds_maxblocks)
-				return (TRUE);
-			errmsgno(EX_BAD, "Cannot write more than remaining DVD capacity.\n");
-			return (FALSE);
-		}
-		/*
-		 * Assume that this must be a CD and not a DVD.
-		 */
-		if (endsec > 449700) {
-			errmsgno(EX_BAD, "Cannot write CD's >= 100 minutes.\n");
-			return (FALSE);
-		}
-	}
-	if ((flags & (F_IGNSIZE|F_FORCE)) != 0)
-		return (TRUE);
-	return (FALSE);
-}
-
-static void 
-raise_fdlim()
-{
-#ifdef	RLIMIT_NOFILE
-
-	struct rlimit	rlim;
-
-	/*
-	 * Set max # of file descriptors to be able to hold all files open
-	 */
-	getrlimit(RLIMIT_NOFILE, &rlim);
-	if (rlim.rlim_cur >= (MAX_TRACK + 10))
-		return;
-
-	rlim.rlim_cur = MAX_TRACK + 10;
-	if (rlim.rlim_cur > rlim.rlim_max)
-		errmsgno(EX_BAD,
-			"Warning: low file descriptor limit (%lld)\n",
-						(Llong)rlim.rlim_max);
-	setrlimit(RLIMIT_NOFILE, &rlim);
-
-#endif	/* RLIMIT_NOFILE */
-}
-
-static void 
-raise_memlock()
-{
-#ifdef	RLIMIT_MEMLOCK
-	struct rlimit rlim;
-
-	rlim.rlim_cur = rlim.rlim_max = RLIM_INFINITY;
-
-	if (setrlimit(RLIMIT_MEMLOCK, &rlim) < 0)
-		errmsg("Warning: Cannot raise RLIMIT_MEMLOCK limits.");
-#endif	/* RLIMIT_MEMLOCK */
-}
-
-char	*opts =
-"help,version,checkdrive,prcap,inq,scanbus,reset,abort,overburn,ignsize,useinfo,dev*,timeout#,driver*,driveropts*,setdropts,tsize&,padsize&,pregap&,defpregap&,speed#,load,lock,eject,dummy,msinfo,toc,atip,multi,fix,nofix,waiti,immed,debug#,d+,kdebug#,kd#,verbose+,v+,Verbose+,V+,x+,xd#,silent,s,audio,data,mode2,xa,xa1,xa2,xamix,cdi,isosize,nopreemp,preemp,nocopy,copy,nopad,pad,swab,fs&,ts&,blank&,format,formattype&,pktsize#,packet,noclose,force,tao,dao,sao,raw,raw96r,raw96p,raw16,clone,scms,isrc*,mcn*,index*,cuefile*,textfile*,text,shorttrack,noshorttrack,gracetime#,minbuf#";
-
-/*
- * Defines used to find whether a write mode has been specified.
- */
-#define	M_TAO		1	/* Track at Once mode */
-#define	M_SAO		2	/* Session at Once mode (also known as DAO) */
-#define	M_RAW		4	/* Raw mode */
-#define	M_PACKET	8	/* Packed mode */
-static int 
-gargs(int ac, char **av, int *tracksp, track_t *trackp, char **devp, 
-		int *timeoutp, cdr_t **dpp, int *speedp, long *flagsp, int *blankp, 
-		int *formatp)
-{
-	int	cac;
-	char	* const*cav;
-	char	*driver = NULL;
-	char	*dev = NULL;
-	char	*isrc = NULL;
-	char	*mcn = NULL;
-	char	*tindex = NULL;
-	char	*cuefile = NULL;
-	char	*textfile = NULL;
-	long	bltype = -1;
-	int	doformat = 0;
-	int	formattype = -1;
-	Llong	tracksize;
-	Llong	padsize;
-	long	pregapsize;
-	long	defpregap = -1L;
-	int	pktsize;
-	int	speed = -1;
-	int	help = 0;
-	int	version = 0;
-	int	checkdrive = 0;
-	int	setdropts = 0;
-	int	prcap = 0;
-	int	inq = 0;
-	int	scanbus = 0;
-	int	reset = 0;
-	int	doabort = 0;
-	int	overburn = 0;
-	int	ignsize = 0;
-	int	useinfo = 0;
-	int	load = 0;
-	int	lock = 0;
-	int	eject = 0;
-	int	dummy = 0;
-	int	msinfo = 0;
-	int	toc = 0;
-	int	atip = 0;
-	int	multi = 0;
-	int	fix = 0;
-	int	nofix = 0;
-	int	waiti = 0;
-	int	immed = 0;
-	int	audio;
-	int	autoaudio = 0;
-	int	data;
-	int	mode2;
-	int	xa;
-	int	xa1;
-	int	xa2;
-	int	xamix;
-	int	cdi;
-	int	isize;
-	int	ispacket = 0;
-	int	noclose = 0;
-	int	force = 0;
-	int	tao = 0;
-	int	dao = 0;
-	int	raw = 0;
-	int	raw96r = 0;
-	int	raw96p = 0;
-	int	raw16 = 0;
-	int	clone = 0;
-	int	scms = 0;
-	int	preemp = 0;
-	int	nopreemp;
-	int	copy = 0;
-	int	nocopy;
-	int	pad = 0;
-	int	bswab = 0;
-	int	nopad;
-	int	usetext = 0;
-	int	shorttrack = 0;
-	int	noshorttrack;
-	int	flags;
-	int	tracks = *tracksp;
-	int	tracktype = TOC_ROM;
-/*	int	sectype = ST_ROM_MODE1 | ST_MODE_1;*/
-	int	sectype = SECT_ROM;
-	int	dbtype = DB_ROM_MODE1;
-	int	secsize = DATA_SEC_SIZE;
-	int	dataoff = 16;
-	int	ga_ret;
-	int	wm = 0;
-
-	trackp[0].flags |= TI_TAO;
-	trackp[1].pregapsize = -1;
-	*flagsp |= F_WRITE;
-
-	cac = --ac;
-	cav = ++av;
-	for (; ; cac--, cav++) {
-		tracksize = (Llong)-1L;
-		padsize = (Llong)0L;
-		pregapsize = defpregap;
-		audio = data = mode2 = xa = xa1 = xa2 = xamix = cdi = 0;
-		isize = nopreemp = nocopy = nopad = noshorttrack = 0;
-		pktsize = 0;
-		isrc = NULL;
-		tindex = NULL;
-		/*
-		 * Get options up to next file type arg.
-		 */
-		if ((ga_ret = getargs(&cac, &cav, opts,
-				&help, &version, &checkdrive, &prcap,
-				&inq, &scanbus, &reset, &doabort, &overburn, &ignsize,
-				&useinfo,
-				devp, timeoutp, &driver, &driveropts, &setdropts,
-				getllnum, &tracksize,
-				getllnum, &padsize,
-				getnum, &pregapsize,
-				getnum, &defpregap,
-				&speed,
-				&load, &lock,
-				&eject, &dummy, &msinfo, &toc, &atip,
-				&multi, &fix, &nofix, &waiti, &immed,
-				&debug, &debug,
-				&kdebug, &kdebug,
-				&lverbose, &lverbose,
-				&scsi_verbose, &scsi_verbose,
-				&xdebug, &xdebug,
-				&silent, &silent,
-				&audio, &data, &mode2,
-				&xa, &xa1, &xa2, &xamix, &cdi,
-				&isize,
-				&nopreemp, &preemp,
-				&nocopy, &copy,
-				&nopad, &pad, &bswab, getnum, &fs, getnum, &bufsize,
-				getbltype, &bltype, &doformat, getformattype, &formattype, &pktsize,
-				&ispacket, &noclose, &force,
-				&tao, &dao, &dao, &raw, &raw96r, &raw96p, &raw16,
-				&clone,
-				&scms, &isrc, &mcn, &tindex,
-				&cuefile, &textfile, &usetext,
-				&shorttrack, &noshorttrack,
-				&gracetime, &dminbuf)) < 0) {
-			errmsgno(EX_BAD, "Bad Option: %s.\n", cav[0]);
-			susage(EX_BAD);
-		}
-		if (help)
-			usage(0);
-		if (tracks == 0) {
-			if (driver)
-				set_cdrcmds(driver, dpp);
-			if (version)
-				*flagsp |= F_VERSION;
-			if (checkdrive)
-				*flagsp |= F_CHECKDRIVE;
-			if (prcap)
-				*flagsp |= F_PRCAP;
-			if (inq)
-				*flagsp |= F_INQUIRY;
-			if (scanbus)
-				*flagsp |= F_SCANBUS;
-			if (reset)
-				*flagsp |= F_RESET;
-			if (doabort)
-				*flagsp |= F_ABORT;
-			if (overburn)
-				*flagsp |= F_OVERBURN;
-			if (ignsize)
-				*flagsp |= F_IGNSIZE;
-			if (load)
-				*flagsp |= F_LOAD;
-			if (lock)
-				*flagsp |= F_DLCK;
-			if (eject)
-				*flagsp |= F_EJECT;
-			if (dummy)
-				*flagsp |= F_DUMMY;
-			if (setdropts)
-				*flagsp |= F_SETDROPTS;
-			if (msinfo)
-				*flagsp |= F_MSINFO;
-			if (toc) {
-				*flagsp |= F_TOC;
-				*flagsp &= ~F_WRITE;
-			}
-			if (atip) {
-				*flagsp |= F_PRATIP;
-				*flagsp &= ~F_WRITE;
-			}
-			if (multi) {
-				/*
-				 * 2048 Bytes user data
-				 */
-				*flagsp |= F_MULTI;
-				tracktype = TOC_XA2;
-				sectype = ST_ROM_MODE2 | ST_MODE_2_FORM_1;
-				sectype = SECT_MODE_2_F1;
-				dbtype = DB_XA_MODE2;	/* XXX -multi nimmt DB_XA_MODE2_F1 !!! */
-				secsize = DATA_SEC_SIZE;	/* 2048 */
-				dataoff = 24;
-			}
-			if (fix)
-				*flagsp |= F_FIX;
-			if (nofix)
-				*flagsp |= F_NOFIX;
-			if (waiti)
-				*flagsp |= F_WAITI;
-			if (immed)
-				*flagsp |= F_IMMED;
-			if (force)
-				*flagsp |= F_FORCE;
-
-			if (bltype >= 0) {
-				*flagsp |= F_BLANK;
-				*blankp = bltype;
-			}
- 			if (doformat > 0) {
- 				*flagsp |= F_FORMAT;
- 				*formatp |= FULL_FORMAT;
- 			}
- 			if (formattype >= 0) {
- 				*flagsp |= F_FORMAT;
- 				*formatp |= formattype;
- 			}
-			if (ispacket)
-				wm |= M_PACKET;
-			if (tao)
-				wm |= M_TAO;
-			if (dao) {
-				*flagsp |= F_SAO;
-				trackp[0].flags &= ~TI_TAO;
-				trackp[0].flags |= TI_SAO;
-				wm |= M_SAO;
-
-			} else if ((raw == 0) && (raw96r + raw96p + raw16) > 0)
-				raw = 1;
-			if ((raw != 0) && (raw96r + raw96p + raw16) == 0)
-				raw96r = 1;
-			if (raw96r) {
-				if (!dao)
-					*flagsp |= F_RAW;
-				trackp[0].flags &= ~TI_TAO;
-				trackp[0].flags |= TI_RAW;
-				trackp[0].flags |= TI_RAW96R;
-				wm |= M_RAW;
-			}
-			if (raw96p) {
-				if (!dao)
-					*flagsp |= F_RAW;
-				trackp[0].flags &= ~TI_TAO;
-				trackp[0].flags |= TI_RAW;
-				wm |= M_RAW;
-			}
-			if (raw16) {
-				if (!dao)
-					*flagsp |= F_RAW;
-				trackp[0].flags &= ~TI_TAO;
-				trackp[0].flags |= TI_RAW;
-				trackp[0].flags |= TI_RAW16;
-				wm |= M_RAW;
-			}
-			if (mcn) {
-#ifdef	AUINFO
-				setmcn(mcn, &trackp[0]);
-#else
-				trackp[0].isrc = malloc(16);
-				fillbytes(trackp[0].isrc, 16, '\0');
-				strncpy(trackp[0].isrc, mcn, 13);
-#endif
-				mcn = NULL;
-			}
-			if ((raw96r + raw96p + raw16) > 1) {
-				errmsgno(EX_BAD, "Too many raw modes.\n");
-				comerrno(EX_BAD, "Only one of -raw16, -raw96p, -raw96r allowed.\n");
-			}
-			if ((tao + ispacket + dao + raw) > 1) {
-				errmsgno(EX_BAD, "Too many write modes.\n");
-				comerrno(EX_BAD, "Only one of -packet, -dao, -raw allowed.\n");
-			}
-			if (dao && (raw96r + raw96p + raw16) > 0) {
-				if (raw16)
-					comerrno(EX_BAD, "SAO RAW writing does not allow -raw16.\n");
-				if (!clone)
-					comerrno(EX_BAD, "SAO RAW writing only makes sense in clone mode.\n");
-#ifndef	CLONE_WRITE
-				comerrno(EX_BAD, "SAO RAW writing not yet implemented.\n");
-#endif
-				comerrno(EX_BAD, "SAO RAW writing not yet implemented.\n");
-			}
-			if (clone) {
-				*flagsp |= F_CLONE;
-				trackp[0].flags |= TI_CLONE;
-#ifndef	CLONE_WRITE
-				comerrno(EX_BAD, "Clone writing not compiled in.\n");
-#endif
-			}
-			if (textfile) {
-				if (!checktextfile(textfile)) {
-					if ((*flagsp & F_WRITE) != 0) {
-						comerrno(EX_BAD,
-							"Cannot use '%s' as CD-Text file.\n",
-							textfile);
-					}
-				}
-				if ((*flagsp & F_WRITE) != 0) {
-					if ((dao + raw96r + raw96p) == 0)
-						comerrno(EX_BAD,
-							"CD-Text needs -dao, -raw96r or -raw96p.\n");
-				}
-				trackp[0].flags |= TI_TEXT;
-			}
-			version = checkdrive = prcap = inq = scanbus = reset = doabort =
-			overburn = ignsize =
-			load = lock = eject = dummy = msinfo = toc = atip = multi = fix = nofix =
-			waiti = immed = force = dao = setdropts = 0;
-			raw96r = raw96p = raw16 = clone = 0;
-		} else if ((version + checkdrive + prcap + inq + scanbus +
-			    reset + doabort + overburn + ignsize +
-			    load + lock + eject + dummy + msinfo + toc + atip + multi + fix + nofix +
-			    waiti + immed + force + dao + setdropts +
-			    raw96r + raw96p + raw16 + clone) > 0 ||
-				mcn != NULL)
-			comerrno(EX_BAD, "Badly placed option. Global options must be before any track.\n");
-
-		if (nopreemp)
-			preemp = 0;
-		if (nocopy)
-			copy = 0;
-		if (nopad)
-			pad = 0;
-		if (noshorttrack)
-			shorttrack = 0;
-
-		if ((audio + data + mode2 + xa + xa1 + xa2 + xamix) > 1) {
-			errmsgno(EX_BAD, "Too many types for track %d.\n", tracks+1);
-			comerrno(EX_BAD, "Only one of -audio, -data, -mode2, -xa, -xa1, -xa2, -xamix allowed.\n");
-		}
-		if (ispacket && audio) {
-			comerrno(EX_BAD, "Audio data cannot be written in packet mode.\n");
-		}
-		/*
-		 * Check whether the next argument is a file type arg.
-		 * If this is true, then we got a track file name.
-		 * If getargs() did previously return NOTAFLAG, we may have hit
-		 * an argument that has been escaped via "--", so we may not
-		 * call getfiles() again in this case. If we would call
-		 * getfiles() and the current arg has been escaped and looks
-		 * like an option, a call to getfiles() would skip it.
-		 */
-		if (ga_ret != NOTAFLAG)
-			ga_ret = getfiles(&cac, &cav, opts);
-		if (autoaudio) {
-			autoaudio = 0;
-			tracktype = TOC_ROM;
-			sectype = ST_ROM_MODE1 | ST_MODE_1;
-			sectype = SECT_ROM;
-			dbtype = DB_ROM_MODE1;
-			secsize = DATA_SEC_SIZE;	/* 2048 */
-			dataoff = 16;
-		}
-		if (ga_ret == NOTAFLAG && (is_auname(cav[0]) || is_wavname(cav[0]))) {
-			/*
-			 * We got a track and autodetection decided that it
-			 * is an audio track.
-			 */
-			autoaudio++;
-			audio++;
-		}
-		if (data) {
-			/*
-			 * 2048 Bytes user data
-			 */
-			tracktype = TOC_ROM;
-			sectype = ST_ROM_MODE1 | ST_MODE_1;
-			sectype = SECT_ROM;
-			dbtype = DB_ROM_MODE1;
-			secsize = DATA_SEC_SIZE;	/* 2048 */
-			dataoff = 16;
-		}
-		if (mode2) {
-			/*
-			 * 2336 Bytes user data
-			 */
-			tracktype = TOC_ROM;
-			sectype = ST_ROM_MODE2 | ST_MODE_2;
-			sectype = SECT_MODE_2;
-			dbtype = DB_ROM_MODE2;
-			secsize = MODE2_SEC_SIZE;	/* 2336 */
-			dataoff = 16;
-		}
-		if (audio) {
-			/*
-			 * 2352 Bytes user data
-			 */
-			tracktype = TOC_DA;
-			sectype = preemp ? ST_AUDIO_PRE : ST_AUDIO_NOPRE;
-			sectype |= ST_MODE_AUDIO;
-			sectype = SECT_AUDIO;
-			if (preemp)
-				sectype |= ST_PREEMPMASK;
-			dbtype = DB_RAW;
-			secsize = AUDIO_SEC_SIZE;	/* 2352 */
-			dataoff = 0;
-		}
-		if (xa) {
-			/*
-			 * 2048 Bytes user data
-			 */
-			if (tracktype != TOC_CDI)
-				tracktype = TOC_XA2;
-			sectype = ST_ROM_MODE2 | ST_MODE_2_FORM_1;
-			sectype = SECT_MODE_2_F1;
-			dbtype = DB_XA_MODE2;
-			secsize = DATA_SEC_SIZE;	/* 2048 */
-			dataoff = 24;
-		}
-		if (xa1) {
-			/*
-			 * 8 Bytes subheader + 2048 Bytes user data
-			 */
-			if (tracktype != TOC_CDI)
-				tracktype = TOC_XA2;
-			sectype = ST_ROM_MODE2 | ST_MODE_2_FORM_1;
-			sectype = SECT_MODE_2_F1;
-			dbtype = DB_XA_MODE2_F1;
-			secsize = 2056;
-			dataoff = 16;
-		}
-		if (xa2) {
-			/*
-			 * 2324 Bytes user data
-			 */
-			if (tracktype != TOC_CDI)
-				tracktype = TOC_XA2;
-			sectype = ST_ROM_MODE2 | ST_MODE_2_FORM_2;
-			sectype = SECT_MODE_2_F2;
-			dbtype = DB_XA_MODE2_F2;
-			secsize = 2324;
-			dataoff = 24;
-		}
-		if (xamix) {
-			/*
-			 * 8 Bytes subheader + 2324 Bytes user data
-			 */
-			if (tracktype != TOC_CDI)
-				tracktype = TOC_XA2;
-			sectype = ST_ROM_MODE2 | ST_MODE_2_MIXED;
-			sectype = SECT_MODE_2_MIX;
-			dbtype = DB_XA_MODE2_MIX;
-			secsize = 2332;
-			dataoff = 16;
-		}
-		if (cdi) {
-			tracktype = TOC_CDI;
-		}
-		if (tracks == 0) {
-			trackp[0].tracktype = tracktype;
-			trackp[0].dbtype = dbtype;
-			trackp[0].isecsize = secsize;
-			trackp[0].secsize = secsize;
-			if ((*flagsp & F_RAW) != 0) {
-				trackp[0].secsize = is_raw16(&trackp[0]) ?
-						RAW16_SEC_SIZE:RAW96_SEC_SIZE;
-			}
-			if ((*flagsp & F_DUMMY) != 0)
-				trackp[0].tracktype |= TOCF_DUMMY;
-			if ((*flagsp & F_MULTI) != 0)
-				trackp[0].tracktype |= TOCF_MULTI;
-		}
-
-		flags = trackp[0].flags;
-
-		if ((sectype & ST_AUDIOMASK) != 0)
-			flags |= TI_AUDIO;
-		if (isize) {
-			flags |= TI_ISOSIZE;
-			if ((*flagsp & F_MULTI) != 0)
-				comerrno(EX_BAD, "Cannot get isosize for multi session disks.\n");
-			/*
-			 * As we do not get the padding from the ISO-9660
-			 * formatting utility, we need to force padding here.
-			 */
-			flags |= TI_PAD;
-			if (padsize == (Llong)0L)
-				padsize = (Llong)PAD_SIZE;
-		}
-
-		if ((flags & TI_AUDIO) != 0) {
-			if (preemp)
-				flags |= TI_PREEMP;
-			if (copy)
-				flags |= TI_COPY;
-			if (scms)
-				flags |= TI_SCMS;
-		}
-		if (pad || ((flags & TI_AUDIO) == 0 && padsize > (Llong)0L)) {
-			flags |= TI_PAD;
-			if ((flags & TI_AUDIO) == 0 && padsize == (Llong)0L)
-				padsize = (Llong)PAD_SIZE;
-		}
-		if (shorttrack && (*flagsp & (F_SAO|F_RAW)) != 0)
-			flags |= TI_SHORT_TRACK;
-		if (noshorttrack)
-			flags &= ~TI_SHORT_TRACK;
-		if (bswab)
-			flags |= TI_SWAB;
-		if (ispacket) {
-			flags |= TI_PACKET;
-			trackp[0].flags &= ~TI_TAO;
-		}
-		if (noclose)
-			flags |= TI_NOCLOSE;
-		if (useinfo)
-			flags |= TI_USEINFO;
-
-		if (ga_ret == NOARGS) {
-			/*
-			 * All options have already been parsed and no more
-			 * file type arguments are present.
-			 */
-			break;
-		}
-		if (tracks == 0 && (wm == 0)) {
-			errmsgno(EX_BAD, "No write mode specified.\n");
-			errmsgno(EX_BAD, "Asuming -tao mode.\n");
-			errmsgno(EX_BAD, "Future versions of wodim may have different drive dependent defaults.\n");
-			tao = 1;
-		}
-		tracks++;
-
-		if (tracks > MAX_TRACK)
-			comerrno(EX_BAD, "Track limit (%d) exceeded\n",
-								MAX_TRACK);
-		/*
-		 * Make 'tracks' immediately usable in track structure.
-		 */
-		{	register int i;
-			for (i = 0; i < MAX_TRACK+2; i++)
-				trackp[i].tracks = tracks;
-		}
-
-		if (strcmp("-", cav[0]) == 0)
-			*flagsp |= F_STDIN;
-
-		if (!is_auname(cav[0]) && !is_wavname(cav[0]))
-			flags |= TI_NOAUHDR;
-
-		if ((*flagsp & (F_SAO|F_RAW)) != 0 && (flags & TI_AUDIO) != 0)
-			flags |= TI_PREGAP;	/* Hack for now */
-		if (tracks == 1)
-			flags &= ~TI_PREGAP;
-
-		if (tracks == 1 && (pregapsize != -1L && pregapsize != 150))
-			pregapsize = -1L;
-		trackp[tracks].filename = cav[0];
-		trackp[tracks].trackstart = 0L;
-		trackp[tracks].itracksize = tracksize;
-		trackp[tracks].tracksize = tracksize;
-		trackp[tracks].tracksecs = -1L;
-		if (tracksize >= 0)
-			trackp[tracks].tracksecs = (tracksize+secsize-1)/secsize;
-		if (trackp[tracks].pregapsize < 0)
-			trackp[tracks].pregapsize = pregapsize;
-		trackp[tracks+1].pregapsize = -1;
-		trackp[tracks].padsecs = (padsize+2047)/2048;
-		trackp[tracks].isecsize = secsize;
-		trackp[tracks].secsize = secsize;
-		trackp[tracks].flags = flags;
-		/*
-		 * XXX Dies ist falsch: auch bei SAO/RAW kann
-		 * XXX secsize != isecsize sein.
-		 */
-		if ((*flagsp & F_RAW) != 0) {
-			if (is_raw16(&trackp[tracks]))
-				trackp[tracks].secsize = RAW16_SEC_SIZE;
-			else
-				trackp[tracks].secsize = RAW96_SEC_SIZE;
-#ifndef	HAVE_LIB_EDC_ECC
-			if ((sectype & ST_MODE_MASK) != ST_MODE_AUDIO) {
-				errmsgno(EX_BAD,
-					"EDC/ECC library not compiled in.\n");
-				comerrno(EX_BAD,
-					"Data sectors are not supported in RAW mode.\n");
-			}
-#endif
-		}
-		trackp[tracks].secspt = 0;	/* transfer size is set up in set_trsizes() */
-		trackp[tracks].pktsize = pktsize;
-		trackp[tracks].trackno = tracks;
-		trackp[tracks].sectype = sectype;
-#ifdef	CLONE_WRITE
-		if ((*flagsp & F_CLONE) != 0) {
-			trackp[tracks].isecsize = 2448;
-			trackp[tracks].sectype |= ST_MODE_RAW;
-			dataoff = 0;
-		}
-#endif
-		trackp[tracks].dataoff = dataoff;
-		trackp[tracks].tracktype = tracktype;
-		trackp[tracks].dbtype = dbtype;
-		trackp[tracks].flags = flags;
-		trackp[tracks].nindex = 1;
-		trackp[tracks].tindex = 0;
-		if (isrc) {
-#ifdef	AUINFO
-			setisrc(isrc, &trackp[tracks]);
-#else
-			trackp[tracks].isrc = malloc(16);
-			fillbytes(trackp[tracks].isrc, 16, '\0');
-			strncpy(trackp[tracks].isrc, isrc, 12);
-#endif
-		}
-		if (tindex) {
-#ifdef	AUINFO
-			setindex(tindex, &trackp[tracks]);
-#endif
-		}
-	}
-
-	if (dminbuf >= 0) {
-		if (dminbuf < 25 || dminbuf > 95)
-			comerrno(EX_BAD,
-			"Bad minbuf=%d option (must be between 25 and 95)\n",
-				dminbuf);
-	}
-
-	if (speed < 0 && speed != -1)
-		comerrno(EX_BAD, "Bad speed option.\n");
-
-	if (fs < 0L && fs != -1L)
-		comerrno(EX_BAD, "Bad fifo size option.\n");
-
-	if (bufsize < 0L && bufsize != -1L)
-		comerrno(EX_BAD, "Bad transfer size option.\n");
-	if (bufsize < 0L)
-		bufsize = CDR_BUF_SIZE;
-	if (bufsize > CDR_MAX_BUF_SIZE)
-		bufsize = CDR_MAX_BUF_SIZE;
-
-	dev = *devp;
-	cdr_defaults(&dev, &speed, &fs, &driveropts);
-	if (debug) {
-		printf("dev: '%s' speed: %d fs: %ld driveropts '%s'\n",
-					dev, speed, fs, driveropts);
-	}
-	if (speed >= 0)
-		*speedp = speed;
-
-	if (fs < 0L)
-		fs = DEFAULT_FIFOSIZE;
-	if (fs < 2*bufsize) {
-		errmsgno(EX_BAD, "Fifo size %ld too small, turning fifo off.\n", fs);
-		fs = 0L;
-	}
-
-	if (dev != *devp && (*flagsp & F_SCANBUS) == 0)
-		*devp = dev;
-
-	if (!*devp && (*flagsp & (F_VERSION|F_SCANBUS)) == 0) {
-		errmsgno(EX_BAD, "No CD/DVD-Recorder device specified.\n");
-		susage(EX_BAD);
-	}
-	if (*devp &&
-	    ((strncmp(*devp, "HELP", 4) == 0) ||
-	    (strncmp(*devp, "help", 4) == 0))) {
-		*flagsp |= F_CHECKDRIVE; /* Set this for not calling mlockall() */
-		return ispacket;
-	}
-	if (*flagsp & (F_LOAD|F_DLCK|F_SETDROPTS|F_MSINFO|F_TOC|F_PRATIP|F_FIX|F_VERSION|F_CHECKDRIVE|F_PRCAP|F_INQUIRY|F_SCANBUS|F_RESET|F_ABORT)) {
-		if (tracks != 0) {
-			errmsgno(EX_BAD, "No tracks allowed with this option\n");
-			susage(EX_BAD);
-		}
-		return ispacket;
-	}
-	*tracksp = tracks;
-	if (*flagsp & F_SAO) {
-		/*
-		 * Make sure that you change WRITER_MAXWAIT & READER_MAXWAIT
-		 * too if you change this timeout.
-		 */
-		if (*timeoutp < 200)		/* Lead in size is 2:30 */
-			*timeoutp = 200;	/* 200s is 150s *1.33	*/
-	}
-	if (usetext) {
-		trackp[MAX_TRACK+1].flags |= TI_TEXT;
-	}
-	if (cuefile) {
-#ifdef	FUTURE
-		if ((*flagsp & F_SAO) == 0 &&
-		    (*flagsp & F_RAW) == 0) {
-#else
-		if ((*flagsp & F_SAO) == 0) {
-#endif
-			errmsgno(EX_BAD, "The cuefile= option only works with -dao.\n");
-			susage(EX_BAD);
-		}
-		if (tracks > 0) {
-			errmsgno(EX_BAD, "No tracks allowed with the cuefile= option\n");
-			susage(EX_BAD);
-		}
-		cuefilename = cuefile;
-		return ispacket;
-	}
-	if (tracks == 0 && (*flagsp & (F_LOAD|F_DLCK|F_EJECT|F_BLANK|F_FORMAT)) == 0) {
-		errmsgno(EX_BAD, "No tracks specified. Need at least one.\n");
-		susage(EX_BAD);
-	}
-	return ispacket;
-}
-
-static void 
-set_trsizes(cdr_t *dp, int tracks, track_t *trackp)
-{
-	int	i;
-	int	secsize;
-	int	secspt;
-
-	trackp[1].flags		|= TI_FIRST;
-	trackp[tracks].flags	|= TI_LAST;
-
-	if (xdebug)
-		printf("Set Transfersizes start\n");
-	for (i = 0; i <= tracks+1; i++) {
-		if ((dp->cdr_flags & CDR_SWABAUDIO) != 0 &&
-					is_audio(&trackp[i])) {
-			trackp[i].flags ^= TI_SWAB;
-		}
-		if (!is_audio(&trackp[i]))
-			trackp[i].flags &= ~TI_SWAB;	/* Only swab audio  */
-
-		/*
-		 * Use the biggest sector size to compute how many
-		 * sectors may fit into one single DMA buffer.
-		 */
-		secsize = trackp[i].secsize;
-		if (trackp[i].isecsize > secsize)
-			secsize = trackp[i].isecsize;
-
-		/*
-		 * We are using SCSI Group 0 write
-		 * and cannot write more than 255 secs at once.
-		 */
-		secspt = bufsize/secsize;
-		secspt = min(255, secspt);
-		trackp[i].secspt = secspt;
-
-		if (is_packet(&trackp[i]) && trackp[i].pktsize > 0) {
-			if (trackp[i].secspt >= trackp[i].pktsize) {
-				trackp[i].secspt = trackp[i].pktsize;
-			} else {
-				comerrno(EX_BAD,
-					"Track %d packet size %d exceeds buffer limit of %d sectors",
-					i, trackp[i].pktsize, trackp[i].secspt);
-			}
-		}
-		if (xdebug) {
-			printf("Track %d flags %X secspt %d secsize: %d isecsize: %d\n",
-				i, trackp[i].flags, trackp[i].secspt,
-				trackp[i].secsize, trackp[i].isecsize);
-		}
-	}
-	if (xdebug)
-		printf("Set Transfersizes end\n");
-}
-
-void 
-load_media(SCSI *scgp, cdr_t *dp, BOOL doexit)
-{
-	int	code;
-	int	key;
-	BOOL	immed = (dp->cdr_cmdflags&F_IMMED) != 0;
-
-	/*
-	 * Do some preparation before...
-	 */
-	scgp->silent++;			/* Be quiet if this fails		*/
-	test_unit_ready(scgp);		/* First eat up unit attention		*/
-	if ((*dp->cdr_load)(scgp, dp) < 0) {	/* now try to load media and	*/
-		if (!doexit)
-			return;
-		comerrno(EX_BAD, "Cannot load media.\n");
-	}
-	scsi_start_stop_unit(scgp, 1, 0, immed); /* start unit in silent mode	*/
-	scgp->silent--;
-
-	if (!wait_unit_ready(scgp, 60)) {
-		code = scg_sense_code(scgp);
-		key = scg_sense_key(scgp);
-		scgp->silent++;
-		scsi_prevent_removal(scgp, 0); /* In case someone locked it */
-		scgp->silent--;
-
-		if (!doexit)
-			return;
-		if (key == SC_NOT_READY && (code == 0x3A || code == 0x30))
-			comerrno(EX_BAD, "No disk / Wrong disk!\n");
-		comerrno(EX_BAD, "CD/DVD-Recorder not ready.\n");
-	}
-
-	scsi_prevent_removal(scgp, 1);
-	scsi_start_stop_unit(scgp, 1, 0, immed);
-	wait_unit_ready(scgp, 120);
-	scgp->silent++;
-	if(geteuid() == 0) /* EB: needed? Not allowed for non-root, that is sure. */
-      rezero_unit(scgp);	/* Is this needed? Not supported by some drvives */
-	scgp->silent--;
-	test_unit_ready(scgp);
-	scsi_start_stop_unit(scgp, 1, 0, immed);
-	wait_unit_ready(scgp, 120);
-}
-
-void 
-unload_media(SCSI *scgp, cdr_t *dp, int flags)
-{
-	scsi_prevent_removal(scgp, 0);
-	if ((flags & F_EJECT) != 0) {
-		if ((*dp->cdr_unload)(scgp, dp) < 0)
-			errmsgno(EX_BAD, "Cannot eject media.\n");
-	}
-}
-
-void 
-reload_media(SCSI *scgp, cdr_t *dp)
-{
-	char	ans[2];
-#ifdef	F_GETFL
-	int	f = -1;
-#endif
-
-	errmsgno(EX_BAD, "Drive needs to reload the media to return to proper status.\n");
-	unload_media(scgp, dp, F_EJECT);
-
-	/*
-	 * Note that even Notebook drives identify as CDR_TRAYLOAD
-	 */
-	if ((dp->cdr_flags & CDR_TRAYLOAD) != 0) {
-		scgp->silent++;
-		load_media(scgp, dp, FALSE);
-		scgp->silent--;
-	}
-
-	scgp->silent++;
-	if (((dp->cdr_flags & CDR_TRAYLOAD) == 0) ||
-				!wait_unit_ready(scgp, 5)) {
-		static FILE	*tty = NULL;
-
-		printf("Re-load disk and hit <CR>");
-		if (isgui)
-			printf("\n");
-		flush();
-
-		if (tty == NULL) {
-			tty = stdin;
-			if ((dp->cdr_cmdflags & F_STDIN) != 0)
-				tty = fileluopen(STDERR_FILENO, "rw");
-		}
-#ifdef	F_GETFL
-		if (tty != NULL)
-			f = fcntl(fileno(tty), F_GETFL, 0);
-		if (f < 0 || (f & O_ACCMODE) == O_WRONLY) {
-#ifdef	SIGUSR1
-			signal(SIGUSR1, catchsig);
-			printf("Controlling file not open for reading, send SIGUSR1 to continue.\n");
-			flush();
-			pause();
-#endif
-		} else
-#endif
-		if (fgetline(tty, ans, 1) < 0)
-			comerrno(EX_BAD, "Aborted by EOF on input.\n");
-	}
-	scgp->silent--;
-
-	load_media(scgp, dp, TRUE);
-}
-
-void 
-set_secsize(SCSI *scgp, int secsize)
-{
-	if (secsize > 0) {
-		/*
-		 * Try to restore the old sector size.
-		 */
-		scgp->silent++;
-		select_secsize(scgp, secsize);
-		scgp->silent--;
-	}
-}
-
-static int 
-get_dmaspeed(SCSI *scgp, cdr_t *dp)
-{
-	int	i;
-	long	t;
-	int	bs;
-	int	tsize;
-
-  if(getenv("CDR_NODMATEST"))
-     return -1;
-
-  if (debug || lverbose)
-     fprintf( stderr, 
-           "Beginning DMA speed test. Set CDR_NODMATEST environment variable if device\n"
-           "communication breaks or freezes immediately after that.\n" );
-
-	fillbytes((caddr_t)buf, 4, '\0');
-	tsize = 0;
-	scgp->silent++;
-	i = read_buffer(scgp, buf, 4, 0);
-	scgp->silent--;
-	if (i < 0)
-		return (-1);
-	tsize = a_to_u_4_byte(buf);
-	if (tsize <= 0)
-		return (-1);
-
-	if (gettimeofday(&starttime, (struct timezone *)0) < 0)
-		return (-1);
-
-	bs = bufsize;
-	if (tsize < bs)
-		bs = tsize;
-	for (i = 0; i < 100; i++) {
-		if (read_buffer(scgp, buf, bs, 0) < 0)
-			return (-1);
-	}
-	if (gettimeofday(&fixtime, (struct timezone *)0) < 0) {
-		errmsg("Cannot get DMA stop time\n");
-		return (-1);
-	}
-	timevaldiff(&starttime, &fixtime);
-	tsize = bs * 100;
-	t = fixtime.tv_sec * 1000 + fixtime.tv_usec / 1000;
-	if (t <= 0)
-		return (-1);
-#ifdef	DEBUG
-	fprintf(stderr, "Read Speed: %lu %ld %ld kB/s %ldx CD %ldx DVD\n",
-		tsize, t, tsize/t, tsize/t/176, tsize/t/1385);
-#endif
-
-	return (tsize/t);
-}
-
-
-static BOOL 
-do_opc(SCSI *scgp, cdr_t *dp, int flags)
-{
-	if ((flags & F_DUMMY) == 0 && dp->cdr_opc) {
-		if (debug || lverbose) {
-			printf("Performing OPC...\n");
-			flush();
-		}
-		if (dp->cdr_opc(scgp, NULL, 0, TRUE) < 0) {
-			errmsgno(EX_BAD, "OPC failed.\n");
-			if ((flags & F_FORCE) == 0)
-				return (FALSE);
-		}
-	}
-	return (TRUE);
-}
-
-static void 
-check_recovery(SCSI *scgp, cdr_t *dp, int flags)
-{
-	if ((*dp->cdr_check_recovery)(scgp, dp)) {
-		errmsgno(EX_BAD, "Recovery needed.\n");
-		unload_media(scgp, dp, flags);
-		comexit(EX_BAD);
-	}
-}
-
-#ifndef	DEBUG
-#define	DEBUG
-#endif
-void 
-audioread(SCSI *scgp, cdr_t *dp, int flags)
-{
-#ifdef	DEBUG
-	int speed = 1;
-	int	oflags = dp->cdr_cmdflags;
-
-	dp->cdr_cmdflags &= ~F_DUMMY;
-	if ((*dp->cdr_set_speed_dummy)(scgp, dp, &speed) < 0)
-		comexit(-1);
-	dp->cdr_dstat->ds_wspeed = speed; /* XXX Remove 'speed' in future */
-	dp->cdr_cmdflags = oflags;
-
-	if ((*dp->cdr_set_secsize)(scgp, 2352) < 0)
-		comexit(-1);
-	scgp->cap->c_bsize = 2352;
-
-	read_scsi(scgp, buf, 1000, 1);
-	printf("XXX:\n");
-	write(1, buf, 512);
-	unload_media(scgp, dp, flags);
-	comexit(0);
-#endif
-}
-
-static void 
-print_msinfo(SCSI *scgp, cdr_t *dp)
-{
-	long	off;
-	long	fa;
-
-	if ((*dp->cdr_session_offset)(scgp, &off) < 0) {
-		errmsgno(EX_BAD, "Cannot read session offset\n");
-		return;
-	}
-	if (lverbose)
-		printf("session offset: %ld\n", off);
-
-	if (dp->cdr_next_wr_address(scgp, (track_t *)0, &fa) < 0) {
-		errmsgno(EX_BAD, "Cannot read first writable address\n");
-		return;
-	}
-	printf("%ld,%ld\n", off, fa);
-}
-
-static void 
-print_toc(SCSI *scgp, cdr_t *dp)
-{
-	int	first;
-	int	last;
-	long	lba;
-	long	xlba;
-	struct msf msf;
-	int	adr;
-	int	control;
-	int	mode;
-	int	i;
-
-	scgp->silent++;
-	if (read_capacity(scgp) < 0) {
-		scgp->silent--;
-		errmsgno(EX_BAD, "Cannot read capacity\n");
-		return;
-	}
-	scgp->silent--;
-	if (read_tochdr(scgp, dp, &first, &last) < 0) {
-		errmsgno(EX_BAD, "Cannot read TOC/PMA\n");
-		return;
-	}
-	printf("first: %d last %d\n", first, last);
-	for (i = first; i <= last; i++) {
-		read_trackinfo(scgp, i, &lba, &msf, &adr, &control, &mode);
-		xlba = -150 +
-			msf.msf_frame + (75*msf.msf_sec) + (75*60*msf.msf_min);
-		if (xlba == lba/4)
-			lba = xlba;
-		print_track(i, lba, &msf, adr, control, mode);
-	}
-	i = 0xAA;
-	read_trackinfo(scgp, i, &lba, &msf, &adr, &control, &mode);
-	xlba = -150 +
-		msf.msf_frame + (75*msf.msf_sec) + (75*60*msf.msf_min);
-	if (xlba == lba/4)
-		lba = xlba;
-	print_track(i, lba, &msf, adr, control, mode);
-	if (lverbose > 1) {
-		scgp->silent++;
-		if (read_cdtext(scgp) < 0)
-			errmsgno(EX_BAD, "No CD-Text or CD-Text unaware drive.\n");
-		scgp->silent++;
-	}
-}
-
-static void 
-print_track(int track, long lba, struct msf *msp, int adr, 
-				int control, int mode)
-{
-	long	lba_512 = lba*4;
-
-	if (track == 0xAA)
-		printf("track:lout ");
-	else
-		printf("track: %3d ", track);
-
-	printf("lba: %9ld (%9ld) %02d:%02d:%02d adr: %X control: %X mode: %d\n",
-			lba, lba_512,
-			msp->msf_min,
-			msp->msf_sec,
-			msp->msf_frame,
-			adr, control, mode);
-}
-
-#ifdef	HAVE_SYS_PRIOCNTL_H	/* The preferred SYSvR4 schduler */
-
-#include <sys/procset.h>	/* Needed for SCO Openserver */
-#include <sys/priocntl.h>
-#include <sys/rtpriocntl.h>
-
-void 
-raisepri(int pri)
-{
-	int		pid;
-	int		classes;
-	int		ret;
-	pcinfo_t	info;
-	pcparms_t	param;
-	rtinfo_t	rtinfo;
-	rtparms_t	rtparam;
-
-	pid = getpid();
-
-	/* get info */
-	strcpy(info.pc_clname, "RT");
-	classes = priocntl(P_PID, pid, PC_GETCID, (void *)&info);
-	if (classes == -1)
-		comerr("Cannot get priority class id priocntl(PC_GETCID)\n");
-
-	movebytes(info.pc_clinfo, &rtinfo, sizeof (rtinfo_t));
-
-	/* set priority to max */
-	rtparam.rt_pri = rtinfo.rt_maxpri - pri;
-	rtparam.rt_tqsecs = 0;
-	rtparam.rt_tqnsecs = RT_TQDEF;
-	param.pc_cid = info.pc_cid;
-	movebytes(&rtparam, param.pc_clparms, sizeof (rtparms_t));
-	ret = priocntl(P_PID, pid, PC_SETPARMS, (void *)&param);
-	if (ret == -1) {
-		errmsg("WARNING: Cannot set priority class parameters priocntl(PC_SETPARMS)\n");
-		errmsgno(EX_BAD, "WARNING: This causes a high risk for buffer underruns.\n");
-	}
-}
-
-#else	/* HAVE_SYS_PRIOCNTL_H */
-
-#if defined(_POSIX_PRIORITY_SCHEDULING) && _POSIX_PRIORITY_SCHEDULING -0 >= 0
-/*
- * The second best choice: POSIX real time scheduling.
- */
-/*
- * XXX Ugly but needed because of a typo in /usr/iclude/sched.h on Linux.
- * XXX This should be removed as soon as we are sure that Linux-2.0.29 is gone.
- */
-#ifdef	__linux
-#define	_P	__P
-#endif
-
-#include <sched.h>
-
-#ifdef	__linux
-#undef	_P
-#endif
-
-static int 
-rt_raisepri(int pri)
-{
-	struct sched_param scp;
-
-	/*
-	 * Verify that scheduling is available
-	 */
-#ifdef	_SC_PRIORITY_SCHEDULING
-	if (sysconf(_SC_PRIORITY_SCHEDULING) == -1) {
-		errmsg("WARNING: RR-scheduler not available, disabling.\n");
-		return (-1);
-	}
-#endif
-	fillbytes(&scp, sizeof (scp), '\0');
-	scp.sched_priority = sched_get_priority_max(SCHED_RR) - pri;
-	if (sched_setscheduler(0, SCHED_RR, &scp) < 0) {
-		errmsg("WARNING: Cannot set RR-scheduler\n");
-		return (-1);
-	}
-	return (0);
-}
-
-#else	/* _POSIX_PRIORITY_SCHEDULING */
-
-#ifdef	__CYGWIN32__
-/*
- * Win32 specific priority settings.
- */
-/*
- * NOTE: Base.h from Cygwin-B20 has a second typedef for BOOL.
- *	 We define BOOL to make all static code use BOOL
- *	 from Windows.h and use the hidden __SBOOL for
- *	 our global interfaces.
- *
- * NOTE: windows.h from Cygwin-1.x includes a structure field named sample,
- *	 so me may not define our own 'sample' or need to #undef it now.
- *	 With a few nasty exceptions, Microsoft assumes that any global
- *	 defines or identifiers will begin with an Uppercase letter, so
- *	 there may be more of these problems in the future.
- *
- * NOTE: windows.h defines interface as an alias for struct, this
- *	 is used by COM/OLE2, I guess it is class on C++
- *	 We man need to #undef 'interface'
- */
-#define	BOOL	WBOOL		/* This is the Win BOOL		*/
-#define	format	__format	/* Avoid format parameter hides global ... */
-#include <windows.h>
-#undef format
-#undef interface
-
-static int 
-rt_raisepri(int pri)
-{
-	int prios[] = {THREAD_PRIORITY_TIME_CRITICAL, THREAD_PRIORITY_HIGHEST};
-
-	/* set priority class */
-	if (SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS) == FALSE) {
-		errmsgno(EX_BAD, "No realtime priority class possible.\n");
-		return (-1);
-	}
-
-	/* set thread priority */
-	if (pri >= 0 && pri <= 1 && SetThreadPriority(GetCurrentThread(), prios[pri]) == FALSE) {
-		errmsgno(EX_BAD, "Could not set realtime priority.\n");
-		return (-1);
-	}
-	return (0);
-}
-
-#else
-/*
- * This OS does not support real time scheduling.
- */
-static int 
-rt_raisepri(int pri)
-{
-	return (-1);
-}
-
-#endif	/* __CYGWIN32__ */
-
-#endif	/* _POSIX_PRIORITY_SCHEDULING */
-
-void 
-raisepri(int pri)
-{
-	if (rt_raisepri(pri) >= 0)
-		return;
-#if	defined(HAVE_SETPRIORITY) && defined(PRIO_PROCESS)
-
-	if (setpriority(PRIO_PROCESS, getpid(), -20 + pri) < 0) {
-		errmsg("WARNING: Cannot set priority using setpriority().\n");
-		errmsgno(EX_BAD, "WARNING: This causes a high risk for buffer underruns.\n");
-	}
-#else
-#ifdef	HAVE_DOSSETPRIORITY	/* RT priority on OS/2 */
-	/*
-	 * Set priority to timecritical 31 - pri (arg)
-	 */
-	DosSetPriority(0, 3, 31, 0);
-	DosSetPriority(0, 3, -pri, 0);
-#else
-#if	defined(HAVE_NICE) && !defined(__DJGPP__) /* DOS has nice but no multitasking */
-	if (nice(-20 + pri) == -1) {
-		errmsg("WARNING: Cannot set priority using nice().\n");
-		errmsgno(EX_BAD, "WARNING: This causes a high risk for buffer underruns.\n");
-	}
-#else
-	errmsgno(EX_BAD, "WARNING: Cannot set priority on this OS.\n");
-	errmsgno(EX_BAD, "WARNING: This causes a high risk for buffer underruns.\n");
-#endif
-#endif
-#endif
-}
-
-#endif	/* HAVE_SYS_PRIOCNTL_H */
-
-#ifdef	HAVE_SELECT
-/*
- * sys/types.h and sys/time.h are already included.
- */
-#else
-#	include	<stropts.h>
-#	include	<poll.h>
-
-#ifndef	INFTIM
-#define	INFTIM	(-1)
-#endif
-#endif
-
-#if	defined(HAVE_SELECT) && defined(NEED_SYS_SELECT_H)
-#include <sys/select.h>
-#endif
-#if	defined(HAVE_SELECT) && defined(NEED_SYS_SOCKET_H)
-#include <sys/socket.h>
-#endif
-
-static void 
-wait_input()
-{
-#ifdef	HAVE_SELECT
-	fd_set	in;
-
-	FD_ZERO(&in);
-	FD_SET(STDIN_FILENO, &in);
-	select(1, &in, NULL, NULL, 0);
-#else
-	struct pollfd pfd;
-
-	pfd.fd = STDIN_FILENO;
-	pfd.events = POLLIN;
-	pfd.revents = 0;
-	poll(&pfd, (unsigned long)1, INFTIM);
-#endif
-}
-
-static void 
-checkgui()
-{
-	struct stat st;
-
-	if (fstat(STDERR_FILENO, &st) >= 0 && !S_ISCHR(st.st_mode)) {
-		isgui = TRUE;
-		if (lverbose > 1)
-			printf("Using remote (pipe) mode for interactive i/o.\n");
-	}
-}
-
-static int 
-getbltype(char *optstr, long *typep)
-{
-	if (streql(optstr, "all")) {
-		*typep = BLANK_DISC;
-	} else if (streql(optstr, "disc")) {
-		*typep = BLANK_DISC;
-	} else if (streql(optstr, "disk")) {
-		*typep = BLANK_DISC;
-	} else if (streql(optstr, "fast")) {
-		*typep = BLANK_MINIMAL;
-	} else if (streql(optstr, "minimal")) {
-		*typep = BLANK_MINIMAL;
-	} else if (streql(optstr, "track")) {
-		*typep = BLANK_TRACK;
-	} else if (streql(optstr, "unreserve")) {
-		*typep = BLANK_UNRESERVE;
-	} else if (streql(optstr, "trtail")) {
-		*typep = BLANK_TAIL;
-	} else if (streql(optstr, "unclose")) {
-		*typep = BLANK_UNCLOSE;
-	} else if (streql(optstr, "session")) {
-		*typep = BLANK_SESSION;
-	} else if (streql(optstr, "help")) {
-		blusage(0);
-	} else {
-		fprintf(stderr, "Illegal blanking type '%s'.\n", optstr);
-		blusage(EX_BAD);
-		return (-1);
-	}
-	return (TRUE);
-}
-
-static int 
-getformattype(char *optstr, long *typep)
-{
-	if (streql(optstr, "full")) {
-		*typep = FULL_FORMAT;
-	} else if (streql(optstr, "background")) {
-		*typep = BACKGROUND_FORMAT;
-	} else if (streql(optstr, "force")) {
-		*typep = FORCE_FORMAT;
-	} else if (streql(optstr, "help")) {
-		formattypeusage(0);
-	} else {
-		fprintf(stderr, "Illegal blanking type '%s'.\n", optstr);
-		formattypeusage(EX_BAD);
-		return (-1);
-	}
-	return (TRUE);
-}
-static void 
-print_drflags(cdr_t *dp)
-{
-	printf("Driver flags   : ");
-
-	if ((dp->cdr_flags & CDR_DVD) != 0)
-		printf("DVD ");
-
-	if ((dp->cdr_flags & CDR_MMC3) != 0)
-		printf("MMC-3 ");
-	else if ((dp->cdr_flags & CDR_MMC2) != 0)
-		printf("MMC-2 ");
-	else if ((dp->cdr_flags & CDR_MMC) != 0)
-		printf("MMC ");
-
-	if ((dp->cdr_flags & CDR_SWABAUDIO) != 0)
-		printf("SWABAUDIO ");
-	if ((dp->cdr_flags & CDR_BURNFREE) != 0)
-		printf("BURNFREE ");
-	if ((dp->cdr_flags & CDR_VARIREC) != 0)
-		printf("VARIREC ");
-	if ((dp->cdr_flags & CDR_GIGAREC) != 0)
-		printf("GIGAREC ");
-	if ((dp->cdr_flags & CDR_AUDIOMASTER) != 0)
-		printf("AUDIOMASTER ");
-	if ((dp->cdr_flags & CDR_FORCESPEED) != 0)
-		printf("FORCESPEED ");
-	if ((dp->cdr_flags & CDR_SPEEDREAD) != 0)
-		printf("SPEEDREAD ");
-	if ((dp->cdr_flags & CDR_DISKTATTOO) != 0)
-		printf("DISKTATTOO ");
-	if ((dp->cdr_flags & CDR_SINGLESESS) != 0)
-		printf("SINGLESESSION ");
-	if ((dp->cdr_flags & CDR_HIDE_CDR) != 0)
-		printf("HIDECDR ");
-	printf("\n");
-}
-
-static void 
-print_wrmodes(cdr_t *dp)
-{
-	BOOL	needblank = FALSE;
-
-	printf("Supported modes: ");
-	if ((dp->cdr_flags & CDR_TAO) != 0) {
-		printf("TAO");
-		needblank = TRUE;
-	}
-	if ((dp->cdr_flags & CDR_PACKET) != 0) {
-		printf("%sPACKET", needblank?" ":"");
-		needblank = TRUE;
-	}
-	if ((dp->cdr_flags & CDR_SAO) != 0) {
-		printf("%sSAO", needblank?" ":"");
-		needblank = TRUE;
-	}
-#ifdef	__needed__
-	if ((dp->cdr_flags & (CDR_SAO|CDR_SRAW16)) == (CDR_SAO|CDR_SRAW16)) {
-		printf("%sSAO/R16", needblank?" ":"");
-		needblank = TRUE;
-	}
-#endif
-	if ((dp->cdr_flags & (CDR_SAO|CDR_SRAW96P)) == (CDR_SAO|CDR_SRAW96P)) {
-		printf("%sSAO/R96P", needblank?" ":"");
-		needblank = TRUE;
-	}
-	if ((dp->cdr_flags & (CDR_SAO|CDR_SRAW96R)) == (CDR_SAO|CDR_SRAW96R)) {
-		printf("%sSAO/R96R", needblank?" ":"");
-		needblank = TRUE;
-	}
-	if ((dp->cdr_flags & (CDR_RAW|CDR_RAW16)) == (CDR_RAW|CDR_RAW16)) {
-		printf("%sRAW/R16", needblank?" ":"");
-		needblank = TRUE;
-	}
-	if ((dp->cdr_flags & (CDR_RAW|CDR_RAW96P)) == (CDR_RAW|CDR_RAW96P)) {
-		printf("%sRAW/R96P", needblank?" ":"");
-		needblank = TRUE;
-	}
-	if ((dp->cdr_flags & (CDR_RAW|CDR_RAW96R)) == (CDR_RAW|CDR_RAW96R)) {
-		printf("%sRAW/R96R", needblank?" ":"");
-		needblank = TRUE;
-	}
-	printf("\n");
-}
-
-static BOOL 
-check_wrmode(cdr_t *dp, int wmode, int tflags)
-{
-	int	cdflags = dp->cdr_flags;
-
-	if ((tflags & TI_PACKET) != 0 && (cdflags & CDR_PACKET) == 0) {
-		errmsgno(EX_BAD, "Drive does not support PACKET recording.\n");
-		return (FALSE);
-	}
-	if ((tflags & TI_TAO) != 0 && (cdflags & CDR_TAO) == 0) {
-		errmsgno(EX_BAD, "Drive does not support TAO recording.\n");
-		return (FALSE);
-	}
-	if ((wmode & F_SAO) != 0) {
-		if ((cdflags & CDR_SAO) == 0) {
-			errmsgno(EX_BAD, "Drive does not support SAO recording.\n");
-			if ((cdflags & CDR_RAW) != 0)
-				errmsgno(EX_BAD, "Try -raw option.\n");
-			return (FALSE);
-		}
-#ifdef	__needed__
-		if ((tflags & TI_RAW16) != 0 && (cdflags & CDR_SRAW16) == 0) {
-			errmsgno(EX_BAD, "Drive does not support SAO/RAW16.\n");
-			goto badsecs;
-		}
-#endif
-		if ((tflags & (TI_RAW|TI_RAW16|TI_RAW96R)) == TI_RAW && (cdflags & CDR_SRAW96P) == 0) {
-			errmsgno(EX_BAD, "Drive does not support SAO/RAW96P.\n");
-			goto badsecs;
-		}
-		if ((tflags & (TI_RAW|TI_RAW16|TI_RAW96R)) == (TI_RAW|TI_RAW96R) && (cdflags & CDR_SRAW96R) == 0) {
-			errmsgno(EX_BAD, "Drive does not support SAO/RAW96R.\n");
-			goto badsecs;
-		}
-	}
-	if ((wmode & F_RAW) != 0) {
-		if ((cdflags & CDR_RAW) == 0) {
-			errmsgno(EX_BAD, "Drive does not support RAW recording.\n");
-			return (FALSE);
-		}
-		if ((tflags & TI_RAW16) != 0 && (cdflags & CDR_RAW16) == 0) {
-			errmsgno(EX_BAD, "Drive does not support RAW/RAW16.\n");
-			goto badsecs;
-		}
-		if ((tflags & (TI_RAW|TI_RAW16|TI_RAW96R)) == TI_RAW && (cdflags & CDR_RAW96P) == 0) {
-			errmsgno(EX_BAD, "Drive does not support RAW/RAW96P.\n");
-			goto badsecs;
-		}
-		if ((tflags & (TI_RAW|TI_RAW16|TI_RAW96R)) == (TI_RAW|TI_RAW96R) && (cdflags & CDR_RAW96R) == 0) {
-			errmsgno(EX_BAD, "Drive does not support RAW/RAW96R.\n");
-			goto badsecs;
-		}
-	}
-	return (TRUE);
-
-badsecs:
-	if ((wmode & F_SAO) != 0)
-		cdflags &= ~(CDR_RAW16|CDR_RAW96P|CDR_RAW96R);
-	if ((wmode & F_RAW) != 0)
-		cdflags &= ~(CDR_SRAW96P|CDR_SRAW96R);
-
-	if ((cdflags & (CDR_SRAW96R|CDR_RAW96R)) != 0)
-		errmsgno(EX_BAD, "Try -raw96r option.\n");
-	else if ((cdflags & (CDR_SRAW96P|CDR_RAW96P)) != 0)
-		errmsgno(EX_BAD, "Try -raw96p option.\n");
-	else if ((cdflags & CDR_RAW16) != 0)
-		errmsgno(EX_BAD, "Try -raw16 option.\n");
-	return (FALSE);
-}
-
-static void 
-set_wrmode(cdr_t *dp, int wmode, int tflags)
-{
-	dstat_t	*dsp = dp->cdr_dstat;
-
-	if ((tflags & TI_PACKET) != 0) {
-		dsp->ds_wrmode = WM_PACKET;
-		return;
-	}
-	if ((tflags & TI_TAO) != 0) {
-		dsp->ds_wrmode = WM_TAO;
-		return;
-	}
-	if ((wmode & F_SAO) != 0) {
-		if ((tflags & (TI_RAW|TI_RAW16|TI_RAW96R)) == 0) {
-			dsp->ds_wrmode = WM_SAO;
-			return;
-		}
-		if ((tflags & TI_RAW16) != 0) {		/* Is this needed? */
-			dsp->ds_wrmode = WM_SAO_RAW16;
-			return;
-		}
-		if ((tflags & (TI_RAW|TI_RAW16|TI_RAW96R)) == TI_RAW) {
-			dsp->ds_wrmode = WM_SAO_RAW96P;
-			return;
-		}
-		if ((tflags & (TI_RAW|TI_RAW16|TI_RAW96R)) == (TI_RAW|TI_RAW96R)) {
-			dsp->ds_wrmode = WM_SAO_RAW96R;
-			return;
-		}
-	}
-	if ((wmode & F_RAW) != 0) {
-		if ((tflags & TI_RAW16) != 0) {
-			dsp->ds_wrmode = WM_RAW_RAW16;
-			return;
-		}
-		if ((tflags & (TI_RAW|TI_RAW16|TI_RAW96R)) == TI_RAW) {
-			dsp->ds_wrmode = WM_RAW_RAW96P;
-			return;
-		}
-		if ((tflags & (TI_RAW|TI_RAW16|TI_RAW96R)) == (TI_RAW|TI_RAW96R)) {
-			dsp->ds_wrmode = WM_RAW_RAW96R;
-			return;
-		}
-	}
-	dsp->ds_wrmode = WM_NONE;
-}
-
-#if	defined(linux) || defined(__linux) || defined(__linux__)
-#ifdef	HAVE_UNAME
-#include <sys/utsname.h>
-#endif
-#endif
-
-#ifdef __linux__
-static int 
-get_cap(cap_value_t cap_array)
-{ 
-    	  int ret;
-	  cap_t capa;
-	  capa = cap_get_proc();
-	  cap_set_flag(capa, CAP_EFFECTIVE,  1, &cap_array, CAP_SET);
-	  ret = cap_set_proc(capa);
-	  cap_free(capa);
-	  return ret; 
-}
-#endif

Modified: nonameyet/branches/surgery/debian/control
===================================================================
--- nonameyet/branches/surgery/debian/control	2006-11-19 17:32:55 UTC (rev 400)
+++ nonameyet/branches/surgery/debian/control	2006-11-19 17:41:44 UTC (rev 401)
@@ -6,30 +6,6 @@
 Build-Depends: debhelper (>=5.0.37.3), zlib1g-dev, autotools-dev, cmake (>= 2.4.3-1), libcap-dev [!kfreebsd-i386 !kfreebsd-amd64 !hurd-i386], libcam-dev [kfreebsd-i386 kfreebsd-amd64], libmagic-dev
 Standards-Version: 3.7.2
 
-Package: wodim
-Architecture: any
-Depends: ${shlibs:Depends}
-Recommends: mkisofs
-Replaces: cdrtools-doc (<< 5:1.0~pre1-1), cdrecord (<< 5:1.0~pre1-1)
-Suggests: cdrkit-doc
-Conflicts: cdrecord (<< 5:1.0~pre1-1)
-Description: command line CD/DVD writing tool
- wodim allows you to create CDs or DVDs on a CD/DVD recorder.
- It supports writing data, audio, mixed, multi-session, and CD+ disc and DVD
- data and video disks on DVD capable devices, on just about every type of
- CD/DVD recorder out there.
- .
- Please install cdrkit-doc if you want most of the documentation and
- README files.
-
-Package: cdrecord
-Architecture: all
-Depends: wodim (>= 5:1.0~pre1-1), debconf | debconf-2.0
-Description: Dummy package for transition to wodim
- This is a dummy package to ease the transition to wodim, the fork
- of cdrecord. Please use wodim instead of cdrecord.
- It provides a cdrecord symlink to wodim for compatibility purposes.
-
 Package: mkisofs
 Architecture: any
 Depends: ${shlibs:Depends}
@@ -48,20 +24,6 @@
  Please install cdrkit-doc if you want most of the documentation and
  Readme-files.
 
-Package: cdda2wav
-Architecture: any
-Suggests: vorbis-tools, cdrkit-doc
-Depends: ${shlibs:Depends}
-Section: sound
-Description: Creates WAV files from audio CDs
- cdda2wav lets you digitally copy audio tracks from a CD-ROM, avoiding
- the distortion that is introduced when recording via a sound card. Data 
- can be dumped into raw (cdr), wav or sun format sound files. Options control
- the recording format (stereo/mono; 8/16 bits; sampling rate, etc).
- .
- Please install cdrkit-doc if you want most of the documentation and
- Readme-files.
-
 Package: cdrkit-doc
 Architecture: all
 Section: doc

Modified: nonameyet/branches/surgery/include/AddScgBits.cmake
===================================================================
--- nonameyet/branches/surgery/include/AddScgBits.cmake	2006-11-19 17:32:55 UTC (rev 400)
+++ nonameyet/branches/surgery/include/AddScgBits.cmake	2006-11-19 17:41:44 UTC (rev 401)
@@ -1,17 +1,18 @@
 
-LIST(APPEND EXTRA_LIBS "scg")
-
-INCLUDE(CheckIncludeFiles)
-CHECK_INCLUDE_FILES("stdio.h;camlib.h" HAVE_CAMLIB_H)
-
-if(HAVE_CAMLIB_H)
-
-   # quick an dirty, should better become a variable used by libscg only,
-   # analogous to SCG_SELF_LIBS
-   ADD_DEFINITIONS(-DHAVE_CAMLIB_H)
-
-   LIST(APPEND EXTRA_LIBS "cam")
-   LIST(APPEND SCG_SELF_LIBS "cam")
-
-endif(HAVE_CAMLIB_H)
-
+#
+#LIST(APPEND EXTRA_LIBS "scg")
+#
+#INCLUDE(CheckIncludeFiles)
+#CHECK_INCLUDE_FILES("stdio.h;camlib.h" HAVE_CAMLIB_H)
+#
+#if(HAVE_CAMLIB_H)
+#
+#   # quick an dirty, should better become a variable used by libscg only,
+#   # analogous to SCG_SELF_LIBS
+#   ADD_DEFINITIONS(-DHAVE_CAMLIB_H)
+#
+#   LIST(APPEND EXTRA_LIBS "cam")
+#   LIST(APPEND SCG_SELF_LIBS "cam")
+#
+#endif(HAVE_CAMLIB_H)
+#

Modified: nonameyet/branches/surgery/libhfs_iso/CMakeLists.txt
===================================================================
--- nonameyet/branches/surgery/libhfs_iso/CMakeLists.txt	2006-11-19 17:32:55 UTC (rev 400)
+++ nonameyet/branches/surgery/libhfs_iso/CMakeLists.txt	2006-11-19 17:41:44 UTC (rev 401)
@@ -1,6 +1,6 @@
 PROJECT (LIBhfs_iso)
 INCLUDE_DIRECTORIES(../include ../libhfs_iso ../cdrecord ${CMAKE_BINARY_DIR})
-ADD_DEFINITIONS(-DUSE_LARGEFILES -DABORT_DEEP_ISO_ONLY -DAPPLE_HYB -DUDF -DDVD_VIDEO -DSORTING -DHAVE_CONFIG_H -DUSE_LIBSCHILY -DUSE_SCG)
+ADD_DEFINITIONS(-DUSE_LARGEFILES -DABORT_DEEP_ISO_ONLY -DAPPLE_HYB -DUDF -DDVD_VIDEO -DSORTING -DHAVE_CONFIG_H -DUSE_LIBSCHILY)
 
 
 SET(LIBhfs_iso_SRCS block.c btree.c data.c file.c gdata.c hfs.c low.c node.c record.c volume.c)

Deleted: nonameyet/branches/surgery/libscg/scsitransp.c
===================================================================
--- nonameyet/branches/surgery/libscg/scsitransp.c	2006-11-19 17:32:55 UTC (rev 400)
+++ nonameyet/branches/surgery/libscg/scsitransp.c	2006-11-19 17:41:44 UTC (rev 401)
@@ -1,1372 +0,0 @@
-/*
- * This file has been modified for the cdrkit suite.
- *
- * The behaviour and appearence of the program code below can differ to a major
- * extent from the version distributed by the original author(s).
- *
- * For details, see Changelog file distributed with the cdrkit package. If you
- * received this file from another source then ask the distributing person for
- * a log of modifications.
- *
- */
-
-/* @(#)scsitransp.c	1.91 04/06/17 Copyright 1988,1995,2000-2004 J. Schilling */
-/*#ifndef lint*/
-static	char sccsid[] =
-	"@(#)scsitransp.c	1.91 04/06/17 Copyright 1988,1995,2000-2004 J. Schilling";
-/*#endif*/
-/*
- *	SCSI user level command transport routines (generic part).
- *
- *	Warning: you may change this source, but if you do that
- *	you need to change the _scg_version and _scg_auth* string below.
- *	You may not return "schily" for an SCG_AUTHOR request anymore.
- *	Choose your name instead of "schily" and make clear that the version
- *	string is related to a modified source.
- *
- *	Copyright (c) 1988,1995,2000-2004 J. Schilling
- */
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; see the file COPYING.  If not, write to the Free Software
- * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <mconfig.h>
-#include <stdio.h>
-#include <standard.h>
-#include <stdxlib.h>
-#include <unixstd.h>
-#include <errno.h>
-#include <timedefs.h>
-#include <strdefs.h>
-#include <schily.h>
-
-#include <scg/scgcmd.h>
-#include <scg/scsireg.h>
-#include <scg/scsitransp.h>
-#include "scgtimes.h"
-
-/*
- *	Warning: you may change this source, but if you do that
- *	you need to change the _scg_version and _scg_auth* string below.
- *	You may not return "schily" for an SCG_AUTHOR request anymore.
- *	Choose your name instead of "schily" and make clear that the version
- *	string is related to a modified source.
- */
-static	char	_scg_version[]		= "0.8ubuntu1+debburn1";	/* The global libscg version	*/
-static	char	_scg_auth_ubuntu[]	= "debburn project";	/* The author for this module	*/
-
-#define	DEFTIMEOUT	20	/* Default timeout for SCSI command transport */
-
-char	*scg_version(SCSI *scgp, int what);
-int	scg__open(SCSI *scgp, char *device);
-int	scg__close(SCSI *scgp);
-BOOL	scg_havebus(SCSI *scgp, int);
-int	scg_initiator_id(SCSI *scgp);
-int	scg_isatapi(SCSI *scgp);
-int	scg_reset(SCSI *scgp, int what);
-void	*scg_getbuf(SCSI *scgp, long);
-void	scg_freebuf(SCSI *scgp);
-long	scg_bufsize(SCSI *scgp, long);
-void	scg_setnonstderrs(SCSI *scgp, const char **);
-BOOL	scg_yes(char *);
-#ifdef	nonono
-static	void	scg_sighandler(int);
-#endif
-int	scg_cmd(SCSI *scgp);
-void	scg_vhead(SCSI *scgp);
-int	scg_svhead(SCSI *scgp, char *buf, int maxcnt);
-int	scg_vtail(SCSI *scgp);
-int	scg_svtail(SCSI *scgp, int *retp, char *buf, int maxcnt);
-void	scg_vsetup(SCSI *scgp);
-int	scg_getresid(SCSI *scgp);
-int	scg_getdmacnt(SCSI *scgp);
-BOOL	scg_cmd_err(SCSI *scgp);
-void	scg_printerr(SCSI *scgp);
-void	scg_fprinterr(SCSI *scgp, FILE *f);
-int	scg_sprinterr(SCSI *scgp, char *buf, int maxcnt);
-int	scg__sprinterr(SCSI *scgp, char *buf, int maxcnt);
-void	scg_printcdb(SCSI *scgp);
-int	scg_sprintcdb(SCSI *scgp, char *buf, int maxcnt);
-void	scg_printwdata(SCSI *scgp);
-int	scg_sprintwdata(SCSI *scgp, char *buf, int maxcnt);
-void	scg_printrdata(SCSI *scgp);
-int	scg_sprintrdata(SCSI *scgp, char *buf, int maxcnt);
-void	scg_printresult(SCSI *scgp);
-int	scg_sprintresult(SCSI *scgp, char *buf, int maxcnt);
-void	scg_printstatus(SCSI *scgp);
-int	scg_sprintstatus(SCSI *scgp, char *buf, int maxcnt);
-void	scg_fprbytes(FILE *, char *, unsigned char *, int);
-void	scg_fprascii(FILE *, char *, unsigned char *, int);
-void	scg_prbytes(char *, unsigned char *, int);
-void	scg_prascii(char *, unsigned char *, int);
-int	scg_sprbytes(char *buf, int maxcnt, char *, unsigned char *, int);
-int	scg_sprascii(char *buf, int maxcnt, char *, unsigned char *, int);
-void	scg_fprsense(FILE *f, unsigned char *, int);
-int	scg_sprsense(char *buf, int maxcnt, unsigned char *, int);
-void	scg_prsense(unsigned char *, int);
-int	scg_cmd_status(SCSI *scgp);
-int	scg_sense_key(SCSI *scgp);
-int	scg_sense_code(SCSI *scgp);
-int	scg_sense_qual(SCSI *scgp);
-unsigned char *scg_sense_table(SCSI *scgp);
-void	scg_fprintdev(FILE *, struct scsi_inquiry *);
-void	scg_printdev(struct scsi_inquiry *);
-int	scg_printf(SCSI *scgp, const char *form, ...);
-int	scg_errflush(SCSI *scgp);
-int	scg_errfflush(SCSI *scgp, FILE *f);
-
-/*
- * Return version information for the SCSI transport code.
- * This has been introduced to make it easier to trace down problems
- * in applications.
- *
- * If scgp is NULL, return general library version information.
- * If scgp is != NULL, return version information for the low level transport.
- */
-char *
-scg_version(SCSI *scgp, int what)
-{
-	if (scgp == (SCSI *)0) {
-		switch (what) {
-
-		case SCG_VERSION:
-			return (_scg_version);
-		/*
-		 * If you changed this source, you are not allowed to
-		 * return "schily" for the SCG_AUTHOR request.
-		 */
-		case SCG_AUTHOR:
-			return (_scg_auth_ubuntu);
-		case SCG_SCCS_ID:
-			return (sccsid);
-		default:
-			return ((char *)0);
-		}
-	}
-	return (SCGO_VERSION(scgp, what));
-}
-
-/*
- * Call low level SCSI open routine from transport abstraction layer.
- */
-int
-scg__open(SCSI *scgp, char *device)
-{
-	int	ret;
-	scg_ops_t *ops;
-extern	scg_ops_t scg_std_ops;
-
-#define printf(x) fprintf(stderr, x)
-/* The code is not modified. Only moved to where it belongs to, stopping sabotage of frontend programs' functionality */
-
-#ifndef SHUT_UP
-/* 
- * Who defines which changes decrease the quality and how? The one who hates
- * all changes not done by him personally? There are more harsh (but more
- * precise) words to describe stuff like that below, for now let's call it
- * "unpleasant easter egg" or "addition of code which is enabled by conditional
- * compilation when a condition appears which the creator of the code dislikes
- * by principle".
- */
-/*
-	 * Begin restricted code for quality assurance.
-	 *
-	 * Warning: you are not allowed to modify the quality ensurance code below.
-	 *
-	 * This restiction is introduced because this way, I hope that people
-	 * contribute to the project instead of creating branches.
-	 */
-#if	!defined(IS_SCHILY_XCONFIG)
-	printf("\nWarning: This version of libscg has not been configured via the standard\n");
-	printf("autoconfiguration method of the Schily makefile system. There is a high risk\n");
-	printf("that the code is not configured correctly and for this reason will not behave\n");
-	printf("as expected.\n");
-#endif
-	/*
-	 * End restricted code for quality assurance.
-	 */
-#endif /* SHUT_UP */
-#undef printf
-
-	scgp->ops = &scg_std_ops;
-
-	if (device && strncmp(device, "REMOTE", 6) == 0) {
-		ops = scg_remote();
-		if (ops != NULL)
-			scgp->ops = ops;
-	}
-
-	ret = SCGO_OPEN(scgp, device);
-	if (ret < 0)
-		return (ret);
-
-	/*
-	 * Now make scgp->fd valid if possible.
-	 * Note that scg_scsibus(scgp)/scg_target(scgp)/scg_lun(scgp) may have
-	 * changed in SCGO_OPEN().
-	 */
-	scg_settarget(scgp, scg_scsibus(scgp), scg_target(scgp), scg_lun(scgp));
-	return (ret);
-}
-
-/*
- * Call low level SCSI close routine from transport abstraction layer.
- */
-int
-scg__close(SCSI *scgp)
-{
-	return (SCGO_CLOSE(scgp));
-}
-
-/*
- * Retrieve max DMA count for this target.
- */
-long
-scg_bufsize(SCSI *scgp, long amt)
-{
-	long	maxdma;
-
-	maxdma = SCGO_MAXDMA(scgp, amt);
-	if (amt <= 0 || amt > maxdma)
-		amt = maxdma;
-
-	scgp->maxdma = maxdma;	/* Max possible  */
-	scgp->maxbuf = amt;	/* Current value */
-
-	return (amt);
-}
-
-/*
- * Allocate a buffer that may be used for DMA.
- */
-void *
-scg_getbuf(SCSI *scgp, long amt)
-{
-	void	*buf;
-
-	if (amt <= 0 || amt > scg_bufsize(scgp, amt))
-		return ((void *)0);
-
-	buf = SCGO_GETBUF(scgp, amt);
-	scgp->bufptr = buf;
-	return (buf);
-}
-
-/*
- * Free DMA buffer.
- */
-void
-scg_freebuf(SCSI *scgp)
-{
-	SCGO_FREEBUF(scgp);
-	scgp->bufptr = NULL;
-}
-
-/*
- * Check if 'busno' is a valid SCSI bus number.
- */
-BOOL
-scg_havebus(SCSI *scgp, int busno)
-{
-	return (SCGO_HAVEBUS(scgp, busno));
-}
-
-/*
- * Return SCSI initiator ID for current SCSI bus if available.
- */
-int
-scg_initiator_id(SCSI *scgp)
-{
-	return (SCGO_INITIATOR_ID(scgp));
-}
-
-/*
- * Return a hint whether current SCSI target refers to a ATAPI device.
- */
-int
-scg_isatapi(SCSI *scgp)
-{
-	return (SCGO_ISATAPI(scgp));
-}
-
-/*
- * Reset SCSI bus or target.
- */
-int
-scg_reset(SCSI *scgp, int what)
-{
-	return (SCGO_RESET(scgp, what));
-}
-
-/*
- * Set up nonstd error vector for curren target.
- * To clear additional error table, call scg_setnonstderrs(scgp, NULL);
- * Note: do not use this when scanning the SCSI bus.
- */
-void
-scg_setnonstderrs(SCSI *scgp, const char **vec)
-{
-	scgp->nonstderrs = vec;
-}
-
-/*
- * Simple Yes/No answer checker.
- */
-BOOL
-scg_yes(char *msg)
-{
-	char okbuf[10];
-
-	js_printf("%s", msg);
-	flush();
-	if (getline(okbuf, sizeof (okbuf)) == EOF)
-		exit(EX_BAD);
-	if (streql(okbuf, "y") || streql(okbuf, "yes") ||
-	    streql(okbuf, "Y") || streql(okbuf, "YES"))
-		return (TRUE);
-	else
-		return (FALSE);
-}
-
-#ifdef	nonono
-static void
-scg_sighandler(int sig)
-{
-	js_printf("\n");
-	if (scsi_running) {
-		js_printf("Running command: %s\n", scsi_command);
-		js_printf("Resetting SCSI - Bus.\n");
-		if (scg_reset(scgp) < 0)
-			errmsg("Cannot reset SCSI - Bus.\n");
-	}
-	if (scg_yes("EXIT ? "))
-		exit(sig);
-}
-#endif
-
-/*
- * Send a SCSI command.
- * Do error checking and reporting depending on the values of
- * scgp->verbose, scgp->debug and scgp->silent.
- */
-int
-scg_cmd(SCSI *scgp)
-{
-		int		ret;
-	register struct	scg_cmd	*scmd = scgp->scmd;
-
-	/*
-	 * Reset old error messages in scgp->errstr
-	 */
-	scgp->errptr = scgp->errbeg = scgp->errstr;
-
-	scmd->kdebug = scgp->kdebug;
-	if (scmd->timeout == 0 || scmd->timeout < scgp->deftimeout)
-		scmd->timeout = scgp->deftimeout;
-	if (scgp->disre_disable)
-		scmd->flags &= ~SCG_DISRE_ENA;
-	if (scgp->noparity)
-		scmd->flags |= SCG_NOPARITY;
-
-	scmd->u_sense.cmd_sense[0] = 0;		/* Paranioa */
-	if (scmd->sense_len > SCG_MAX_SENSE)
-		scmd->sense_len = SCG_MAX_SENSE;
-	else if (scmd->sense_len < 0)
-		scmd->sense_len = 0;
-
-	if (scgp->verbose) {
-		scg_vhead(scgp);
-		scg_errflush(scgp);
-	}
-
-	if (scgp->running) {
-		if (scgp->curcmdname) {
-			fprintf(stderr, "Currently running '%s' command.\n",
-							scgp->curcmdname);
-		}
-		raisecond("SCSI ALREADY RUNNING !!", 0L);
-	}
-	scgp->cb_fun = NULL;
-	gettimeofday(scgp->cmdstart, (struct timezone *)0);
-	scgp->curcmdname = scgp->cmdname;
-	scgp->running = TRUE;
-	ret = SCGO_SEND(scgp);
-	scgp->running = FALSE;
-	__scg_times(scgp);
-	if (ret < 0) {
-		/*
-		 * Old /dev/scg versions will not allow to access targets > 7.
-		 * Include a workaround to make this non fatal.
-		 */
-		if (scg_target(scgp) < 8 || geterrno() != EINVAL)
-			comerr("Cannot send SCSI cmd via ioctl\n");
-		if (scmd->ux_errno == 0)
-			scmd->ux_errno = geterrno();
-		if (scmd->error == SCG_NO_ERROR)
-			scmd->error = SCG_FATAL;
-		if (scgp->debug > 0) {
-			errmsg("ret < 0 errno: %d ux_errno: %d error: %d\n",
-					geterrno(), scmd->ux_errno, scmd->error);
-		}
-	}
-
-	ret = scg_vtail(scgp);
-	scg_errflush(scgp);
-	if (scgp->cb_fun != NULL)
-		(*scgp->cb_fun)(scgp->cb_arg);
-	return (ret);
-}
-
-/*
- * Fill the head of verbose printing into the SCSI error buffer.
- * Action depends on SCSI verbose status.
- */
-void
-scg_vhead(SCSI *scgp)
-{
-	scgp->errptr += scg_svhead(scgp, scgp->errptr, scg_errrsize(scgp));
-}
-
-/*
- * Fill the head of verbose printing into a buffer.
- * Action depends on SCSI verbose status.
- */
-int
-scg_svhead(SCSI *scgp, char *buf, int maxcnt)
-{
-	register char	*p = buf;
-	register int	amt;
-
-	if (scgp->verbose <= 0)
-		return (0);
-
-	amt = js_snprintf(p, maxcnt,
-		"\nExecuting '%s' command on Bus %d Target %d, Lun %d timeout %ds\n",
-								/* XXX Really this ??? */
-/*		scgp->cmdname, scg_scsibus(scgp), scg_target(scgp), scgp->scmd->cdb.g0_cdb.lun,*/
-		scgp->cmdname, scg_scsibus(scgp), scg_target(scgp), scg_lun(scgp),
-		scgp->scmd->timeout);
-	if (amt < 0)
-		return (amt);
-	p += amt;
-	maxcnt -= amt;
-
-	amt = scg_sprintcdb(scgp, p, maxcnt);
-	if (amt < 0)
-		return (amt);
-	p += amt;
-	maxcnt -= amt;
-
-	if (scgp->verbose > 1) {
-		amt = scg_sprintwdata(scgp, p, maxcnt);
-		if (amt < 0)
-			return (amt);
-		p += amt;
-		maxcnt -= amt;
-	}
-	return (p - buf);
-}
-
-/*
- * Fill the tail of verbose printing into the SCSI error buffer.
- * Action depends on SCSI verbose status.
- */
-int
-scg_vtail(SCSI *scgp)
-{
-	int	ret;
-
-	scgp->errptr += scg_svtail(scgp, &ret, scgp->errptr, scg_errrsize(scgp));
-	return (ret);
-}
-
-/*
- * Fill the tail of verbose printing into a buffer.
- * Action depends on SCSI verbose status.
- */
-int
-scg_svtail(SCSI *scgp, int *retp, char *buf, int maxcnt)
-{
-	register char	*p = buf;
-	register int	amt;
-	int	ret;
-
-	ret = scg_cmd_err(scgp) ? -1 : 0;
-	if (retp)
-		*retp = ret;
-	if (ret) {
-		if (scgp->silent <= 0 || scgp->verbose) {
-			amt = scg__sprinterr(scgp, p, maxcnt);
-			if (amt < 0)
-				return (amt);
-			p += amt;
-			maxcnt -= amt;
-		}
-	}
-	if ((scgp->silent <= 0 || scgp->verbose) && scgp->scmd->resid) {
-		if (scgp->scmd->resid < 0) {
-			/*
-			 * An operating system that does DMA the right way
-			 * will not allow DMA overruns - it will stop DMA
-			 * before bad things happen.
-			 * A DMA residual count < 0 (-1) is a hint for a DMA
-			 * overrun but does not affect the transfer count.
-			 */
-			amt = js_snprintf(p, maxcnt, "DMA overrun, ");
-			if (amt < 0)
-				return (amt);
-			p += amt;
-			maxcnt -= amt;
-		}
-		amt = js_snprintf(p, maxcnt, "resid: %d\n", scgp->scmd->resid);
-		if (amt < 0)
-			return (amt);
-		p += amt;
-		maxcnt -= amt;
-	}
-	if (scgp->verbose > 0 || (ret < 0 && scgp->silent <= 0)) {
-		amt = scg_sprintresult(scgp, p, maxcnt);
-		if (amt < 0)
-			return (amt);
-		p += amt;
-		maxcnt -= amt;
-	}
-	return (p - buf);
-}
-
-/*
- * Set up SCSI error buffer with verbose print data.
- * Action depends on SCSI verbose status.
- */
-void
-scg_vsetup(SCSI *scgp)
-{
-	scg_vhead(scgp);
-	scg_vtail(scgp);
-}
-
-/*
- * Return the residual DMA count for last command.
- * If this count is < 0, then a DMA overrun occured.
- */
-int
-scg_getresid(SCSI *scgp)
-{
-	return (scgp->scmd->resid);
-}
-
-/*
- * Return the actual DMA count for last command.
- */
-int
-scg_getdmacnt(SCSI *scgp)
-{
-	register struct scg_cmd *scmd = scgp->scmd;
-
-	if (scmd->resid < 0)
-		return (scmd->size);
-
-	return (scmd->size - scmd->resid);
-}
-
-/*
- * Test if last SCSI command got an error.
- */
-BOOL
-scg_cmd_err(SCSI *scgp)
-{
-	register struct scg_cmd *cp = scgp->scmd;
-
-	if (cp->error != SCG_NO_ERROR ||
-				cp->ux_errno != 0 ||
-				*(Uchar *)&cp->scb != 0 ||
-				cp->u_sense.cmd_sense[0] != 0)	/* Paranioa */
-		return (TRUE);
-	return (FALSE);
-}
-
-/*
- * Used to print error messges if the command itself has been run silently.
- *
- * print the following SCSI codes:
- *
- * -	command transport status
- * -	CDB
- * -	SCSI status byte
- * -	Sense Bytes
- * -	Decoded Sense data
- * -	DMA status
- * -	SCSI timing
- *
- * to SCSI errfile.
- */
-void
-scg_printerr(SCSI *scgp)
-{
-	scg_fprinterr(scgp, (FILE *)scgp->errfile);
-}
-
-/*
- * print the following SCSI codes:
- *
- * -	command transport status
- * -	CDB
- * -	SCSI status byte
- * -	Sense Bytes
- * -	Decoded Sense data
- * -	DMA status
- * -	SCSI timing
- *
- * to a file.
- */
-void
-scg_fprinterr(SCSI *scgp, FILE *f)
-{
-	char	errbuf[SCSI_ERRSTR_SIZE];
-	int	amt;
-
-	amt = scg_sprinterr(scgp, errbuf, sizeof (errbuf));
-	if (amt > 0) {
-		filewrite(f, errbuf, amt);
-		fflush(f);
-	}
-}
-
-/*
- * print the following SCSI codes:
- *
- * -	command transport status
- * -	CDB
- * -	SCSI status byte
- * -	Sense Bytes
- * -	Decoded Sense data
- * -	DMA status
- * -	SCSI timing
- *
- * into a buffer.
- */
-int
-scg_sprinterr(SCSI *scgp, char *buf, int maxcnt)
-{
-	int	amt;
-	int	osilent = scgp->silent;
-	int	overbose = scgp->verbose;
-
-	scgp->silent = 0;
-	scgp->verbose = 0;
-	amt = scg_svtail(scgp, NULL, buf, maxcnt);
-	scgp->silent = osilent;
-	scgp->verbose = overbose;
-	return (amt);
-}
-
-/*
- * print the following SCSI codes:
- *
- * -	command transport status
- * -	CDB
- * -	SCSI status byte
- * -	Sense Bytes
- * -	Decoded Sense data
- *
- * into a buffer.
- */
-int
-scg__sprinterr(SCSI *scgp, char *buf, int maxcnt)
-{
-	register struct scg_cmd *cp = scgp->scmd;
-	register char		*err;
-		char		*cmdname = "SCSI command name not set by caller";
-		char		errbuf[64];
-	register char		*p = buf;
-	register int		amt;
-
-	switch (cp->error) {
-
-	case SCG_NO_ERROR :	err = "no error"; break;
-	case SCG_RETRYABLE:	err = "retryable error"; break;
-	case SCG_FATAL    :	err = "fatal error"; break;
-				/*
-				 * We need to cast timeval->* to long because
-				 * of the broken sys/time.h in Linux.
-				 */
-	case SCG_TIMEOUT  :	js_snprintf(errbuf, sizeof (errbuf),
-					"cmd timeout after %ld.%03ld (%d) s",
-					(long)scgp->cmdstop->tv_sec,
-					(long)scgp->cmdstop->tv_usec/1000,
-								cp->timeout);
-				err = errbuf;
-				break;
-	default:		js_snprintf(errbuf, sizeof (errbuf),
-					"error: %d", cp->error);
-				err = errbuf;
-	}
-
-	if (scgp->cmdname != NULL && scgp->cmdname[0] != '\0')
-		cmdname = scgp->cmdname;
-	amt = serrmsgno(cp->ux_errno, p, maxcnt, "%s: scsi sendcmd: %s\n", cmdname, err);
-	if (amt < 0)
-		return (amt);
-	p += amt;
-	maxcnt -= amt;
-
-	amt = scg_sprintcdb(scgp, p, maxcnt);
-	if (amt < 0)
-		return (amt);
-	p += amt;
-	maxcnt -= amt;
-
-	if (cp->error <= SCG_RETRYABLE) {
-		amt = scg_sprintstatus(scgp, p, maxcnt);
-		if (amt < 0)
-			return (amt);
-		p += amt;
-		maxcnt -= amt;
-	}
-
-	if (cp->scb.chk) {
-		amt = scg_sprsense(p, maxcnt, (Uchar *)&cp->sense, cp->sense_count);
-		if (amt < 0)
-			return (amt);
-		p += amt;
-		maxcnt -= amt;
-		amt = scg__errmsg(scgp, p, maxcnt, &cp->sense, &cp->scb, -1);
-		if (amt < 0)
-			return (amt);
-		p += amt;
-		maxcnt -= amt;
-	}
-	return (p - buf);
-}
-
-/*
- * XXX Do we need this function?
- *
- * print the SCSI Command descriptor block to XXX stderr.
- */
-void
-scg_printcdb(SCSI *scgp)
-{
-	scg_prbytes("CDB: ", scgp->scmd->cdb.cmd_cdb, scgp->scmd->cdb_len);
-}
-
-/*
- * print the SCSI Command descriptor block into a buffer.
- */
-int
-scg_sprintcdb(SCSI *scgp, char *buf, int maxcnt)
-{
-	int	cnt;
-
-	cnt = scg_sprbytes(buf, maxcnt, "CDB: ", scgp->scmd->cdb.cmd_cdb, scgp->scmd->cdb_len);
-	if (cnt < 0)
-		cnt = 0;
-	return (cnt);
-}
-
-/*
- * XXX Do we need this function?
- * XXX scg_printrdata() is used.
- * XXX We need to check if we should write to stderr or better to scg->errfile
- *
- * print the SCSI send data to stderr.
- */
-void
-scg_printwdata(SCSI *scgp)
-{
-	register struct	scg_cmd	*scmd = scgp->scmd;
-
-	if (scmd->size > 0 && (scmd->flags & SCG_RECV_DATA) == 0) {
-		js_fprintf(stderr, "Sending %d (0x%X) bytes of data.\n",
-			scmd->size, scmd->size);
-		scg_prbytes("Write Data: ",
-			(Uchar *)scmd->addr,
-			scmd->size > 100 ? 100 : scmd->size);
-	}
-}
-
-/*
- * print the SCSI send data into a buffer.
- */
-int
-scg_sprintwdata(SCSI *scgp, char *buf, int maxcnt)
-{
-	register struct	scg_cmd	*scmd = scgp->scmd;
-	register char		*p = buf;
-	register int		amt;
-
-	if (scmd->size > 0 && (scmd->flags & SCG_RECV_DATA) == 0) {
-		amt = js_snprintf(p, maxcnt,
-			"Sending %d (0x%X) bytes of data.\n",
-			scmd->size, scmd->size);
-		if (amt < 0)
-			return (amt);
-		p += amt;
-		maxcnt -= amt;
-		amt = scg_sprbytes(p, maxcnt, "Write Data: ",
-			(Uchar *)scmd->addr,
-			scmd->size > 100 ? 100 : scmd->size);
-		if (amt < 0)
-			return (amt);
-		p += amt;
-	}
-	return (p - buf);
-}
-
-/*
- * XXX We need to check if we should write to stderr or better to scg->errfile
- *
- * print the SCSI received data to stderr.
- */
-void
-scg_printrdata(SCSI *scgp)
-{
-	register struct	scg_cmd	*scmd = scgp->scmd;
-	register int		trcnt = scg_getdmacnt(scgp);
-
-	if (scmd->size > 0 && (scmd->flags & SCG_RECV_DATA) != 0) {
-		js_fprintf(stderr, "Got %d (0x%X), expecting %d (0x%X) bytes of data.\n",
-			trcnt, trcnt,
-			scmd->size, scmd->size);
-		scg_prbytes("Received Data: ",
-			(Uchar *)scmd->addr,
-			trcnt > 100 ? 100 : trcnt);
-	}
-}
-
-/*
- * print the SCSI received data into a buffer.
- */
-int
-scg_sprintrdata(SCSI *scgp, char *buf, int maxcnt)
-{
-	register struct	scg_cmd	*scmd = scgp->scmd;
-	register char		*p = buf;
-	register int		amt;
-	register int		trcnt = scg_getdmacnt(scgp);
-
-	if (scmd->size > 0 && (scmd->flags & SCG_RECV_DATA) != 0) {
-		amt = js_snprintf(p, maxcnt,
-			"Got %d (0x%X), expecting %d (0x%X) bytes of data.\n",
-			trcnt, trcnt,
-			scmd->size, scmd->size);
-		if (amt < 0)
-			return (amt);
-		p += amt;
-		maxcnt -= amt;
-		amt = scg_sprbytes(p, maxcnt,
-			"Received Data: ",
-			(Uchar *)scmd->addr,
-			trcnt > 100 ? 100 : trcnt);
-		if (amt < 0)
-			return (amt);
-		p += amt;
-	}
-	return (p - buf);
-}
-
-/*
- * XXX We need to check if we should write to stderr or better to scg->errfile
- *
- * print the SCSI timings and (depending on verbose) received data to stderr.
- */
-void
-scg_printresult(SCSI *scgp)
-{
-	js_fprintf(stderr, "cmd finished after %ld.%03lds timeout %ds\n",
-		(long)scgp->cmdstop->tv_sec,
-		(long)scgp->cmdstop->tv_usec/1000,
-		scgp->scmd->timeout);
-	if (scgp->verbose > 1)
-		scg_printrdata(scgp);
-	flush();
-}
-
-/*
- * print the SCSI timings and (depending on verbose) received data into a buffer.
- */
-int
-scg_sprintresult(SCSI *scgp, char *buf, int maxcnt)
-{
-	register char		*p = buf;
-	register int		amt;
-
-	amt = js_snprintf(p, maxcnt,
-		"cmd finished after %ld.%03lds timeout %ds\n",
-		(long)scgp->cmdstop->tv_sec,
-		(long)scgp->cmdstop->tv_usec/1000,
-		scgp->scmd->timeout);
-	if (amt < 0)
-		return (amt);
-	p += amt;
-	maxcnt -= amt;
-	if (scgp->verbose > 1) {
-		amt = scg_sprintrdata(scgp, p, maxcnt);
-		if (amt < 0)
-			return (amt);
-		p += amt;
-	}
-	return (p - buf);
-}
-
-/*
- * XXX Do we need this function?
- *
- * print the SCSI status byte in human readable form to the SCSI error file.
- */
-void
-scg_printstatus(SCSI *scgp)
-{
-	char	errbuf[SCSI_ERRSTR_SIZE];
-	int	amt;
-
-	amt = scg_sprintstatus(scgp, errbuf, sizeof (errbuf));
-	if (amt > 0) {
-		filewrite((FILE *)scgp->errfile, errbuf, amt);
-		fflush((FILE *)scgp->errfile);
-	}
-}
-
-/*
- * print the SCSI status byte in human readable form into a buffer.
- */
-int
-scg_sprintstatus(SCSI *scgp, char *buf, int maxcnt)
-{
-	register struct scg_cmd *cp = scgp->scmd;
-		char	*err;
-		char	*err2 = "";
-	register char	*p = buf;
-	register int	amt;
-
-	amt = js_snprintf(p, maxcnt, "status: 0x%x ", *(Uchar *)&cp->scb);
-	if (amt < 0)
-		return (amt);
-	p += amt;
-	maxcnt -= amt;
-#ifdef	SCSI_EXTENDED_STATUS
-	if (cp->scb.ext_st1) {
-		amt = js_snprintf(p, maxcnt, "0x%x ", ((Uchar *)&cp->scb)[1]);
-		if (amt < 0)
-			return (amt);
-		p += amt;
-		maxcnt -= amt;
-	}
-	if (cp->scb.ext_st2) {
-		amt = js_snprintf(p, maxcnt, "0x%x ", ((Uchar *)&cp->scb)[2]);
-		if (amt < 0)
-			return (amt);
-		p += amt;
-		maxcnt -= amt;
-	}
-#endif
-	switch (*(Uchar *)&cp->scb & 036) {
-
-	case 0  : err = "GOOD STATUS";			break;
-	case 02 : err = "CHECK CONDITION";		break;
-	case 04 : err = "CONDITION MET/GOOD";		break;
-	case 010: err = "BUSY";				break;
-	case 020: err = "INTERMEDIATE GOOD STATUS";	break;
-	case 024: err = "INTERMEDIATE CONDITION MET/GOOD"; break;
-	case 030: err = "RESERVATION CONFLICT";		break;
-	default : err = "Reserved";			break;
-	}
-#ifdef	SCSI_EXTENDED_STATUS
-	if (cp->scb.ext_st1 && cp->scb.ha_er)
-		err2 = " host adapter detected error";
-#endif
-	amt = js_snprintf(p, maxcnt, "(%s%s)\n", err, err2);
-	if (amt < 0)
-		return (amt);
-	p += amt;
-	return (p - buf);
-}
-
-/*
- * print some bytes in hex to a file.
- */
-void
-scg_fprbytes(FILE *f, char *s, register Uchar *cp, register int n)
-{
-	js_fprintf(f, "%s", s);
-	while (--n >= 0)
-		js_fprintf(f, " %02X", *cp++);
-	js_fprintf(f, "\n");
-}
-
-/*
- * print some bytes in ascii to a file.
- */
-void
-scg_fprascii(FILE *f, char *s, register Uchar *cp, register int n)
-{
-	register int	c;
-
-	js_fprintf(f, "%s", s);
-	while (--n >= 0) {
-		c = *cp++;
-		if (c >= ' ' && c < 0177)
-			js_fprintf(f, "%c", c);
-		else
-			js_fprintf(f, ".");
-	}
-	js_fprintf(f, "\n");
-}
-
-/*
- * XXX We need to check if we should write to stderr or better to scg->errfile
- *
- * print some bytes in hex to stderr.
- */
-void
-scg_prbytes(char *s, register Uchar *cp, register int n)
-{
-	scg_fprbytes(stderr, s, cp, n);
-}
-
-/*
- * XXX We need to check if we should write to stderr or better to scg->errfile
- *
- * print some bytes in ascii to stderr.
- */
-void
-scg_prascii(char *s, register Uchar *cp, register int n)
-{
-	scg_fprascii(stderr, s, cp, n);
-}
-
-/*
- * print some bytes in hex into a buffer.
- */
-int
-scg_sprbytes(char *buf, int maxcnt, char *s, register Uchar *cp, register int n)
-{
-	register char	*p = buf;
-	register int	amt;
-
-	amt = js_snprintf(p, maxcnt, "%s", s);
-	if (amt < 0)
-		return (amt);
-	p += amt;
-	maxcnt -= amt;
-
-	while (--n >= 0) {
-		amt = js_snprintf(p, maxcnt, " %02X", *cp++);
-		if (amt < 0)
-			return (amt);
-		p += amt;
-		maxcnt -= amt;
-	}
-	amt = js_snprintf(p, maxcnt, "\n");
-	if (amt < 0)
-		return (amt);
-	p += amt;
-	return (p - buf);
-}
-
-/*
- * print some bytes in ascii into a buffer.
- */
-int
-scg_sprascii(char *buf, int maxcnt, char *s, register Uchar *cp, register int n)
-{
-	register char	*p = buf;
-	register int	amt;
-	register int	c;
-
-	amt = js_snprintf(p, maxcnt, "%s", s);
-	if (amt < 0)
-		return (amt);
-	p += amt;
-	maxcnt -= amt;
-
-	while (--n >= 0) {
-		c = *cp++;
-		if (c >= ' ' && c < 0177)
-			amt = js_snprintf(p, maxcnt, "%c", c);
-		else
-			amt = js_snprintf(p, maxcnt, ".");
-		if (amt < 0)
-			return (amt);
-		p += amt;
-		maxcnt -= amt;
-	}
-	amt = js_snprintf(p, maxcnt, "\n");
-	if (amt < 0)
-		return (amt);
-	p += amt;
-	return (p - buf);
-}
-
-/*
- * print the SCSI sense data for last command in hex to a file.
- */
-void
-scg_fprsense(FILE *f, Uchar *cp, int n)
-{
-	scg_fprbytes(f, "Sense Bytes:", cp, n);
-}
-
-/*
- * XXX We need to check if we should write to stderr or better to scg->errfile
- *
- * print the SCSI sense data for last command in hex to stderr.
- */
-void
-scg_prsense(Uchar *cp, int n)
-{
-	scg_fprsense(stderr, cp, n);
-}
-
-/*
- * print the SCSI sense data for last command in hex into a buffer.
- */
-int
-scg_sprsense(char *buf, int maxcnt, Uchar *cp, int n)
-{
-	return (scg_sprbytes(buf, maxcnt, "Sense Bytes:", cp, n));
-}
-
-/*
- * Return the SCSI status byte for last command.
- */
-int
-scg_cmd_status(SCSI *scgp)
-{
-	struct scg_cmd	*cp = scgp->scmd;
-	int		cmdstatus = *(Uchar *)&cp->scb;
-
-	return (cmdstatus);
-}
-
-/*
- * Return the SCSI sense key for last command.
- */
-int
-scg_sense_key(SCSI *scgp)
-{
-	register struct scg_cmd *cp = scgp->scmd;
-	int	key = -1;
-
-	if (!scg_cmd_err(scgp))
-		return (0);
-
-	if (cp->sense.code >= 0x70)
-		key = ((struct scsi_ext_sense *)&(cp->sense))->key;
-	return (key);
-}
-
-/*
- * Return all the SCSI sense table last command.
- */
-unsigned char *
-scg_sense_table(SCSI *scgp)
-{
-	register struct scg_cmd *cp = scgp->scmd;
-
-	if(!scg_cmd_err(scgp))
-		return (0);
-
-	if (cp->sense.code >= 0x70)
-	return &(cp->sense);
-}
-
-
-/*
- * Return the SCSI sense code for last command.
- */
-int
-scg_sense_code(SCSI *scgp)
-{
-	register struct scg_cmd *cp = scgp->scmd;
-	int	code = -1;
-
-	if (!scg_cmd_err(scgp))
-		return (0);
-
-	if (cp->sense.code >= 0x70)
-		code = ((struct scsi_ext_sense *)&(cp->sense))->sense_code;
-	else
-		code = cp->sense.code;
-	return (code);
-}
-
-/*
- * Return the SCSI sense qualifier for last command.
- */
-int
-scg_sense_qual(SCSI *scgp)
-{
-	register struct scg_cmd *cp = scgp->scmd;
-
-	if (!scg_cmd_err(scgp))
-		return (0);
-
-	if (cp->sense.code >= 0x70)
-		return (((struct scsi_ext_sense *)&(cp->sense))->qual_code);
-	else
-		return (0);
-}
-
-/*
- * Print the device type from the SCSI inquiry buffer to file.
- */
-void
-scg_fprintdev(FILE *f, struct scsi_inquiry *ip)
-{
-	if (ip->removable)
-		js_fprintf(f, "Removable ");
-	if (ip->data_format >= 2) {
-		switch (ip->qualifier) {
-
-		case INQ_DEV_PRESENT:
-			break;
-		case INQ_DEV_NOTPR:
-			js_fprintf(f, "not present ");
-			break;
-		case INQ_DEV_RES:
-			js_fprintf(f, "reserved ");
-			break;
-		case INQ_DEV_NOTSUP:
-			if (ip->type == INQ_NODEV) {
-				js_fprintf(f, "unsupported\n"); return;
-			}
-			js_fprintf(f, "unsupported ");
-			break;
-		default:
-			js_fprintf(f, "vendor specific %d ",
-						(int)ip->qualifier);
-		}
-	}
-	switch (ip->type) {
-
-	case INQ_DASD:
-		js_fprintf(f, "Disk");		break;
-	case INQ_SEQD:
-		js_fprintf(f, "Tape");		break;
-	case INQ_PRTD:
-		js_fprintf(f, "Printer");	break;
-	case INQ_PROCD:
-		js_fprintf(f, "Processor");	break;
-	case INQ_WORM:
-		js_fprintf(f, "WORM");		break;
-	case INQ_ROMD:
-		js_fprintf(f, "CD-ROM");	break;
-	case INQ_SCAN:
-		js_fprintf(f, "Scanner");	break;
-	case INQ_OMEM:
-		js_fprintf(f, "Optical Storage"); break;
-	case INQ_JUKE:
-		js_fprintf(f, "Juke Box");	break;
-	case INQ_COMM:
-		js_fprintf(f, "Communication");	break;
-	case INQ_IT8_1:
-		js_fprintf(f, "IT8 1");		break;
-	case INQ_IT8_2:
-		js_fprintf(f, "IT8 2");		break;
-	case INQ_STARR:
-		js_fprintf(f, "Storage array");	break;
-	case INQ_ENCL:
-		js_fprintf(f, "Enclosure services"); break;
-	case INQ_SDAD:
-		js_fprintf(f, "Simple direct access"); break;
-	case INQ_OCRW:
-		js_fprintf(f, "Optical card r/w"); break;
-	case INQ_BRIDGE:
-		js_fprintf(f, "Bridging expander"); break;
-	case INQ_OSD:
-		js_fprintf(f, "Object based storage"); break;
-	case INQ_ADC:
-		js_fprintf(f, "Automation/Drive Interface"); break;
-	case INQ_WELLKNOWN:
-		js_fprintf(f, "Well known lun"); break;
-
-	case INQ_NODEV:
-		if (ip->data_format >= 2) {
-			js_fprintf(f, "unknown/no device");
-			break;
-		} else if (ip->qualifier == INQ_DEV_NOTSUP) {
-			js_fprintf(f, "unit not present");
-			break;
-		}
-	default:
-		js_fprintf(f, "unknown device type 0x%x",
-						(int)ip->type);
-	}
-	js_fprintf(f, "\n");
-}
-
-/*
- * Print the device type from the SCSI inquiry buffer to stdout.
- */
-void
-scg_printdev(struct scsi_inquiry *ip)
-{
-	scg_fprintdev(stdout, ip);
-}
-
-#include <vadefs.h>
-
-/*
- * print into the SCSI error buffer, adjust the next write pointer.
- */
-/* VARARGS2 */
-int
-scg_printf(SCSI *scgp, const char *form, ...)
-{
-	int	cnt;
-	va_list	args;
-
-	va_start(args, form);
-	cnt = js_snprintf(scgp->errptr, scg_errrsize(scgp), "%r", form, args);
-	va_end(args);
-
-	if (cnt < 0) {
-		scgp->errptr[0] = '\0';
-	} else {
-		scgp->errptr += cnt;
-	}
-	return (cnt);
-}
-
-/*
- * Flush the SCSI error buffer to SCSI errfile.
- * Clear error buffer after flushing.
- */
-int
-scg_errflush(SCSI *scgp)
-{
-	if (scgp->errfile == NULL)
-		return (0);
-
-	return (scg_errfflush(scgp, (FILE *)scgp->errfile));
-}
-
-/*
- * Flush the SCSI error buffer to a file.
- * Clear error buffer after flushing.
- */
-int
-scg_errfflush(SCSI *scgp, FILE *f)
-{
-	int	cnt;
-
-	cnt = scgp->errptr - scgp->errbeg;
-	if (cnt > 0) {
-		filewrite(f, scgp->errbeg, cnt);
-		fflush(f);
-		scgp->errbeg = scgp->errptr;
-	}
-	return (cnt);
-}

Modified: nonameyet/branches/surgery/mkisofs/CMakeLists.txt
===================================================================
--- nonameyet/branches/surgery/mkisofs/CMakeLists.txt	2006-11-19 17:32:55 UTC (rev 400)
+++ nonameyet/branches/surgery/mkisofs/CMakeLists.txt	2006-11-19 17:41:44 UTC (rev 401)
@@ -1,6 +1,6 @@
 PROJECT (MKISOFS)
 
-INCLUDE(../include/AddScgBits.cmake)
+#INCLUDE(../include/AddScgBits.cmake)
 INCLUDE(../include/AddSchilyBits.cmake)
 
 INCLUDE_DIRECTORIES(../include ../libhfs_iso ../cdrecord ${CMAKE_BINARY_DIR})
@@ -22,9 +22,9 @@
 endif(USE_LIBICONV)
 	
 
-ADD_DEFINITIONS(-DUSE_LARGEFILES -DABORT_DEEP_ISO_ONLY -DAPPLE_HYB -DUDF -DDVD_VIDEO -DSORTING -DHAVE_CONFIG_H -DUSE_LIBSCHILY -DUSE_SCG -DJIGDO_TEMPLATE)
+ADD_DEFINITIONS(-DUSE_LARGEFILES -DABORT_DEEP_ISO_ONLY -DAPPLE_HYB -DUDF -DDVD_VIDEO -DSORTING -DHAVE_CONFIG_H -DUSE_LIBSCHILY -DJIGDO_TEMPLATE)
 
-SET(MKISOFS_MOST_SRCS apple.c boot.c cd_misc.c defaults.c desktop.c dvd_file.c dvd_reader.c eltorito.c exclude.c files.c fnmatch.c getnum.c getopt.c getopt1.c hash.c ifo_read.c joliet.c mac_label.c match.c modes.c multi.c name.c rock.c scsi.c scsi_cdr.c stream.c tree.c udf.c vms.c volume.c write.c boot-alpha.c boot-hppa.c boot-mips.c md5.c jte.c rsync.c
+SET(MKISOFS_MOST_SRCS apple.c boot.c cd_misc.c defaults.c desktop.c dvd_file.c dvd_reader.c eltorito.c exclude.c files.c fnmatch.c getnum.c getopt.c getopt1.c hash.c ifo_read.c joliet.c mac_label.c match.c multi.c name.c rock.c stream.c tree.c udf.c vms.c volume.c write.c boot-alpha.c boot-hppa.c boot-mips.c md5.c jte.c rsync.c
 	boot-mipsel.c endian.c  )
 
 #SET_SOURCE_FILES_PROPERTIES(${MKISOFS_MOST_SRCS} PROPERTIES )
@@ -35,7 +35,7 @@
 
 # common lib set and mkisofs source parts for the rest
 LINK_LIBRARIES(${EXTRA_LIBS} deflt unls ${EXTRA_LIBICONV} )
-SET(MI_COMMON scsi.c scsi_cdr.c cd_misc.c modes.c defaults.c getnum.c)
+SET(MI_COMMON cd_misc.c defaults.c getnum.c)
 ADD_EXECUTABLE(devdump diag/dump.c  ${MI_COMMON})
 ADD_EXECUTABLE(isodebug	diag/isodebug.c   ${MI_COMMON})
 ADD_EXECUTABLE(isodump	diag/isodump.c    ${MI_COMMON})




More information about the Debburn-changes mailing list