BSDI Fixes.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: sample5.c,v 1.3 2003/09/29 02:56:22 rocky Exp $
|
||||
$Id: sample5.c,v 1.4 2003/10/02 02:59:57 rocky Exp $
|
||||
|
||||
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -50,7 +50,8 @@ main(int argc, const char *argv[])
|
||||
|
||||
/* Print out a list of CD-drives */
|
||||
cd_drives = cdio_get_devices(DRIVER_DEVICE);
|
||||
for( c = cd_drives; *c != NULL; *c++ ) {
|
||||
if (NULL != cd_drives)
|
||||
for( c = cd_drives; *c != NULL; c++ ) {
|
||||
printf("Drive %s\n", *c);
|
||||
}
|
||||
|
||||
@@ -62,7 +63,7 @@ main(int argc, const char *argv[])
|
||||
cd_drives = cdio_get_devices_with_cap(NULL, CDIO_FS_MATCH_ALL, false);
|
||||
|
||||
if (NULL != cd_drives) {
|
||||
for( c = cd_drives; *c != NULL; *c++ ) {
|
||||
for( c = cd_drives; *c != NULL; c++ ) {
|
||||
printf("Drive %s\n", *c);
|
||||
}
|
||||
|
||||
@@ -77,7 +78,7 @@ main(int argc, const char *argv[])
|
||||
cd_drives = cdio_get_devices_with_cap(NULL, CDIO_FS_AUDIO, false);
|
||||
|
||||
if (NULL != cd_drives) {
|
||||
for( c = cd_drives; *c != NULL; *c++ ) {
|
||||
for( c = cd_drives; *c != NULL; c++ ) {
|
||||
printf("drive: %s\n", *c);
|
||||
}
|
||||
|
||||
@@ -92,7 +93,7 @@ main(int argc, const char *argv[])
|
||||
(CDIO_FS_ANAL_SVCD|CDIO_FS_ANAL_CVD|CDIO_FS_ANAL_VIDEOCD|CDIO_FS_UNKNOWN),
|
||||
true);
|
||||
if (NULL != cd_drives) {
|
||||
for( c = cd_drives; *c != NULL; *c++ ) {
|
||||
for( c = cd_drives; *c != NULL; c++ ) {
|
||||
printf("drive: %s\n", *c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: cd_types.h,v 1.2 2003/09/28 17:14:20 rocky Exp $
|
||||
$Id: cd_types.h,v 1.3 2003/10/02 02:59:57 rocky Exp $
|
||||
|
||||
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
||||
Copyright (C) 1996,1997,1998 Gerd Knorr <kraxel@bytesex.org>
|
||||
@@ -38,9 +38,19 @@ extern "C" {
|
||||
#define CDIO_FS_INTERACTIVE 4
|
||||
#define CDIO_FS_HFS 5
|
||||
#define CDIO_FS_UFS 6
|
||||
|
||||
/* EXT2 was the GNU/Linux native filesystem for early kernels. Newer
|
||||
GNU/Linux OS's may use EXT3 which EXT2 with a journal. */
|
||||
#define CDIO_FS_EXT2 7
|
||||
|
||||
#define CDIO_FS_ISO_HFS 8 /* both hfs & isofs filesystem */
|
||||
#define CDIO_FS_ISO_9660_INTERACTIVE 9 /* both CD-RTOS and isofs filesystem */
|
||||
|
||||
|
||||
/* The 3DO is, technically, a set of specifications created by the 3DO
|
||||
company. These specs are for making a 3DO Interactive Multiplayer
|
||||
which uses a CD-player. Panasonic in the early 90's was the first
|
||||
company to manufacture and market a 3DO player. */
|
||||
#define CDIO_FS_3DO 10
|
||||
|
||||
#define CDIO_FS_MASK 15 /* Should be 2*n-1 and > above */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* -*- c -*-
|
||||
$Id: cdio.h,v 1.26 2003/09/30 03:26:11 rocky Exp $
|
||||
$Id: cdio.h,v 1.27 2003/10/02 02:59:57 rocky Exp $
|
||||
|
||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
||||
@@ -367,6 +367,8 @@ extern "C" {
|
||||
|
||||
char * cdio_get_default_device_bsdi(void);
|
||||
|
||||
char **cdio_get_devices_bsdi(void);
|
||||
|
||||
/*! BSDI CD-reading routines.
|
||||
NULL is returned on error.
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: _cdio_bincue.c,v 1.33 2003/09/30 03:26:11 rocky Exp $
|
||||
$Id: _cdio_bincue.c,v 1.34 2003/10/02 02:59:58 rocky Exp $
|
||||
|
||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
Copyright (C) 2002,2003 Rocky Bernstein <rocky@panix.com>
|
||||
@@ -24,7 +24,7 @@
|
||||
(*.cue).
|
||||
*/
|
||||
|
||||
static const char _rcsid[] = "$Id: _cdio_bincue.c,v 1.33 2003/09/30 03:26:11 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: _cdio_bincue.c,v 1.34 2003/10/02 02:59:58 rocky Exp $";
|
||||
|
||||
#include "cdio_assert.h"
|
||||
#include "cdio_private.h"
|
||||
@@ -321,19 +321,19 @@ _cdio_image_read_cue (_img_private_t *_obj)
|
||||
_obj->mcn=NULL;
|
||||
|
||||
while ((fgets(line, MAXLINE, fp)) != NULL) {
|
||||
char *s=NULL;
|
||||
char s[80];
|
||||
char *p;
|
||||
/*printf("Retrieved line of length %zu :\n", read);
|
||||
printf("%s", line); */
|
||||
for (p=line; isspace(*p); p++) ;
|
||||
if (1==sscanf(p, "FILE \"%a[^\"]", &s)) {
|
||||
if (1==sscanf(p, "FILE \"%80s[^\"]", s)) {
|
||||
/* Should expand file name based on cue file basename.
|
||||
free(_obj->bin_file);
|
||||
_obj->bin_file = s;
|
||||
_obj->bin_file = strdup(s);
|
||||
*/
|
||||
/* printf("Found file name %s\n", s); */
|
||||
} else if (1==sscanf(p, "CATALOG %as", &s)) {
|
||||
_obj->mcn = s;
|
||||
} else if (1==sscanf(p, "CATALOG %80s", s)) {
|
||||
_obj->mcn = strdup(s);
|
||||
} else if (2==sscanf(p, "TRACK %d MODE2/%d", &track_num, &blocksize)) {
|
||||
track_info_t *this_track=&(_obj->tocent[_obj->total_tracks]);
|
||||
this_track->track_num = track_num;
|
||||
|
||||
141
lib/_cdio_bsdi.c
141
lib/_cdio_bsdi.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: _cdio_bsdi.c,v 1.13 2003/09/25 09:38:16 rocky Exp $
|
||||
$Id: _cdio_bsdi.c,v 1.14 2003/10/02 02:59:58 rocky Exp $
|
||||
|
||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
Copyright (C) 2002,2003 Rocky Bernstein <rocky@panix.com>
|
||||
@@ -19,7 +19,7 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* This file contains Linux-specific code and implements low-level
|
||||
/* This file contains BSDI-specific code and implements low-level
|
||||
control of the CD drive.
|
||||
*/
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
static const char _rcsid[] = "$Id: _cdio_bsdi.c,v 1.13 2003/09/25 09:38:16 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: _cdio_bsdi.c,v 1.14 2003/10/02 02:59:58 rocky Exp $";
|
||||
|
||||
#include <cdio/sector.h>
|
||||
#include <cdio/util.h>
|
||||
@@ -76,6 +76,37 @@ typedef struct {
|
||||
|
||||
} _img_private_t;
|
||||
|
||||
/* Check a drive to see if it is a CD-ROM
|
||||
Return 1 if a CD-ROM. 0 if it exists but isn't a CD-ROM drive
|
||||
and -1 if no device exists .
|
||||
*/
|
||||
static int
|
||||
cdio_is_cdrom(char *drive, char *mnttype)
|
||||
{
|
||||
bool is_cd=false;
|
||||
int cdfd;
|
||||
struct cdrom_tochdr tochdr;
|
||||
|
||||
/* If it doesn't exist, return -1 */
|
||||
if ( !cdio_is_device_quiet_generic(drive) ) {
|
||||
return(false);
|
||||
}
|
||||
|
||||
/* If it does exist, verify that it's an available CD-ROM */
|
||||
cdfd = open(drive, (O_RDONLY|O_EXCL|O_NONBLOCK), 0);
|
||||
if ( cdfd >= 0 ) {
|
||||
if ( ioctl(cdfd, CDROMREADTOCHDR, &tochdr) != -1 ) {
|
||||
is_cd = true;
|
||||
}
|
||||
close(cdfd);
|
||||
}
|
||||
/* Even if we can't read it, it might be mounted */
|
||||
else if ( mnttype && (strcmp(mnttype, "iso9660") == 0) ) {
|
||||
is_cd = true;
|
||||
}
|
||||
return(is_cd);
|
||||
}
|
||||
|
||||
/*!
|
||||
Initialize CD device.
|
||||
*/
|
||||
@@ -100,6 +131,62 @@ _cdio_init (_img_private_t *_obj)
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Read audio sectors
|
||||
*/
|
||||
static int
|
||||
_read_audio_sectors (void *user_data, void *data, lsn_t lsn,
|
||||
unsigned int nblocks)
|
||||
{
|
||||
char buf[CDIO_CD_FRAMESIZE_RAW] = { 0, };
|
||||
struct cdrom_msf *msf = (struct cdrom_msf *) &buf;
|
||||
msf_t _msf;
|
||||
|
||||
_img_private_t *_obj = user_data;
|
||||
|
||||
cdio_lba_to_msf (cdio_lsn_to_lba(lsn), &_msf);
|
||||
msf->cdmsf_min0 = from_bcd8(_msf.m);
|
||||
msf->cdmsf_sec0 = from_bcd8(_msf.s);
|
||||
msf->cdmsf_frame0 = from_bcd8(_msf.f);
|
||||
|
||||
if (_obj->ioctls_debugged == 75)
|
||||
cdio_debug ("only displaying every 75th ioctl from now on");
|
||||
|
||||
if (_obj->ioctls_debugged == 30 * 75)
|
||||
cdio_debug ("only displaying every 30*75th ioctl from now on");
|
||||
|
||||
if (_obj->ioctls_debugged < 75
|
||||
|| (_obj->ioctls_debugged < (30 * 75)
|
||||
&& _obj->ioctls_debugged % 75 == 0)
|
||||
|| _obj->ioctls_debugged % (30 * 75) == 0)
|
||||
cdio_debug ("reading %2.2d:%2.2d:%2.2d",
|
||||
msf->cdmsf_min0, msf->cdmsf_sec0, msf->cdmsf_frame0);
|
||||
|
||||
_obj->ioctls_debugged++;
|
||||
|
||||
switch (_obj->access_mode) {
|
||||
case _AM_NONE:
|
||||
cdio_error ("no way to read audio");
|
||||
return 1;
|
||||
break;
|
||||
|
||||
case _AM_IOCTL: {
|
||||
unsigned int i;
|
||||
for (i=0; i < nblocks; i++) {
|
||||
if (ioctl (_obj->gen.fd, CDROMREADRAW, &buf) == -1) {
|
||||
perror ("ioctl()");
|
||||
return 1;
|
||||
/* exit (EXIT_FAILURE); */
|
||||
}
|
||||
memcpy (((char *)data) + (CDIO_CD_FRAMESIZE_RAW * i), buf,
|
||||
CDIO_CD_FRAMESIZE_RAW);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Reads a single mode2 sector from cd device into data starting
|
||||
from lsn. Returns 0 if no error.
|
||||
@@ -475,7 +562,50 @@ _cdio_get_track_msf(void *user_data, track_t track_num, msf_t *msf)
|
||||
#endif /* HAVE_BSDI_CDROM */
|
||||
|
||||
/*!
|
||||
Return a string containing the default VCD device if none is specified.
|
||||
Return an array of strings giving possible CD devices.
|
||||
*/
|
||||
char **
|
||||
cdio_get_devices_bsdi (void)
|
||||
{
|
||||
#ifndef HAVE_BSDI_CDROM
|
||||
return NULL;
|
||||
#else
|
||||
char drive[40];
|
||||
char **drives = NULL;
|
||||
unsigned int num_drives=0;
|
||||
char c;
|
||||
|
||||
/* Scan the system for CD-ROM drives.
|
||||
*/
|
||||
|
||||
#if FINISHED
|
||||
/* Now check the currently mounted CD drives */
|
||||
if (NULL != (ret_drive = cdio_check_mounts("/etc/mtab"))) {
|
||||
cdio_add_device_list(&drives, drive, &num_drives);
|
||||
}
|
||||
|
||||
/* Finally check possible mountable drives in /etc/fstab */
|
||||
if (NULL != (ret_drive = cdio_check_mounts("/etc/fstab"))) {
|
||||
cdio_add_device_list(&drives, drive, &num_drives);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Scan the system for CD-ROM drives.
|
||||
Not always 100% reliable, so use the USE_MNTENT code above first.
|
||||
*/
|
||||
for ( c='c'; c <='h'; c++ ) {
|
||||
sprintf(drive, "/dev/rsr0%c", c);
|
||||
if ( cdio_is_cdrom(drive, NULL) > 0 ) {
|
||||
cdio_add_device_list(&drives, drive, &num_drives);
|
||||
}
|
||||
}
|
||||
cdio_add_device_list(&drives, NULL, &num_drives);
|
||||
return drives;
|
||||
#endif /*HAVE_BSDI_CDROM*/
|
||||
}
|
||||
|
||||
/*!
|
||||
Return a string containing the default CD device if none is specified.
|
||||
*/
|
||||
char *
|
||||
cdio_get_default_device_bsdi(void)
|
||||
@@ -501,6 +631,7 @@ cdio_open_bsdi (const char *source_name)
|
||||
.free = cdio_generic_free,
|
||||
.get_arg = _cdio_get_arg,
|
||||
.get_default_device = cdio_get_default_device_bsdi,
|
||||
.get_devices = cdio_get_devices_bsdi,
|
||||
.get_first_track_num= _cdio_get_first_track_num,
|
||||
.get_mcn = NULL,
|
||||
.get_num_tracks = _cdio_get_num_tracks,
|
||||
@@ -511,7 +642,7 @@ cdio_open_bsdi (const char *source_name)
|
||||
.lseek = cdio_generic_lseek,
|
||||
.read = cdio_generic_read,
|
||||
.read_mode2_sector = _read_mode2_sector,
|
||||
.read_audio_sectors = NULL,
|
||||
.read_audio_sectors = _read_audio_sectors,
|
||||
.read_mode2_sectors = _read_mode2_sectors,
|
||||
.set_arg = _cdio_set_arg,
|
||||
.stat_size = _cdio_stat_size
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: cdio.c,v 1.30 2003/09/30 03:26:11 rocky Exp $
|
||||
$Id: cdio.c,v 1.31 2003/10/02 02:59:58 rocky Exp $
|
||||
|
||||
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
@@ -37,7 +37,7 @@
|
||||
#include <cdio/logging.h>
|
||||
#include "cdio_private.h"
|
||||
|
||||
static const char _rcsid[] = "$Id: cdio.c,v 1.30 2003/09/30 03:26:11 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: cdio.c,v 1.31 2003/10/02 02:59:58 rocky Exp $";
|
||||
|
||||
|
||||
const char *track_format2str[6] =
|
||||
@@ -225,7 +225,7 @@ cdio_eject_media (CdIo **obj)
|
||||
void cdio_free_device_list (char * device_list[])
|
||||
{
|
||||
if (NULL == device_list) return;
|
||||
for ( ; *device_list != NULL ; *device_list++ )
|
||||
for ( ; *device_list != NULL ; device_list++ )
|
||||
free(*device_list);
|
||||
}
|
||||
|
||||
@@ -328,10 +328,11 @@ cdio_get_devices_with_cap (char* search_devices[],
|
||||
int num_drives=0;
|
||||
|
||||
if (NULL == drives) drives=cdio_get_devices(DRIVER_DEVICE);
|
||||
if (NULL == drives) return NULL;
|
||||
|
||||
if (capabilities == CDIO_FS_MATCH_ALL) {
|
||||
/* Duplicate drives into drives_ret. */
|
||||
for( ; *drives != NULL; *drives++ ) {
|
||||
for( ; *drives != NULL; drives++ ) {
|
||||
cdio_add_device_list(&drives_ret, *drives, &num_drives);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: cd-read.c,v 1.8 2003/09/27 23:29:29 rocky Exp $
|
||||
$Id: cd-read.c,v 1.9 2003/10/02 02:59:58 rocky Exp $
|
||||
|
||||
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -110,8 +110,8 @@ hexdump (uint8_t * buffer, unsigned int len)
|
||||
if (i % 2 == 1)
|
||||
printf (" ");
|
||||
if (i % 16 == 15) {
|
||||
printf (" ");
|
||||
uint8_t *p;
|
||||
printf (" ");
|
||||
for (p=buffer-15; p <= buffer; p++) {
|
||||
printf("%c", isprint(*p) ? *p : '.');
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: testdefault.c,v 1.1 2003/10/01 02:44:21 rocky Exp $
|
||||
$Id: testdefault.c,v 1.2 2003/10/02 02:59:58 rocky Exp $
|
||||
|
||||
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -87,7 +87,7 @@ main(int argc, const char *argv[])
|
||||
|
||||
nrg_images = cdio_get_devices(DRIVER_NRG);
|
||||
|
||||
for (imgs=nrg_images; *imgs != NULL; *imgs++) {
|
||||
for (imgs=nrg_images; *imgs != NULL; imgs++) {
|
||||
printf("NRG image %s\n", *imgs);
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ main(int argc, const char *argv[])
|
||||
|
||||
bincue_images = cdio_get_devices(DRIVER_BINCUE);
|
||||
|
||||
for (imgs=bincue_images; *imgs != NULL; *imgs++) {
|
||||
for (imgs=bincue_images; *imgs != NULL; imgs++) {
|
||||
printf("bincue image %s\n", *imgs);
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ main(int argc, const char *argv[])
|
||||
return 3;
|
||||
}
|
||||
|
||||
for( c = imgs; *c != NULL; *c++ ) {
|
||||
for( c = imgs; *c != NULL; c++ ) {
|
||||
printf("%s\n", *c);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user