Use new common scsi_mmc.h.

This commit is contained in:
rocky
2003-09-14 09:34:17 +00:00
parent ff6d081f64
commit 63af058973
6 changed files with 59 additions and 77 deletions

View File

@@ -1,4 +1,4 @@
# $Id: Makefile.am,v 1.12 2003/09/13 06:25:37 rocky Exp $ # $Id: Makefile.am,v 1.13 2003/09/14 09:34:17 rocky Exp $
# #
# Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> # Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
# #
@@ -44,6 +44,7 @@ libcdio_sources = \
ds.c \ ds.c \
ds.h \ ds.h \
logging.c \ logging.c \
scsi_mmc.h \
sector.c \ sector.c \
util.c util.c

View File

@@ -1,5 +1,5 @@
/* /*
$Id: _cdio_linux.c,v 1.16 2003/09/01 15:11:36 rocky Exp $ $Id: _cdio_linux.c,v 1.17 2003/09/14 09:34:17 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_linux.c,v 1.16 2003/09/01 15:11:36 rocky Exp $"; static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.17 2003/09/14 09:34:17 rocky Exp $";
#include <string.h> #include <string.h>
@@ -35,6 +35,7 @@ static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.16 2003/09/01 15:11:36 rock
#include <cdio/util.h> #include <cdio/util.h>
#include "cdio_assert.h" #include "cdio_assert.h"
#include "cdio_private.h" #include "cdio_private.h"
#include "scsi_mmc.h"
#ifdef HAVE_LINUX_CDROM #ifdef HAVE_LINUX_CDROM
@@ -245,14 +246,9 @@ _read_packet_audio_sector (int fd, void *buf, lba_t lba)
cgc.cmd[0] = GPCMD_READ_CD; cgc.cmd[0] = GPCMD_READ_CD;
cgc.cmd[1] = 0; /* Any type of sectors returned */ cgc.cmd[1] = 0; /* Any type of sectors returned */
cgc.cmd[2] = (lba >> 24) & 0xff; SCSI_MMC_SET_READ_LBA(cgc.cmd, lba);
cgc.cmd[3] = (lba >> 16) & 0xff; SCSI_MMC_SET_READ_LENGTH(cgc.cmd, nblocks);
cgc.cmd[4] = (lba >> 8) & 0xff;
cgc.cmd[5] = (lba >> 0) & 0xff;
cgc.cmd[6] = (nblocks >> 16) & 0xff;
cgc.cmd[7] = (nblocks >> 8) & 0xff;
cgc.cmd[8] = (nblocks >> 0) & 0xff;
cgc.cmd[9] = 0x78; /* All headers */ cgc.cmd[9] = 0x78; /* All headers */
cgc.buflen = CDIO_CD_FRAMESIZE_RAW * nblocks; cgc.buflen = CDIO_CD_FRAMESIZE_RAW * nblocks;
@@ -280,15 +276,9 @@ __read_packet_mode2_sectors (int fd, void *buf, lba_t lba,
memset (&cgc, 0, sizeof (struct cdrom_generic_command)); memset (&cgc, 0, sizeof (struct cdrom_generic_command));
cgc.cmd[0] = use_read_10 ? GPCMD_READ_10 : GPCMD_READ_CD; cgc.cmd[0] = use_read_10 ? GPCMD_READ_10 : GPCMD_READ_CD;
cgc.cmd[2] = (lba >> 24) & 0xff;
cgc.cmd[3] = (lba >> 16) & 0xff;
cgc.cmd[4] = (lba >> 8) & 0xff;
cgc.cmd[5] = (lba >> 0) & 0xff;
cgc.cmd[6] = (nblocks >> 16) & 0xff; SCSI_MMC_SET_READ_LBA(cgc.cmd, lba);
cgc.cmd[7] = (nblocks >> 8) & 0xff; SCSI_MMC_SET_READ_LENGTH(cgc.cmd, nblocks);
cgc.cmd[8] = (nblocks >> 0) & 0xff;
if (!use_read_10) if (!use_read_10)
{ {

View File

@@ -1,5 +1,5 @@
/* /*
$Id: _cdio_sunos.c,v 1.15 2003/09/01 15:11:36 rocky Exp $ $Id: _cdio_sunos.c,v 1.16 2003/09/14 09:34:17 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>
@@ -30,12 +30,13 @@
#include <cdio/util.h> #include <cdio/util.h>
#include "cdio_assert.h" #include "cdio_assert.h"
#include "cdio_private.h" #include "cdio_private.h"
#include "scsi_mmc.h"
#define DEFAULT_CDIO_DEVICE "/vol/dev/aliases/cdrom0" #define DEFAULT_CDIO_DEVICE "/vol/dev/aliases/cdrom0"
#ifdef HAVE_SOLARIS_CDROM #ifdef HAVE_SOLARIS_CDROM
static const char _rcsid[] = "$Id: _cdio_sunos.c,v 1.15 2003/09/01 15:11:36 rocky Exp $"; static const char _rcsid[] = "$Id: _cdio_sunos.c,v 1.16 2003/09/14 09:34:17 rocky Exp $";
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -186,13 +187,10 @@ _cdio_read_mode2_sector (void *user_data, void *data, lsn_t lsn,
memset(&sc, 0, sizeof(sc)); memset(&sc, 0, sizeof(sc));
cdb.scc_cmd = 0xBE; cdb.scc_cmd = 0xBE;
cdb.cdb_opaque[1] = (sector_type) << 2; cdb.cdb_opaque[1] = (sector_type) << 2;
cdb.cdb_opaque[2] = (lsn >> 24) & 0xff;
cdb.cdb_opaque[3] = (lsn >> 16) & 0xff; SCSI_MMC_SET_READ_LBA(cdb.cdb_opaque, lsn);
cdb.cdb_opaque[4] = (lsn >> 8) & 0xff; SCSI_MMC_SET_READ_LENGTH(cdb.cdb_opaque, blocks);
cdb.cdb_opaque[5] = lsn & 0xff;
cdb.cdb_opaque[6] = (blocks >> 16) & 0xff;
cdb.cdb_opaque[7] = (blocks >> 8) & 0xff;
cdb.cdb_opaque[8] = blocks & 0xff;
cdb.cdb_opaque[9] = (sync << 7) | cdb.cdb_opaque[9] = (sync << 7) |
(header_code << 5) | (header_code << 5) |
(user_data << 4) | (user_data << 4) |
@@ -296,13 +294,10 @@ _cdio_read_audio_sector (void *user_data, void *data, lsn_t lsn)
memset(&sc, 0, sizeof(sc)); memset(&sc, 0, sizeof(sc));
cdb.scc_cmd = 0xBE; cdb.scc_cmd = 0xBE;
cdb.cdb_opaque[1] = (sector_type) << 2; cdb.cdb_opaque[1] = (sector_type) << 2;
cdb.cdb_opaque[2] = (lsn >> 24) & 0xff;
cdb.cdb_opaque[3] = (lsn >> 16) & 0xff; SCSI_MMC_SET_READ_LBA(cdb.cdb_opaque, lsn);
cdb.cdb_opaque[4] = (lsn >> 8) & 0xff; SCSI_MMC_SET_READ_LENGTH(cdb.cdb_opaque, blocks);
cdb.cdb_opaque[5] = lsn & 0xff;
cdb.cdb_opaque[6] = (blocks >> 16) & 0xff;
cdb.cdb_opaque[7] = (blocks >> 8) & 0xff;
cdb.cdb_opaque[8] = blocks & 0xff;
cdb.cdb_opaque[9] = (sync << 7) | cdb.cdb_opaque[9] = (sync << 7) |
(header_code << 5) | (header_code << 5) |
(user_data << 4) | (user_data << 4) |

View File

@@ -1,5 +1,5 @@
/* /*
$Id: _cdio_win32.c,v 1.10 2003/08/11 09:19:18 rocky Exp $ $Id: _cdio_win32.c,v 1.11 2003/09/14 09:34:18 rocky Exp $
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
@@ -26,13 +26,14 @@
# include "config.h" # include "config.h"
#endif #endif
static const char _rcsid[] = "$Id: _cdio_win32.c,v 1.10 2003/08/11 09:19:18 rocky Exp $"; static const char _rcsid[] = "$Id: _cdio_win32.c,v 1.11 2003/09/14 09:34:18 rocky Exp $";
#include <cdio/cdio.h> #include <cdio/cdio.h>
#include <cdio/sector.h> #include <cdio/sector.h>
#include <cdio/util.h> #include <cdio/util.h>
#include "cdio_assert.h" #include "cdio_assert.h"
#include "cdio_private.h" #include "cdio_private.h"
#include "scsi_mmc.h"
/* LBA = msf.frame + 75 * ( msf.second - 2 + 60 * msf.minute ) */ /* LBA = msf.frame + 75 * ( msf.second - 2 + 60 * msf.minute ) */
#define MSF_TO_LBA2(min, sec, frame) ((int)frame + 75 * (sec -2 + 60 * min)) #define MSF_TO_LBA2(min, sec, frame) ((int)frame + 75 * (sec -2 + 60 * min))
@@ -534,15 +535,9 @@ _cdio_read_raw_sector (void *user_data, void *data, lsn_t lsn)
/* Start of LSN */ /* Start of LSN */
ssc.CDBByte[ 1 ] = (sector_type) << 2; ssc.CDBByte[ 1 ] = (sector_type) << 2;
ssc.CDBByte[ 2 ] = (lsn >> 24) & 0xff;
ssc.CDBByte[ 3 ] = (lsn >> 16) & 0xff; SCSI_MMC_SET_READ_LBA(ssc.CDBByte, lsn);
ssc.CDBByte[ 4 ] = (lsn >> 8) & 0xff; SCSI_MMC_SET_READ_LENGTH(ssc.CDBByte, blocks);
ssc.CDBByte[ 5 ] = (lsn ) & 0xff;
/* Transfer length */
ssc.CDBByte[ 6 ] = (blocks >> 16) & 0xff;
ssc.CDBByte[ 7 ] = (blocks >> 8) & 0xff;
ssc.CDBByte[ 8 ] = blocks & 0xff;
ssc.CDBByte[ 9 ] = (sync << 7) | ssc.CDBByte[ 9 ] = (sync << 7) |
(header_code << 5) | (header_code << 5) |
@@ -617,7 +612,7 @@ _cdio_read_mode2_sector (void *user_data, void *data, lsn_t lsn,
|| (_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->gen.ioctls_debugged % (30 * 75) == 0) || _obj->gen.ioctls_debugged % (30 * 75) == 0)
cdio_debug ("reading %d", lsn); cdio_debug ("reading %lu", (unsigned long int) lsn);
_obj->gen.ioctls_debugged++; _obj->gen.ioctls_debugged++;
@@ -802,7 +797,8 @@ _cdio_read_toc (_img_private_t *_obj)
((int)p_fulltoc[ i_index+2 ] << 8) + ((int)p_fulltoc[ i_index+2 ] << 8) +
(int)p_fulltoc[ i_index+3 ]; (int)p_fulltoc[ i_index+3 ];
cdio_debug( "p_sectors: %i %i", i, _obj->tocent[i].start_lsn ); cdio_debug( "p_sectors: %i %lu",
i, (unsigned long int) _obj->tocent[i].start_lsn );
} }
free( p_fulltoc ); free( p_fulltoc );
@@ -833,7 +829,8 @@ _cdio_read_toc (_img_private_t *_obj)
cdrom_toc.TrackData[i].Address[1], cdrom_toc.TrackData[i].Address[1],
cdrom_toc.TrackData[i].Address[2], cdrom_toc.TrackData[i].Address[2],
cdrom_toc.TrackData[i].Address[3] ); cdrom_toc.TrackData[i].Address[3] );
cdio_debug("p_sectors: %i, %i", i, (_obj->tocent[i].start_lsn)); cdio_debug("p_sectors: %i, %lu", i,
(unsigned long int) (_obj->tocent[i].start_lsn));
} }
} }
return true; return true;
@@ -936,9 +933,7 @@ _cdio_get_track_format(void *user_data, track_t track_num)
MCI_OPEN_PARMS op; MCI_OPEN_PARMS op;
MCI_STATUS_PARMS st; MCI_STATUS_PARMS st;
DWORD i_flags; DWORD i_flags;
char psz_drive[4];
int ret; int ret;
unsigned int len = strlen(_obj->gen.source_name);
memset( &op, 0, sizeof(MCI_OPEN_PARMS) ); memset( &op, 0, sizeof(MCI_OPEN_PARMS) );
op.lpstrDeviceType = (LPCSTR)MCI_DEVTYPE_CD_AUDIO; op.lpstrDeviceType = (LPCSTR)MCI_DEVTYPE_CD_AUDIO;

