Based on the NetBSD port, initially brought to Open by

Alexander S . Guy.

Some minor packaging tweaks.

Uses cd0c by default, as this is the most likely place for a CD-Rom drive.
This commit is contained in:
espie 2000-09-21 16:07:20 +00:00
parent 9e22a1c042
commit 319fa1c71d
19 changed files with 1056 additions and 0 deletions

29
audio/cdparanoia/Makefile Normal file
View File

@ -0,0 +1,29 @@
# $OpenBSD: Makefile,v 1.1.1.1 2000/09/21 16:07:20 espie Exp $
# $NetBSD: Makefile,v 1.1.1.1 2000/01/19 08:03:00 itohy Exp $
DISTNAME= cdparanoia-III-alpha9.7
PKGNAME= cdparanoia-3.a9.7
CATEGORIES= audio
NEED_VERSION= 1.317
MASTER_SITES= http://www.xiph.org/paranoia/download/
EXTRACT_SUFX= .src.tgz
MAINTAINER= ports@openbsd.org
HOMEPAGE= http://www.xiph.org/paranoia/
CONFIGURE_STYLE= autoconf
ALL_TARGET= static
PERMIT_PACKAGE_CDROM= Yes
PERMIT_PACKAGE_FTP= Yes
PERMIT_DISTFILES_CDROM= Yes
PERMIT_DISTFILES_FTP= Yes
CONFIGURE_ENV=GCC=${CC}
do-install:
${INSTALL_PROGRAM} ${WRKBUILD}/cdparanoia ${PREFIX}/bin
${INSTALL_MAN} ${WRKBUILD}/cdparanoia.1 ${PREFIX}/man/man1
${INSTALL_DATA} ${WRKBUILD}/FAQ.txt ${PREFIX}/share/cdparanoia-FAQ
.include <bsd.port.mk>

View File

@ -0,0 +1,5 @@
$NetBSD: md5,v 1.1.1.1 2000/01/19 08:03:00 itohy Exp $
MD5 (cdparanoia-III-alpha9.7.src.tgz) = 0820b2b52b721745f926c913c0a2653f
SHA1 (cdparanoia-III-alpha9.7.src.tgz) = 7c379d3628878fd79ebc1d567408a4d31a7f2e39
RMD160 (cdparanoia-III-alpha9.7.src.tgz) = 0bb9d202a78b0abf36ed6f93742c709ba6eee4d0

View File

@ -0,0 +1,55 @@
$OpenBSD: patch-Makefile_in,v 1.1.1.1 2000/09/21 16:07:22 espie Exp $
--- Makefile.in.orig Tue Sep 19 16:17:29 2000
+++ Makefile.in Tue Sep 19 16:16:29 2000
@@ -8,7 +8,7 @@ VPATH=@srcdir@
srcdir=@srcdir@
@SET_MAKE@
-FLAGS=@TYPESIZES@ @CFLAGS@
+FLAGS=@GETOPT_LONG@ @TYPESIZES@ @CFLAGS@
OPT=@OPT@ $(FLAGS)
DEBUG=@DEBUG@ $(FLAGS)
CC=@CC@
@@ -27,29 +27,27 @@ PWD = $(shell pwd)
OFILES = main.o report.o header.o buffering_write.o
-export STATIC
-export VERSION
+STLIBS = interface/libcdda_interface.a paranoia/libcdda_paranoia.a -lm
+STLIBDEP = interface/libcdda_interface.a paranoia/libcdda_paranoia.a
-ifeq ($(STATIC),TRUE)
- LIBS = interface/libcdda_interface.a paranoia/libcdda_paranoia.a \
- -static -lm
- LIBDEP = interface/libcdda_interface.a paranoia/libcdda_paranoia.a
-else
- LIBS = -lcdda_interface -lcdda_paranoia -lm
- LIBDEP = interface/libcdda_interface.so paranoia/libcdda_paranoia.so
-endif
+SHLIBS = -lcdda_interface -lcdda_paranoia -lm
+SHLIBDEP = interface/libcdda_interface.so paranoia/libcdda_paranoia.so
-all:
+all:
cd interface && $(MAKE) all
cd paranoia && $(MAKE) all
- $(MAKE) cdparanoia CFLAGS="$(OPT)"
- strip cdparanoia
+ $(MAKE) cdparanoia CFLAGS="$(OPT)" LIBS="$(SHLIBS)" LIBDEP="$(SHLIBDEP)"
-debug:
+static:
+ cd interface && $(MAKE) lib
+ cd paranoia && $(MAKE) lib
+ $(MAKE) cdparanoia CFLAGS="$(OPT)" LIBS="$(STLIBS)" LIBDEP="$(STLIBDEP)"
+
+debug:
cd interface && $(MAKE) debug
cd paranoia && $(MAKE) debug
- $(MAKE) cdparanoia CFLAGS="$(DEBUG)" STATIC=TRUE
+ $(MAKE) cdparanoia CFLAGS="$(DEBUG)" LIBS="$(STLIBS)" LIBDEP="$(STLIBDEP)"
test:
cd interface && $(MAKE) all

View File

