[Debburn-changes] r371 - nonameyet/branches/experimental/cdrecord
Eduard Bloch
blade at costa.debian.org
Wed Oct 25 23:12:47 CEST 2006
Author: blade
Date: 2006-10-25 21:12:46 +0000 (Wed, 25 Oct 2006)
New Revision: 371
Removed:
nonameyet/branches/experimental/cdrecord/COPYING
Modified:
nonameyet/branches/experimental/cdrecord/cdrecord.c
Log:
installed cdrecord.c from cdrecord-1.8a29 and removed cdrecord/COPYING
Deleted: nonameyet/branches/experimental/cdrecord/COPYING
===================================================================
--- nonameyet/branches/experimental/cdrecord/COPYING 2006-10-25 21:10:03 UTC (rev 370)
+++ nonameyet/branches/experimental/cdrecord/COPYING 2006-10-25 21:12:46 UTC (rev 371)
@@ -1,16 +0,0 @@
-This software is under GPL but you should read the following clarifications:
-
-
-- You may not modify certain copyright messages in cdrecord.c
-
- See cdrecord.c for further information.
-
-
-- You may (with a few exceptions) not modify the location of the
- configuration file /etc/default/cdrecord.
-
- See defaults.c for further information.
-
-Please note that this is just the way I interpret the GPL and as this
-is my software, users should follow my interpretation of the GPL and not
-use their own different interpretations.
Modified: nonameyet/branches/experimental/cdrecord/cdrecord.c
===================================================================
--- nonameyet/branches/experimental/cdrecord/cdrecord.c 2006-10-25 21:10:03 UTC (rev 370)
+++ nonameyet/branches/experimental/cdrecord/cdrecord.c 2006-10-25 21:12:46 UTC (rev 371)
@@ -1,43 +1,27 @@
-/*
- * 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 */
+/* %Z%%M% %I% %E% Copyright 1995 J. Schilling */
#ifndef lint
static char sccsid[] =
- "@(#)cdrecord.c 1.310 06/02/09 Copyright 1995-2006 J. Schilling";
+ "%Z%%M% %I% %E% Copyright 1995 J. Schilling";
#endif
/*
* Record data on a CD/CVD-Recorder
*
- * Copyright (c) 1995-2006 J. Schilling
+ * Copyright (c) 1995 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.
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
*
* 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.
+ * 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, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <mconfig.h>
@@ -46,27 +30,22 @@
#include <stdxlib.h>
#include <fctldefs.h>
#include <errno.h>
-#include <timedefs.h>
+#include <sys/types.h>
+#include <sys/time.h>
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h> /* for rlimit */
#endif
+#include <sys/stat.h>
#include <statdefs.h>
#include <unixstd.h>
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
#endif
#include <strdefs.h>
+#include <waitdefs.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 */
@@ -74,22 +53,9 @@
#include "auheader.h"
#include "cdrecord.h"
-#include "defaults.h"
-#include "movesect.h"
-#ifdef __linux__
-#include <sys/capability.h> /* for rawio capability */
-#endif
+char cdr_version[] = "1.8a28";
-#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.
*/
@@ -124,7 +90,7 @@
char *db2name[] = {
"Raw (audio)",
"Raw (audio) with P/Q sub channel",
- "Raw (audio) with P/W packed sub channel",
+ "Raw (audio) with P/W sub channel",
"Raw (audio) with P/W raw sub channel",
"Reserved mode 4",
"Reserved mode 5",
@@ -132,448 +98,184 @@
"Vendor unique mode 7",
"CD-ROM mode 1",
"CD-ROM mode 2",
+ "CD-ROM XA mode 1",
"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",
};
+int debug; /* print debug messages */
+LOCAL int scsi_verbose; /* SCSI verbose flag */
+int lverbose; /* local verbose flag */
+
/*
- * Map write modes into names.
+ * NOTICE: You should not make BUF_SIZE more than
+ * the buffer size of the CD-Recorder.
+ *
+ * Do not set BUF_SIZE to be more than 126 KBytes
+ * if you are running cdrecord on a sun4c machine.
+ *
+ * WARNING: Philips CDD 521 dies if BUF_SIZE is to big.
*/
-static char wm_none[] = "unknown";
-static char wm_ill[] = "illegal";
+/*#define BUF_SIZE (126*1024)*/
+/*#define BUF_SIZE (100*1024)*/
+#define BUF_SIZE (63*1024)
+/*#define BUF_SIZE (56*1024)*/
-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 */
+long bufsize; /* The size of the transfer buffer */
+int data_secs_per_tr; /* # of data secs per transfer */
+int audio_secs_per_tr; /* # of audio secs per transfer */
-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;
+int didintr;
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);
+EXPORT int main __PR((int ac, char **av));
+LOCAL void usage __PR((int));
+LOCAL void blusage __PR((int));
+LOCAL void intr __PR((int sig));
+EXPORT int read_buf __PR((int f, char *bp, int size));
+EXPORT int get_buf __PR((int f, char **bpp, int size));
+LOCAL int write_track_data __PR((SCSI *scgp, cdr_t *, int , track_t *));
+EXPORT int pad_track __PR((SCSI *scgp, cdr_t *dp, int track, track_t *trackp,
+ long startsec, long amt,
+ BOOL dolast, long *bytesp));
+EXPORT int write_buf __PR((SCSI *scgp, cdr_t *dp, int track, track_t *trackp,
+ char *bp, long startsec, long amt, int secsize,
+ BOOL dolast, long *bytesp));
+LOCAL void printdata __PR((int, track_t *));
+LOCAL void printaudio __PR((int, track_t *));
+LOCAL void checkfile __PR((int, track_t *));
+LOCAL int checkfiles __PR((int, track_t *));
+LOCAL void setpregaps __PR((int, track_t *));
+LOCAL long checktsize __PR((int, track_t *));
+LOCAL void checksize __PR((track_t *));
+LOCAL BOOL checkdsize __PR((SCSI *scgp, cdr_t *dp, dstat_t *dsp, long tsize));
+LOCAL void raise_fdlim __PR((void));
+LOCAL void gargs __PR((int, char **, int *, track_t *, char **,
+ int *, cdr_t **,
+ int *, long *, int *, int *));
+LOCAL void set_trsizes __PR((cdr_t *, int, track_t *));
+EXPORT void load_media __PR((SCSI *scgp, cdr_t *));
+EXPORT void unload_media __PR((SCSI *scgp, cdr_t *, int));
+EXPORT void set_secsize __PR((SCSI *scgp, int secsize));
+LOCAL void check_recovery __PR((SCSI *scgp, cdr_t *, int));
+ void audioread __PR((SCSI *scgp, cdr_t *, int));
+LOCAL void print_msinfo __PR((SCSI *scgp, cdr_t *));
+LOCAL void print_toc __PR((SCSI *scgp, cdr_t *));
+LOCAL void print_track __PR((int, long, struct msf *, int, int, int));
+LOCAL void prtimediff __PR((const char *fmt,
+ struct timeval *start,
+ struct timeval *stop));
#if !defined(HAVE_SYS_PRIOCNTL_H)
-static int rt_raisepri(int);
+LOCAL int rt_raisepri __PR((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);
+EXPORT void raisepri __PR((int));
+LOCAL void checkgui __PR((void));
+LOCAL char * astoll __PR((const char *s, Llong *ll));
+LOCAL Llong number __PR((char* arg, int* retp));
+EXPORT int getnum __PR((char* arg, long* valp));
+EXPORT int getllnum __PR((char *arg, Llong* lvalp));
+LOCAL int getbltype __PR((char* optstr, long *typep));
-#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;
-
-int
-main(int argc, char *argv[])
+EXPORT int
+main(ac, av)
+ int ac;
+ char *av[];
{
char *dev = NULL;
int timeout = 40; /* Set default timeout to 40s CW-7502 is slow*/
- int speed = -1;
+ int speed = 1;
long flags = 0L;
+ int toctype = -1;
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;
+ dstat_t ds;
long startsec = 0L;
+ int old_secsize = -1;
int errs = 0;
- SCSI *scgp = NULL;
+ SCSI *scgp;
char errstr[80];
- BOOL gracedone = FALSE;
- int ispacket;
- BOOL is_cdwr = FALSE;
- BOOL is_dvdwr = FALSE;
+#ifdef __EMX__
+ /* This gives wildcard expansion with Non-Posix shells with EMX */
+ _wildcard(&ac, &av);
+#endif
+ save_args(ac, av);
- /* 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");
- }
-
- 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"
- );
-
- if(strcmp(argv[0], "cdrecord") == 0)
- strcpy(argv[0], "wodim");
-
-#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;
+ fillbytes(track, sizeof(track), '\0');
raise_fdlim();
- ispacket = gargs(argc, argv, &tracks, track, &dev, &timeout, &dp, &speed, &flags,
- &blanktype, &formattype);
- if ((track[0].tracktype & TOC_MASK) == TOC_MASK)
+ gargs(ac, av, &tracks, track, &dev, &timeout, &dp, &speed, &flags,
+ &toctype, &blanktype);
+ if (toctype < 0)
comerrno(EX_BAD, "Internal error: Bad TOC type.\n");
+ if ((flags & F_MSINFO) == 0 || lverbose || flags & F_VERSION)
+ printf("Cdrecord release %s Copyright (C) 1995-1999 Jörg Schilling\n",
+ cdr_version);
+ if (flags & F_VERSION)
+ exit(0);
- 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);
- }
-
checkgui();
if (debug || lverbose) {
printf("TOC Type: %d = %s\n",
- track[0].tracktype & TOC_MASK,
- toc2name[track[0].tracktype & TOC_MASK]);
+ toctype, toc2name[toctype & 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.
+ * but you need access to root anyway to use /dev/scg?
*/
- 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");
- }
+#if defined(HAVE_MLOCKALL) || defined(_POSIX_MEMLOCK)
+ if (mlockall(MCL_CURRENT|MCL_FUTURE) < 0)
+ comerr("Cannot do mlockall(2).\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) */
+ init_fifo(fs);
}
- if ((flags & F_WAITI) != 0) {
- if (lverbose)
- printf("Waiting for data on stdin...\n");
- wait_input();
+ if ((scgp = open_scsi(dev, errstr, sizeof(errstr),
+ debug, (flags & F_MSINFO) == 0 || lverbose)) == (SCSI *)0) {
+ comerr("%s%sCannot open SCSI driver.\n", errstr, errstr[0]?". ":"");
}
-
- /*
- * 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);
- }
-
- /*
- * XXX scg_open() needs root privilleges (According to Joerg Schilling, but let's try anyway)
- */
- if (
- (scgp = scg_open(dev, errstr, sizeof (errstr),
- debug,
- /* disabled unless one can explain my what is so special about the F_MSINFO option that the absense of it requires printing of the uber-verbose scg messages (flags & F_MSINFO) == 0 || */
- lverbose)) == (SCSI *)0
- )
- {
- if (dev != NULL
- || (flags & F_SCANBUS) == 0
- || (scgp = scg_open("ATA", errstr, sizeof (errstr),
- debug,
- /* disabled unless one can explain my what is so special about the F_MSINFO option that the absense of it requires printing of the uber-verbose scg messages (flags & F_MSINFO) == 0 || */
- lverbose)) == (SCSI *)0
- )
- {
- errmsg("%s%sCannot open SCSI driver.\n", errstr, errstr[0]?". ":"");
- errmsgno(EX_BAD, "For possible targets try 'wodim -scanbus'.%s\n",
- geteuid() ? " Make sure you are root.":"");
- errmsgno(EX_BAD, "For possible transport specifiers try 'wodim dev=help'.\n");
- errmsgno(EX_BAD, "\n");
- errmsgno(EX_BAD, "For more information, install the cdrkit-doc\n");
- errmsgno(EX_BAD, "package and read /usr/share/doc/wodim/README.ATAPI.setup .\n");
- exit(EX_BAD);
- }
- else {
- dev = "ATA";
- }
- }
-#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);
+ scsi_settimeout(scgp, timeout);
scgp->verbose = scsi_verbose;
- scgp->silent = silent;
scgp->debug = debug;
- scgp->kdebug = kdebug;
- scgp->cap->c_bsize = DATA_SEC_SIZE;
+ scgp->cap->c_bsize = 2048;
-
- 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));
- }
- }
- 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)
+ bufsize = scsi_bufsize(scgp, BUF_SIZE);
+ if ((buf = scsi_getbuf(scgp, bufsize)) == NULL)
comerr("Cannot get SCSI I/O buffer.\n");
if ((flags & F_SCANBUS) != 0) {
- select_target(scgp, stdout);
+ select_target(scgp);
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");
+ scsireset(scgp);
exit(0);
}
-
/*
* First try to check which type of SCSI device we
* have.
*/
if (debug || lverbose)
- printf("atapi: %d\n", scg_isatapi(scgp));
+ printf("atapi: %d\n", scsi_isatapi(scgp));
scgp->silent++;
test_unit_ready(scgp); /* eat up unit attention */
scgp->silent--;
@@ -583,146 +285,47 @@
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() */
+ if (dp == (cdr_t *)NULL) { /* No driver= option specified */
+ dp = get_cdrcmds(scgp);
} 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 (!is_cddrive(scgp))
+ comerrno(EX_BAD, "Sorry, no CD/DVD-Drive found on this target.\n");
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) {
- printf("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 (((flags & (F_MSINFO|F_TOC|F_LOAD|F_EJECT)) == 0 || tracks > 0) &&
+ (dp->cdr_flags & CDR_ISREADER) != 0) {
+ comerrno(EX_BAD,
+ "Sorry, no CD/DVD-Recorder or unsupported CD/DVD-Recorder found on this target.\n");
}
- 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);
+ printf("Driver flags : ");
+ if ((dp->cdr_flags & CDR_SWABAUDIO) != 0)
+ printf("SWABAUDIO");
+ printf("\n");
}
scgp->silent++;
if ((debug || lverbose)) {
tsize = -1;
- if ((*dp->cdr_buffer_cap)(scgp, &tsize, (long *)0) < 0 || tsize < 0) {
+ 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);
+ tsize = a_to_u_long(buf);
}
if (tsize > 0) {
printf("Drive buf size : %lu = %lu KB\n",
@@ -731,469 +334,159 @@
}
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))
+ if (tracks > 0 && (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) {
+ if (tracks == 0 && (flags & (F_FIX|F_BLANK)) == 0 && (flags & F_EJECT) != 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);
- }
-
+ flush();
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);
+do_cue(tracks, track, 0);
/*
- * Make wm2name[wrmode] work.
- * This must be done after the track flags have been set up
- * by the functions above.
+ * Is this the right place to do this ?
*/
- 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);
+ check_recovery(scgp, dp, 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);
+ load_media(scgp, dp);
- 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 */
+ if ((flags & F_LOAD) != 0) {
+ scsi_prevent_removal(scgp, 0); /* allow manual open */
+ exit(0);
}
- 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);
-
+ old_secsize = sense_secsize(scgp, 1);
+ if (old_secsize < 0)
+ old_secsize = sense_secsize(scgp, 0);
if (lverbose)
- printf("Current Secsize: %d\n", exargs.old_secsize);
+ printf("Current Secsize: %d\n", 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;*/
+ fillbytes(&ds, sizeof(ds), '\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;
+ ds.ds_cdrflags = RF_WRITE;
+ if (flags & F_PRATIP) {
+ lverbose++; /* XXX Hack */
}
- 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) {
+ if ((*dp->cdr_getdisktype)(scgp, dp, &ds) < 0) {
errmsgno(EX_BAD, "Cannot get disk type.\n");
if ((flags & F_FORCE) == 0)
- comexit(EX_BAD);
+ exit(EX_BAD);
}
if (flags & F_PRATIP) {
- comexit(0);
+ lverbose--; /* XXX Hack */
+ scsi_prevent_removal(scgp, 0);
+ exit(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) {
+ if (flags & F_MSINFO) {
/*
- * Note that the set speed function also contains
- * drive option processing for speed related drive options.
+ * Dirty hack!
+ * At least MMC drives will not return the next writable
+ * address we expect when the drive's write mode is set
+ * tp DAO/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. Set_speed_dummy() witha a
+ * 'speedp' f 0 sets the write mode to TAO on MMC drives.
*/
- 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) {
+ scgp->silent++;
+ (*dp->cdr_set_speed_dummy)(scgp, 0, TRUE);
+ scgp->silent--;
print_msinfo(scgp, dp);
- comexit(0);
+ scsi_prevent_removal(scgp, 0);
+ exit(0);
}
if (flags & F_TOC) {
print_toc(scgp, dp);
- comexit(0);
+ scsi_prevent_removal(scgp, 0);
+ exit(0);
}
+
#ifdef XXX
if ((*dp->cdr_check_session)() < 0) {
- comexit(EX_BAD);
+ set_secsize(scgp, old_secsize);
+ unload_media(scgp, dp, flags);
+ exit(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");
+ "WARNING: Track 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);
+ } else if (!checkdsize(scgp, dp, &ds, tsize) && (flags & (F_IGNSIZE|F_FORCE)) == 0) {
+ set_secsize(scgp, old_secsize);
+ unload_media(scgp, dp, flags);
+ exit(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.
+ * Start the extra process needed for improved buffering.
*/
- 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))
+ if (!init_faio(tracks, track, bufsize))
fs = 0L;
- else
- on_comerr(excdr, &exargs);
-
-#if defined(USE_POSIX_PRIORITY_SCHEDULING) && defined(HAVE_SETREUID)
+ }
+ if (old_secsize > 0 && old_secsize != 2048) {
/*
- * XXX Below this point we never need root privilleges anymore.
+ * Some drives (e.g. Plextor) don't like to write correctly
+ * in DAO mode if the sector size is set to 512 bytes.
*/
- 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
+ set_secsize(scgp, 2048);
}
- if ((*dp->cdr_set_speed_dummy)(scgp, dp, &speed) < 0) {
+ if ((*dp->cdr_set_speed_dummy)(scgp, &speed, flags & F_DUMMY) < 0) {
errmsgno(EX_BAD, "Cannot set speed/dummy.\n");
- if ((flags & F_FORCE) == 0)
- comexit(EX_BAD);
+ set_secsize(scgp, old_secsize);
+ unload_media(scgp, dp, flags);
+ exit(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);
+ scsi_blank(scgp, 0L, blanktype);
+ exit(0);
}
-
/*
* Last chance to quit!
*/
- if (gracewait(dp, &gracedone) < 0) {
- /*
- * In case kill() did not work ;-)
- */
- errs++;
- goto restore_it;
+ printf("Starting to write CD/DVD at speed %d in %s mode for %s session.\n",
+ speed,
+ (flags & F_DUMMY) ? "dummy" : "write",
+ (flags & F_MULTI) ? "multi" : "single");
+ printf("Last chance to quit, starting %s write in 9 seconds.",
+ (flags & F_DUMMY)?"dummy":"real");
+ flush();
+ signal(SIGINT, intr);
+ for (i=9; --i > 0;) {
+ sleep(1);
+ if (didintr) {
+ printf("\n");
+ goto restore_it;
+ }
+ printf("\b\b\b\b\b\b\b\b\b\b%d seconds.", i);
+ flush();
}
-
- 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);
- }
- }
-
+ signal(SIGINT, SIG_DFL);
+ printf("\n");
if (tracks > 0 && fs > 0l) {
/*
* Wait for the read-buffer to become full.
@@ -1203,15 +496,12 @@
* we abort before the writing process started.
*/
if (!await_faio()) {
- comerrno(EX_BAD, "Input buffer error, aborting.\n");
+ errmsgno(EX_BAD, "Input buffer error, aborting.\n");
+ set_secsize(scgp, old_secsize);
+ unload_media(scgp, dp, flags);
+ exit(EX_BAD);
}
}
- 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");
@@ -1219,73 +509,22 @@
* 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) {
+ if ((*dp->cdr_blank)(scgp, 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);
+ set_secsize(scgp, old_secsize);
+ unload_media(scgp, dp, flags);
+ exit(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 (!wait_unit_ready(scgp, 60) || tracks == 0) {
+ set_secsize(scgp, old_secsize);
+ unload_media(scgp, dp, flags);
+ exit(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.
@@ -1293,51 +532,30 @@
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.
+ * Get the number of the next recordable track.
*/
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 = 1; i <= tracks; i++) {
+ track[i].trackno = i + trackno;
}
+ trackno++;
+ track[0].trackno = trackno; /* XXX Hack for TEAC fixate */
- 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 ((*dp->cdr_open_session)(scgp, tracks, track, toctype, flags & F_MULTI) < 0) {
+ errmsgno(EX_BAD, "Cannot open new session.\n");
+ set_secsize(scgp, old_secsize);
+ unload_media(scgp, dp, flags);
+ exit(EX_BAD);
}
- if (!do_opc(scgp, dp, flags))
- comexit(EX_BAD);
/*
* As long as open_session() will do nothing but
@@ -1349,33 +567,58 @@
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 (flags & F_SAO) {
+ if (debug || lverbose) {
+ printf("Sending CUE sheet...\n");
+ flush();
+ }
+ if ((*dp->cdr_send_cue)(scgp, tracks, track) < 0) {
+ errmsgno(EX_BAD, "Cannot send CUE sheet.\n");
+ set_secsize(scgp, old_secsize);
+ unload_media(scgp, dp, flags);
+ exit(EX_BAD);
+ }
+ }
+ if ((flags & F_SAO)) {
+ (*dp->cdr_next_wr_address)(scgp, 0, &track[0], &startsec);
+ if (startsec <= 0 && startsec != -150) {
+ errmsgno(EX_BAD, "WARNING: Drive returns wrong startsec (%d) using -150\n",
+ startsec);
+ startsec = -150;
+ }
- if (lverbose && (dp->cdr_dstat->ds_cdrflags & RF_LEADIN) != 0) {
+ if (debug)
+ printf("SAO startsec: %ld\n", startsec);
- if (gettimeofday(&fixtime, (struct timezone *)0) < 0)
- errmsg("Cannot get lead-in write time\n");
- prtimediff("Lead-in write time: ", &starttime, &fixtime);
- }
+ for (i = 1; i <= tracks; i++) {
+ track[i].trackstart += startsec +150;
+ }
+#ifdef XXX
+ if (debug || lverbose)
+ printf("Writing lead-in...\n");
- if (gettimeofday(&wstarttime, (struct timezone *)0) < 0)
- errmsg("Cannot get start time\n");
- for (i = 1; i <= tracks; i++) {
+ pad_track(scgp, dp, 1, &track[1], -150, 0,
+ FALSE, 0);
+#endif
+ }
+ /*
+ * Need to set trackno to the real value from
+ * the current disk status.
+ */
+ for (i = 1; i <= tracks; i++, trackno++) {
startsec = 0L;
- if ((*dp->cdr_open_track)(scgp, dp, &track[i]) < 0) {
- errmsgno(EX_BAD, "Cannot open next track.\n");
+ /*
+ * trackno is the "real" track number while 'i' is a counter
+ * going from 1 to tracks.
+ */
+ if ((*dp->cdr_open_track)(scgp, dp, trackno, &track[i]) < 0) {
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");
+ if ((flags & F_SAO) == 0) {
+ if ((*dp->cdr_next_wr_address)(scgp, trackno, &track[i], &startsec) < 0) {
errs++;
break;
}
@@ -1386,38 +629,19 @@
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");
- }
+ if (write_track_data(scgp, dp, trackno, &track[i]) < 0) {
errs++;
sleep(5);
- unit_ready(scgp);
- (*dp->cdr_close_track)(scgp, dp, &track[i]);
+ request_sense(scgp);
+ (*dp->cdr_close_track)(scgp, trackno, &track[i]);
break;
}
- if ((*dp->cdr_close_track)(scgp, dp, &track[i]) < 0) {
+ if ((*dp->cdr_close_track)(scgp, trackno, &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");
+ if (scsi_sense_key(scgp) != SC_ILLEGAL_REQUEST ||
+ scsi_sense_code(scgp) != 0xB5) {
errs++;
break;
}
@@ -1426,440 +650,147 @@
fix_it:
if (gettimeofday(&stoptime, (struct timezone *)0) < 0)
errmsg("Cannot get stop time\n");
- cdrstats(dp);
+ if (lverbose)
+ prtimediff("Writing time: ", &starttime, &stoptime);
- 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 ((*dp->cdr_fixate)(scgp, flags & F_MULTI, flags & F_DUMMY,
+ toctype, tracks, track) < 0)
+ 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.
+ * Try to restore the old sector size.
*/
- kill_faio();
- comexit(errs?-2:0);
- return (0);
-}
+ set_secsize(scgp, old_secsize);
+ unload_media(scgp, dp, flags);
-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;
+#ifdef FIFO
+ if (tracks > 0 && fs > 0L) {
+ kill_faio();
+ wait(0);
+ if (debug || lverbose)
+ fifo_stats();
}
- 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);
+#endif
- 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;
+ exit(errs?-2:0);
return (0);
}
-static void
-cdrstats(cdr_t *dp)
+LOCAL void
+usage(excode)
+ int excode;
{
- float secsps = 75.0;
- int nsecs;
- float fspeed;
- struct timeval tcur;
- struct timeval tlast;
- BOOL nostop = FALSE;
+ errmsgno(EX_BAD, "Usage: %s [options] track1...trackn\n",
+ get_progname());
- 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");
+ error("Options:\n");
+ error("\t-version print version information and exit\n");
+ error("\t-v increment general verbose level by one\n");
+ error("\t-V increment SCSI command transport verbose level by one\n");
+ error("\t-debug print additional debug messages\n");
+ error("\tdev=target SCSI target to use as CD/DVD-Recorder\n");
+ error("\ttimeout=# set the default SCSI command timeout to #.\n");
+ error("\tdriver=name user supplied driver name, use with extreme care\n");
+ error("\t-checkdrive check if a driver for the drive is present\n");
+ error("\t-prcap print drive capabilities for MMC compliant drives\n");
+ error("\t-inq do an inquiry for the drive end exit\n");
+ error("\t-scanbus scan the SCSI bus end exit\n");
+ error("\t-reset reset the SCSI bus with the cdrecorder (if possible)\n");
+ error("\t-ignsize ignore the known size of a medium (may cause problems)\n");
+ error("\t-useinfo use *.inf files to overwrite audio options.\n");
+ error("\tspeed=# set speed of drive\n");
+ error("\tblank=type blank a CD-RW disc (see blank=help)\n");
#ifdef FIFO
- fprintf(stderr, "\tfs=# Set fifo size to # (0 to disable, default is %ld MB)\n",
- DEFAULT_FIFOSIZE/(1024L*1024L));
+ error("\tfs=# Set fifo size to # (0 to disable, default is %ld MB)\n",
+ DEFAULT_FIFOSIZE/(1024*1024));
#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");
+ error("\t-load load the disk and exit (works only with tray loader)\n");
+ error("\t-eject eject the disk after doing the work\n");
+ error("\t-dummy do everything with laser turned off\n");
+ error("\t-msinfo retrieve multi-session info for mkisofs >= 1.10\n");
+ error("\t-toc retrieve and print TOC/PMA data\n");
+ error("\t-atip retrieve and print ATIP data\n");
+ error("\t-multi generate a TOC that allows multi session\n");
+ error("\t In this case default track type is CD-ROM XA2\n");
+ error("\t-fix fixate a corrupt or unfixated disk (generate a TOC)\n");
+ error("\t-nofix do not fixate disk after writing tracks\n");
+ error("\t-force force to continue on some errors to allow blanking bad disks\n");
+ error("\t-dao Write disk in DAO mode. This option will go away in the future.\n");
+ error("\ttsize=# Length of valid data in next track\n");
+ error("\tpadsize=# Amount of padding for next track\n");
+ error("\tpregap=# Amount of pre-gap sectors before next track\n");
+ error("\tdefpregap=# Amount of pre-gap sectors for all but track #1\n");
+ error("\tmcn=text Set the media catalog number for this CD to 'text'\n");
+ error("\tisrc=text Set the ISRC number for the next track to 'text'\n");
+ error("\tindex=list Set the index list for the next track to 'list'\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");
+ error("\t-audio Subsequent tracks are CD-DA audio tracks\n");
+ error("\t-data Subsequent tracks are CD-ROM data mode 1 (default)\n");
+ error("\t-mode2 Subsequent tracks are CD-ROM data mode 2\n");
+ error("\t-xa1 Subsequent tracks are CD-ROM XA mode 1\n");
+ error("\t-xa2 Subsequent tracks are CD-ROM XA mode 2\n");
+ error("\t-cdi Subsequent tracks are CDI tracks\n");
+ error("\t-isosize Use iso9660 file system size for next data track\n");
+ error("\t-preemp Audio tracks are mastered with 50/15 µs preemphasis\n");
+ error("\t-nopreemp Audio tracks are mastered with no preemphasis (default)\n");
+ error("\t-pad Pad data tracks with %d zeroed sectors\n", PAD_SECS);
+ error("\t Pad audio tracks to a multiple of %d bytes\n", AUDIO_SEC_SIZE);
+ error("\t-nopad Do not pad data tracks (default)\n");
+ error("\t-swab Audio data source is byte-swapped (little-endian/Intel)\n");
+ error("The type of the first track is used for the toc type.\n");
+ error("Currently only form 1 tracks are supported.\n");
exit(excode);
}
-static void
-blusage(int ret)
+LOCAL void
+blusage(ret)
+ 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");
+ error("Blanking options:\n");
+ error("\tall\t\tblank the entire disk\n");
+ error("\tdisc\t\tblank the entire disk\n");
+ error("\tdisk\t\tblank the entire disk\n");
+ error("\tfast\t\tminimally blank the entire disk (PMA, TOC, pregap)\n");
+ error("\tminimal\t\tminimally blank the entire disk (PMA, TOC, pregap)\n");
+ error("\ttrack\t\tblank a track\n");
+ error("\tunreserve\tunreserve a track\n");
+ error("\ttrtail\t\tblank a track tail\n");
+ error("\tunclose\t\tunclose last session\n");
+ error("\tsession\t\tblank last session\n");
exit(ret);
/* NOTREACHED */
}
-static void
-formattypeusage(int ret)
+LOCAL void
+intr(sig)
+ int sig;
{
- 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");
+ sig = 0; /* Fake usage */
- exit(ret);
- /* NOTREACHED */
-}
-
-/* ARGSUSED */
-static void
-intr(int sig)
-{
- sig = 0; /* Fake usage for gcc */
-
signal(SIGINT, intr);
didintr++;
}
-static void
-catchsig(int sig)
+EXPORT int
+read_buf(f, bp, size)
+ int f;
+ char *bp;
+ int size;
{
- 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;
@@ -1867,7 +798,7 @@
do {
do {
n = read(f, p, size-amount);
- } while (n < 0 && (geterrno() == EAGAIN || geterrno() == EINTR));
+ } while (n < 0 && (errno == EAGAIN || errno == EINTR));
if (n < 0)
return (n);
amount += n;
@@ -1877,184 +808,62 @@
return (amount);
}
-int
-fill_buf(int f, track_t *trackp, long secno, char *bp, int size)
+EXPORT int
+get_buf(f, bpp, size)
+ int f;
+ char **bpp;
+ 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));
+ return (read_buf(f, *bpp, size));
}
}
-int
-write_secs(SCSI *scgp, cdr_t *dp, char *bp, long startsec, int bytespt,
- int secspt, BOOL islast)
+LOCAL int
+write_track_data(scgp, dp, track, trackp)
+ SCSI *scgp;
+ cdr_t *dp;
+ int track;
+ track_t *trackp;
{
- 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 f;
int isaudio;
long startsec;
- Llong bytes_read = 0;
- Llong bytes = 0;
- Llong savbytes = 0;
+ long bytes_read = 0;
+ long bytes = 0;
+ long savbytes = 0;
int count;
- Llong tracksize;
+ long tracksize;
int secsize;
int secspt;
int bytespt;
int bytes_to_read;
long amount;
int pad;
+ int bswab;
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 per;
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 */
+ if (read_buff_cap(scgp, &bsize, &bfree) < 0)
+ bsize = -1;
scgp->silent--;
if (is_packet(trackp)) /* XXX Ugly hack for now */
- return (write_packet_data(scgp, dp, trackp));
+ return (write_packet_data(scgp, dp, track, trackp));
- if (trackp->xfp != NULL)
- f = xfileno(trackp->xfp);
-
+ f = trackp->f;
isaudio = is_audio(trackp);
tracksize = trackp->tracksize;
startsec = trackp->trackstart;
@@ -2062,8 +871,9 @@
secsize = trackp->secsize;
secspt = trackp->secspt;
bytespt = secsize * secspt;
-
+
pad = !isaudio && is_pad(trackp); /* Pad only data tracks */
+ bswab = isaudio && is_swab(trackp); /* Swab only audio tracks */
if (debug) {
printf("secsize:%d secspt:%d bytespt:%d audio:%d pad:%d\n",
@@ -2072,24 +882,22 @@
if (lverbose) {
if (tracksize > 0)
- printf("\rTrack %02d: 0 of %4lld MB written.",
- track, tracksize >> 20);
+ printf("\rTrack %02d: 0 of %3ld MB written.",
+ track, tracksize >> 20);
else
- printf("\rTrack %02d: 0 MB written.", track);
+ 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 = tracksize - bytes_read;
+ if (bytes_to_read > bytespt)
bytes_to_read = bytespt;
- else
- bytes_to_read = tracksize - bytes_read;
}
- count = get_buf(f, trackp, startsec, &bp, bytes_to_read);
+ count = get_buf(f, &bp, bytes_to_read);
if (count < 0)
comerr("read error on input file\n");
@@ -2098,16 +906,13 @@
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))
+ if (trackp->padsize == 0 && (bytes_read/secsize) >= 300)
islast = TRUE;
}
+ if (bswab)
+ swabbytes(bp, count);
+
if (count < bytespt) {
if (debug) {
printf("\nNOTICE: reducing block size for last record.\n");
@@ -2116,25 +921,20 @@
if ((amount = count % secsize) != 0) {
amount = secsize - amount;
+ fillbytes(&bp[count], amount, '\0');
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))
+ if (trackp->padsize == 0 && (bytes_read/secsize) >= 300)
islast = TRUE;
}
- amount = write_secs(scgp, dp, bp, startsec, bytespt, secspt, islast);
+ amount = (*dp->cdr_write_trackdata)(scgp, bp, startsec, bytespt, secspt, islast);
if (amount < 0) {
- printf("%swrite track data: error after %lld bytes\n",
+ printf("%swrite track data: error after %ld bytes\n",
neednl?"\n":"", bytes);
return (-1);
}
@@ -2143,219 +943,108 @@
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);
+ printf("\rTrack %02d: %3ld", track, bytes >> 20);
if (tracksize > 0)
- printf(" of %4lld MB", tracksize >> 20);
+ printf(" of %3ld 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);
+#ifdef BCAP
+ if (bsize >= 0) {
+ read_buff_cap(scgp, 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",
+ printf("[%3d] %3d %3d\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 ((bytes / secsize) < 300) {
+ amount = roundup(trackp->padsize, secsize);
+ if (((bytes+amount) / secsize) < 300)
+ trackp->padsize = 300 * secsize - bytes;
}
- 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 (trackp->padsize) {
if (neednl) {
printf("\n");
neednl = FALSE;
}
- if ((padbytes >> 20) > 0) {
+ if ((trackp->padsize >> 20) > 0) {
neednl = TRUE;
} else if (lverbose) {
- printf("Track %02d: writing %3lld KB of pad data.\n",
- track, (Llong)(padbytes >> 10));
+ printf("Track %02d: writing %3ld KB of pad data.\n",
+ track, trackp->padsize >> 10);
neednl = FALSE;
}
- pad_track(scgp, dp, trackp, startsec, padbytes,
- TRUE, &savbytes);
- bytes += savbytes;
- startsec += savbytes / secsize;
+ pad_track(scgp, dp, track, trackp, startsec, trackp->padsize,
+ TRUE, &amount);
+ bytes += amount;
+ startsec += amount / secsize;
}
- printf("%sTrack %02d: Total bytes read/written: %lld/%lld (%lld sectors).\n",
- neednl?"\n":"", track, bytes_read, bytes, bytes/secsize);
+ printf("%sTrack %02d: Total bytes read/written: %ld/%ld (%ld sectors).\n",
+ neednl?"\n":"", track, bytes_read, bytes, bytes/secsize);
flush();
- return (0);
+ return 0;
}
-int
-pad_track(SCSI *scgp, cdr_t *dp, track_t *trackp, long startsec, Llong amt,
- BOOL dolast, Llong *bytesp)
+EXPORT int
+pad_track(scgp, dp, track, trackp, startsec, amt, dolast, bytesp)
+ SCSI *scgp;
+ cdr_t *dp;
+ int track;
+ track_t *trackp;
+ long startsec;
+ long amt;
+ BOOL dolast;
+ long *bytesp;
{
- int track = trackp->trackno;
- Llong bytes = 0;
- Llong savbytes = 0;
- Llong padsize = amt;
+ long bytes = 0;
+ long savbytes = 0;
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.",
+ printf("\rTrack %02d: 0 of %3ld MB pad written.",
track, amt >> 20);
flush();
}
- gettimeofday(&tlast, (struct timezone *)0);
do {
if (amt < bytespt) {
bytespt = roundup(amt, secsize);
- secspt = bytespt / 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);
+ amount = (*dp->cdr_write_trackdata)(scgp, buf, startsec, bytespt, secspt, islast);
if (amount < 0) {
- printf("%swrite track pad data: error after %lld bytes\n",
+ 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);
+read_buff_cap(scgp, 0, 0);
return (-1);
}
amt -= amount;
@@ -2363,71 +1052,34 @@
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");
+ printf("\rTrack %02d: %3ld", track, bytes >> 20);
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);
+ return (bytes);
}
#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)
+EXPORT int
+write_buf(scgp, dp, track, trackp, bp, startsec, amt, secsize, dolast, bytesp)
+ SCSI *scgp;
+ cdr_t *dp;
+ int track;
+ track_t *trackp;
+ char *bp;
+ long startsec;
+ long amt;
+ int secsize;
+ BOOL dolast;
+ long *bytesp;
{
- int track = trackp->trackno;
- Llong bytes = 0;
- Llong savbytes = 0;
+ long bytes = 0;
+ long savbytes = 0;
/* int secsize;*/
int secspt;
int bytespt;
@@ -2441,29 +1093,29 @@
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.",
+ printf("\rTrack %02d: 0 of %3ld MB pad written.",
track, amt >> 20);
flush();
}
do {
if (amt < bytespt) {
bytespt = roundup(amt, secsize);
- secspt = bytespt / secsize;
+ secspt = bytespt / secsize;
}
if (dolast && (amt - bytespt) <= 0)
islast = TRUE;
- amount = write_secs(scgp, dp, bp, startsec, bytespt, secspt, islast);
+ amount = (*dp->cdr_write_trackdata)(scgp, 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);
+read_buff_cap(scgp, 0, 0);
return (-1);
}
amt -= amount;
@@ -2484,102 +1136,85 @@
}
#endif /* USE_WRITE_BUF */
-static void
-printdata(int track, track_t *trackp)
+LOCAL void
+printdata(track, trackp)
+ int track;
+ track_t *trackp;
{
- if (trackp->itracksize >= 0) {
- printf("Track %02d: data %4lld MB ",
- track, (Llong)(trackp->itracksize >> 20));
+ if (trackp->tracksize >= 0) {
+ printf("Track %02d: data %3ld MB ",
+ track, trackp->tracksize >> 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));
+ if (trackp->padsize > 0) {
+ if ((trackp->padsize >> 20) > 0)
+ printf(" padsize: %3ld MB", trackp->padsize >> 20);
else
- printf(" padsize: %4lld KB", (Llong)(padbytes >> 10));
+ printf(" padsize: %3ld KB", trackp->padsize >> 10);
}
- if (trackp->pregapsize != (trackp->flags & TI_DVD)? 0 : 150) {
+ if (trackp->pregapsize != 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)
+LOCAL void
+printaudio(track, trackp)
+ 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),
+ if (trackp->tracksize >= 0) {
+ printf("Track %02d: audio %3ld MB (%02d:%02d.%02d) %spreemp%s%s",
+ track, trackp->tracksize >> 20,
+ minutes(trackp->tracksize),
+ seconds(trackp->tracksize),
+ hseconds(trackp->tracksize),
is_preemp(trackp) ? "" : "no ",
is_swab(trackp) ? " swab":"",
- ((trackp->itracksize < 300L*trackp->isecsize) ||
- (trackp->itracksize % trackp->isecsize)) &&
+ ((trackp->tracksize < 300L*trackp->secsize) ||
+ (trackp->tracksize % trackp->secsize)) &&
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" : "");
+ (trackp->tracksize % trackp->secsize) && 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));
+ if (trackp->padsize > 0) {
+ if ((trackp->padsize >> 20) > 0)
+ printf(" padsize: %3ld MB", trackp->padsize >> 20);
else
- printf(" padsize: %4lld KB", (Llong)(padbytes >> 10));
+ printf(" padsize: %3ld KB", trackp->padsize >> 10);
printf(" (%02d:%02d.%02d)",
- Sminutes(trackp->padsecs),
- Sseconds(trackp->padsecs),
- Shseconds(trackp->padsecs));
+ minutes(trackp->padsize),
+ seconds(trackp->padsize),
+ hseconds(trackp->padsize));
}
- if (trackp->pregapsize != ((trackp->flags & TI_DVD)? 0 : 150) || xdebug > 0) {
+ if (trackp->pregapsize != 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
-checkfile(int track, track_t *trackp)
+LOCAL void
+checkfile(track, trackp)
+ int track;
+ track_t *trackp;
{
- if (trackp->itracksize > 0 &&
+ if (trackp->tracksize > 0 &&
is_audio(trackp) &&
- ((!is_shorttrk(trackp) &&
- (trackp->itracksize < 300L*trackp->isecsize)) ||
- (trackp->itracksize % trackp->isecsize)) &&
+ ((trackp->tracksize < 300L*trackp->secsize) ||
+ (trackp->tracksize % trackp->secsize)) &&
!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");
+ errmsgno(EX_BAD, "Bad audio track size %ld for track %02d.\n",
+ trackp->tracksize, track);
+ comerrno(EX_BAD, "Audio tracks must be at least %ld bytes and a multiple of %d.\n",
+ 300L*trackp->secsize, trackp->secsize);
}
-
- if (lverbose == 0 && xdebug == 0)
+
+ if (!lverbose)
return;
if (is_audio(trackp))
@@ -2588,487 +1223,200 @@
printdata(track, trackp);
}
-static int
-checkfiles(int tracks, track_t *trackp)
+LOCAL int
+checkfiles(tracks, trackp)
+ 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++) {
+ for (i = 1; i <= tracks; 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)
+LOCAL void
+setpregaps(tracks, trackp)
+ 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;
+ /*
+ * Set some values for track 0 (the lead-in)
+ * XXX There should be a better place to do this.
+ */
sectype = trackp[1].sectype;
- sectype &= ST_MASK;
+ trackp[0].sectype = sectype;
+ trackp[0].dbtype = trackp[1].dbtype;
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 = 150; /* Default Pre GAP */
+ if (sectype != tp->sectype) {
tp->pregapsize = 255; /* Pre GAP is 255 */
tp->flags &= ~TI_PREGAP;
}
}
- sectype = tp->sectype & ST_MASK; /* Save old sectype */
+ sectype = tp->sectype; /* 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;
- }
+ /*
+ * Set some values for track 0xAA (the lead-out)
+ * XXX There should be a better place to do this.
+ */
+ trackp[tracks+1].sectype = sectype;
+ trackp[tracks+1].dbtype = trackp[tracks].dbtype;
}
-/*
- * Check total size of the medium
- */
-static long
-checktsize(int tracks, track_t *trackp)
+LOCAL long
+checktsize(tracks, trackp)
+ int tracks;
+ track_t *trackp;
{
int i;
- Llong curr;
- Llong total = -150; /* CD track #1 pregap compensation */
+ long curr;
+ long total = -150;
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",
+ printf("track: %d start: %ld 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)
+ if (tp->tracksize >= 0) {
+ curr = (tp->tracksize + (tp->secsize-1)) / tp->secsize;
+ curr += (tp->padsize + (tp->secsize-1)) / tp->secsize;
+
+ if (curr < 300) /* Minimum track size is 4s */
curr = 300;
- if ((trackp->flags & TI_DVD) == 0) {
- /*
- * XXX Was passiert hier bei is_packet() ???
- */
- if (is_tao(tp) && !is_audio(tp)) {
- curr += 2;
- }
+ 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 ??? */
+ btotal = (Ullong)total * 2352;
+/* XXX 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);
- }
+ printf("Total size: %3lu MB (%02d:%02d.%02d) = %ld sectors\n",
+ (Ulong)(btotal >> 20),
+ minutes(btotal),
+ seconds(btotal),
+ hseconds(btotal), total);
+ btotal += 150 * 2352;
+ printf("Lout start: %3lu MB (%02d:%02d/%02d) = %ld sectors\n",
+ (Ulong)(btotal >> 20),
+ minutes(btotal),
+ seconds(btotal),
+ frames(btotal), total);
}
return (total);
}
-static void
-opentracks(track_t *trackp)
+LOCAL void
+checksize(trackp)
+ 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->tracksize < 0 && (trackp->flags & TI_ISOSIZE) != 0) {
+ trackp->tracksize = isosize(trackp->f);
}
- 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->tracksize < 0 && (trackp->flags & TI_NOAUHDR) == 0) {
+ trackp->tracksize = ausize(trackp->f);
}
- 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 */
+ if (trackp->tracksize < 0 && (trackp->flags & TI_NOAUHDR) == 0) {
+ trackp->tracksize = wavsize(trackp->f);
+ if (trackp->tracksize > 0) /* Force little endian input */
trackp->flags |= TI_SWAB;
}
- if (trackp->itracksize == AU_BAD_CODING) {
+ if (trackp->tracksize == 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->tracksize < 0 &&
+ fstat(trackp->f, &st) >= 0 && S_ISREG(st.st_mode)) {
+ trackp->tracksize = 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)
+LOCAL BOOL
+checkdsize(scgp, dp, dsp, tsize)
+ SCSI *scgp;
+ cdr_t *dp;
+ dstat_t *dsp;
+ long tsize;
{
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);
+ (*dp->cdr_next_wr_address)(scgp, /*i*/ 0, (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);
+ dsp->ds_maxblocks,
+ dsp->ds_maxblocks - startsec,
+ 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;*/
+/* return (FALSE);*/
}
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);
+ dsp->ds_maxrblocks,
+ dsp->ds_maxrblocks - startsec,
+ 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;
+ return (FALSE);
}
- 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)) {
+ if (endsec >= (405000-301)) { /*<90 min disk*/
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*/
+ "Data will not fit on any disk.\n");
+ return (FALSE);
+ } else if (endsec >= (333000-150)) { /* 74 min disk*/
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");
- }
+ "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);
+ return (TRUE);
}
-static void
+LOCAL void
raise_fdlim()
{
#ifdef RLIMIT_NOFILE
@@ -3079,46 +1427,32 @@
* 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);
+ "warning: low file descriptor limit (%ld)\n",
+ 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#";
+"help,version,checkdrive,prcap,inq,scanbus,reset,ignsize,useinfo,dev*,timeout#,driver*,tsize&,padsize&,pregap&,defpregap&,speed#,load,eject,dummy,msinfo,toc,atip,multi,fix,nofix,debug,v+,V+,audio,data,mode2,xa1,xa2,cdi,isosize,nopreemp,preemp,nopad,pad,swab,fs&,blank&,pktsize#,packet,noclose,force,dao,scms,isrc*,mcn*,index*";
-/*
- * 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)
+LOCAL void
+gargs(ac, av, tracksp, trackp, devp, timeoutp, dpp, speedp, flagsp, toctypep, blankp)
+ int ac;
+ char **av;
+ int *tracksp;
+ track_t *trackp;
+ cdr_t **dpp;
+ char **devp;
+ int *timeoutp;
+ int *speedp;
+ long *flagsp;
+ int *toctypep;
+ int *blankp;
{
int cac;
char * const*cav;
@@ -3127,31 +1461,24 @@
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;
+ long secsize;
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;
@@ -3160,49 +1487,30 @@
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 sectype = ST_ROM_MODE1;
int dbtype = DB_ROM_MODE1;
- int secsize = DATA_SEC_SIZE;
- int dataoff = 16;
- int ga_ret;
- int wm = 0;
+ int got_track;
trackp[0].flags |= TI_TAO;
trackp[1].pregapsize = -1;
@@ -3210,53 +1518,39 @@
cac = --ac;
cav = ++av;
- for (; ; cac--, cav++) {
+ 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;
+ audio = data = mode2 = xa1 = xa2 = cdi = 0;
+ isize = nopreemp = nopad = 0;
pktsize = 0;
isrc = NULL;
tindex = NULL;
- /*
- * Get options up to next file type arg.
- */
- if ((ga_ret = getargs(&cac, &cav, opts,
+ if (getargs(&cac, &cav, opts,
&help, &version, &checkdrive, &prcap,
- &inq, &scanbus, &reset, &doabort, &overburn, &ignsize,
+ &inq, &scanbus, &reset, &ignsize,
&useinfo,
- devp, timeoutp, &driver, &driveropts, &setdropts,
+ devp, timeoutp, &driver,
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,
+ &load, &eject, &dummy, &msinfo, &toc, &atip,
+ &multi, &fix, &nofix,
+ &debug, &lverbose, &scsi_verbose,
&audio, &data, &mode2,
- &xa, &xa1, &xa2, &xamix, &cdi,
+ &xa1, &xa2, &cdi,
&isize,
&nopreemp, &preemp,
- &nocopy, ©,
- &nopad, &pad, &bswab, getnum, &fs, getnum, &bufsize,
- getbltype, &bltype, &doformat, getformattype, &formattype, &pktsize,
+ &nopad, &pad, &bswab, getnum, &fs,
+ getbltype, &bltype, &pktsize,
&ispacket, &noclose, &force,
- &tao, &dao, &dao, &raw, &raw96r, &raw96p, &raw16,
- &clone,
- &scms, &isrc, &mcn, &tindex,
- &cuefile, &textfile, &usetext,
- &shorttrack, &noshorttrack,
- &gracetime, &dminbuf)) < 0) {
+ &dao, &scms,
+ &isrc, &mcn, &tindex) < 0) {
errmsgno(EX_BAD, "Bad Option: %s.\n", cav[0]);
- susage(EX_BAD);
+ usage(EX_BAD);
}
if (help)
usage(0);
@@ -3275,22 +1569,14 @@
*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) {
@@ -3302,77 +1588,26 @@
*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;
+ sectype = ST_ROM_MODE2;
+ dbtype = DB_XA_MODE2;
}
if (fix)
*flagsp |= F_FIX;
if (nofix)
*flagsp |= F_NOFIX;
- if (waiti)
- *flagsp |= F_WAITI;
- if (immed)
- *flagsp |= F_IMMED;
- if (force)
+ 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]);
@@ -3383,338 +1618,165 @@
#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 ||
+ version = checkdrive = prcap = inq = scanbus = reset = ignsize =
+ load = eject = dummy = msinfo = toc = atip = multi = fix = nofix = force = dao = 0;
+ } else if ((version + checkdrive + prcap + inq + scanbus + reset + ignsize +
+ load + eject + dummy + msinfo + toc + atip + multi + fix + nofix + force + dao) > 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) {
+ if ((audio + data + mode2 + xa1 + xa2 + cdi) > 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");
+ comerrno(EX_BAD, "Only one of -audio, -data, -mode2, -xa1, -xa2, -cdi 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);
+ got_track = getfiles(&cac, &cav, opts);
if (autoaudio) {
autoaudio = 0;
tracktype = TOC_ROM;
- sectype = ST_ROM_MODE1 | ST_MODE_1;
- sectype = SECT_ROM;
+ sectype = ST_ROM_MODE1;
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.
- */
+ if (got_track != 0 && (is_auname(cav[0]) || is_wavname(cav[0]))) {
autoaudio++;
audio++;
}
if (data) {
- /*
- * 2048 Bytes user data
- */
tracktype = TOC_ROM;
- sectype = ST_ROM_MODE1 | ST_MODE_1;
- sectype = SECT_ROM;
+ sectype = ST_ROM_MODE1;
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;
+ sectype = ST_ROM_MODE2;
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;
+ tracktype = TOC_XA1;
+ sectype = ST_ROM_MODE1;
+ dbtype = DB_XA_MODE1;
}
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;
+ tracktype = TOC_XA2;
+ sectype = ST_ROM_MODE2;
+ dbtype = DB_XA_MODE2_F1;
}
- 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;
+ sectype = ST_ROM_MODE2;
+ dbtype = DB_XA_MODE2_F1;
}
- 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;
- }
+ if (tracks == 0)
+ *toctypep = tracktype;
- flags = trackp[0].flags;
-
+ flags = 0;
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 (preemp)
+ flags |= TI_PREEMP;
+ if (scms)
+ flags |= TI_SCMS;
- 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)) {
+ if ((flags & TI_AUDIO) == 0 && padsize > (Llong)0L)
+ pad = TRUE;
+ if (pad) {
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) {
+ if (ispacket)
flags |= TI_PACKET;
- trackp[0].flags &= ~TI_TAO;
- }
- if (noclose)
+ 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.
- */
+ if ((*flagsp & F_SAO) == 0)
+ flags |= TI_TAO;
+
+ if (got_track == 0)
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 (strcmp("-", cav[0]) == 0) {
+ trackp[tracks].f = STDIN_FILENO;
+#if defined(__CYGWIN32__) || defined(__EMX__)
+ setmode(STDIN_FILENO, O_BINARY);
+#endif
+ } else {
+ if (access(cav[0], R_OK) < 0)
+ comerr("No read access for '%s'.\n", cav[0]);
+
+ if ((trackp[tracks].f = open(cav[0], O_RDONLY|O_BINARY)) < 0)
+ comerr("Cannot open '%s'.\n", cav[0]);
+ }
if (!is_auname(cav[0]) && !is_wavname(cav[0]))
flags |= TI_NOAUHDR;
- if ((*flagsp & (F_SAO|F_RAW)) != 0 && (flags & TI_AUDIO) != 0)
+ if ((*flagsp & F_SAO) != 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];
+ secsize = tracktype == TOC_DA ? AUDIO_SEC_SIZE : DATA_SEC_SIZE;
+ 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].padsize = padsize;
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;
+ checksize(&trackp[tracks]);
+ tracksize = trackp[tracks].tracksize;
+ if (tracksize > 0 && (tracksize / secsize) < 300) {
+ tracksize = roundup(tracksize, secsize);
+ padsize = tracksize + roundup(padsize, secsize);
+ if ((padsize / secsize) < 300) {
+ trackp[tracks].padsize =
+ 300 * secsize - tracksize;
+ }
+ }
+#ifdef AUINFO
+ if (useinfo) {
+ auinfo(cav[0], tracks, trackp);
+ if (tracks == 1)
+ printf("pregap1: %ld\n", trackp[1].pregapsize);
+ }
+#endif
if (isrc) {
#ifdef AUINFO
setisrc(isrc, &trackp[tracks]);
@@ -3729,13 +1791,14 @@
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 (debug) {
+ printf("File: '%s' tracksize: %ld secsize: %d tracktype: %d = %s sectype: %X = %s dbtype: %s flags %X\n",
+ cav[0], trackp[tracks].tracksize,
+ trackp[tracks].secsize,
+ tracktype, toc2name[tracktype & TOC_MASK],
+ sectype, st2name[sectype & ST_MASK], db2name[dbtype], flags);
+ }
}
if (speed < 0 && speed != -1)
@@ -3744,49 +1807,35 @@
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);
- }
+ cdr_defaults(&dev, &speed, &fs);
+ if (debug)
+ printf("dev: %s speed: %d fs: %ld\n", dev, speed, fs);
+
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);
+ usage(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 (*flagsp & (F_LOAD|F_MSINFO|F_TOC|F_PRATIP|F_FIX|F_VERSION|F_CHECKDRIVE|F_PRCAP|F_INQUIRY|F_SCANBUS|F_RESET)) {
if (tracks != 0) {
errmsgno(EX_BAD, "No tracks allowed with this option\n");
- susage(EX_BAD);
+ usage(EX_BAD);
}
- return ispacket;
+ return;
}
+ if (tracks == 0 && (*flagsp & (F_LOAD|F_EJECT|F_BLANK)) == 0) {
+ errmsgno(EX_BAD, "No tracks specified. Need at least one.\n");
+ usage(EX_BAD);
+ }
*tracksp = tracks;
if (*flagsp & F_SAO) {
/*
@@ -3796,69 +1845,33 @@
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)
+LOCAL void
+set_trsizes(dp, tracks, trackp)
+ cdr_t *dp;
+ int tracks;
+ track_t *trackp;
{
int i;
- int secsize;
- int secspt;
+ /*
+ * We are using SCSI Group 0 write
+ * and cannot write more than 255 secs at once.
+ */
+ data_secs_per_tr = bufsize/DATA_SEC_SIZE;
+ audio_secs_per_tr = bufsize/AUDIO_SEC_SIZE;
+ data_secs_per_tr = min(255, data_secs_per_tr);
+ audio_secs_per_tr = min(255, audio_secs_per_tr);
+
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;
-
+
+ for (i = 1; i <= tracks; i++) {
+ trackp[i].secspt =
+ is_audio(&trackp[i]) ?
+ audio_secs_per_tr :
+ data_secs_per_tr;
if (is_packet(&trackp[i]) && trackp[i].pktsize > 0) {
if (trackp[i].secspt >= trackp[i].pktsize) {
trackp[i].secspt = trackp[i].pktsize;
@@ -3868,130 +1881,67 @@
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 ((dp->cdr_flags & CDR_SWABAUDIO) != 0 &&
+ is_audio(&trackp[i])) {
+ trackp[i].flags ^= TI_SWAB;
}
}
- if (xdebug)
- printf("Set Transfersizes end\n");
}
-void
-load_media(SCSI *scgp, cdr_t *dp, BOOL doexit)
+EXPORT void
+load_media(scgp, dp)
+ SCSI *scgp;
+ cdr_t *dp;
{
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++; /* Be quiet if this fails */
+ test_unit_ready(scgp); /* First eat up unit attention */
+ (*dp->cdr_load)(scgp); /* now try to load media and */
+ scsi_start_stop_unit(scgp, 1, 0);/* 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--;
+ code = scsi_sense_code(scgp);
+ key = scsi_sense_key(scgp);
+ scsi_prevent_removal(scgp, 0);/* In case someone locked it */
- 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);
+ scsi_start_stop_unit(scgp, 1, 0);
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 */
+ 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);
+ scsi_start_stop_unit(scgp, 1, 0);
wait_unit_ready(scgp, 120);
}
-void
-unload_media(SCSI *scgp, cdr_t *dp, int flags)
+EXPORT void
+unload_media(scgp, dp, flags)
+ 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");
- }
+ if ((flags & F_EJECT) != 0)
+ (*dp->cdr_unload)(scgp);
}
-void
-reload_media(SCSI *scgp, cdr_t *dp)
+EXPORT void
+set_secsize(scgp, secsize)
+ SCSI *scgp;
+ int secsize;
{
- 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.
@@ -4002,110 +1952,47 @@
}
}
-static int
-get_dmaspeed(SCSI *scgp, cdr_t *dp)
+LOCAL void
+check_recovery(scgp, dp, flags)
+ SCSI *scgp;
+ cdr_t *dp;
+ int flags;
{
- int i;
- long t;
- int bs;
- int tsize;
-
- 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)) {
+ if ((*dp->cdr_check_recovery)(scgp)) {
errmsgno(EX_BAD, "Recovery needed.\n");
unload_media(scgp, dp, flags);
- comexit(EX_BAD);
+ exit(EX_BAD);
}
}
-#ifndef DEBUG
#define DEBUG
-#endif
-void
-audioread(SCSI *scgp, cdr_t *dp, int flags)
+void audioread(scgp, dp, flags)
+ SCSI *scgp;
+ cdr_t *dp;
+ int flags;
{
#ifdef DEBUG
int speed = 1;
- int oflags = dp->cdr_cmdflags;
+ int dummy = 0;
- 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_speed_dummy)(scgp, &speed, dummy) < 0)
+ exit(-1);
if ((*dp->cdr_set_secsize)(scgp, 2352) < 0)
- comexit(-1);
+ exit(-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);
+ exit(0);
#endif
}
-static void
-print_msinfo(SCSI *scgp, cdr_t *dp)
+LOCAL void
+print_msinfo(scgp, dp)
+ SCSI *scgp;
+ cdr_t *dp;
{
long off;
long fa;
@@ -4117,15 +2004,17 @@
if (lverbose)
printf("session offset: %ld\n", off);
- if (dp->cdr_next_wr_address(scgp, (track_t *)0, &fa) < 0) {
+ if (dp->cdr_next_wr_address(scgp, 0, (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)
+LOCAL void
+print_toc(scgp, dp)
+ SCSI *scgp;
+ cdr_t *dp;
{
int first;
int last;
@@ -4172,9 +2061,14 @@
}
}
-static void
-print_track(int track, long lba, struct msf *msp, int adr,
- int control, int mode)
+LOCAL void
+print_track(track, lba, msp, adr, control, mode)
+ int track;
+ long lba;
+ struct msf *msp;
+ int adr;
+ int control;
+ int mode;
{
long lba_512 = lba*4;
@@ -4191,14 +2085,40 @@
adr, control, mode);
}
-#ifdef HAVE_SYS_PRIOCNTL_H /* The preferred SYSvR4 schduler */
+LOCAL void
+prtimediff(fmt, start, stop)
+ const char *fmt;
+ struct timeval *start;
+ struct timeval *stop;
+{
+ struct timeval tv;
-#include <sys/procset.h> /* Needed for SCO Openserver */
+ tv.tv_sec = stop->tv_sec - start->tv_sec;
+ tv.tv_usec = stop->tv_usec - start->tv_usec;
+ while (tv.tv_usec > 1000000) {
+ tv.tv_usec -= 1000000;
+ tv.tv_sec += 1;
+ }
+ while (tv.tv_usec < 0) {
+ tv.tv_usec += 1000000;
+ tv.tv_sec -= 1;
+ }
+ /*
+ * We need to cast timeval->* to long because
+ * of the broken sys/time.h in Linux.
+ */
+ printf("%s%4ld.%03lds\n", fmt, (long)tv.tv_sec, (long)tv.tv_usec/1000);
+ flush();
+}
+
+#ifdef HAVE_SYS_PRIOCNTL_H
+
#include <sys/priocntl.h>
#include <sys/rtpriocntl.h>
-void
-raisepri(int pri)
+EXPORT void
+raisepri(pri)
+ int pri;
{
int pid;
int classes;
@@ -4216,28 +2136,23 @@
if (classes == -1)
comerr("Cannot get priority class id priocntl(PC_GETCID)\n");
- movebytes(info.pc_clinfo, &rtinfo, sizeof (rtinfo_t));
-
+ 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));
+ movebytes(&rtparam, param.pc_clparms, sizeof(rtparms_t));
ret = priocntl(P_PID, pid, PC_SETPARMS, (void *)¶m);
- 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");
- }
+ if (ret == -1)
+ comerr("Cannot set priority class parameters priocntl(PC_SETPARMS)\n");
}
#else /* HAVE_SYS_PRIOCNTL_H */
-#if defined(_POSIX_PRIORITY_SCHEDULING) && _POSIX_PRIORITY_SCHEDULING -0 >= 0
+#if defined(_POSIX_PRIORITY_SCHEDULING)
/*
- * 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.
*/
@@ -4251,8 +2166,9 @@
#undef _P
#endif
-static int
-rt_raisepri(int pri)
+LOCAL int
+rt_raisepri(pri)
+ int pri;
{
struct sched_param scp;
@@ -4262,10 +2178,10 @@
#ifdef _SC_PRIORITY_SCHEDULING
if (sysconf(_SC_PRIORITY_SCHEDULING) == -1) {
errmsg("WARNING: RR-scheduler not available, disabling.\n");
- return (-1);
+ return(-1);
}
#endif
- fillbytes(&scp, sizeof (scp), '\0');
+ 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");
@@ -4277,36 +2193,26 @@
#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
+ * NOTE: Base.h has a second typedef for BOOL.
+ * We define BOOL to make all local 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>
+#define format __format
+#include <vadefs.h>
+#include <Windows32/Base.h>
+#include <Windows32/Defines.h>
+#include <Windows32/Structures.h>
+#include <Windows32/Functions.h>
#undef format
-#undef interface
-static int
-rt_raisepri(int pri)
+LOCAL int
+rt_raisepri(pri)
+ 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");
@@ -4314,7 +2220,7 @@
}
/* set thread priority */
- if (pri >= 0 && pri <= 1 && SetThreadPriority(GetCurrentThread(), prios[pri]) == FALSE) {
+ if (SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL-pri) == FALSE) {
errmsgno(EX_BAD, "Could not set realtime priority.\n");
return (-1);
}
@@ -4322,11 +2228,10 @@
}
#else
-/*
- * This OS does not support real time scheduling.
- */
-static int
-rt_raisepri(int pri)
+
+LOCAL int
+rt_raisepri(pri)
+ int pri;
{
return (-1);
}
@@ -4335,17 +2240,16 @@
#endif /* _POSIX_PRIORITY_SCHEDULING */
-void
-raisepri(int pri)
+EXPORT void
+raisepri(pri)
+ 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");
- }
+ if (setpriority(PRIO_PROCESS, getpid(), -20 + pri) < 0)
+ comerr("Cannot set priority using setpriority().\n");
#else
#ifdef HAVE_DOSSETPRIORITY /* RT priority on OS/2 */
/*
@@ -4354,14 +2258,11 @@
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");
- }
+#ifdef HAVE_NICE
+ if (nice(-20 + pri) == -1)
+ comerr("Cannot set priority using nice().\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");
+ errmsgno(EX_BAD, "Cannot set priority on this OS.\n");
#endif
#endif
#endif
@@ -4369,59 +2270,115 @@
#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>
+LOCAL void
+checkgui()
+{
+ struct stat st;
-#ifndef INFTIM
-#define INFTIM (-1)
-#endif
-#endif
+ 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");
+ }
+}
-#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
+LOCAL char *
+astoll(s, ll)
+ register const char *s;
+ Llong *ll;
+{
+ char *p;
+ long l = 0;
-static void
-wait_input()
+ p = astol(s, &l);
+ *ll = (Llong)l;
+ return (p);
+}
+
+LOCAL Llong
+number(arg, retp)
+ register char *arg;
+ int *retp;
{
-#ifdef HAVE_SELECT
- fd_set in;
+ Llong val = 0;
- FD_ZERO(&in);
- FD_SET(STDIN_FILENO, &in);
- select(1, &in, NULL, NULL, 0);
-#else
- struct pollfd pfd;
+ if (*retp != 1)
+ return (val);
+ if (*arg == '\0') {
+ *retp = -1;
+ } else if (*(arg = astoll(arg, &val))) {
+ if (*arg == 'p' || *arg == 'P') {
+ val *= (1024*1024);
+ val *= (1024*1024*1024);
+ arg++;
+ }
+ if (*arg == 't' || *arg == 'T') {
+ val *= (1024*1024);
+ val *= (1024*1024);
+ arg++;
+ }
+ if (*arg == 'g' || *arg == 'G') {
+ val *= (1024*1024*1024);
+ arg++;
+ }
+ if (*arg == 'm' || *arg == 'M') {
+ val *= (1024*1024);
+ arg++;
+ }
+ else if (*arg == 'f' || *arg == 'F') {
+ val *= 2352;
+ arg++;
+ }
+ else if (*arg == 's' || *arg == 'S') {
+ val *= 2048;
+ arg++;
+ }
+ else if (*arg == 'k' || *arg == 'K') {
+ val *= 1024;
+ arg++;
+ }
+ else if (*arg == 'b' || *arg == 'B') {
+ val *= 512;
+ arg++;
+ }
+ else if (*arg == 'w' || *arg == 'W') {
+ val *= 2;
+ arg++;
+ }
+ if (*arg == '*' || *arg == 'x')
+ val *= number(++arg, retp);
+ else if (*arg != '\0')
+ *retp = -1;
+ }
+ return (val);
+}
- pfd.fd = STDIN_FILENO;
- pfd.events = POLLIN;
- pfd.revents = 0;
- poll(&pfd, (unsigned long)1, INFTIM);
-#endif
+EXPORT int
+getnum(arg, valp)
+ char *arg;
+ long *valp;
+{
+ int ret = 1;
+
+ *valp = (long)number(arg, &ret);
+ return (ret);
}
-static void
-checkgui()
+EXPORT int
+getllnum(arg, lvalp)
+ char *arg;
+ Llong *lvalp;
{
- struct stat st;
+ int ret = 1;
- 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");
- }
+ *lvalp = number(arg, &ret);
+ return (ret);
}
-static int
-getbltype(char *optstr, long *typep)
+LOCAL int
+getbltype(optstr, typep)
+ char *optstr;
+ long *typep;
{
if (streql(optstr, "all")) {
*typep = BLANK_DISC;
@@ -4446,250 +2403,9 @@
} else if (streql(optstr, "help")) {
blusage(0);
} else {
- fprintf(stderr, "Illegal blanking type '%s'.\n", optstr);
+ error("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
More information about the Debburn-changes
mailing list