View File

@@ -1,5 +1,5 @@
/* /*
$Id: cd-info.c,v 1.33 2003/09/07 18:12:30 rocky Exp $ $Id: cd-info.c,v 1.34 2003/09/14 09:34:18 rocky Exp $
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
Copyright (C) 1996,1997,1998 Gerd Knorr <kraxel@bytesex.org> Copyright (C) 1996,1997,1998 Gerd Knorr <kraxel@bytesex.org>
@@ -639,20 +639,20 @@ print_iso9660_recurse (CdIo *cdio, const char pathname[], cdio_fs_anal_t fs,
_cdio_list_append (dirlist, strdup (_fullname)); _cdio_list_append (dirlist, strdup (_fullname));
if (fs & CDIO_FS_ANAL_XA) { if (fs & CDIO_FS_ANAL_XA) {
printf ( " %c %s %d %d [fn %.2d] [LSN %6d] ", printf ( " %c %s %d %d [fn %.2d] [LSN %6lu] ",
(statbuf.type == _STAT_DIR) ? 'd' : '-', (statbuf.type == _STAT_DIR) ? 'd' : '-',
iso9660_get_xa_attr_str (statbuf.xa.attributes), iso9660_get_xa_attr_str (statbuf.xa.attributes),
uint16_from_be (statbuf.xa.user_id), uint16_from_be (statbuf.xa.user_id),
uint16_from_be (statbuf.xa.group_id), uint16_from_be (statbuf.xa.group_id),
statbuf.xa.filenum, statbuf.xa.filenum,
statbuf.lsn); (long unsigned int) statbuf.lsn);
if (uint16_from_be(statbuf.xa.attributes) & XA_ATTR_MODE2FORM2) { if (uint16_from_be(statbuf.xa.attributes) & XA_ATTR_MODE2FORM2) {
printf ("%9d (%9d)", printf ("%9u (%9u)",
statbuf.secsize * M2F2_SECTOR_SIZE, (unsigned int) statbuf.secsize * M2F2_SECTOR_SIZE,
statbuf.size); (unsigned int) statbuf.size);
} else { } else {
printf ("%9d", statbuf.size); printf ("%9u", (unsigned int) statbuf.size);
} }
} }
strftime(date_str, DATESTR_SIZE, "%b %e %Y %H:%M ", &statbuf.tm); strftime(date_str, DATESTR_SIZE, "%b %e %Y %H:%M ", &statbuf.tm);
@@ -706,7 +706,7 @@ print_iso9660_fs (CdIo *cdio, cdio_fs_anal_t fs, track_format_t track_format)
const lsn_t extent = iso9660_get_root_lsn(&pvd); const lsn_t extent = iso9660_get_root_lsn(&pvd);
printf ("ISO9660 filesystem\n"); printf ("ISO9660 filesystem\n");
printf (" root dir in PVD set to lsn %d\n\n", extent); printf (" root dir in PVD set to lsn %lu\n\n", (long unsigned) extent);
print_iso9660_recurse (cdio, "/", fs, is_mode2); print_iso9660_recurse (cdio, "/", fs, is_mode2);
} }
@@ -820,7 +820,7 @@ main(int argc, const char *argv[])
CdIo *cdio=NULL; CdIo *cdio=NULL;
cdio_fs_anal_t fs=0; cdio_fs_anal_t fs=0;
int i; int i;
lsn_t start_track; /* first sector of track */ lsn_t start_track_lsn; /* lsn of first track */
lsn_t data_start =0; /* start of data area */ lsn_t data_start =0; /* start of data area */
int ms_offset = 0; int ms_offset = 0;
track_t num_tracks=0; track_t num_tracks=0;
@@ -947,16 +947,16 @@ main(int argc, const char *argv[])
if (i == CDIO_CDROM_LEADOUT_TRACK) { if (i == CDIO_CDROM_LEADOUT_TRACK) {
if (!opts.no_tracks) if (!opts.no_tracks)
printf("%3d: %2.2x:%2.2x:%2.2x %06d leadout\n", printf("%3d: %2.2x:%2.2x:%2.2x %06lu leadout\n",
(int) i, (int) i,
msf.m, msf.s, msf.f, msf.m, msf.s, msf.f,
cdio_msf_to_lsn(&msf)); (long unsigned int) cdio_msf_to_lsn(&msf));
break; break;
} else if (!opts.no_tracks) { } else if (!opts.no_tracks) {
printf("%3d: %2.2x:%2.2x:%2.2x %06d %s\n", printf("%3d: %2.2x:%2.2x:%2.2x %06lu %s\n",
(int) i, (int) i,
msf.m, msf.s, msf.f, msf.m, msf.s, msf.f,
cdio_msf_to_lsn(&msf), (long unsigned int) cdio_msf_to_lsn(&msf),
track_format2str[cdio_get_track_format(cdio, i)]); track_format2str[cdio_get_track_format(cdio, i)]);
} }
@@ -1049,18 +1049,18 @@ main(int argc, const char *argv[])
msf_t msf; msf_t msf;
cdio_get_track_msf(cdio, 1, &msf); cdio_get_track_msf(cdio, 1, &msf);
start_track = cdio_msf_to_lsn(&msf); start_track_lsn = cdio_msf_to_lsn(&msf);
/* CD-I/Ready says start_track <= 30*75 then CDDA */ /* CD-I/Ready says start_track_lsn <= 30*75 then CDDA */
if (start_track > 100 /* 100 is just a guess */) { if (start_track_lsn > 100 /* 100 is just a guess */) {
fs = cdio_guess_cd_type(cdio, 0, 1, &cdio_analysis); fs = cdio_guess_cd_type(cdio, 0, 1, &cdio_analysis);
if ((CDIO_FSTYPE(fs)) != CDIO_FS_UNKNOWN) if ((CDIO_FSTYPE(fs)) != CDIO_FS_UNKNOWN)
fs |= CDIO_FS_ANAL_HIDDEN_TRACK; fs |= CDIO_FS_ANAL_HIDDEN_TRACK;
else { else {
fs &= ~CDIO_FS_MASK; /* del filesystem info */ fs &= ~CDIO_FS_MASK; /* del filesystem info */
printf("Oops: %i unused sectors at start, " printf("Oops: %lu unused sectors at start, "
"but hidden track check failed.\n", "but hidden track check failed.\n",
start_track); (long unsigned int) start_track_lsn);
} }
} }
print_analysis(ms_offset, cdio_analysis, fs, first_data, num_audio, print_analysis(ms_offset, cdio_analysis, fs, first_data, num_audio,
@@ -1087,24 +1087,25 @@ main(int argc, const char *argv[])
; ;
} }
start_track = (i == 1) ? 0 : cdio_msf_to_lsn(&msf); start_track_lsn = (i == 1) ? 0 : cdio_msf_to_lsn(&msf);
/* save the start of the data area */ /* save the start of the data area */
if (i == first_data) if (i == first_data)
data_start = start_track; data_start = start_track_lsn;
/* skip tracks which belong to the current walked session */ /* skip tracks which belong to the current walked session */
if (start_track < data_start + cdio_analysis.isofs_size) if (start_track_lsn < data_start + cdio_analysis.isofs_size)
continue; continue;
fs = cdio_guess_cd_type(cdio, start_track, i, &cdio_analysis); fs = cdio_guess_cd_type(cdio, start_track_lsn, i, &cdio_analysis);
if (i > 1) { if (i > 1) {
/* track is beyond last session -> new session found */ /* track is beyond last session -> new session found */
ms_offset = start_track; ms_offset = start_track_lsn;
printf("session #%d starts at track %2i, LSN: %6i," printf("session #%d starts at track %2i, LSN: %lu,"
" ISO 9660 blocks: %6i\n", " ISO 9660 blocks: %6i\n",
j++, i, start_track, cdio_analysis.isofs_size); j++, i, (unsigned long int) start_track_lsn,
cdio_analysis.isofs_size);
printf("ISO 9660: %i blocks, label `%.32s'\n", printf("ISO 9660: %i blocks, label `%.32s'\n",
cdio_analysis.isofs_size, cdio_analysis.iso_label); cdio_analysis.isofs_size, cdio_analysis.iso_label);
fs |= CDIO_FS_ANAL_MULTISESSION; fs |= CDIO_FS_ANAL_MULTISESSION;

View File

@@ -1,4 +1,4 @@
# $Id: Makefile.am,v 1.8 2003/09/14 07:49:12 rocky Exp $ # $Id: Makefile.am,v 1.9 2003/09/14 09:34:18 rocky Exp $
# #
# Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> # Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
# #
@@ -45,6 +45,6 @@ EXTRA_DIST = $(check_SCRIPTS) $(check_DATA) \
check_common_fn check_cue.sh.in check_nrg.sh.in check_common_fn check_cue.sh.in check_nrg.sh.in
TESTS = $(check_PROGRAMS) $(check_SCRIPTS) TESTS = $(check_PROGRAMS) $(check_SCRIPTS)
XFAIL_TESTS = testassert${EXEEXT} XFAIL_TESTS = testassert
MOSTLYCLEANFILES = core.* *.dump MOSTLYCLEANFILES = core.* *.dump