diff --git a/include/cdio/cdio.h b/include/cdio/cdio.h index dc29c144..fa535120 100644 --- a/include/cdio/cdio.h +++ b/include/cdio/cdio.h @@ -1,5 +1,5 @@ /* -*- c -*- - $Id: cdio.h,v 1.49 2004/05/13 01:50:10 rocky Exp $ + $Id: cdio.h,v 1.50 2004/05/19 03:00:03 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel Copyright (C) 2003, 2004 Rocky Bernstein @@ -546,20 +546,32 @@ extern "C" { /*! Set up CD-ROM for reading. The device_name is the some sort of device name. - NULL is returned on error. + @return the cdio object for subsequent operations. + NULL on error or there is no driver for a some sort of hardware CD-ROM. */ CdIo * cdio_open_cd (const char *device_name); - /*! cdrao BIN/CUE CD disk-image routines. Source is the .cue file + /*! Set up CD-ROM for reading. The device_name is + the some sort of device name. - NULL is returned on error. + @return the cdio object for subsequent operations. + NULL on error or there is no driver for a some sort of hardware CD-ROM. + */ + CdIo * cdio_open_am_cd (const char *psz_device, + const char *psz_access_mode); + + /*! CDRWIN BIN/CUE CD disk-image routines. Source is the .cue file + + @return the cdio object for subsequent operations. + NULL on error. */ CdIo * cdio_open_cue (const char *cue_name); /*! Set up CD-ROM for reading using the BSDI driver. The device_name is the some sort of device name. - NULL is returned on error or there is no BSDI driver. + @return the cdio object for subsequent operations. + NULL on error or there is no BSDI driver. @see cdio_open */ @@ -568,7 +580,8 @@ extern "C" { /*! Set up CD-ROM for reading using the BSDI driver. The device_name is the some sort of device name. - NULL is returned on error or there is no BSDI driver. + @return the cdio object for subsequent operations. + NULL on error or there is no BSDI driver. @see cdio_open */ @@ -578,7 +591,8 @@ extern "C" { /*! Return a string containing the default device name that the BSDI driver would use when none is specified. - NULL is returned on error or there is no CD-ROM device. + @return the cdio object for subsequent operations. + NULL on error or there is no BSDI driver. @see cdio_open_cd, cdio_open */ @@ -623,14 +637,16 @@ extern "C" { /*! Set up CD-ROM for reading using the GNU/Linux driver. The device_name is the some sort of device name. - NULL is returned on error or there is no GNU/Linux driver. + @return the cdio object for subsequent operations. + NULL on error or there is no GNU/Linux driver. */ CdIo * cdio_open_linux (const char *source_name); - /*! Set up CD-ROM for reading using the GNU/Linux driver. The device_name is - the some sort of device name. + /*! Set up CD-ROM for reading using the GNU/Linux driver. The + device_name is the some sort of device name. - NULL is returned on error or there is no GNU/Linux driver. + @return the cdio object for subsequent operations. + NULL on error or there is no GNU/Linux driver. */ CdIo * cdio_open_am_linux (const char *source_name, const char *access_mode); @@ -653,14 +669,16 @@ extern "C" { /*! Set up CD-ROM for reading using the Sun Solaris driver. The device_name is the some sort of device name. - NULL is returned on error or there is no Solaris driver. + @return the cdio object for subsequent operations. + NULL on error or there is no Solaris driver. */ CdIo * cdio_open_solaris (const char *source_name); /*! Set up CD-ROM for reading using the Sun Solaris driver. The device_name is the some sort of device name. - NULL is returned on error or there is no Solaris driver. + @return the cdio object for subsequent operations. + NULL on error or there is no Solaris driver. */ CdIo * cdio_open_am_solaris (const char *psz_source_name, const char *psz_access_mode); diff --git a/lib/FreeBSD/freebsd.c b/lib/FreeBSD/freebsd.c index 39809ef1..a4d99470 100644 --- a/lib/FreeBSD/freebsd.c +++ b/lib/FreeBSD/freebsd.c @@ -1,5 +1,5 @@ /* - $Id: freebsd.c,v 1.13 2004/05/16 13:33:26 rocky Exp $ + $Id: freebsd.c,v 1.14 2004/05/19 03:00:12 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein @@ -27,7 +27,7 @@ # include "config.h" #endif -static const char _rcsid[] = "$Id: freebsd.c,v 1.13 2004/05/16 13:33:26 rocky Exp $"; +static const char _rcsid[] = "$Id: freebsd.c,v 1.14 2004/05/19 03:00:12 rocky Exp $"; #include "freebsd.h" @@ -288,6 +288,7 @@ _get_first_track_num_freebsd(void *env) static char * _get_mcn_freebsd (const void *env) { +#if FIXED const _img_private_t *_obj = env; struct ioc_read_subchannel subchannel; struct cd_sub_channel_info subchannel_info; @@ -310,6 +311,10 @@ _get_mcn_freebsd (const void *env) { return strdup(subchannel_info.what.media_catalog.mc_number); else return NULL; +#else + return NULL; +#endif + } /*! @@ -395,7 +400,7 @@ _get_track_lba_freebsd(void *env, track_t track_num) if (track_num > TOTAL_TRACKS+1 || track_num == 0) { return CDIO_INVALID_LBA; } else { - return cdio_lsn_to_lba(_obj->tocent[track_num-1].entry.addr.lba); + return cdio_lsn_to_lba(ntohl(_obj->tocent[track_num-1].entry.addr.lba)); } } @@ -509,18 +514,18 @@ cdio_open_am_freebsd (const char *psz_orig_source_name, _data = _cdio_malloc (sizeof (_img_private_t)); _data->access_mode = str_to_access_mode_freebsd(psz_access_mode); - _data->device = strdup(psz_source_name); _data->gen.init = false; _data->gen.fd = -1; if (NULL == psz_orig_source_name) { psz_source_name=cdio_get_default_device_freebsd(); + _data->device = psz_source_name; _set_arg_freebsd(_data, "source", psz_source_name); - free(psz_source_name); } else { - if (cdio_is_device_generic(psz_orig_source_name)) + if (cdio_is_device_generic(psz_orig_source_name)) { _set_arg_freebsd(_data, "source", psz_orig_source_name); - else { + _data->device = strdup(psz_orig_source_name); + } else { /* The below would be okay if all device drivers worked this way. */ #if 0 cdio_info ("source %s is a not a device", psz_orig_source_name); diff --git a/lib/FreeBSD/freebsd.h b/lib/FreeBSD/freebsd.h index beb5a753..2e024736 100644 --- a/lib/FreeBSD/freebsd.h +++ b/lib/FreeBSD/freebsd.h @@ -1,5 +1,5 @@ /* - $Id: freebsd.h,v 1.5 2004/05/13 04:32:14 rocky Exp $ + $Id: freebsd.h,v 1.6 2004/05/19 03:00:12 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein @@ -63,6 +63,7 @@ #include #include #include +#include #define HAVE_FREEBSD_CAM #ifdef HAVE_FREEBSD_CAM @@ -144,6 +145,9 @@ int read_mode2_sector_freebsd_ioctl (_img_private_t *env, void *data, int read_mode2_sectors_freebsd_cam (_img_private_t *env, void *buf, uint32_t lba, unsigned int nblocks, bool b_form2); + +bool read_toc_freebsd_ioctl (_img_private_t *_obj); + /*! Return the size of the CD in logical block address (LBA) units. */ diff --git a/lib/cdio.c b/lib/cdio.c index 12c44dfc..ef1113bf 100644 --- a/lib/cdio.c +++ b/lib/cdio.c @@ -1,5 +1,5 @@ /* - $Id: cdio.c,v 1.52 2004/05/13 01:50:20 rocky Exp $ + $Id: cdio.c,v 1.53 2004/05/19 03:00:03 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein Copyright (C) 2001 Herbert Valerio Riedel @@ -37,7 +37,7 @@ #include #include "cdio_private.h" -static const char _rcsid[] = "$Id: cdio.c,v 1.52 2004/05/13 01:50:20 rocky Exp $"; +static const char _rcsid[] = "$Id: cdio.c,v 1.53 2004/05/19 03:00:03 rocky Exp $"; const char *track_format2str[6] = @@ -913,7 +913,7 @@ cdio_open_am (const char *psz_orig_source, driver_id_t driver_id, case DRIVER_DEVICE: { /* Scan for a driver. */ - CdIo *ret = cdio_open_cd(psz_source); + CdIo *ret = cdio_open_am_cd(psz_source, psz_access_mode); free(psz_source); return ret; } @@ -942,6 +942,26 @@ cdio_open_am (const char *psz_orig_source, driver_id_t driver_id, } +/*! + Set up CD-ROM for reading. The device_name is + the some sort of device name. + + @return the cdio object for subsequent operations. + NULL on error or there is no driver for a some sort of hardware CD-ROM. +*/ +CdIo * +cdio_open_cd (const char *psz_source) +{ + return cdio_open_am_cd(psz_source, NULL); +} + +/*! + Set up CD-ROM for reading. The device_name is + the some sort of device name. + + @return the cdio object for subsequent operations. + NULL on error or there is no driver for a some sort of hardware CD-ROM. +*/ /* In the future we'll have more complicated code to allow selection of an I/O routine as well as code to find an appropriate default routine among the "registered" routines. Possibly classes too @@ -951,13 +971,13 @@ cdio_open_am (const char *psz_orig_source, driver_id_t driver_id, For now though, we'll start more simply... */ CdIo * -cdio_open_cd (const char *source_name) +cdio_open_am_cd (const char *psz_source, const char *psz_access_mode) { if (CdIo_last_driver == -1) cdio_init(); /* Scan for a driver. */ return scan_for_driver(CDIO_MIN_DEVICE_DRIVER, CDIO_MAX_DEVICE_DRIVER, - source_name, NULL); + psz_source, psz_access_mode); } diff --git a/lib/sector.c b/lib/sector.c index daf37d8b..f95f9ca1 100644 --- a/lib/sector.c +++ b/lib/sector.c @@ -1,5 +1,5 @@ /* - $Id: sector.c,v 1.8 2004/05/11 12:17:17 rocky Exp $ + $Id: sector.c,v 1.9 2004/05/19 03:00:12 rocky Exp $ Copyright (C) 2004 Rocky Bernstein Copyright (C) 2000 Herbert Valerio Riedel @@ -25,6 +25,7 @@ #include #include +#include #include "cdio_assert.h" #include @@ -33,7 +34,7 @@ #endif -static const char _rcsid[] = "$Id: sector.c,v 1.8 2004/05/11 12:17:17 rocky Exp $"; +static const char _rcsid[] = "$Id: sector.c,v 1.9 2004/05/19 03:00:12 rocky Exp $"; lba_t cdio_lba_to_lsn (lba_t lba) @@ -68,6 +69,11 @@ cdio_lsn_to_msf (lsn_t lsn, msf_t *msf) f = lsn + CDIO_CD_MAX_LSN; } + if (m > 99) { + cdio_warn ("number of minutes (%d) truncated to 99.", m); + m = 99; + } + msf->m = to_bcd8 (m); msf->s = to_bcd8 (s); msf->f = to_bcd8 (f);