@ -0,0 +1,13 @@
$OpenBSD: patch-configure_guess,v 1.1.1.1 2000/09/21 16:07:22 espie Exp $
--- configure.guess.orig Tue Sep 19 16:17:51 2000
+++ configure.guess Tue Sep 19 16:16:35 2000
@@ -319,6 +319,9 @@ EOF
*:FreeBSD:*:*)
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
exit 0 ;;
+ *:OpenBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ exit 0 ;;
*:NetBSD:*:*)
echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
exit 0 ;;

View File

@ -0,0 +1,38 @@
$OpenBSD: patch-configure_in,v 1.1.1.1 2000/09/21 16:07:22 espie Exp $
--- configure.in.orig Mon Aug 16 00:29:43 1999
+++ configure.in Tue Sep 19 16:29:30 2000
@@ -14,15 +14,15 @@ AC_CHECK_PROG(INSTALL,install,install)
if test -z "$GCC"; then
DEBUG="-g"
- OPT="-O"
+ OPT="-O ${COPT}"
else
case $host in
- i?86-*-linux*)
+ i?86-*-*)
DEBUG="-g -Wall -fsigned-char"
- OPT="-O20 -ffast-math -fsigned-char -finline-functions";;
+ OPT="-O20 -ffast-math -fsigned-char -finline-functions ${COPT}";;
*)
DEBUG="-g -Wall -fsigned-char"
- OPT="-O20 -fsigned-char";;
+ OPT="-O20 -fsigned-char ${COPT}";;
esac
fi
@@ -63,11 +63,14 @@ fi
AC_CHECK_HEADERS(linux/sbpcd.h, SBPCD_H="-DSBPCD_H='1' ")
AC_CHECK_HEADERS(linux/ucdrom.h, UCDROM_H="-DUCDROM_H='1' ")
+AC_CHECK_FUNCS(getopt_long, GETOPT_LONG="-DGETOPT_LONG='1' ")
+
AC_PROG_MAKE_SET
AC_C_CONST
AC_SUBST(SBPCD_H)
AC_SUBST(UCDROM_H)
+AC_SUBST(GETOPT_LONG)
AC_SUBST(TYPESIZES)
AC_SUBST(OPT)
AC_SUBST(DEBUG)

View File

@ -0,0 +1,12 @@
$OpenBSD: patch-configure_sub,v 1.1.1.1 2000/09/21 16:07:22 espie Exp $
--- configure.sub.orig Tue Sep 19 16:18:13 2000
+++ configure.sub Tue Sep 19 16:16:35 2000
@@ -638,7 +638,7 @@ case $os in
| -amigados* | -msdos* | -newsos* | -unicos* | -aos* \
| -nindy* | -vxworks* | -ebmon* | -hms* | -mvs* | -clix* \
| -riscos* | -linux* | -uniplus* | -iris* | -rtu* | -xenix* \
- | -hiux* | -386bsd* | -netbsd* | -freebsd* | -riscix* \
+ | -hiux* | -386bsd* | -openbsd* | -netbsd* | -freebsd* | -riscix* \
| -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* )

View File

@ -0,0 +1,21 @@
$OpenBSD: patch-interface_Makefile_in,v 1.1.1.1 2000/09/21 16:07:20 espie Exp $
--- interface/Makefile.in.orig Tue Sep 19 16:18:33 2000
+++ interface/Makefile.in Tue Sep 19 16:16:31 2000
@@ -21,8 +21,6 @@ CPPFLAGS+=-D_REENTRANT
OFILES = scan_devices.o common_interface.o cooked_interface.o interface.o\
scsi_interface.o smallft.o toc.o test_interface.o
-export VERSION
-
all: lib slib
debug:
@@ -33,7 +31,7 @@ lib:
slib:
$(MAKE) lessmessy
- $(MAKE) libcdda_interface.so CFLAGS="$(OPT) -fpic"
+ $(MAKE) libcdda_interface.so VERSION=$(VERSION) CFLAGS="$(OPT) -fpic"
[ -e libcdda_interface.so.0 ] || ln -s libcdda_interface.so libcdda_interface.so.0
test:

View File

