OS fixes.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: _cdio_bsdi.c,v 1.17 2003/10/03 03:46:54 rocky Exp $
|
$Id: _cdio_bsdi.c,v 1.18 2003/10/03 04:04:24 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||||
Copyright (C) 2002,2003 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2002,2003 Rocky Bernstein <rocky@panix.com>
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char _rcsid[] = "$Id: _cdio_bsdi.c,v 1.17 2003/10/03 03:46:54 rocky Exp $";
|
static const char _rcsid[] = "$Id: _cdio_bsdi.c,v 1.18 2003/10/03 04:04:24 rocky Exp $";
|
||||||
|
|
||||||
#include <cdio/sector.h>
|
#include <cdio/sector.h>
|
||||||
#include <cdio/util.h>
|
#include <cdio/util.h>
|
||||||
@@ -156,20 +156,20 @@ _read_audio_sectors (void *env, void *data, lsn_t lsn,
|
|||||||
msf->cdmsf_sec0 = from_bcd8(_msf.s);
|
msf->cdmsf_sec0 = from_bcd8(_msf.s);
|
||||||
msf->cdmsf_frame0 = from_bcd8(_msf.f);
|
msf->cdmsf_frame0 = from_bcd8(_msf.f);
|
||||||
|
|
||||||
if (_obj->ioctls_debugged == 75)
|
if (_obj->gen.ioctls_debugged == 75)
|
||||||
cdio_debug ("only displaying every 75th ioctl from now on");
|
cdio_debug ("only displaying every 75th ioctl from now on");
|
||||||
|
|
||||||
if (_obj->ioctls_debugged == 30 * 75)
|
if (_obj->gen.ioctls_debugged == 30 * 75)
|
||||||
cdio_debug ("only displaying every 30*75th ioctl from now on");
|
cdio_debug ("only displaying every 30*75th ioctl from now on");
|
||||||
|
|
||||||
if (_obj->ioctls_debugged < 75
|
if (_obj->gen.ioctls_debugged < 75
|
||||||
|| (_obj->ioctls_debugged < (30 * 75)
|
|| (_obj->gen.ioctls_debugged < (30 * 75)
|
||||||
&& _obj->ioctls_debugged % 75 == 0)
|
&& _obj->gen.ioctls_debugged % 75 == 0)
|
||||||
|| _obj->ioctls_debugged % (30 * 75) == 0)
|
|| _obj->gen.ioctls_debugged % (30 * 75) == 0)
|
||||||
cdio_debug ("reading %2.2d:%2.2d:%2.2d",
|
cdio_debug ("reading %2.2d:%2.2d:%2.2d",
|
||||||
msf->cdmsf_min0, msf->cdmsf_sec0, msf->cdmsf_frame0);
|
msf->cdmsf_min0, msf->cdmsf_sec0, msf->cdmsf_frame0);
|
||||||
|
|
||||||
_obj->ioctls_debugged++;
|
_obj->gen.ioctls_debugged++;
|
||||||
|
|
||||||
switch (_obj->access_mode) {
|
switch (_obj->access_mode) {
|
||||||
case _AM_NONE:
|
case _AM_NONE:
|
||||||
@@ -223,7 +223,7 @@ _cdio_read_mode2_sector (void *env, void *data, lsn_t lsn,
|
|||||||
if (_obj->gen.ioctls_debugged < 75
|
if (_obj->gen.ioctls_debugged < 75
|
||||||
|| (_obj->gen.ioctls_debugged < (30 * 75)
|
|| (_obj->gen.ioctls_debugged < (30 * 75)
|
||||||
&& _obj->gen.ioctls_debugged % 75 == 0)
|
&& _obj->gen.ioctls_debugged % 75 == 0)
|
||||||
|| _obj->ioctls_debugged % (30 * 75) == 0)
|
|| _obj->gen.ioctls_debugged % (30 * 75) == 0)
|
||||||
cdio_debug ("reading %2.2d:%2.2d:%2.2d",
|
cdio_debug ("reading %2.2d:%2.2d:%2.2d",
|
||||||
msf->cdmsf_min0, msf->cdmsf_sec0, msf->cdmsf_frame0);
|
msf->cdmsf_min0, msf->cdmsf_sec0, msf->cdmsf_frame0);
|
||||||
|
|
||||||
@@ -261,7 +261,7 @@ _cdio_read_mode2_sector (void *env, void *data, lsn_t lsn,
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
_cdio_read_mode2_sectors (void *env, void *data, lsn_t lsn,
|
_cdio_read_mode2_sectors (void *env, void *data, lsn_t lsn,
|
||||||
bool mode2_form2, unsigned int nblocks)
|
bool mode2_form2, unsigned int nblocks)
|
||||||
{
|
{
|
||||||
_img_private_t *_obj = env;
|
_img_private_t *_obj = env;
|
||||||
int i;
|
int i;
|
||||||
@@ -469,6 +469,21 @@ _cdio_get_first_track_num(void *env)
|
|||||||
return FIRST_TRACK_NUM;
|
return FIRST_TRACK_NUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Return the media catalog number MCN.
|
||||||
|
Note: string is malloc'd so caller should free() then returned
|
||||||
|
string when done with it.
|
||||||
|
*/
|
||||||
|
static char *
|
||||||
|
_cdio_get_mcn (void *env) {
|
||||||
|
|
||||||
|
struct cdrom_mcn mcn;
|
||||||
|
_img_private_t *_obj = env;
|
||||||
|
if (ioctl(_obj->gen.fd, CDROM_GET_MCN, &mcn) != 0)
|
||||||
|
return NULL;
|
||||||
|
return strdup(mcn.medium_catalog_number);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Return the number of tracks in the current medium.
|
Return the number of tracks in the current medium.
|
||||||
CDIO_INVALID_TRACK is returned on error.
|
CDIO_INVALID_TRACK is returned on error.
|
||||||
@@ -644,7 +659,7 @@ cdio_open_bsdi (const char *source_name)
|
|||||||
.get_default_device = cdio_get_default_device_bsdi,
|
.get_default_device = cdio_get_default_device_bsdi,
|
||||||
.get_devices = cdio_get_devices_bsdi,
|
.get_devices = cdio_get_devices_bsdi,
|
||||||
.get_first_track_num= _cdio_get_first_track_num,
|
.get_first_track_num= _cdio_get_first_track_num,
|
||||||
.get_mcn = NULL,
|
.get_mcn = _cdio_get_mcn,
|
||||||
.get_num_tracks = _cdio_get_num_tracks,
|
.get_num_tracks = _cdio_get_num_tracks,
|
||||||
.get_track_format = _cdio_get_track_format,
|
.get_track_format = _cdio_get_track_format,
|
||||||
.get_track_green = _cdio_get_track_green,
|
.get_track_green = _cdio_get_track_green,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: _cdio_freebsd.c,v 1.16 2003/09/25 09:38:16 rocky Exp $
|
$Id: _cdio_freebsd.c,v 1.17 2003/10/03 04:04:24 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char _rcsid[] = "$Id: _cdio_freebsd.c,v 1.16 2003/09/25 09:38:16 rocky Exp $";
|
static const char _rcsid[] = "$Id: _cdio_freebsd.c,v 1.17 2003/10/03 04:04:24 rocky Exp $";
|
||||||
|
|
||||||
#include <cdio/sector.h>
|
#include <cdio/sector.h>
|
||||||
#include <cdio/util.h>
|
#include <cdio/util.h>
|
||||||
@@ -70,6 +70,10 @@ typedef struct {
|
|||||||
_AM_IOCTL,
|
_AM_IOCTL,
|
||||||
} access_mode;
|
} access_mode;
|
||||||
|
|
||||||
|
char *source_name;
|
||||||
|
|
||||||
|
bool init;
|
||||||
|
|
||||||
/* Track information */
|
/* Track information */
|
||||||
bool toc_init; /* if true, info below is valid. */
|
bool toc_init; /* if true, info below is valid. */
|
||||||
struct ioc_toc_header tochdr;
|
struct ioc_toc_header tochdr;
|
||||||
@@ -77,6 +81,42 @@ typedef struct {
|
|||||||
|
|
||||||
} _img_private_t;
|
} _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 bool
|
||||||
|
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);
|
||||||
|
|
||||||
|
/* Should we want to test the condition in more detail:
|
||||||
|
ENOENT is the error for /dev/xxxxx does not exist;
|
||||||
|
ENODEV means there's no drive present. */
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_set_bsize (int fd, unsigned int bsize)
|
_set_bsize (int fd, unsigned int bsize)
|
||||||
{
|
{
|
||||||
@@ -162,11 +202,11 @@ _cdio_read_mode2_sector (void *env, void *data, lsn_t lsn,
|
|||||||
if (_obj->gen.ioctls_debugged == 75)
|
if (_obj->gen.ioctls_debugged == 75)
|
||||||
cdio_debug ("only displaying every 75th ioctl from now on");
|
cdio_debug ("only displaying every 75th ioctl from now on");
|
||||||
|
|
||||||
if (_obj->get.ioctls_debugged == 30 * 75)
|
if (_obj->gen.ioctls_debugged == 30 * 75)
|
||||||
cdio_debug ("only displaying every 30*75th ioctl from now on");
|
cdio_debug ("only displaying every 30*75th ioctl from now on");
|
||||||
|
|
||||||
if (_obj->gen.ioctls_debugged < 75
|
if (_obj->gen.ioctls_debugged < 75
|
||||||
|| (_obj->get.ioctls_debugged < (30 * 75)
|
|| (_obj->gen.ioctls_debugged < (30 * 75)
|
||||||
&& _obj->gen.ioctls_debugged % 75 == 0)
|
&& _obj->gen.ioctls_debugged % 75 == 0)
|
||||||
|| _obj->ioctls_debugged % (30 * 75) == 0)
|
|| _obj->ioctls_debugged % (30 * 75) == 0)
|
||||||
cdio_debug ("reading %2.2d:%2.2d:%2.2d",
|
cdio_debug ("reading %2.2d:%2.2d:%2.2d",
|
||||||
@@ -207,7 +247,7 @@ _cdio_read_mode2_sector (void *env, void *data, lsn_t lsn,
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
_cdio_read_mode2_sectors (void *env, void *data, lsn_t lsn,
|
_cdio_read_mode2_sectors (void *env, void *data, lsn_t lsn,
|
||||||
bool mode2_form2, unsigned int nblocks)
|
bool mode2_form2, unsigned int nblocks)
|
||||||
{
|
{
|
||||||
_img_private_t *_obj = env;
|
_img_private_t *_obj = env;
|
||||||
int i;
|
int i;
|
||||||
@@ -474,6 +514,53 @@ _cdio_get_track_msf(void *env, track_t track_num, msf_t *msf)
|
|||||||
|
|
||||||
#endif /* HAVE_FREEBSD_CDROM */
|
#endif /* HAVE_FREEBSD_CDROM */
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Return an array of strings giving possible CD devices.
|
||||||
|
*/
|
||||||
|
char **
|
||||||
|
cdio_get_devices_freebsd (void)
|
||||||
|
{
|
||||||
|
#ifndef HAVE_FREEBSD_CDROM
|
||||||
|
return NULL;
|
||||||
|
#else
|
||||||
|
char drive[40];
|
||||||
|
char **drives = NULL;
|
||||||
|
unsigned int num_drives=0;
|
||||||
|
bool exists=true;
|
||||||
|
char c;
|
||||||
|
|
||||||
|
/* Scan the system for CD-ROM drives.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef USE_ETC_FSTAB
|
||||||
|
|
||||||
|
struct fstab *fs;
|
||||||
|
setfsent();
|
||||||
|
|
||||||
|
/* Check what's in /etc/fstab... */
|
||||||
|
while ( (fs = getfsent()) )
|
||||||
|
{
|
||||||
|
if (strncmp(fs->fs_spec, "/dev/sr", 7))
|
||||||
|
cdio_add_device_list(&drives, fs->fs_spec, &num_drives);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Scan the system for CD-ROM drives.
|
||||||
|
Not always 100% reliable, so use the USE_MNTENT code above first.
|
||||||
|
*/
|
||||||
|
for ( c='0'; exists && c <='9'; c++ ) {
|
||||||
|
sprintf(drive, "/dev/acd%cc", c);
|
||||||
|
exists = cdio_is_cdrom(drive, NULL);
|
||||||
|
if ( exists ) {
|
||||||
|
cdio_add_device_list(&drives, drive, &num_drives);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cdio_add_device_list(&drives, NULL, &num_drives);
|
||||||
|
return drives;
|
||||||
|
#endif /*HAVE_FREEBSD_CDROM*/
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Return a string containing the default CD device if none is specified.
|
Return a string containing the default CD device if none is specified.
|
||||||
*/
|
*/
|
||||||
@@ -501,6 +588,7 @@ cdio_open_freebsd (const char *source_name)
|
|||||||
.free = _cdio_generic_free,
|
.free = _cdio_generic_free,
|
||||||
.get_arg = _cdio_get_arg,
|
.get_arg = _cdio_get_arg,
|
||||||
.get_default_device = _cdio_get_default_device_freebsd,
|
.get_default_device = _cdio_get_default_device_freebsd,
|
||||||
|
.get_devices = cdio_get_devices_freebsd,
|
||||||
.get_first_track_num= _cdio_get_first_track_num,
|
.get_first_track_num= _cdio_get_first_track_num,
|
||||||
.get_mcn = NULL,
|
.get_mcn = NULL,
|
||||||
.get_num_tracks = _cdio_get_num_tracks,
|
.get_num_tracks = _cdio_get_num_tracks,
|
||||||
|
|||||||
Reference in New Issue
Block a user