Allow more freedom in specifying access mode.
Image drivers now have an "image" access mode.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/* -*- c -*-
|
||||
$Id: cdio.h,v 1.48 2004/05/11 12:17:17 rocky Exp $
|
||||
$Id: cdio.h,v 1.49 2004/05/13 01:50:10 rocky Exp $
|
||||
|
||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||
@@ -311,7 +311,7 @@ extern "C" {
|
||||
unsigned int cdio_get_track_sec_count(const CdIo *obj, track_t track_num);
|
||||
|
||||
/*!
|
||||
Reposition read/write file offset
|
||||
Reposition read offset
|
||||
Similar to (if not the same as) libc's lseek()
|
||||
|
||||
@param obj object to get information from
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: freebsd.c,v 1.10 2004/05/07 21:39:43 rocky Exp $
|
||||
$Id: freebsd.c,v 1.11 2004/05/13 01:50:22 rocky Exp $
|
||||
|
||||
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
static const char _rcsid[] = "$Id: freebsd.c,v 1.10 2004/05/07 21:39:43 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: freebsd.c,v 1.11 2004/05/13 01:50:22 rocky Exp $";
|
||||
|
||||
#include "freebsd.h"
|
||||
|
||||
@@ -36,7 +36,7 @@ static const char _rcsid[] = "$Id: freebsd.c,v 1.10 2004/05/07 21:39:43 rocky Ex
|
||||
static access_mode_t
|
||||
str_to_access_mode_freebsd(const char *psz_access_mode)
|
||||
{
|
||||
const access_mode_t default_access_mode = _AM_IOCTL;
|
||||
const access_mode_t default_access_mode = DEFAULT_FREEBSD_AM;
|
||||
|
||||
if (NULL==psz_access_mode) return default_access_mode;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: freebsd.h,v 1.3 2004/05/05 02:47:18 rocky Exp $
|
||||
$Id: freebsd.h,v 1.4 2004/05/13 01:50:23 rocky Exp $
|
||||
|
||||
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -31,8 +31,19 @@
|
||||
#include "cdio_assert.h"
|
||||
#include "cdio_private.h"
|
||||
|
||||
/* Is this the right default? */
|
||||
#define DEFAULT_CDIO_DEVICE "/dev/cd0c"
|
||||
/*!
|
||||
For ioctl access /dev/acd0c is preferred over /dev/cd0c.
|
||||
For cam access /dev/cd0c is preferred. DEFAULT_CDIO_DEVICE and
|
||||
DEFAULT_FREEBSD_AM should be consistent.
|
||||
*/
|
||||
|
||||
#ifndef DEFUALT_CDIO_DEVICE
|
||||
#define DEFAULT_CDIO_DEVICE "/dev/acd0c"
|
||||
#endif
|
||||
|
||||
#ifndef DEFUALT_FREEBSD_AM
|
||||
#define DEFAULT_FREEBSD_AM _AM_IOCTL
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: _cdio_generic.c,v 1.14 2004/05/05 10:34:55 rocky Exp $
|
||||
$Id: _cdio_generic.c,v 1.15 2004/05/13 01:50:20 rocky Exp $
|
||||
|
||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||
@@ -27,7 +27,7 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
static const char _rcsid[] = "$Id: _cdio_generic.c,v 1.14 2004/05/05 10:34:55 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: _cdio_generic.c,v 1.15 2004/05/13 01:50:20 rocky Exp $";
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -101,7 +101,7 @@ cdio_generic_init (void *user_data)
|
||||
/*!
|
||||
Reads into buf the next size bytes.
|
||||
Returns -1 on error.
|
||||
Is in fact libc's read().
|
||||
Is in fact libc's lseek().
|
||||
*/
|
||||
off_t
|
||||
cdio_generic_lseek (void *user_data, off_t offset, int whence)
|
||||
|
||||
58
lib/cdio.c
58
lib/cdio.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: cdio.c,v 1.51 2004/05/09 22:12:49 rocky Exp $
|
||||
$Id: cdio.c,v 1.52 2004/05/13 01:50:20 rocky Exp $
|
||||
|
||||
Copyright (C) 2003, 2004 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.51 2004/05/09 22:12:49 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: cdio.c,v 1.52 2004/05/13 01:50:20 rocky Exp $";
|
||||
|
||||
|
||||
const char *track_format2str[6] =
|
||||
@@ -192,13 +192,15 @@ CdIo_driver_t CdIo_all_drivers[CDIO_MAX_DRIVER+1] = {
|
||||
};
|
||||
|
||||
static CdIo *
|
||||
scan_for_driver(driver_id_t start, driver_id_t end, const char *source_name)
|
||||
scan_for_driver(driver_id_t start, driver_id_t end,
|
||||
const char *psz_source, const char *access_mode)
|
||||
{
|
||||
driver_id_t driver_id;
|
||||
|
||||
for (driver_id=start; driver_id<=end; driver_id++) {
|
||||
if ((*CdIo_all_drivers[driver_id].have_driver)()) {
|
||||
CdIo *ret=(*CdIo_all_drivers[driver_id].driver_open)(source_name);
|
||||
CdIo *ret=
|
||||
(*CdIo_all_drivers[driver_id].driver_open_am)(psz_source, access_mode);
|
||||
if (ret != NULL) {
|
||||
ret->driver_id = driver_id;
|
||||
return ret;
|
||||
@@ -312,7 +314,7 @@ cdio_get_devices (driver_id_t driver_id)
|
||||
/* FIXME: spit out unknown to give image drivers as well. */
|
||||
case DRIVER_UNKNOWN:
|
||||
case DRIVER_DEVICE:
|
||||
cdio = scan_for_driver(DRIVER_UNKNOWN, CDIO_MAX_DRIVER, NULL);
|
||||
cdio = scan_for_driver(DRIVER_UNKNOWN, CDIO_MAX_DRIVER, NULL, NULL);
|
||||
break;
|
||||
default:
|
||||
return (*CdIo_all_drivers[driver_id].get_devices)();
|
||||
@@ -430,7 +432,7 @@ cdio_get_drive_cap_dev (const char *device)
|
||||
cdio_drive_cap_t i_drivetype = CDIO_DRIVE_CAP_UNKNOWN;
|
||||
|
||||
CdIo *cdio=scan_for_driver(CDIO_MIN_DRIVER, CDIO_MAX_DRIVER,
|
||||
device);
|
||||
device, NULL);
|
||||
if (cdio) {
|
||||
i_drivetype=cdio_get_drive_cap(cdio);
|
||||
cdio_destroy(cdio);
|
||||
@@ -639,10 +641,10 @@ cdio_have_driver(driver_id_t driver_id)
|
||||
}
|
||||
|
||||
bool
|
||||
cdio_is_device(const char *source_name, driver_id_t driver_id)
|
||||
cdio_is_device(const char *psz_source, driver_id_t driver_id)
|
||||
{
|
||||
if (CdIo_all_drivers[driver_id].is_device == NULL) return false;
|
||||
return (*CdIo_all_drivers[driver_id].is_device)(source_name);
|
||||
return (*CdIo_all_drivers[driver_id].is_device)(psz_source);
|
||||
}
|
||||
|
||||
|
||||
@@ -877,28 +879,42 @@ cdio_set_arg (CdIo *cdio, const char key[], const char value[])
|
||||
CdIo *
|
||||
cdio_open (const char *orig_source_name, driver_id_t driver_id)
|
||||
{
|
||||
char *source_name;
|
||||
return cdio_open_am(orig_source_name, driver_id, NULL);
|
||||
}
|
||||
|
||||
/*! Sets up to read from place specified by source_name and
|
||||
driver_id. This should be called before using any other routine,
|
||||
except cdio_init. This will call cdio_init, if that hasn't been
|
||||
done previously.
|
||||
|
||||
NULL is returned on error.
|
||||
*/
|
||||
CdIo *
|
||||
cdio_open_am (const char *psz_orig_source, driver_id_t driver_id,
|
||||
const char *psz_access_mode)
|
||||
{
|
||||
char *psz_source;
|
||||
|
||||
if (CdIo_last_driver == -1) cdio_init();
|
||||
|
||||
if (NULL == orig_source_name || strlen(orig_source_name)==0)
|
||||
source_name = cdio_get_default_device(NULL);
|
||||
if (NULL == psz_orig_source || strlen(psz_orig_source)==0)
|
||||
psz_source = cdio_get_default_device(NULL);
|
||||
else
|
||||
source_name = strdup(orig_source_name);
|
||||
psz_source = strdup(psz_orig_source);
|
||||
|
||||
switch (driver_id) {
|
||||
case DRIVER_UNKNOWN:
|
||||
{
|
||||
CdIo *cdio=scan_for_driver(CDIO_MIN_DRIVER, CDIO_MAX_DRIVER,
|
||||
source_name);
|
||||
free(source_name);
|
||||
psz_source, psz_access_mode);
|
||||
free(psz_source);
|
||||
return cdio;
|
||||
}
|
||||
case DRIVER_DEVICE:
|
||||
{
|
||||
/* Scan for a driver. */
|
||||
CdIo *ret = cdio_open_cd(source_name);
|
||||
free(source_name);
|
||||
CdIo *ret = cdio_open_cd(psz_source);
|
||||
free(psz_source);
|
||||
return ret;
|
||||
}
|
||||
break;
|
||||
@@ -912,14 +928,16 @@ cdio_open (const char *orig_source_name, driver_id_t driver_id)
|
||||
case DRIVER_BINCUE:
|
||||
case DRIVER_CDRDAO:
|
||||
if ((*CdIo_all_drivers[driver_id].have_driver)()) {
|
||||
CdIo *ret = (*CdIo_all_drivers[driver_id].driver_open)(source_name);
|
||||
CdIo *ret =
|
||||
(*CdIo_all_drivers[driver_id].driver_open_am)(psz_source,
|
||||
psz_access_mode);
|
||||
if (ret) ret->driver_id = driver_id;
|
||||
free(source_name);
|
||||
free(psz_source);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
free(source_name);
|
||||
free(psz_source);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -939,7 +957,7 @@ cdio_open_cd (const char *source_name)
|
||||
|
||||
/* Scan for a driver. */
|
||||
return scan_for_driver(CDIO_MIN_DEVICE_DRIVER, CDIO_MAX_DEVICE_DRIVER,
|
||||
source_name);
|
||||
source_name, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: bincue.c,v 1.17 2004/05/11 02:15:58 rocky Exp $
|
||||
$Id: bincue.c,v 1.18 2004/05/13 01:50:23 rocky Exp $
|
||||
|
||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||
@@ -24,7 +24,7 @@
|
||||
(*.cue).
|
||||
*/
|
||||
|
||||
static const char _rcsid[] = "$Id: bincue.c,v 1.17 2004/05/11 02:15:58 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: bincue.c,v 1.18 2004/05/13 01:50:23 rocky Exp $";
|
||||
|
||||
#include "cdio_assert.h"
|
||||
#include "cdio_private.h"
|
||||
@@ -713,6 +713,8 @@ _get_arg_bincue (void *env, const char key[])
|
||||
return _obj->gen.source_name;
|
||||
} else if (!strcmp (key, "cue")) {
|
||||
return _obj->cue_name;
|
||||
} else if (!strcmp(key, "access-mode")) {
|
||||
return "image";
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: cdrdao.c,v 1.6 2004/05/11 02:16:00 rocky Exp $
|
||||
$Id: cdrdao.c,v 1.7 2004/05/13 01:50:24 rocky Exp $
|
||||
|
||||
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
||||
toc reading routine adapted from cuetools
|
||||
@@ -25,7 +25,7 @@
|
||||
(*.cue).
|
||||
*/
|
||||
|
||||
static const char _rcsid[] = "$Id: cdrdao.c,v 1.6 2004/05/11 02:16:00 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: cdrdao.c,v 1.7 2004/05/13 01:50:24 rocky Exp $";
|
||||
|
||||
#include "cdio_assert.h"
|
||||
#include "cdio_private.h"
|
||||
@@ -1054,6 +1054,8 @@ _get_arg_cdrdao (void *env, const char key[])
|
||||
return _obj->tocent[0].filename;
|
||||
} else if (!strcmp (key, "toc")) {
|
||||
return _obj->toc_name;
|
||||
} else if (!strcmp(key, "access-mode")) {
|
||||
return "image";
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -1200,8 +1202,8 @@ cdio_is_tocfile(const char *toc_name)
|
||||
CdIo *
|
||||
cdio_open_am_cdrdao (const char *psz_source_name, const char *psz_access_mode)
|
||||
{
|
||||
if (psz_access_mode != NULL)
|
||||
cdio_warn ("there is only one access mode for toc. Arg %s ignored",
|
||||
if (psz_access_mode != NULL && strcmp(psz_access_mode, "image"))
|
||||
cdio_warn ("there is only one access mode, 'image' for toc. Arg %s ignored",
|
||||
psz_access_mode);
|
||||
return cdio_open_cdrdao(psz_source_name);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: nrg.c,v 1.13 2004/05/11 02:16:01 rocky Exp $
|
||||
$Id: nrg.c,v 1.14 2004/05/13 01:50:25 rocky Exp $
|
||||
|
||||
Copyright (C) 2001, 2003 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||
@@ -48,7 +48,7 @@
|
||||
#include "cdio_private.h"
|
||||
#include "_cdio_stdio.h"
|
||||
|
||||
static const char _rcsid[] = "$Id: nrg.c,v 1.13 2004/05/11 02:16:01 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: nrg.c,v 1.14 2004/05/13 01:50:25 rocky Exp $";
|
||||
|
||||
/* structures used */
|
||||
|
||||
@@ -1047,6 +1047,8 @@ _get_arg_nrg (void *env, const char key[])
|
||||
|
||||
if (!strcmp (key, "source")) {
|
||||
return _obj->gen.source_name;
|
||||
} else if (!strcmp(key, "access-mode")) {
|
||||
return "image";
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -1185,7 +1187,7 @@ cdio_is_nrg(const char *psz_nrg)
|
||||
CdIo *
|
||||
cdio_open_am_nrg (const char *psz_source_name, const char *psz_access_mode)
|
||||
{
|
||||
if (psz_access_mode != NULL)
|
||||
if (psz_access_mode != NULL && strcmp(psz_access_mode, "image"))
|
||||
cdio_warn ("there is only one access mode for nrg. Arg %s ignored",
|
||||
psz_access_mode);
|
||||
return cdio_open_nrg(psz_source_name);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: cd-info.c,v 1.60 2004/05/09 17:05:34 rocky Exp $
|
||||
$Id: cd-info.c,v 1.61 2004/05/13 01:50:28 rocky Exp $
|
||||
|
||||
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||
Copyright (C) 1996, 1997, 1998 Gerd Knorr <kraxel@bytesex.org>
|
||||
@@ -739,6 +739,7 @@ init(void)
|
||||
opts.no_ioctl = 0;
|
||||
opts.no_analysis = 0;
|
||||
opts.source_image = IMAGE_UNKNOWN;
|
||||
opts.access_mode = NULL;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
@@ -786,21 +787,21 @@ main(int argc, const char *argv[])
|
||||
switch (opts.source_image) {
|
||||
case IMAGE_UNKNOWN:
|
||||
case IMAGE_AUTO:
|
||||
cdio = cdio_open (source_name, DRIVER_UNKNOWN);
|
||||
cdio = cdio_open_am (source_name, DRIVER_UNKNOWN, opts.access_mode);
|
||||
if (cdio==NULL) {
|
||||
err_exit("%s: Error in automatically selecting driver for input %s\n",
|
||||
program_name, source_name);
|
||||
}
|
||||
break;
|
||||
case IMAGE_DEVICE:
|
||||
cdio = cdio_open (source_name, DRIVER_DEVICE);
|
||||
cdio = cdio_open_am (source_name, DRIVER_DEVICE, opts.access_mode);
|
||||
if (cdio==NULL) {
|
||||
err_exit("%s: Error in automatically selecting device for input %s\n",
|
||||
program_name, source_name);
|
||||
}
|
||||
break;
|
||||
case IMAGE_BIN:
|
||||
cdio = cdio_open (source_name, DRIVER_BINCUE);
|
||||
cdio = cdio_open_am (source_name, DRIVER_BINCUE, opts.access_mode);
|
||||
if (cdio==NULL) {
|
||||
err_exit("%s: Error in opening bin/cue for input %s\n",
|
||||
program_name, source_name);
|
||||
@@ -814,7 +815,7 @@ main(int argc, const char *argv[])
|
||||
}
|
||||
break;
|
||||
case IMAGE_NRG:
|
||||
cdio = cdio_open (source_name, DRIVER_NRG);
|
||||
cdio = cdio_open_am (source_name, DRIVER_NRG, opts.access_mode);
|
||||
if (cdio==NULL) {
|
||||
err_exit("%s: Error in opening NRG with input %s\n",
|
||||
program_name, source_name);
|
||||
@@ -822,7 +823,7 @@ main(int argc, const char *argv[])
|
||||
break;
|
||||
|
||||
case IMAGE_CDRDAO:
|
||||
cdio = cdio_open (source_name, DRIVER_CDRDAO);
|
||||
cdio = cdio_open_am (source_name, DRIVER_CDRDAO, opts.access_mode);
|
||||
if (cdio==NULL) {
|
||||
err_exit("%s: Error in opening TOC with input %s\n",
|
||||
program_name, source_name);
|
||||
@@ -844,7 +845,8 @@ main(int argc, const char *argv[])
|
||||
|
||||
if (opts.silent == 0) {
|
||||
printf("CD location : %s\n", source_name);
|
||||
printf("CD driver name: %s\n\n", cdio_get_driver_name(cdio));
|
||||
printf("CD driver name: %s\n", cdio_get_driver_name(cdio));
|
||||
printf(" access mode: %s\n\n", cdio_get_arg(cdio, "access-mode"));
|
||||
}
|
||||
|
||||
{
|
||||
@@ -866,10 +868,6 @@ main(int argc, const char *argv[])
|
||||
free(device_list);
|
||||
}
|
||||
|
||||
if (opts.access_mode!=NULL) {
|
||||
cdio_set_arg(cdio, "access-mode", opts.access_mode);
|
||||
}
|
||||
|
||||
first_track_num = cdio_get_first_track_num(cdio);
|
||||
num_tracks = cdio_get_num_tracks(cdio);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user