@ -0,0 +1,88 @@
$OpenBSD: patch-interface_common_interface_c,v 1.1.1.1 2000/09/21 16:07:20 espie Exp $
--- interface/common_interface.c.orig Tue Sep 19 16:18:59 2000
+++ interface/common_interface.c Tue Sep 19 16:16:35 2000
@@ -13,19 +13,29 @@
#include "utils.h"
#include "smallft.h"
+#ifdef __linux__
#include <linux/hdreg.h>
+#endif
/* Test for presence of a cdrom by pinging with the 'CDROMVOLREAD' ioctl() */
int ioctl_ping_cdrom(int fd){
+#ifdef __linux__
struct cdrom_volctrl volctl;
if (ioctl(fd, CDROMVOLREAD, &volctl))
return(1); /* failure */
+#endif
+#ifdef __NetBSD__
+ struct ioc_vol volctl;
+ if (ioctl(fd, CDIOCGETVOL, &volctl))
+ return(1); /* failure */
+#endif
return(0);
/* success! */
}
+#ifdef __linux__
/* Use the ioctl thingy above ping the cdrom; this will get model info */
char *atapi_drive_info(int fd){
/* Work around the fact that the struct grew without warning in
@@ -46,6 +56,7 @@ char *atapi_drive_info(int fd){
free(id);
return(ret);
}
+#endif
int data_bigendianp(cdrom_drive *d){
float lsb_votes=0;
@@ -171,7 +182,9 @@ int data_bigendianp(cdrom_drive *d){
knows the leasoud/leadin size. */
int FixupTOC(cdrom_drive *d,int tracks){
+#ifdef __linux__
struct cdrom_multisession ms_str;
+#endif
int j;
/* First off, make sure the 'starting sector' is >=0 */
@@ -209,13 +222,24 @@ int FixupTOC(cdrom_drive *d,int tracks){
CDROM device, not the generic device. */
if (d->ioctl_fd != -1) {
+#ifdef __linux__
int result;
ms_str.addr_format = CDROM_LBA;
result = ioctl(d->ioctl_fd, CDROMMULTISESSION, &ms_str);
if (result == -1) return -1;
+# define ms_addr (ms_str.addr.lba)
+#endif
+
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+ int ms_addr;
+
+ ms_addr = 0; /* last session */
+ if (ioctl(d->ioctl_fd, CDIOREADMSADDR, &ms_addr) == -1)
+ return -1;
+#endif
- if (ms_str.addr.lba > 100) {
+ if (ms_addr > 100) {
/* This is an odd little piece of code --Monty */
@@ -223,8 +247,8 @@ int FixupTOC(cdrom_drive *d,int tracks){
/* adjust end of last audio track to be in the first session */
for (j = tracks-1; j >= 0; j--) {
if (j > 0 && !IS_AUDIO(d,j) && IS_AUDIO(d,j-1)) {
- if (d->disc_toc[j].dwStartSector > ms_str.addr.lba - 11400)
- d->disc_toc[j].dwStartSector = ms_str.addr.lba - 11400;
+ if (d->disc_toc[j].dwStartSector > ms_addr - 11400)
+ d->disc_toc[j].dwStartSector = ms_addr - 11400;
break;
}
}

View File

@ -0,0 +1,110 @@
$OpenBSD: patch-interface_cooked_interface_c,v 1.1.1.1 2000/09/21 16:07:20 espie Exp $
--- interface/cooked_interface.c.orig Tue Sep 19 16:19:14 2000
+++ interface/cooked_interface.c Tue Sep 19 16:16:33 2000
@@ -13,6 +13,7 @@
static int cooked_readtoc (cdrom_drive *d){
int i;
int tracks;
+#ifdef __linux__
struct cdrom_tochdr hdr;
struct cdrom_tocentry entry;
@@ -52,6 +53,45 @@ static int cooked_readtoc (cdrom_drive *
d->disc_toc[i].dwStartSector = entry.cdte_addr.lba;
tracks=hdr.cdth_trk1+1;
+#endif
+
+#ifdef __NetBSD__
+ struct ioc_read_toc_entry hdr;
+ struct cd_toc_entry entries[MAXTRK + 1]; /* + 1 for leadout */
+
+ hdr.address_format = CD_LBA_FORMAT;
+ hdr.starting_track = 1;
+ hdr.data_len = sizeof entries;
+ hdr.data = entries;
+ memset(entries, 0, sizeof entries);
+
+ /* get all TOC entries at once */
+#ifndef CDIOREADTOCENTRIES
+#define CDIOREADTOCENTRIES CDIOREADTOCENTRYS
+#endif
+ if(ioctl(d->ioctl_fd, CDIOREADTOCENTRIES, &hdr))
+ switch(errno){
+ case EPERM:
+ cderror(d,"102: Permision denied on cdrom (ioctl) device\n");
+ return(-102);
+ default:
+ cderror(d,"004: Unable to read table of contents header\n");
+ return(-4);
+ }
+
+ for(i = 0; i < MAXTRK + 1; i++) {
+ d->disc_toc[i].bFlags = (entries[i].addr_type << 4) | (entries[i].control & 0x0f);
+ d->disc_toc[i].bTrack = entries[i].track;
+ d->disc_toc[i].dwStartSector = entries[i].addr.lba;
+ if (entries[i].track == 0) {
+ cderror(d,"005: Unable to read table of contents entry\n");
+ return(-5);
+ }
+ if (entries[i].track >= 100)
+ break; /* leadout */
+ }
+ tracks = i;
+#endif
d->cd_extra=FixupTOC(d,tracks);
return(--tracks); /* without lead-out */
}
@@ -60,10 +100,15 @@ static int cooked_readtoc (cdrom_drive *
/* Set operating speed */
static int cooked_setspeed(cdrom_drive *d, int speed)
{
+#ifdef __linux__
if(d->ioctl_fd!=-1)
return ioctl(d->ioctl_fd, CDROM_SELECT_SPEED, speed);
else
return 0;
+#endif
+#ifdef __NetBSD__
+ errx(1, "cooked_setspeed: not implemented");
+#endif
}
@@ -72,6 +117,7 @@ static int cooked_setspeed(cdrom_drive *
*/
static long cooked_read (cdrom_drive *d, void *p, long begin, long sectors){
+#ifdef __linux__
int retry_count,err;
struct cdrom_read_audio arg;
char *buffer=(char *)p;
@@ -127,6 +173,10 @@ static long cooked_read (cdrom_drive *d,
} while (err);
return(sectors);
+#endif
+#ifdef __NetBSD__
+ errx(1, "cooked_read: not implemented");
+#endif
}
/* hook */
@@ -191,6 +241,7 @@ static void check_exceptions(cdrom_drive
/* set function pointers to use the ioctl routines */
int cooked_init_drive (cdrom_drive *d){
+#ifdef __linux__
int ret;
switch(d->drive_type){
@@ -255,5 +306,9 @@ int cooked_init_drive (cdrom_drive *d){
if((ret=verify_read_command(d)))return(ret);
d->error_retry=1;
return(0);
+#endif
+#ifdef __NetBSD__
+ errx(1, "cooked_init_drive: not implemented");
+#endif
}

View File

@ -0,0 +1,36 @@
$OpenBSD: patch-interface_low_interface_h,v 1.1.1.1 2000/09/21 16:07:21 espie Exp $
--- interface/low_interface.h.orig Tue Sep 19 16:19:33 2000
+++ interface/low_interface.h Tue Sep 19 16:16:35 2000
@@ -25,6 +25,7 @@
#include <sys/time.h>
#include <sys/types.h>
+#ifdef __linux__
#include <linux/major.h>
#include <linux/version.h>
@@ -48,13 +49,24 @@
#include <linux/cdrom.h>
#include <linux/major.h>
+#endif
+
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+#include <sys/scsiio.h>
+#include <sys/cdio.h>
+#endif
#include "cdda_interface.h"
#define MAX_RETRIES 8
#define MAX_BIG_BUFF_SIZE 65536
#define MIN_BIG_BUFF_SIZE 4096
+#ifdef __linux__
#define SG_OFF sizeof(struct sg_header)
+#endif
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+#define SG_OFF sizeof(scsireq_t)
+#endif
#ifndef SG_EMULATED_HOST
/* old kernel version; the check for the ioctl is still runtime, this

View File

@ -0,0 +1,207 @@
$OpenBSD: patch-interface_scan_devices_c,v 1.1.1.1 2000/09/21 16:07:21 espie Exp $
--- interface/scan_devices.c.orig Tue Dec 14 08:30:23 1999
+++ interface/scan_devices.c Thu Sep 21 17:19:18 2000
@@ -17,6 +17,8 @@
#include "common_interface.h"
#include "utils.h"
+#ifdef __linux__
+
#define MAX_DEV_LEN 20 /* Safe because strings only come from below */
/* must be absolute paths! */
static char *scsi_cdrom_prefixes[3]={"/dev/scd","/dev/sr",NULL};
@@ -28,10 +30,16 @@ static char *cdrom_devices[14]={"/dev/cd
/* "/dev/aztcd", timeout is too long */
"/dev/cm206cd",
"/dev/gscd","/dev/optcd",NULL};
+#endif
+#ifdef __OpenBSD__
+static char *cdrom_devices[]={"/dev/cdrom", "/dev/cd?c", "/dev/mcd?c",
+ "/dev/acd?c", NULL };
+#endif
/* Functions here look for a cdrom drive; full init of a drive type
happens in interface.c */
+#if defined(__linux__) /* not OpenBSD yet */
cdrom_drive *cdda_find_a_cdrom(int messagedest,char **messages){
/* Brute force... */
@@ -54,10 +62,12 @@ cdrom_drive *cdda_find_a_cdrom(int messa
if((d=cdda_identify(buffer,messagedest,messages)))
return(d);
idmessage(messagedest,messages,"",NULL);
+#ifdef __linux__
buffer[pos-(cdrom_devices[i])]=j+97;
if((d=cdda_identify(buffer,messagedest,messages)))
return(d);
idmessage(messagedest,messages,"",NULL);
+#endif
}
}else{
/* Name. Go for it. */
@@ -78,6 +88,15 @@ cdrom_drive *cdda_find_a_cdrom(int messa
}
return(NULL);
}
+#endif /* __linux__ */
+
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+cdrom_drive *cdda_find_a_cdrom(int messagedest,char **messages)
+{
+ errx(1, "cdda_find_a_cdrom: not implemented");
+ /* NOTREACHED */
+}
+#endif /* __NetBSD__ || __OpenBSD__ */
cdrom_drive *cdda_identify(const char *device, int messagedest,char **messages){
struct stat st;
@@ -143,6 +162,7 @@ char *test_resolve_symlink(const char *f
cdrom_drive *cdda_identify_cooked(const char *dev, int messagedest,
char **messages){
+#ifdef __linux__
cdrom_drive *d=NULL;
struct stat st;
int fd=-1;
@@ -270,6 +290,12 @@ cdrom_drive *cdda_identify_cooked(const
idmessage(messagedest,messages,"\t\tCDROM sensed: %s\n",description);
return(d);
+#endif
+
+#ifdef __NetBSD__
+ /* no kernel support for CD-DA */
+ return NULL;
+#endif
}
struct sg_id {
@@ -289,12 +315,18 @@ typedef struct scsiid{
/* Even *this* isn't as simple as it bloody well should be :-P */
static int get_scsi_id(int fd, scsiid *id){
+#ifdef __linux__
struct sg_id argid;
+#endif
+#ifdef __NetBSD__
+ struct scsi_addr argid;
+#endif
int busarg;
/* get the host/id/lun */
if(fd==-1)return(-1);
+#ifdef __linux__
if(ioctl(fd,SCSI_IOCTL_GET_IDLUN,&argid))return(-1);
id->bus=argid.l2; /* for now */
id->id=argid.l1&0xff;
@@ -302,6 +334,13 @@ static int get_scsi_id(int fd, scsiid *i
if(ioctl(fd,SCSI_IOCTL_GET_BUS_NUMBER,&busarg)==0)
id->bus=busarg;
+#endif
+#ifdef __NetBSD__
+ if(ioctl(fd,SCIOCIDENTIFY,&argid))return(-1);
+ id->bus=argid.addr.scsi.scbus;
+ id->id=argid.addr.scsi.target;
+ id->lun=argid.addr.scsi.lun;
+#endif
return(0);
}
@@ -410,6 +449,7 @@ cdrom_drive *cdda_identify_scsi(const ch
generic_device);
return(NULL);
}
+#ifdef __linux__
if((int)(g_st.st_rdev>>8)!=SCSI_GENERIC_MAJOR){
if((int)(g_st.st_rdev>>8)!=SCSI_CDROM_MAJOR){
idmessage(messagedest,messages,"\t\t%s is not a SCSI device",
@@ -421,6 +461,7 @@ cdrom_drive *cdda_identify_scsi(const ch
ioctl_device=temp;
}
}
+#endif
}
if(ioctl_device){
if(stat(ioctl_device,&i_st)){
@@ -428,6 +469,7 @@ cdrom_drive *cdda_identify_scsi(const ch
ioctl_device);
return(NULL);
}
+#ifdef __linux__
if((int)(i_st.st_rdev>>8)!=SCSI_CDROM_MAJOR){
if((int)(i_st.st_rdev>>8)!=SCSI_GENERIC_MAJOR){
idmessage(messagedest,messages,"\t\t%s is not a SCSI device",
@@ -439,6 +481,7 @@ cdrom_drive *cdda_identify_scsi(const ch
ioctl_device=temp;
}
}
+#endif
}
/* we need to resolve any symlinks for the lookup code to work */
@@ -455,6 +498,7 @@ cdrom_drive *cdda_identify_scsi(const ch
}
if(!generic_device || !ioctl_device){
+#ifdef __linux__
if(generic_device){
ioctl_device=scsi_match(generic_device,scsi_cdrom_prefixes,O_RDWR,
O_RDONLY|O_NONBLOCK,
@@ -468,6 +512,9 @@ cdrom_drive *cdda_identify_scsi(const ch
if(!generic_device)
goto cdda_identify_scsi_fail;
}
+#else
+ goto cdda_identify_scsi_fail;
+#endif
}
idmessage(messagedest,messages,"\t\tgeneric device: %s",generic_device);
@@ -504,6 +551,7 @@ cdrom_drive *cdda_identify_scsi(const ch
type=(int)(i_st.st_rdev>>8);
+#ifdef __linux__
if(type==SCSI_CDROM_MAJOR){
if (!S_ISBLK(i_st.st_mode)) {
idmessage(messagedest,messages,"\t\tSCSI CDROM device %s not a "
@@ -515,8 +563,10 @@ cdrom_drive *cdda_identify_scsi(const ch
"major number",ioctl_device);
goto cdda_identify_scsi_fail;
}
+#endif
}
+#ifdef __linux__
if((int)(g_st.st_rdev>>8)==SCSI_GENERIC_MAJOR){
if (!S_ISCHR(g_st.st_mode)) {
idmessage(messagedest,messages,"\t\tGeneric SCSI device %s not a "
@@ -528,6 +578,7 @@ cdrom_drive *cdda_identify_scsi(const ch
"major number",generic_device);
goto cdda_identify_scsi_fail;
}
+#endif
d=calloc(1,sizeof(cdrom_drive));
@@ -564,7 +615,16 @@ cdrom_drive *cdda_identify_scsi(const ch
/* It would seem some TOSHIBA CDROM gets things wrong */
- if (!strncmp (p + 8, "TOSHIBA", 7) &&
+#ifndef TYPE_DISK
+#define TYPE_DISK 0 /* direct */
+#endif
+#ifndef TYPE_WORM
+#define TYPE_WORM 4 /* write once, read many */
+#endif
+#ifndef TYPE_ROM
+#define TYPE_ROM 5 /* CD-ROM */
+#endif
+ if (p && !strncmp (p + 8, "TOSHIBA", 7) &&
!strncmp (p + 16, "CD-ROM", 6) &&
p[0] == TYPE_DISK) {
p[0] = TYPE_ROM;

View File

@ -0,0 +1,198 @@
$OpenBSD: patch-interface_scsi_interface_c,v 1.1.1.1 2000/09/21 16:07:21 espie Exp $
--- interface/scsi_interface.c.orig Tue Sep 19 16:20:14 2000
+++ interface/scsi_interface.c Tue Sep 19 16:16:36 2000
@@ -32,6 +32,7 @@ static int Dummy (cdrom_drive *d,int s){
#endif
static int look_for_dougg(cdrom_drive *d){
+#ifdef __linux__
/* are we using the new SG driver by Doug Gilbert? If so, our memory
strategy will be different. */
int reserved,table;
@@ -78,6 +79,9 @@ static int look_for_dougg(cdrom_drive *d
}
return(1);
+#else
+ return(0);
+#endif
}
static void find_bloody_big_buff_size(cdrom_drive *d){
@@ -142,6 +146,7 @@ static void reset_scsi(cdrom_drive *d){
}
+#ifdef __linux__
static void clear_garbage(cdrom_drive *d){
fd_set fdset;
struct timeval tv;
@@ -172,20 +177,28 @@ static void clear_garbage(cdrom_drive *d
flag=1;
}
}
+#endif
/* process a complete scsi command. */
static int handle_scsi_cmd(cdrom_drive *d,
unsigned int cmd_len,
unsigned int in_size,
unsigned int out_size,
- unsigned char bytefill,
+ unsigned int bfill,
int bytecheck){
+ unsigned char bytefill = bfill;
int status = 0;
+#ifdef __linux__
struct sg_header *sg_hd=(struct sg_header *)d->sg;
long writebytes=SG_OFF+cmd_len+in_size;
+#endif
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+ scsireq_t *sreq = (scsireq_t *)d->sg;
+#endif
/* generic scsi device services */
+#ifdef __linux__
/* clear out any possibly preexisting garbage */
clear_garbage(d);
@@ -291,11 +304,53 @@ static int handle_scsi_cmd(cdrom_drive *
if(errno==0)errno=EIO;
return(TR_EREAD);
}
+#endif /* __linux__ */
+
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+ if (in_size && out_size) {
+ warnx("handle_scsi_cmd: in and out is not supported");
+ abort();
+ }
+ memset(sreq, 0, sizeof(scsireq_t));
+ sreq->cmdlen = cmd_len;
+ memcpy(sreq->cmd, d->sg_buffer, cmd_len);
+ if (in_size) {
+ sreq->flags = SCCMD_WRITE;
+ sreq->databuf = d->sg_buffer + cmd_len;
+ sreq->datalen = in_size;
+ }
+ if (out_size) {
+ sreq->flags = SCCMD_READ;
+ sreq->databuf = d->sg_buffer;
+ sreq->datalen = out_size;
+ if(bytecheck)
+ memset(d->sg_buffer, bytefill, out_size);
+ }
+ sreq->senselen = SENSEBUFLEN;
+ sreq->timeout = 10000; /* 10s */
+
+ status = ioctl(d->cdda_fd, SCIOCCOMMAND, (void *) sreq);
+ if (status < 0)
+ return(TR_ILLEGAL);
+#endif
- if(sg_hd->sense_buffer[0]){
+#ifdef __linux__
+ if(sg_hd->sense_buffer[0])
+#endif
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+ if (sreq->sense[0])
+#endif
+ {
+#ifdef __linux__
char key=sg_hd->sense_buffer[2]&0xf;
char ASC=sg_hd->sense_buffer[12];
char ASCQ=sg_hd->sense_buffer[13];
+#endif
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+ char key = sreq->sense[2]&0xf;
+ char ASC = sreq->sense[12];
+ char ASCQ = sreq->sense[13];
+#endif
switch(key){
case 0:
if(errno==0)errno=EIO;
@@ -333,9 +388,20 @@ static int handle_scsi_cmd(cdrom_drive *
commands still get through. Perhaps no data comes back even
though the target reports success? */
- if(bytecheck && in_size+cmd_len<out_size){
+#ifdef __linux__
+ if(bytecheck && in_size+cmd_len<out_size)
+#endif
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+ if(bytecheck && out_size)
+#endif
+ {
long i,flag=0;
+#ifdef __linux__
for(i=in_size;i<out_size;i++)
+#endif
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+ for(i=0;i<out_size;i++)
+#endif
if(d->sg_buffer[i]!=bytefill){
flag=1;
break;
@@ -840,16 +906,29 @@ static long scsi_read_map (cdrom_drive *
while(1) {
if((err=map(d,(p?buffer:NULL),begin,sectors))){
if(d->report_all){
+#ifdef __linux__
struct sg_header *sg_hd=(struct sg_header *)d->sg;
+#endif
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+ scsireq_t *sreq=(scsireq_t *)d->sg;
+#endif
char b[256];
sprintf(b,"scsi_read error: sector=%ld length=%ld retry=%d\n",
begin,sectors,retry_count);
cdmessage(d,b);
sprintf(b," Sense key: %x ASC: %x ASCQ: %x\n",
+#ifdef __linux__
(int)(sg_hd->sense_buffer[2]&0xf),
(int)(sg_hd->sense_buffer[12]),
- (int)(sg_hd->sense_buffer[13]));
+ (int)(sg_hd->sense_buffer[13])
+#endif
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+ (int)(sreq->sense[2]&0xf),
+ (int)(sreq->sense[12]),
+ (int)(sreq->sense[13])
+#endif
+ );
cdmessage(d,b);
sprintf(b," Transport error: %s\n",strerror_tr[err]);
cdmessage(d,b);
@@ -859,9 +938,17 @@ static long scsi_read_map (cdrom_drive *
fprintf(stderr,"scsi_read error: sector=%ld length=%ld retry=%d\n",
begin,sectors,retry_count);
fprintf(stderr," Sense key: %x ASC: %x ASCQ: %x\n",
+#ifdef __linux__
(int)(sg_hd->sense_buffer[2]&0xf),
(int)(sg_hd->sense_buffer[12]),
- (int)(sg_hd->sense_buffer[13]));
+ (int)(sg_hd->sense_buffer[13])
+#endif
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+ (int)(sreq->sense[2]&0xf),
+ (int)(sreq->sense[12]),
+ (int)(sreq->sense[13])
+#endif
+ );
fprintf(stderr," Transport error: %s\n",strerror_tr[err]);
fprintf(stderr," System error: %s\n",strerror(errno));
}
@@ -1376,6 +1463,11 @@ static int guess_atapi(cdrom_drive *d,in
/* Mt Fuji */
if(reportp)
cdmessage(d,"\tDrive appears to be Mt. Fuji ATAPI C/DVD\n");
+ return(1);
+ case 0x32:
+ /* Toshiba DVD */
+ if(reportp)
+ cdmessage(d,"\tDrive appears to be Toshiba ATAPI C/DVD\n");
return(1);
default:
if(reportp)

View File

@ -0,0 +1,36 @@
$OpenBSD: patch-interface_utils_h,v 1.1.1.1 2000/09/21 16:07:21 espie Exp $
--- interface/utils.h.orig Tue Sep 19 16:20:29 2000
+++ interface/utils.h Tue Sep 19 16:16:36 2000
@@ -1,4 +1,16 @@
+#ifdef __linux__
#include <endian.h>
+#endif
+#ifdef __NetBSD__
+#include <sys/param.h>
+#if __NetBSD_Version__ >= 104010000
+#include <sys/endian.h>
+#else
+#include <machine/endian.h>
+#include <machine/bswap.h>
+#endif
+#include <err.h> /* XXX */
+#endif
#include <stdio.h>
#include <errno.h>
#include <string.h>
@@ -13,6 +25,7 @@ static inline int bigendianp(void){
return(1);
}
+#if !defined(__OpenBSD__)
static inline size32 swap32(size32 x){
return((((unsigned size32)x & 0x000000ffU) << 24) |
(((unsigned size32)x & 0x0000ff00U) << 8) |
@@ -24,6 +37,7 @@ static inline size16 swap16(size16 x){
return((((unsigned size16)x & 0x00ffU) << 8) |
(((unsigned size16)x & 0xff00U) >> 8));
}
+#endif /* !defined(__OpenBSD__) */
#if BYTE_ORDER == LITTLE_ENDIAN

View File

@ -0,0 +1,121 @@
$OpenBSD: patch-main_c,v 1.1.1.1 2000/09/21 16:07:22 espie Exp $
--- main.c.orig Tue Dec 14 09:18:44 1999
+++ main.c Tue Sep 19 16:45:23 2000
@@ -49,7 +49,9 @@
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
+#ifdef GETOPT_LONG
#include <getopt.h>
+#endif
#include <errno.h>
#include <math.h>
#include <sys/time.h>
@@ -231,6 +233,7 @@ VERSION"\n"
" cdparanoia [options] <span> [outfile]\n\n"
"OPTIONS:\n"
+#ifdef GETOPT_LONG
" -v --verbose : extra verbose operation\n"
" -q --quiet : quiet operation\n"
" -e --stderr-progress : force output of progress information to\n"
@@ -274,6 +277,46 @@ VERSION"\n"
" -Z --disable-paranoia : disable all paranoia checking\n"
" -Y --disable-extra-paranoia : only do cdda2wav-style overlap checking\n"
" -X --abort-on-skip : abort on imperfect reads/skips\n\n"
+#else
+" -v : extra verbose operation\n"
+" -q : quiet operation\n"
+" -e : force output of progress information to\n"
+" stderr (for wrapper scripts)\n"
+" -V : print version info and quit\n"
+" -Q : autosense drive, query disc and quit\n"
+" -B : 'batch' mode (saves each track to a seperate file.\n"
+" -s : do an exhaustive search for drive\n"
+" -h : print help\n\n"
+
+" -p : output raw 16 bit PCM in host byte order\n"
+" -r : output raw 16 bit little-endian PCM\n"
+" -R : output raw 16 bit big-endian PCM\n"
+" -w : output as WAV file (default)\n"
+" -f : output as AIFF file\n"
+" -a : output as AIFF-C file\n"
+" -i <file> : output human readable ripping info to file\n\n"
+
+" -c : force treating drive as little endian\n"
+" -C : force treating drive as big endian\n"
+" -n <n> : force default number of sectors in read to n sectors\n"
+" -o <n> : force minimum overlap search during\n"
+" verification to n sectors\n"
+" -d <dev> : use specified device; disallow autosense\n"
+" -g <dev> : use specified generic scsi device\n"
+" -S <n> : read from device at specified speed\n"
+" -t <n> : Add <n> sectors to the values reported\n"
+" when addressing tracks. May be negative\n"
+" -T : Assume that the beginning offset of\n"
+" track 1 as reported in the TOC will be\n"
+" addressed as LBA 0. Necessary for some\n"
+" Toshiba drives to get track boundaries\n"
+" correct\n"
+" -z : never accept any less than perfect\n"
+" data reconstruction (don't allow 'V's)\n"
+" -Z : disable all paranoia checking\n"
+" -Y : only do cdda2wav-style overlap checking\n"
+" -X : abort on imperfect reads/skips\n\n"
+#endif
"OUTPUT SMILIES:\n"
" :-) Normal operation, low/no jitter\n"
@@ -374,7 +417,7 @@ static void callback(long inpos, int fun
int graph=30;
char buffer[256];
static long c_sector=0,v_sector=0;
- static char dispcache[30]=" ";
+ static char dispcache[30 + 1]=" ";
static int last=0;
static long lasttime=0;
long sector,osector=0;
@@ -585,6 +628,7 @@ static void callback(long inpos, int fun
const char *optstring = "escCn:o:d:g:S:prRwafvqVQhZzYXWBi:Tt:";
+#ifdef GETOPT_LONG
struct option options [] = {
{"stderr-progress",no_argument,NULL,'e'},
{"search-for-drive",no_argument,NULL,'s'},
@@ -618,6 +662,7 @@ struct option options [] = {
{NULL,0,NULL,0}
};
+#endif
long blocking_write(int outf, char *buffer, long num){
long words=0,temp;
@@ -668,7 +713,12 @@ int main(int argc,char *argv[]){
atexit(cleanup);
- while((c=getopt_long(argc,argv,optstring,options,&long_option_index))!=EOF){
+#ifdef GETOPT_LONG
+ while((c=getopt_long(argc,argv,optstring,options,&long_option_index))!=EOF)
+#else
+ while((c=getopt(argc,argv,optstring))!=EOF)
+#endif
+ {
switch(c){
case 'B':
batch=1;
@@ -797,6 +847,13 @@ int main(int argc,char *argv[]){
report(VERSION);
/* Query the cdrom/disc; we may need to override some settings */
+
+#if defined(__NetBSD__) || defined(__OpenBSD__) /* XXX */
+ if (!force_generic_device)
+ force_generic_device = copystring("/dev/cd0c");
+ if (!force_cdrom_device)
+ force_cdrom_device=copystring(force_generic_device);
+#endif
if(force_generic_device)
d=cdda_identify_scsi(force_generic_device,force_cdrom_device,verbose,NULL);

View File

@ -0,0 +1,20 @@
$OpenBSD: patch-paranoia_Makefile_in,v 1.1.1.1 2000/09/21 16:07:22 espie Exp $
--- paranoia/Makefile.in.orig Tue Sep 19 16:21:11 2000
+++ paranoia/Makefile.in Tue Sep 19 16:16:31 2000
@@ -22,7 +22,6 @@ OFILES = paranoia.o p_block.o overlap.o
#TFILES = isort.t gap.t p_block.t paranoia.t
LIBS = ../interface/libcdda_interface.a -lm
-export VERSION
all: lib slib
@@ -34,7 +33,7 @@ lib:
slib:
$(MAKE) lessmessy
- $(MAKE) libcdda_paranoia.so CFLAGS="$(OPT) -fpic"
+ $(MAKE) libcdda_paranoia.so VERSION=$(VERSION) CFLAGS="$(OPT) -fpic"
#test: $(TFILES)
#

View File

@ -0,0 +1,48 @@
$OpenBSD: patch-utils_h,v 1.1.1.1 2000/09/21 16:07:22 espie Exp $
--- utils.h.orig Tue Sep 19 16:21:26 2000
+++ utils.h Tue Sep 19 16:16:36 2000
@@ -1,5 +1,16 @@
#include <stdlib.h>
+#ifdef __linux__
#include <endian.h>
+#endif
+#ifdef __NetBSD__
+#include <sys/param.h>
+#if __NetBSD_Version__ >= 104010000
+#include <sys/endian.h>
+#else
+#include <machine/endian.h>
+#include <machine/bswap.h>
+#endif
+#endif
#include <stdio.h>
#include <errno.h>
#include <string.h>
@@ -18,17 +29,27 @@ static inline int bigendianp(void){
return(1);
}
+#if !defined(__OpenBSD__)
static inline size32 swap32(size32 x){
+#ifdef __NetBSD__
+ return bswap32(x);
+#else
return((((unsigned size32)x & 0x000000ffU) << 24) |
(((unsigned size32)x & 0x0000ff00U) << 8) |
(((unsigned size32)x & 0x00ff0000U) >> 8) |
(((unsigned size32)x & 0xff000000U) >> 24));
+#endif
}
static inline size16 swap16(size16 x){
+#ifdef __NetBSD__
+ return bswap16(x);
+#else
return((((unsigned size16)x & 0x00ffU) << 8) |
(((unsigned size16)x & 0xff00U) >> 8));
+#endif
}
+#endif /* !defined(__OpenBSD__) */
#if BYTE_ORDER == LITTLE_ENDIAN

View File

@ -0,0 +1 @@
CDDA reading utility with extra data verification features

View File

@ -0,0 +1,14 @@
Cdparanoia retrieves audio tracks from CDDA capable CDROM drives.
The data can be saved to a file or directed to standard output
in WAV, AIFF, AIFF-C or raw format. Most ATAPI, SCSI and several
proprietary CDROM drive makes are supported; cdparanoia can
determine if the target drive is CDDA capable.
In addition to simple reading, cdparanoia adds extra-robust
data verification, synchronization, error handling and scratch
reconstruction capability.
The OpenBSD port does not implement automatic recognition of cdrom devices,
it defaults to using /dev/cd0c if no -g option is used.
WWW: ${HOMEPAGE}

View File

@ -0,0 +1,4 @@
@comment $OpenBSD: PLIST,v 1.1.1.1 2000/09/21 16:07:22 espie Exp $
bin/cdparanoia
man/man1/cdparanoia.1
share/cdparanoia-FAQ