Add scsi_mmc_get_hwinfo.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: scsi_mmc.h,v 1.23 2004/07/29 05:31:27 rocky Exp $
|
||||
$Id: scsi_mmc.h,v 1.24 2004/07/31 07:43:26 rocky Exp $
|
||||
|
||||
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -109,6 +109,12 @@
|
||||
#define CDIO_MMC_HW_MODEL_LEN 16 /**< length of model field */
|
||||
#define CDIO_MMC_HW_REVISION_LEN 4 /**< length of revision field */
|
||||
|
||||
typedef struct scsi_mmc_hwinfo
|
||||
{
|
||||
char vendor [CDIO_MMC_HW_VENDOR_LEN+1];
|
||||
char model [CDIO_MMC_HW_MODEL_LEN+1];
|
||||
char revision[CDIO_MMC_HW_REVISION_LEN+1];
|
||||
} scsi_mmc_hwinfo_t;
|
||||
|
||||
/*! This is listed as optional in ATAPI 2.6, but is (curiously)
|
||||
missing from Mt. Fuji, Table 57. It _is_ mentioned in Mt. Fuji
|
||||
@@ -210,7 +216,11 @@ int scsi_mmc_eject_media( const CdIo *cdio);
|
||||
int scsi_mmc_read_sectors ( const CdIo *cdio, void *p_buf, lba_t lba,
|
||||
int sector_type, unsigned int nblocks);
|
||||
|
||||
int scsi_mmc_set_bsize ( const CdIo *cdio, unsigned int bsize);
|
||||
/*!
|
||||
Set the block size for subsequest read requests, via a SCSI MMC
|
||||
MODE_SELECT 6 command.
|
||||
*/
|
||||
int scsi_mmc_set_blocksize ( const CdIo *cdio, unsigned int bsize);
|
||||
|
||||
/*!
|
||||
Return the the kind of drive capabilities of device.
|
||||
@@ -226,7 +236,24 @@ void scsi_mmc_get_drive_cap (const CdIo *p_cdio,
|
||||
discmode_t scsi_mmc_get_dvd_struct_physical ( const CdIo *p_cdio,
|
||||
cdio_dvd_struct_t *s);
|
||||
|
||||
/*!
|
||||
Get the CD-ROM hardware info via a SCSI MMC INQUIRY command.
|
||||
False is returned if we had an error getting the information.
|
||||
*/
|
||||
bool scsi_mmc_get_hwinfo ( const CdIo *p_cdio,
|
||||
/* out*/ scsi_mmc_hwinfo_t *hw_info );
|
||||
|
||||
|
||||
/*!
|
||||
Get the media catalog number (MCN) from the CD via MMC.
|
||||
|
||||
@return the media catalog number r NULL if there is none or we
|
||||
don't have the ability to get it.
|
||||
|
||||
Note: string is malloc'd so caller has to free() the returned
|
||||
string when done with it.
|
||||
|
||||
*/
|
||||
char *scsi_mmc_get_mcn ( const CdIo *p_cdio );
|
||||
|
||||
|
||||
#endif /* __SCSI_MMC_H__ */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: _cdio_linux.c,v 1.86 2004/07/29 02:16:20 rocky Exp $
|
||||
$Id: _cdio_linux.c,v 1.87 2004/07/31 07:43:26 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_linux.c,v 1.86 2004/07/29 02:16:20 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.87 2004/07/31 07:43:26 rocky Exp $";
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -558,7 +558,7 @@ _read_mode2_sectors_mmc (_img_private_t *p_env, void *p_buf, lba_t lba,
|
||||
CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_READ_10);
|
||||
CDIO_MMC_SET_READ_LENGTH16(cdb.field, nblocks);
|
||||
|
||||
if ((retval = scsi_mmc_set_bsize (p_env->gen.cdio, M2RAW_SECTOR_SIZE)))
|
||||
if ((retval = scsi_mmc_set_blocksize (p_env->gen.cdio, M2RAW_SECTOR_SIZE)))
|
||||
return retval;
|
||||
|
||||
if ((retval = run_scsi_cmd_linux (p_env, 0,
|
||||
@@ -568,11 +568,11 @@ _read_mode2_sectors_mmc (_img_private_t *p_env, void *p_buf, lba_t lba,
|
||||
M2RAW_SECTOR_SIZE * nblocks,
|
||||
p_buf)))
|
||||
{
|
||||
scsi_mmc_set_bsize (p_env->gen.cdio, CDIO_CD_FRAMESIZE);
|
||||
scsi_mmc_set_blocksize (p_env->gen.cdio, CDIO_CD_FRAMESIZE);
|
||||
return retval;
|
||||
}
|
||||
|
||||
if ((retval = scsi_mmc_set_bsize (p_env->gen.cdio, CDIO_CD_FRAMESIZE)))
|
||||
if ((retval = scsi_mmc_set_blocksize (p_env->gen.cdio, CDIO_CD_FRAMESIZE)))
|
||||
return retval;
|
||||
} else
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Common SCSI Multimedia Command (MMC) routines.
|
||||
|
||||
$Id: scsi_mmc.c,v 1.17 2004/07/29 05:24:21 rocky Exp $
|
||||
$Id: scsi_mmc.c,v 1.18 2004/07/31 07:43:26 rocky Exp $
|
||||
|
||||
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -185,9 +185,9 @@ scsi_mmc_read_sectors ( const CdIo *cdio, void *p_buf, lba_t lba,
|
||||
}
|
||||
|
||||
int
|
||||
scsi_mmc_set_bsize_private ( const void *p_env,
|
||||
const scsi_mmc_run_cmd_fn_t run_scsi_mmc_cmd,
|
||||
unsigned int bsize)
|
||||
scsi_mmc_set_blocksize_private ( const void *p_env,
|
||||
const scsi_mmc_run_cmd_fn_t run_scsi_mmc_cmd,
|
||||
unsigned int bsize)
|
||||
{
|
||||
scsi_mmc_cdb_t cdb = {{0, }};
|
||||
|
||||
@@ -227,11 +227,12 @@ scsi_mmc_set_bsize_private ( const void *p_env,
|
||||
}
|
||||
|
||||
int
|
||||
scsi_mmc_set_bsize ( const CdIo *cdio, unsigned int bsize)
|
||||
scsi_mmc_set_blocksize ( const CdIo *cdio, unsigned int bsize)
|
||||
{
|
||||
if ( ! cdio ) return -2;
|
||||
return
|
||||
scsi_mmc_set_bsize_private (cdio->env, cdio->op.run_scsi_mmc_cmd, bsize);
|
||||
scsi_mmc_set_blocksize_private (cdio->env, cdio->op.run_scsi_mmc_cmd,
|
||||
bsize);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -396,6 +397,45 @@ scsi_mmc_get_dvd_struct_physical ( const CdIo *p_cdio, cdio_dvd_struct_t *s)
|
||||
s);
|
||||
}
|
||||
|
||||
/*!
|
||||
Get the CD-ROM hardware info via a SCSI MMC INQUIRY command.
|
||||
False is returned if we had an error getting the information.
|
||||
*/
|
||||
bool
|
||||
scsi_mmc_get_hwinfo ( const CdIo *p_cdio,
|
||||
/*out*/ scsi_mmc_hwinfo_t *hw_info )
|
||||
{
|
||||
int i_status; /* Result of SCSI MMC command */
|
||||
char buf[36] = { 0, }; /* Place to hold returned data */
|
||||
scsi_mmc_cdb_t cdb = {{0, }}; /* Command Descriptor Block */
|
||||
|
||||
CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_INQUIRY);
|
||||
cdb.field[4] = sizeof(buf);
|
||||
|
||||
if (! p_cdio || ! hw_info ) return false;
|
||||
|
||||
i_status = scsi_mmc_run_cmd(p_cdio, DEFAULT_TIMEOUT_MS,
|
||||
&cdb, SCSI_MMC_DATA_READ,
|
||||
sizeof(buf), &buf);
|
||||
if (i_status == 0) {
|
||||
|
||||
memcpy(hw_info->vendor,
|
||||
buf + 8,
|
||||
sizeof(hw_info->vendor)-1);
|
||||
hw_info->vendor[sizeof(hw_info->vendor)-1] = '\0';
|
||||
memcpy(hw_info->model,
|
||||
buf + 8 + CDIO_MMC_HW_VENDOR_LEN,
|
||||
sizeof(hw_info->model)-1);
|
||||
hw_info->model[sizeof(hw_info->model)-1] = '\0';
|
||||
memcpy(hw_info->revision,
|
||||
buf + 8 + CDIO_MMC_HW_VENDOR_LEN + CDIO_MMC_HW_MODEL_LEN,
|
||||
sizeof(hw_info->revision)-1);
|
||||
hw_info->revision[sizeof(hw_info->revision)-1] = '\0';
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
Return the media catalog number MCN.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* private MMC helper routines.
|
||||
|
||||
$Id: scsi_mmc_private.h,v 1.8 2004/07/28 01:14:42 rocky Exp $
|
||||
$Id: scsi_mmc_private.h,v 1.9 2004/07/31 07:43:26 rocky Exp $
|
||||
|
||||
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -41,9 +41,9 @@ int (*scsi_mmc_run_cmd_fn_t) ( const void *p_user_data,
|
||||
scsi_mmc_direction_t e_direction,
|
||||
unsigned int i_buf, /*in/out*/ void *p_buf );
|
||||
|
||||
int scsi_mmc_set_bsize_mmc_private ( const void *p_env, const
|
||||
scsi_mmc_run_cmd_fn_t run_scsi_mmc_cmd,
|
||||
unsigned int bsize );
|
||||
int scsi_mmc_set_blocksize_mmc_private ( const void *p_env, const
|
||||
scsi_mmc_run_cmd_fn_t run_scsi_mmc_cmd,
|
||||
unsigned int bsize );
|
||||
|
||||
/*!
|
||||
Get the DVD type associated with cd object.
|
||||
@@ -55,9 +55,9 @@ scsi_mmc_get_dvd_struct_physical_private ( void *p_env, const
|
||||
|
||||
|
||||
int
|
||||
scsi_mmc_set_bsize_private ( const void *p_env,
|
||||
const scsi_mmc_run_cmd_fn_t run_scsi_mmc_cmd,
|
||||
unsigned int bsize);
|
||||
scsi_mmc_set_blocksize_private ( const void *p_env,
|
||||
const scsi_mmc_run_cmd_fn_t run_scsi_mmc_cmd,
|
||||
unsigned int bsize);
|
||||
|
||||
char *scsi_mmc_get_mcn_private ( void *p_env,
|
||||
const scsi_mmc_run_cmd_fn_t run_scsi_mmc_cmd
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: cd-drive.c,v 1.3 2004/07/17 22:16:47 rocky Exp $
|
||||
$Id: cd-drive.c,v 1.4 2004/07/31 07:43:26 rocky Exp $
|
||||
|
||||
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#include <cdio/cdio.h>
|
||||
#include <cdio/scsi_mmc.h>
|
||||
|
||||
/* Used by `main' to communicate with `parse_opt'. And global options
|
||||
*/
|
||||
@@ -171,7 +172,7 @@ init(void)
|
||||
int
|
||||
main(int argc, const char *argv[])
|
||||
{
|
||||
CdIo *cdio=NULL;
|
||||
CdIo *p_cdio=NULL;
|
||||
|
||||
init();
|
||||
|
||||
@@ -190,20 +191,20 @@ main(int argc, const char *argv[])
|
||||
if (NULL == source_name) {
|
||||
char *default_device;
|
||||
|
||||
cdio = cdio_open (NULL, DRIVER_UNKNOWN);
|
||||
p_cdio = cdio_open (NULL, DRIVER_UNKNOWN);
|
||||
|
||||
if (NULL != cdio) {
|
||||
default_device = cdio_get_default_device(cdio);
|
||||
if (NULL != p_cdio) {
|
||||
default_device = cdio_get_default_device(p_cdio);
|
||||
|
||||
printf("The driver selected is %s\n", cdio_get_driver_name(cdio));
|
||||
printf("The driver selected is %s\n", cdio_get_driver_name(p_cdio));
|
||||
|
||||
if (default_device) {
|
||||
printf("The default device for this driver is %s\n", default_device);
|
||||
}
|
||||
|
||||
free(default_device);
|
||||
cdio_destroy(cdio);
|
||||
cdio=NULL;
|
||||
cdio_destroy(p_cdio);
|
||||
p_cdio=NULL;
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
@@ -224,25 +225,34 @@ main(int argc, const char *argv[])
|
||||
if (NULL == source_name) {
|
||||
/* Print out a list of CD-drives */
|
||||
|
||||
char **cd_drives=NULL, **cd;
|
||||
char **ppsz_cdrives=NULL, **ppsz_cd;
|
||||
|
||||
cd_drives = cdio_get_devices(DRIVER_DEVICE);
|
||||
if (NULL != cd_drives)
|
||||
for( cd = cd_drives; *cd != NULL; cd++ ) {
|
||||
ppsz_cdrives = cdio_get_devices(DRIVER_DEVICE);
|
||||
if (NULL != ppsz_cdrives)
|
||||
for( ppsz_cd = ppsz_cdrives; *ppsz_cd != NULL; ppsz_cd++ ) {
|
||||
cdio_drive_read_cap_t i_read_cap;
|
||||
cdio_drive_write_cap_t i_write_cap;
|
||||
cdio_drive_misc_cap_t i_misc_cap;
|
||||
CdIo *p_cdio = cdio_open(source_name, DRIVER_UNKNOWN);
|
||||
scsi_mmc_hwinfo_t scsi_mmc_hwinfo;
|
||||
|
||||
cdio_get_drive_cap_dev(*cd, &i_read_cap, &i_write_cap, &i_misc_cap);
|
||||
|
||||
printf("Drive %s\n", *cd);
|
||||
cdio_get_drive_cap_dev(*ppsz_cd, &i_read_cap, &i_write_cap,
|
||||
&i_misc_cap);
|
||||
printf("%28s: %s\n", "Drive", *ppsz_cd);
|
||||
if (scsi_mmc_get_hwinfo(p_cdio, &scsi_mmc_hwinfo)) {
|
||||
printf("%-28s: %s\n%-28s: %s\n%-28s: %s\n",
|
||||
"Vendor" , scsi_mmc_hwinfo.vendor,
|
||||
"Model" , scsi_mmc_hwinfo.model,
|
||||
"Revision", scsi_mmc_hwinfo.revision);
|
||||
}
|
||||
print_drive_capabilities(i_read_cap, i_write_cap, i_misc_cap);
|
||||
printf("\n");
|
||||
if (p_cdio) cdio_destroy(p_cdio);
|
||||
}
|
||||
|
||||
cdio_free_device_list(cd_drives);
|
||||
free(cd_drives);
|
||||
cd_drives = NULL;
|
||||
cdio_free_device_list(ppsz_cdrives);
|
||||
free(ppsz_cdrives);
|
||||
ppsz_cdrives = NULL;
|
||||
} else {
|
||||
/* Print CD-drive info for given source */
|
||||
cdio_drive_read_cap_t i_read_cap;
|
||||
@@ -257,7 +267,7 @@ main(int argc, const char *argv[])
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
myexit(cdio, EXIT_SUCCESS);
|
||||
myexit(p_cdio, EXIT_SUCCESS);
|
||||
/* Not reached:*/
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
121
src/cd-info.c
121
src/cd-info.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: cd-info.c,v 1.79 2004/07/28 22:03:35 rocky Exp $
|
||||
$Id: cd-info.c,v 1.80 2004/07/31 07:43:26 rocky Exp $
|
||||
|
||||
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||
Copyright (C) 1996, 1997, 1998 Gerd Knorr <kraxel@bytesex.org>
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <cdio/cd_types.h>
|
||||
#include <cdio/cdtext.h>
|
||||
#include <cdio/iso9660.h>
|
||||
#include <cdio/scsi_mmc.h>
|
||||
|
||||
#include "cdio_assert.h"
|
||||
#include "bytesex.h"
|
||||
@@ -344,19 +345,19 @@ msf_seconds(msf_t *msf)
|
||||
the number of tracks.
|
||||
*/
|
||||
static unsigned long
|
||||
cddb_discid(CdIo *cdio, int i_tracks)
|
||||
cddb_discid(CdIo *p_cdio, int i_tracks)
|
||||
{
|
||||
int i,t,n=0;
|
||||
msf_t start_msf;
|
||||
msf_t msf;
|
||||
|
||||
for (i = 1; i <= i_tracks; i++) {
|
||||
cdio_get_track_msf(cdio, i, &msf);
|
||||
cdio_get_track_msf(p_cdio, i, &msf);
|
||||
n += cddb_dec_digit_sum(msf_seconds(&msf));
|
||||
}
|
||||
|
||||
cdio_get_track_msf(cdio, 1, &start_msf);
|
||||
cdio_get_track_msf(cdio, CDIO_CDROM_LEADOUT_TRACK, &msf);
|
||||
cdio_get_track_msf(p_cdio, 1, &start_msf);
|
||||
cdio_get_track_msf(p_cdio, CDIO_CDROM_LEADOUT_TRACK, &msf);
|
||||
|
||||
t = msf_seconds(&msf) - msf_seconds(&start_msf);
|
||||
|
||||
@@ -390,8 +391,8 @@ _log_handler (cdio_log_level_t level, const char message[])
|
||||
}
|
||||
|
||||
static void
|
||||
print_cdtext_track_info(CdIo *cdio, track_t i_track, const char *message) {
|
||||
const cdtext_t *cdtext = cdio_get_cdtext(cdio, 0);
|
||||
print_cdtext_track_info(CdIo *p_cdio, track_t i_track, const char *message) {
|
||||
const cdtext_t *cdtext = cdio_get_cdtext(p_cdio, 0);
|
||||
|
||||
if (NULL != cdtext) {
|
||||
cdtext_field_t i;
|
||||
@@ -407,20 +408,20 @@ print_cdtext_track_info(CdIo *cdio, track_t i_track, const char *message) {
|
||||
}
|
||||
|
||||
static void
|
||||
print_cdtext_info(CdIo *cdio, track_t i_tracks, track_t i_first_track) {
|
||||
print_cdtext_info(CdIo *p_cdio, track_t i_tracks, track_t i_first_track) {
|
||||
track_t i_last_track = i_first_track+i_tracks;
|
||||
|
||||
print_cdtext_track_info(cdio, 0, "\nCD-TEXT for Disc:");
|
||||
print_cdtext_track_info(p_cdio, 0, "\nCD-TEXT for Disc:");
|
||||
for ( ; i_first_track < i_last_track; i_first_track++ ) {
|
||||
char msg[50];
|
||||
sprintf(msg, "CD-TEXT for Track %d:", i_first_track);
|
||||
print_cdtext_track_info(cdio, i_first_track, msg);
|
||||
print_cdtext_track_info(p_cdio, i_first_track, msg);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_CDDB
|
||||
static void
|
||||
print_cddb_info(CdIo *cdio, track_t i_tracks, track_t i_first_track) {
|
||||
print_cddb_info(CdIo *p_cdio, track_t i_tracks, track_t i_first_track) {
|
||||
int i, matches;
|
||||
|
||||
cddb_conn_t *conn = cddb_new();
|
||||
@@ -464,12 +465,12 @@ print_cddb_info(CdIo *cdio, track_t i_tracks, track_t i_first_track) {
|
||||
}
|
||||
for(i = 0; i < i_tracks; i++) {
|
||||
cddb_track_t *t = cddb_track_new();
|
||||
t->frame_offset = cdio_get_track_lba(cdio, i+i_first_track);
|
||||
t->frame_offset = cdio_get_track_lba(p_cdio, i+i_first_track);
|
||||
cddb_disc_add_track(disc, t);
|
||||
}
|
||||
|
||||
disc->length =
|
||||
cdio_get_track_lba(cdio, CDIO_CDROM_LEADOUT_TRACK)
|
||||
cdio_get_track_lba(p_cdio, CDIO_CDROM_LEADOUT_TRACK)
|
||||
/ CDIO_CD_FRAMES_PER_SEC;
|
||||
|
||||
if (!cddb_disc_calc_discid(disc)) {
|
||||
@@ -532,7 +533,7 @@ print_vcd_info(driver_id_t driver) {
|
||||
#endif
|
||||
|
||||
static void
|
||||
print_iso9660_recurse (const CdIo *cdio, const char pathname[],
|
||||
print_iso9660_recurse (const CdIo *p_cdio, const char pathname[],
|
||||
cdio_fs_anal_t fs,
|
||||
bool b_mode2)
|
||||
{
|
||||
@@ -540,7 +541,7 @@ print_iso9660_recurse (const CdIo *cdio, const char pathname[],
|
||||
CdioList *dirlist = _cdio_list_new ();
|
||||
CdioListNode *entnode;
|
||||
|
||||
entlist = iso9660_fs_readdir (cdio, pathname, b_mode2);
|
||||
entlist = iso9660_fs_readdir (p_cdio, pathname, b_mode2);
|
||||
|
||||
printf ("%s:\n", pathname);
|
||||
|
||||
@@ -603,7 +604,7 @@ print_iso9660_recurse (const CdIo *cdio, const char pathname[],
|
||||
{
|
||||
char *_fullname = _cdio_list_node_data (entnode);
|
||||
|
||||
print_iso9660_recurse (cdio, _fullname, fs, b_mode2);
|
||||
print_iso9660_recurse (p_cdio, _fullname, fs, b_mode2);
|
||||
}
|
||||
|
||||
_cdio_list_free (dirlist, true);
|
||||
@@ -842,7 +843,7 @@ int
|
||||
main(int argc, const char *argv[])
|
||||
{
|
||||
|
||||
CdIo *cdio=NULL;
|
||||
CdIo *p_cdio=NULL;
|
||||
cdio_fs_anal_t fs=CDIO_FS_AUDIO;
|
||||
int i;
|
||||
lsn_t start_track_lsn; /* lsn of first track */
|
||||
@@ -882,8 +883,8 @@ main(int argc, const char *argv[])
|
||||
switch (opts.source_image) {
|
||||
case IMAGE_UNKNOWN:
|
||||
case IMAGE_AUTO:
|
||||
cdio = cdio_open_am (source_name, DRIVER_UNKNOWN, opts.access_mode);
|
||||
if (cdio==NULL) {
|
||||
p_cdio = cdio_open_am (source_name, DRIVER_UNKNOWN, opts.access_mode);
|
||||
if (p_cdio==NULL) {
|
||||
if (source_name) {
|
||||
err_exit("%s: Error in automatically selecting driver for input %s.\n",
|
||||
program_name, source_name);
|
||||
@@ -894,8 +895,8 @@ main(int argc, const char *argv[])
|
||||
}
|
||||
break;
|
||||
case IMAGE_DEVICE:
|
||||
cdio = cdio_open_am (source_name, DRIVER_DEVICE, opts.access_mode);
|
||||
if (cdio==NULL) {
|
||||
p_cdio = cdio_open_am (source_name, DRIVER_DEVICE, opts.access_mode);
|
||||
if (p_cdio==NULL) {
|
||||
if (source_name) {
|
||||
err_exit("%s: Error in automatically selecting CD-image driver for input %s\n",
|
||||
program_name, source_name);
|
||||
@@ -906,8 +907,8 @@ main(int argc, const char *argv[])
|
||||
}
|
||||
break;
|
||||
case IMAGE_BIN:
|
||||
cdio = cdio_open_am (source_name, DRIVER_BINCUE, opts.access_mode);
|
||||
if (cdio==NULL) {
|
||||
p_cdio = cdio_open_am (source_name, DRIVER_BINCUE, opts.access_mode);
|
||||
if (p_cdio==NULL) {
|
||||
if (source_name) {
|
||||
err_exit("%s: Error in opening bin/cue for input %s\n",
|
||||
program_name, source_name);
|
||||
@@ -918,8 +919,8 @@ main(int argc, const char *argv[])
|
||||
}
|
||||
break;
|
||||
case IMAGE_CUE:
|
||||
cdio = cdio_open_cue(source_name);
|
||||
if (cdio==NULL) {
|
||||
p_cdio = cdio_open_cue(source_name);
|
||||
if (p_cdio==NULL) {
|
||||
if (source_name) {
|
||||
err_exit("%s: Error in opening cue/bin with input %s\n",
|
||||
program_name, source_name);
|
||||
@@ -930,8 +931,8 @@ main(int argc, const char *argv[])
|
||||
}
|
||||
break;
|
||||
case IMAGE_NRG:
|
||||
cdio = cdio_open_am (source_name, DRIVER_NRG, opts.access_mode);
|
||||
if (cdio==NULL) {
|
||||
p_cdio = cdio_open_am (source_name, DRIVER_NRG, opts.access_mode);
|
||||
if (p_cdio==NULL) {
|
||||
if (source_name) {
|
||||
err_exit("%s: Error in opening NRG with input %s\n",
|
||||
program_name, source_name);
|
||||
@@ -943,8 +944,8 @@ main(int argc, const char *argv[])
|
||||
break;
|
||||
|
||||
case IMAGE_CDRDAO:
|
||||
cdio = cdio_open_am (source_name, DRIVER_CDRDAO, opts.access_mode);
|
||||
if (cdio==NULL) {
|
||||
p_cdio = cdio_open_am (source_name, DRIVER_CDRDAO, opts.access_mode);
|
||||
if (p_cdio==NULL) {
|
||||
if (source_name) {
|
||||
err_exit("%s: Error in opening TOC with input %s.\n",
|
||||
program_name, source_name);
|
||||
@@ -956,7 +957,7 @@ main(int argc, const char *argv[])
|
||||
break;
|
||||
}
|
||||
|
||||
if (cdio==NULL) {
|
||||
if (p_cdio==NULL) {
|
||||
if (source_name) {
|
||||
err_exit("%s: Error in opening device driver for input %s.\n",
|
||||
program_name, source_name);
|
||||
@@ -968,7 +969,7 @@ main(int argc, const char *argv[])
|
||||
}
|
||||
|
||||
if (source_name==NULL) {
|
||||
source_name=strdup(cdio_get_arg(cdio, "source"));
|
||||
source_name=strdup(cdio_get_arg(p_cdio, "source"));
|
||||
if (NULL == source_name) {
|
||||
err_exit("%s: No input device given/found\n", program_name);
|
||||
}
|
||||
@@ -976,16 +977,22 @@ main(int argc, const char *argv[])
|
||||
|
||||
if (0 == opts.silent) {
|
||||
printf("CD location : %s\n", source_name);
|
||||
printf("CD driver name: %s\n", cdio_get_driver_name(cdio));
|
||||
printf(" access mode: %s\n\n", cdio_get_arg(cdio, "access-mode"));
|
||||
printf("CD driver name: %s\n", cdio_get_driver_name(p_cdio));
|
||||
printf(" access mode: %s\n\n", cdio_get_arg(p_cdio, "access-mode"));
|
||||
}
|
||||
|
||||
if (0 == opts.no_device) {
|
||||
cdio_drive_read_cap_t i_read_cap;
|
||||
cdio_drive_write_cap_t i_write_cap;
|
||||
cdio_drive_misc_cap_t i_misc_cap;
|
||||
|
||||
cdio_get_drive_cap(cdio, &i_read_cap, &i_write_cap, &i_misc_cap);
|
||||
scsi_mmc_hwinfo_t scsi_mmc_hwinfo;
|
||||
if (scsi_mmc_get_hwinfo(p_cdio, &scsi_mmc_hwinfo)) {
|
||||
printf("%-28s: %s\n%-28s: %s\n%-28s: %s\n",
|
||||
"Vendor" , scsi_mmc_hwinfo.vendor,
|
||||
"Model" , scsi_mmc_hwinfo.model,
|
||||
"Revision", scsi_mmc_hwinfo.revision);
|
||||
}
|
||||
cdio_get_drive_cap(p_cdio, &i_read_cap, &i_write_cap, &i_misc_cap);
|
||||
print_drive_capabilities(i_read_cap, i_write_cap, i_misc_cap);
|
||||
}
|
||||
|
||||
@@ -996,7 +1003,16 @@ main(int argc, const char *argv[])
|
||||
printf("list of devices found:\n");
|
||||
if (NULL != d) {
|
||||
for ( ; *d != NULL ; d++ ) {
|
||||
printf("%s\n", *d);
|
||||
CdIo *p_cdio = cdio_open(source_name, DRIVER_UNKNOWN);
|
||||
scsi_mmc_hwinfo_t scsi_mmc_hwinfo;
|
||||
printf("Drive %s\n", *d);
|
||||
if (scsi_mmc_get_hwinfo(p_cdio, &scsi_mmc_hwinfo)) {
|
||||
printf("%-8s: %s\n%-8s: %s\n%-8s: %s\n",
|
||||
"Vendor" , scsi_mmc_hwinfo.vendor,
|
||||
"Model" , scsi_mmc_hwinfo.model,
|
||||
"Revision", scsi_mmc_hwinfo.revision);
|
||||
}
|
||||
if (p_cdio) cdio_destroy(p_cdio);
|
||||
}
|
||||
}
|
||||
cdio_free_device_list(device_list);
|
||||
@@ -1008,11 +1024,11 @@ main(int argc, const char *argv[])
|
||||
|
||||
if ( 0 == opts.no_disc_mode ) {
|
||||
printf("Disc mode is listed as: %s\n",
|
||||
discmode2str[cdio_get_discmode(cdio)]);
|
||||
discmode2str[cdio_get_discmode(p_cdio)]);
|
||||
}
|
||||
|
||||
i_first_track = cdio_get_first_track_num(cdio);
|
||||
i_tracks = cdio_get_num_tracks(cdio);
|
||||
i_first_track = cdio_get_first_track_num(p_cdio);
|
||||
i_tracks = cdio_get_num_tracks(p_cdio);
|
||||
|
||||
if (!opts.no_tracks) {
|
||||
printf("CD-ROM Track List (%i - %i)\n" NORMAL,
|
||||
@@ -1026,7 +1042,7 @@ main(int argc, const char *argv[])
|
||||
msf_t msf;
|
||||
char *psz_msf;
|
||||
|
||||
if (!cdio_get_track_msf(cdio, i, &msf)) {
|
||||
if (!cdio_get_track_msf(p_cdio, i, &msf)) {
|
||||
err_exit("cdio_track_msf for track %i failed, I give up.\n", i);
|
||||
}
|
||||
|
||||
@@ -1039,11 +1055,11 @@ main(int argc, const char *argv[])
|
||||
} else if (!opts.no_tracks) {
|
||||
printf("%3d: %8s %06lu %-5s %s\n", (int) i, psz_msf,
|
||||
(long unsigned int) cdio_msf_to_lsn(&msf),
|
||||
track_format2str[cdio_get_track_format(cdio, i)],
|
||||
cdio_get_track_green(cdio, i)? "true" : "false");
|
||||
track_format2str[cdio_get_track_format(p_cdio, i)],
|
||||
cdio_get_track_green(p_cdio, i)? "true" : "false");
|
||||
}
|
||||
|
||||
if (TRACK_FORMAT_AUDIO == cdio_get_track_format(cdio, i)) {
|
||||
if (TRACK_FORMAT_AUDIO == cdio_get_track_format(p_cdio, i)) {
|
||||
num_audio++;
|
||||
if (-1 == first_audio) first_audio = i;
|
||||
} else {
|
||||
@@ -1056,7 +1072,7 @@ main(int argc, const char *argv[])
|
||||
|
||||
if (cdio_is_discmode_cdrom(discmode)) {
|
||||
/* get and print MCN */
|
||||
media_catalog_number = cdio_get_mcn(cdio);
|
||||
media_catalog_number = cdio_get_mcn(p_cdio);
|
||||
|
||||
printf("Media Catalog Number (MCN): "); fflush(stdout);
|
||||
if (NULL == media_catalog_number)
|
||||
@@ -1121,12 +1137,12 @@ main(int argc, const char *argv[])
|
||||
/* no data track, may be a "real" audio CD or hidden track CD */
|
||||
|
||||
msf_t msf;
|
||||
cdio_get_track_msf(cdio, 1, &msf);
|
||||
cdio_get_track_msf(p_cdio, 1, &msf);
|
||||
start_track_lsn = cdio_msf_to_lsn(&msf);
|
||||
|
||||
/* CD-I/Ready says start_track_lsn <= 30*75 then CDDA */
|
||||
if (start_track_lsn > 100 /* 100 is just a guess */) {
|
||||
fs = cdio_guess_cd_type(cdio, 0, 1, &cdio_iso_analysis);
|
||||
fs = cdio_guess_cd_type(p_cdio, 0, 1, &cdio_iso_analysis);
|
||||
if ((CDIO_FSTYPE(fs)) != CDIO_FS_UNKNOWN)
|
||||
fs |= CDIO_FS_ANAL_HIDDEN_TRACK;
|
||||
else {
|
||||
@@ -1138,16 +1154,16 @@ main(int argc, const char *argv[])
|
||||
}
|
||||
print_analysis(ms_offset, cdio_iso_analysis, fs, first_data, num_audio,
|
||||
i_tracks, i_first_track,
|
||||
cdio_get_track_format(cdio, 1), cdio);
|
||||
cdio_get_track_format(p_cdio, 1), p_cdio);
|
||||
} else {
|
||||
/* we have data track(s) */
|
||||
int j;
|
||||
|
||||
for (j = 2, i = first_data; i <= i_tracks; i++) {
|
||||
msf_t msf;
|
||||
track_format_t track_format = cdio_get_track_format(cdio, i);
|
||||
track_format_t track_format = cdio_get_track_format(p_cdio, i);
|
||||
|
||||
cdio_get_track_msf(cdio, i, &msf);
|
||||
cdio_get_track_msf(p_cdio, i, &msf);
|
||||
|
||||
switch ( track_format ) {
|
||||
case TRACK_FORMAT_AUDIO:
|
||||
@@ -1170,7 +1186,8 @@ main(int argc, const char *argv[])
|
||||
if (start_track_lsn < data_start + cdio_iso_analysis.isofs_size)
|
||||
continue;
|
||||
|
||||
fs = cdio_guess_cd_type(cdio, start_track_lsn, i, &cdio_iso_analysis);
|
||||
fs = cdio_guess_cd_type(p_cdio, start_track_lsn, i,
|
||||
&cdio_iso_analysis);
|
||||
|
||||
if (i > 1) {
|
||||
/* track is beyond last session -> new session found */
|
||||
@@ -1185,7 +1202,7 @@ main(int argc, const char *argv[])
|
||||
} else {
|
||||
print_analysis(ms_offset, cdio_iso_analysis, fs, first_data,
|
||||
num_audio, i_tracks, i_first_track,
|
||||
track_format, cdio);
|
||||
track_format, p_cdio);
|
||||
}
|
||||
|
||||
if ( !(CDIO_FSTYPE(fs) == CDIO_FS_ISO_9660 ||
|
||||
@@ -1199,7 +1216,7 @@ main(int argc, const char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
myexit(cdio, EXIT_SUCCESS);
|
||||
myexit(p_cdio, EXIT_SUCCESS);
|
||||
/* Not reached:*/
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: cd-read.c,v 1.20 2004/07/16 21:29:35 rocky Exp $
|
||||
$Id: cd-read.c,v 1.21 2004/07/31 07:43:26 rocky Exp $
|
||||
|
||||
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -459,7 +459,7 @@ main(int argc, const char *argv[])
|
||||
{
|
||||
uint8_t buffer[CDIO_CD_FRAMESIZE_RAW] = { 0, };
|
||||
unsigned int blocklen=CDIO_CD_FRAMESIZE_RAW;
|
||||
CdIo *cdio=NULL;
|
||||
CdIo *p_cdio=NULL;
|
||||
int output_fd=-1;
|
||||
FILE *output_stream;
|
||||
|
||||
@@ -474,45 +474,45 @@ main(int argc, const char *argv[])
|
||||
switch (opts.source_image) {
|
||||
case IMAGE_UNKNOWN:
|
||||
case IMAGE_AUTO:
|
||||
cdio = cdio_open (source_name, DRIVER_UNKNOWN);
|
||||
if (cdio==NULL) {
|
||||
p_cdio = cdio_open (source_name, DRIVER_UNKNOWN);
|
||||
if (p_cdio==NULL) {
|
||||
err_exit("Error in automatically selecting driver with input %s\n",
|
||||
source_name);
|
||||
}
|
||||
break;
|
||||
case IMAGE_DEVICE:
|
||||
cdio = cdio_open (source_name, DRIVER_DEVICE);
|
||||
if (cdio==NULL) {
|
||||
p_cdio = cdio_open (source_name, DRIVER_DEVICE);
|
||||
if (p_cdio==NULL) {
|
||||
err_exit("Error in automatically selecting device with input %s\n",
|
||||
source_name ? source_name : "(null)");
|
||||
|
||||
}
|
||||
break;
|
||||
case IMAGE_BIN:
|
||||
cdio = cdio_open (source_name, DRIVER_BINCUE);
|
||||
if (cdio==NULL) {
|
||||
p_cdio = cdio_open (source_name, DRIVER_BINCUE);
|
||||
if (p_cdio==NULL) {
|
||||
err_exit("Error in opening bin/cue file %s\n",
|
||||
source_name ? source_name : "(null)");
|
||||
}
|
||||
break;
|
||||
case IMAGE_CUE:
|
||||
cdio = cdio_open_cue(source_name);
|
||||
if (cdio==NULL) {
|
||||
p_cdio = cdio_open_cue(source_name);
|
||||
if (p_cdio==NULL) {
|
||||
err_exit("Error in opening cue/bin file %s with input\n",
|
||||
source_name ? source_name : "(null)");
|
||||
}
|
||||
break;
|
||||
case IMAGE_NRG:
|
||||
cdio = cdio_open (source_name, DRIVER_NRG);
|
||||
if (cdio==NULL) {
|
||||
p_cdio = cdio_open (source_name, DRIVER_NRG);
|
||||
if (p_cdio==NULL) {
|
||||
err_exit("Error in opening NRG file %s for input\n",
|
||||
source_name ? source_name : "(null)");
|
||||
}
|
||||
break;
|
||||
|
||||
case IMAGE_CDRDAO:
|
||||
cdio = cdio_open (source_name, DRIVER_CDRDAO);
|
||||
if (cdio==NULL) {
|
||||
p_cdio = cdio_open (source_name, DRIVER_CDRDAO);
|
||||
if (p_cdio==NULL) {
|
||||
err_exit("Error in opening TOC file %s for input\n",
|
||||
source_name ? source_name : "(null)");
|
||||
}
|
||||
@@ -520,7 +520,7 @@ main(int argc, const char *argv[])
|
||||
}
|
||||
|
||||
if (opts.access_mode!=NULL) {
|
||||
cdio_set_arg(cdio, "access-mode", opts.access_mode);
|
||||
cdio_set_arg(p_cdio, "access-mode", opts.access_mode);
|
||||
}
|
||||
|
||||
if (opts.output_file!=NULL) {
|
||||
@@ -546,14 +546,14 @@ main(int argc, const char *argv[])
|
||||
for ( ; opts.start_lsn <= opts.end_lsn; opts.start_lsn++ ) {
|
||||
switch (opts.read_mode) {
|
||||
case READ_AUDIO:
|
||||
if (cdio_read_audio_sector(cdio, &buffer, opts.start_lsn)) {
|
||||
if (cdio_read_audio_sector(p_cdio, &buffer, opts.start_lsn)) {
|
||||
fprintf (stderr, "error reading block %u\n",
|
||||
(unsigned int) opts.start_lsn);
|
||||
blocklen = 0;
|
||||
}
|
||||
break;
|
||||
case READ_M1F1:
|
||||
if (cdio_read_mode1_sector(cdio, &buffer, opts.start_lsn, false)) {
|
||||
if (cdio_read_mode1_sector(p_cdio, &buffer, opts.start_lsn, false)) {
|
||||
fprintf (stderr, "error reading block %u\n",
|
||||
(unsigned int) opts.start_lsn);
|
||||
blocklen = 0;
|
||||
@@ -561,7 +561,7 @@ main(int argc, const char *argv[])
|
||||
blocklen=CDIO_CD_FRAMESIZE;
|
||||
break;
|
||||
case READ_M1F2:
|
||||
if (cdio_read_mode1_sector(cdio, &buffer, opts.start_lsn, true)) {
|
||||
if (cdio_read_mode1_sector(p_cdio, &buffer, opts.start_lsn, true)) {
|
||||
fprintf (stderr, "error reading block %u\n",
|
||||
(unsigned int) opts.start_lsn);
|
||||
blocklen = 0;
|
||||
@@ -569,7 +569,7 @@ main(int argc, const char *argv[])
|
||||
blocklen=M2RAW_SECTOR_SIZE;
|
||||
break;
|
||||
case READ_M2F1:
|
||||
if (cdio_read_mode2_sector(cdio, &buffer, opts.start_lsn, false)) {
|
||||
if (cdio_read_mode2_sector(p_cdio, &buffer, opts.start_lsn, false)) {
|
||||
fprintf (stderr, "error reading block %u\n",
|
||||
(unsigned int) opts.start_lsn);
|
||||
blocklen=0;
|
||||
@@ -577,7 +577,7 @@ main(int argc, const char *argv[])
|
||||
blocklen=CDIO_CD_FRAMESIZE;
|
||||
break;
|
||||
case READ_M2F2:
|
||||
if (cdio_read_mode2_sector(cdio, &buffer, opts.start_lsn, true)) {
|
||||
if (cdio_read_mode2_sector(p_cdio, &buffer, opts.start_lsn, true)) {
|
||||
fprintf (stderr, "error reading block %u\n",
|
||||
(unsigned int) opts.start_lsn);
|
||||
blocklen=0;
|
||||
@@ -587,7 +587,7 @@ main(int argc, const char *argv[])
|
||||
#if AUTO_FINISHED
|
||||
case READ_AUTO:
|
||||
/* Find what track lsn is in. Then
|
||||
switch cdio_get_track_format(cdio, i)
|
||||
switch cdio_get_track_format(p_cdio, i)
|
||||
and also test using is_green
|
||||
|
||||
*/
|
||||
@@ -617,7 +617,7 @@ main(int argc, const char *argv[])
|
||||
|
||||
if (opts.output_file) close(output_fd);
|
||||
|
||||
myexit(cdio, EXIT_SUCCESS);
|
||||
myexit(p_cdio, EXIT_SUCCESS);
|
||||
/* Not reached:*/
|
||||
return(EXIT_SUCCESS);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: util.h,v 1.5 2004/07/17 22:16:48 rocky Exp $
|
||||
$Id: util.h,v 1.6 2004/07/31 07:43:26 rocky Exp $
|
||||
|
||||
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
|
||||
#define err_exit(fmt, args...) \
|
||||
fprintf(stderr, "%s: "fmt, program_name, ##args); \
|
||||
myexit(cdio, EXIT_FAILURE)
|
||||
myexit(p_cdio, EXIT_FAILURE)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user