Remove more of the no longer needed distinction (that we sometimes got
wrong) of Mode 1 vs Mode 2 data reading.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
$Id: cd_types.c,v 1.2 2005/01/02 22:43:41 rocky Exp $
|
||||
$Id: cd_types.c,v 1.3 2005/02/17 11:54:28 rocky Exp $
|
||||
|
||||
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -124,33 +124,24 @@ static signature_t sigs[] =
|
||||
Read a particular block into the global array to be used for further
|
||||
analysis later.
|
||||
*/
|
||||
static int
|
||||
_cdio_read_block(const CdIo *cdio, int superblock, uint32_t offset,
|
||||
static driver_return_code_t
|
||||
_cdio_read_block(const CdIo_t *p_cdio, int superblock, uint32_t offset,
|
||||
uint8_t bufnum, track_t i_track)
|
||||
{
|
||||
unsigned int track_sec_count = cdio_get_track_sec_count(cdio, i_track);
|
||||
unsigned int track_sec_count = cdio_get_track_sec_count(p_cdio, i_track);
|
||||
memset(buffer[bufnum], 0, CDIO_CD_FRAMESIZE);
|
||||
|
||||
if ( track_sec_count < superblock) {
|
||||
cdio_debug("reading block %u skipped track %d has only %u sectors\n",
|
||||
superblock, i_track, track_sec_count);
|
||||
return -1;
|
||||
return DRIVER_OP_ERROR;
|
||||
}
|
||||
|
||||
cdio_debug("about to read sector %lu\n",
|
||||
(long unsigned int) offset+superblock);
|
||||
|
||||
if (cdio_get_track_green(cdio, i_track)) {
|
||||
if (0 > cdio_read_mode2_sector(cdio, buffer[bufnum],
|
||||
offset+superblock, false))
|
||||
return -1;
|
||||
} else {
|
||||
if (0 > cdio_read_mode1_sector(cdio, buffer[bufnum],
|
||||
offset+superblock, false))
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return cdio_read_data_sectors (p_cdio, buffer[bufnum], offset+superblock,
|
||||
ISO_BLOCKSIZE, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -221,36 +212,36 @@ _cdio_get_joliet_level( void )
|
||||
is returned in cdio_analysis and the return value.
|
||||
*/
|
||||
cdio_fs_anal_t
|
||||
cdio_guess_cd_type(const CdIo_t *cdio, int start_session, track_t i_track,
|
||||
cdio_guess_cd_type(const CdIo_t *p_cdio, int start_session, track_t i_track,
|
||||
/*out*/ cdio_iso_analysis_t *iso_analysis)
|
||||
{
|
||||
int ret = CDIO_FS_UNKNOWN;
|
||||
bool sector0_read_ok;
|
||||
|
||||
if (TRACK_FORMAT_AUDIO == cdio_get_track_format(cdio, i_track))
|
||||
if (TRACK_FORMAT_AUDIO == cdio_get_track_format(p_cdio, i_track))
|
||||
return CDIO_FS_AUDIO;
|
||||
|
||||
if ( _cdio_read_block(cdio, ISO_PVD_SECTOR, start_session,
|
||||
0, i_track) < 0 )
|
||||
if ( DRIVER_OP_SUCCESS !=
|
||||
_cdio_read_block(p_cdio, ISO_PVD_SECTOR, start_session, 0, i_track) )
|
||||
return CDIO_FS_UNKNOWN;
|
||||
|
||||
if ( _cdio_is_it(INDEX_XISO) )
|
||||
return CDIO_FS_ANAL_XISO;
|
||||
|
||||
if (_cdio_read_block(cdio, ISO_SUPERBLOCK_SECTOR, start_session, 0,
|
||||
i_track) < 0)
|
||||
if ( DRIVER_OP_SUCCESS != _cdio_read_block(p_cdio, ISO_SUPERBLOCK_SECTOR,
|
||||
start_session, 0, i_track) )
|
||||
return ret;
|
||||
|
||||
if ( _cdio_is_it(INDEX_UDF) ) {
|
||||
/* Detect UDF version
|
||||
Test if we have a valid version of UDF the xbox can read natively */
|
||||
if (_cdio_read_block(cdio, 35, start_session, 5, i_track) < 0)
|
||||
if (_cdio_read_block(p_cdio, 35, start_session, 5, i_track) < 0)
|
||||
return CDIO_FS_UNKNOWN;
|
||||
|
||||
iso_analysis->UDFVerMinor=(unsigned int)buffer[5][240];
|
||||
iso_analysis->UDFVerMajor=(unsigned int)buffer[5][241];
|
||||
/* Read disc label */
|
||||
if (_cdio_read_block(cdio, 32, start_session, 5, i_track) < 0)
|
||||
if (_cdio_read_block(p_cdio, 32, start_session, 5, i_track) < 0)
|
||||
return CDIO_FS_UDF;
|
||||
|
||||
strncpy(iso_analysis->iso_label, buffer[5]+25, 33);
|
||||
@@ -266,7 +257,7 @@ cdio_guess_cd_type(const CdIo_t *cdio, int start_session, track_t i_track,
|
||||
/* read sector 0 ONLY, when NO greenbook CD-I !!!! */
|
||||
|
||||
sector0_read_ok =
|
||||
_cdio_read_block(cdio, 0, start_session, 1, i_track) == 0;
|
||||
_cdio_read_block(p_cdio, 0, start_session, 1, i_track) == 0;
|
||||
|
||||
if (_cdio_is_it(INDEX_HS))
|
||||
ret |= CDIO_FS_HIGH_SIERRA;
|
||||
@@ -281,7 +272,7 @@ cdio_guess_cd_type(const CdIo_t *cdio, int start_session, track_t i_track,
|
||||
strncpy(iso_analysis->iso_label, buffer[0]+40,33);
|
||||
iso_analysis->iso_label[32] = '\0';
|
||||
|
||||
if ( _cdio_read_block(cdio, UDF_ANCHOR_SECTOR, start_session, 5,
|
||||
if ( _cdio_read_block(p_cdio, UDF_ANCHOR_SECTOR, start_session, 5,
|
||||
i_track) < 0)
|
||||
return ret;
|
||||
|
||||
@@ -290,7 +281,7 @@ cdio_guess_cd_type(const CdIo_t *cdio, int start_session, track_t i_track,
|
||||
if ( _cdio_is_UDF() ) {
|
||||
/* Detect UDF version.
|
||||
Test if we have a valid version of UDF the xbox can read natively */
|
||||
if ( _cdio_read_block(cdio, 35, start_session, 5, i_track) < 0)
|
||||
if ( _cdio_read_block(p_cdio, 35, start_session, 5, i_track) < 0)
|
||||
return ret;
|
||||
|
||||
iso_analysis->UDFVerMinor=(unsigned int)buffer[5][240];
|
||||
@@ -298,7 +289,7 @@ cdio_guess_cd_type(const CdIo_t *cdio, int start_session, track_t i_track,
|
||||
#if 0
|
||||
/* We are using ISO/UDF cd's as iso,
|
||||
no need to get UDF disc label */
|
||||
if (_cdio_read_block(cdio, 32, start_session, 5, i_track) < 0)
|
||||
if (_cdio_read_block(p_cdio, 32, start_session, 5, i_track) < 0)
|
||||
return ret;
|
||||
stnrcpy(iso_analysis->iso_label, buffer[5]+25, 33);
|
||||
iso_analysis->iso_label[32] = '\0';
|
||||
@@ -311,7 +302,7 @@ cdio_guess_cd_type(const CdIo_t *cdio, int start_session, track_t i_track,
|
||||
ret |= CDIO_FS_ANAL_ROCKRIDGE;
|
||||
#endif
|
||||
|
||||
if (_cdio_read_block(cdio, BOOT_SECTOR, start_session, 3, i_track) < 0)
|
||||
if (_cdio_read_block(p_cdio, BOOT_SECTOR, start_session, 3, i_track) < 0)
|
||||
return ret;
|
||||
|
||||
if (_cdio_is_joliet()) {
|
||||
@@ -324,7 +315,7 @@ cdio_guess_cd_type(const CdIo_t *cdio, int start_session, track_t i_track,
|
||||
if ( _cdio_is_it(INDEX_XA) && _cdio_is_it(INDEX_ISOFS)
|
||||
&& !(sector0_read_ok && _cdio_is_it(INDEX_PHOTO_CD)) ) {
|
||||
|
||||
if ( _cdio_read_block(cdio, VCD_INFO_SECTOR, start_session, 4,
|
||||
if ( _cdio_read_block(p_cdio, VCD_INFO_SECTOR, start_session, 4,
|
||||
i_track) < 0 )
|
||||
return ret;
|
||||
|
||||
@@ -339,7 +330,7 @@ cdio_guess_cd_type(const CdIo_t *cdio, int start_session, track_t i_track,
|
||||
else if (sector0_read_ok && _cdio_is_it(INDEX_EXT2)) ret |= CDIO_FS_EXT2;
|
||||
else if (_cdio_is_3do()) ret |= CDIO_FS_3DO;
|
||||
else {
|
||||
if ( _cdio_read_block(cdio, UFS_SUPERBLOCK_SECTOR, start_session, 2,
|
||||
if ( _cdio_read_block(p_cdio, UFS_SUPERBLOCK_SECTOR, start_session, 2,
|
||||
i_track) < 0 )
|
||||
return ret;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: iso9660_fs.c,v 1.16 2005/02/17 07:03:37 rocky Exp $
|
||||
$Id: iso9660_fs.c,v 1.17 2005/02/17 11:54:28 rocky Exp $
|
||||
|
||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||
@@ -52,14 +52,12 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static const char _rcsid[] = "$Id: iso9660_fs.c,v 1.16 2005/02/17 07:03:37 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: iso9660_fs.c,v 1.17 2005/02/17 11:54:28 rocky Exp $";
|
||||
|
||||
/* Implementation of iso9660_t type */
|
||||
struct _iso9660_s {
|
||||
CdioDataSource_t *stream; /* Stream pointer */
|
||||
bool_3way_t b_xa; /* true if has XA attributes. If true
|
||||
b_mode2 should be set true as well.
|
||||
*/
|
||||
bool_3way_t b_xa; /* true if has XA attributes. */
|
||||
bool_3way_t b_mode2; /* true if has mode 2, false for mode 1. */
|
||||
uint8_t i_joliet_level; /* 0 = no Joliet extensions.
|
||||
1-3: Joliet level. */
|
||||
@@ -792,8 +790,8 @@ iso9660_iso_seek_read (const iso9660_t *p_iso, void *ptr, lsn_t start,
|
||||
|
||||
|
||||
static iso9660_stat_t *
|
||||
_iso9660_dir_to_statbuf (iso9660_dir_t *p_iso9660_dir, bool b_mode2,
|
||||
bool_3way_t b_xa, uint8_t i_joliet_level)
|
||||
_iso9660_dir_to_statbuf (iso9660_dir_t *p_iso9660_dir, bool_3way_t b_xa,
|
||||
uint8_t i_joliet_level)
|
||||
{
|
||||
uint8_t dir_len= iso9660_get_dir_len(p_iso9660_dir);
|
||||
unsigned int filename_len;
|
||||
@@ -850,7 +848,7 @@ _iso9660_dir_to_statbuf (iso9660_dir_t *p_iso9660_dir, bool b_mode2,
|
||||
}
|
||||
|
||||
|
||||
if (b_mode2) {
|
||||
{
|
||||
int su_length = iso9660_get_dir_len(p_iso9660_dir)
|
||||
- sizeof (iso9660_dir_t);
|
||||
su_length -= filename_len;
|
||||
@@ -930,7 +928,6 @@ _fs_stat_root (CdIo_t *p_cdio)
|
||||
{
|
||||
iso_extension_mask_t iso_extension_mask = ISO_EXTENSION_ALL;
|
||||
generic_img_private_t *p_env = (generic_img_private_t *) p_cdio->env;
|
||||
bool b_mode2;
|
||||
iso9660_dir_t *p_iso9660_dir;
|
||||
iso9660_stat_t *p_stat;
|
||||
bool_3way_t b_xa;
|
||||
@@ -944,8 +941,6 @@ _fs_stat_root (CdIo_t *p_cdio)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
b_mode2 = cdio_get_track_green(p_cdio, 1);
|
||||
|
||||
switch(cdio_get_discmode(p_cdio)) {
|
||||
case CDIO_DISC_MODE_CD_XA:
|
||||
b_xa = yep;
|
||||
@@ -965,7 +960,7 @@ _fs_stat_root (CdIo_t *p_cdio)
|
||||
p_iso9660_dir = &(p_env->pvd.root_directory_record) ;
|
||||
#endif
|
||||
|
||||
p_stat = _iso9660_dir_to_statbuf (p_iso9660_dir, b_mode2, b_xa,
|
||||
p_stat = _iso9660_dir_to_statbuf (p_iso9660_dir, b_xa,
|
||||
p_env->i_joliet_level);
|
||||
return p_stat;
|
||||
}
|
||||
@@ -986,15 +981,14 @@ _fs_stat_iso_root (iso9660_t *p_iso)
|
||||
p_iso9660_dir = &(p_iso->pvd.root_directory_record) ;
|
||||
#endif
|
||||
|
||||
p_stat = _iso9660_dir_to_statbuf (p_iso9660_dir, p_iso->b_mode2, p_iso->b_xa,
|
||||
p_stat = _iso9660_dir_to_statbuf (p_iso9660_dir, p_iso->b_xa,
|
||||
p_iso->i_joliet_level);
|
||||
return p_stat;
|
||||
}
|
||||
|
||||
static iso9660_stat_t *
|
||||
_fs_stat_traverse (const CdIo_t *p_cdio, const iso9660_stat_t *_root,
|
||||
char **splitpath, bool b_mode2, bool b_xa,
|
||||
bool translate)
|
||||
char **splitpath, bool b_xa, bool translate)
|
||||
{
|
||||
unsigned offset = 0;
|
||||
uint8_t *_dirbuf = NULL;
|
||||
@@ -1023,15 +1017,9 @@ _fs_stat_traverse (const CdIo_t *p_cdio, const iso9660_stat_t *_root,
|
||||
|
||||
_dirbuf = calloc(1, _root->secsize * ISO_BLOCKSIZE);
|
||||
|
||||
if (b_mode2) {
|
||||
if (cdio_read_mode2_sectors (p_cdio, _dirbuf, _root->lsn, false,
|
||||
_root->secsize))
|
||||
if (cdio_read_data_sectors (p_cdio, _dirbuf, _root->lsn, false,
|
||||
_root->secsize))
|
||||
return NULL;
|
||||
} else {
|
||||
if (cdio_read_mode1_sectors (p_cdio, _dirbuf, _root->lsn, false,
|
||||
_root->secsize))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (offset < (_root->secsize * ISO_BLOCKSIZE))
|
||||
{
|
||||
@@ -1045,7 +1033,7 @@ _fs_stat_traverse (const CdIo_t *p_cdio, const iso9660_stat_t *_root,
|
||||
continue;
|
||||
}
|
||||
|
||||
p_stat = _iso9660_dir_to_statbuf (p_iso9660_dir, b_mode2, dunno,
|
||||
p_stat = _iso9660_dir_to_statbuf (p_iso9660_dir, dunno,
|
||||
p_env->i_joliet_level);
|
||||
|
||||
if (translate) {
|
||||
@@ -1067,8 +1055,7 @@ _fs_stat_traverse (const CdIo_t *p_cdio, const iso9660_stat_t *_root,
|
||||
|
||||
if (!cmp) {
|
||||
iso9660_stat_t *ret_stat
|
||||
= _fs_stat_traverse (p_cdio, p_stat, &splitpath[1], b_mode2, b_xa,
|
||||
translate);
|
||||
= _fs_stat_traverse (p_cdio, p_stat, &splitpath[1], b_xa, translate);
|
||||
free(p_stat);
|
||||
free (_dirbuf);
|
||||
return ret_stat;
|
||||
@@ -1132,8 +1119,8 @@ _fs_iso_stat_traverse (iso9660_t *p_iso, const iso9660_stat_t *_root,
|
||||
continue;
|
||||
}
|
||||
|
||||
p_stat = _iso9660_dir_to_statbuf (p_iso9660_dir, p_iso->b_mode2,
|
||||
p_iso->b_xa, p_iso->i_joliet_level);
|
||||
p_stat = _iso9660_dir_to_statbuf (p_iso9660_dir, p_iso->b_xa,
|
||||
p_iso->i_joliet_level);
|
||||
|
||||
if (translate) {
|
||||
char *trans_fname = malloc(strlen(p_stat->filename)+1);
|
||||
@@ -1181,14 +1168,11 @@ iso9660_fs_stat (CdIo_t *p_cdio, const char psz_path[])
|
||||
iso9660_stat_t *p_root;
|
||||
char **p_psz_splitpath;
|
||||
iso9660_stat_t *p_stat;
|
||||
/* A bit of a hack, we'll assume track 1 contains ISO_PVD_SECTOR.*/
|
||||
bool b_mode2;
|
||||
bool_3way_t b_xa;
|
||||
|
||||
if (!p_cdio) return NULL;
|
||||
if (!psz_path) return NULL;
|
||||
|
||||
b_mode2 = cdio_get_track_green(p_cdio, 1);
|
||||
p_root = _fs_stat_root (p_cdio);
|
||||
|
||||
if (!p_root) return NULL;
|
||||
@@ -1205,8 +1189,7 @@ iso9660_fs_stat (CdIo_t *p_cdio, const char psz_path[])
|
||||
}
|
||||
|
||||
p_psz_splitpath = _cdio_strsplit (psz_path, '/');
|
||||
p_stat = _fs_stat_traverse (p_cdio, p_root, p_psz_splitpath, b_mode2,
|
||||
b_xa, false);
|
||||
p_stat = _fs_stat_traverse (p_cdio, p_root, p_psz_splitpath, b_xa, false);
|
||||
free(p_root);
|
||||
_cdio_strfreev (p_psz_splitpath);
|
||||
|
||||
@@ -1246,8 +1229,7 @@ iso9660_fs_stat_translate (CdIo_t *p_cdio, const char psz_path[],
|
||||
}
|
||||
|
||||
p_psz_splitpath = _cdio_strsplit (psz_path, '/');
|
||||
p_stat = _fs_stat_traverse (p_cdio, p_root, p_psz_splitpath, b_mode2,
|
||||
b_xa, true);
|
||||
p_stat = _fs_stat_traverse (p_cdio, p_root, p_psz_splitpath, b_xa, true);
|
||||
free(p_root);
|
||||
_cdio_strfreev (p_psz_splitpath);
|
||||
|
||||
@@ -1355,7 +1337,7 @@ iso9660_fs_readdir (CdIo_t *p_cdio, const char psz_path[], bool b_mode2)
|
||||
continue;
|
||||
}
|
||||
|
||||
p_iso9660_stat = _iso9660_dir_to_statbuf(p_iso9660_dir, b_mode2, dunno,
|
||||
p_iso9660_stat = _iso9660_dir_to_statbuf(p_iso9660_dir, dunno,
|
||||
p_env->i_joliet_level);
|
||||
_cdio_list_append (retval, p_iso9660_stat);
|
||||
|
||||
@@ -1419,9 +1401,7 @@ iso9660_ifs_readdir (iso9660_t *p_iso, const char psz_path[])
|
||||
continue;
|
||||
}
|
||||
|
||||
p_iso9660_stat = _iso9660_dir_to_statbuf(p_iso9660_dir,
|
||||
p_iso->b_mode2,
|
||||
p_iso->b_xa,
|
||||
p_iso9660_stat = _iso9660_dir_to_statbuf(p_iso9660_dir, p_iso->b_xa,
|
||||
p_iso->i_joliet_level);
|
||||
|
||||
if (p_iso9660_stat)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: cd-info.c,v 1.112 2005/02/05 14:42:28 rocky Exp $
|
||||
$Id: cd-info.c,v 1.113 2005/02/17 11:54:28 rocky Exp $
|
||||
|
||||
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||
Copyright (C) 1996, 1997, 1998 Gerd Knorr <kraxel@bytesex.org>
|
||||
@@ -536,8 +536,7 @@ print_vcd_info(driver_id_t driver) {
|
||||
|
||||
static void
|
||||
print_iso9660_recurse (CdIo_t *p_cdio, const char pathname[],
|
||||
cdio_fs_anal_t fs,
|
||||
bool b_mode2)
|
||||
cdio_fs_anal_t fs)
|
||||
{
|
||||
CdioList_t *entlist;
|
||||
CdioList_t *dirlist = _cdio_list_new ();
|
||||
@@ -548,7 +547,7 @@ print_iso9660_recurse (CdIo_t *p_cdio, const char pathname[],
|
||||
? 0
|
||||
: cdio_get_joliet_level(p_cdio);
|
||||
|
||||
entlist = iso9660_fs_readdir (p_cdio, pathname, b_mode2);
|
||||
entlist = iso9660_fs_readdir (p_cdio, pathname, false);
|
||||
|
||||
printf ("%s:\n", pathname);
|
||||
|
||||
@@ -611,7 +610,7 @@ print_iso9660_recurse (CdIo_t *p_cdio, const char pathname[],
|
||||
{
|
||||
char *_fullname = _cdio_list_node_data (entnode);
|
||||
|
||||
print_iso9660_recurse (p_cdio, _fullname, fs, b_mode2);
|
||||
print_iso9660_recurse (p_cdio, _fullname, fs);
|
||||
}
|
||||
|
||||
_cdio_list_free (dirlist, true);
|
||||
@@ -621,7 +620,6 @@ static void
|
||||
print_iso9660_fs (CdIo_t *p_cdio, cdio_fs_anal_t fs,
|
||||
track_format_t track_format)
|
||||
{
|
||||
bool b_mode2 = false;
|
||||
iso_extension_mask_t iso_extension_mask = ISO_EXTENSION_ALL;
|
||||
|
||||
if (fs & CDIO_FS_ANAL_XA) track_format = TRACK_FORMAT_XA;
|
||||
@@ -633,13 +631,8 @@ print_iso9660_fs (CdIo_t *p_cdio, cdio_fs_anal_t fs,
|
||||
if ( !iso9660_fs_read_superblock(p_cdio, iso_extension_mask) )
|
||||
return;
|
||||
|
||||
b_mode2 = ( TRACK_FORMAT_CDI == track_format
|
||||
|| TRACK_FORMAT_XA == track_format );
|
||||
|
||||
{
|
||||
printf ("ISO9660 filesystem\n");
|
||||
print_iso9660_recurse (p_cdio, "/", fs, b_mode2);
|
||||
}
|
||||
printf ("ISO9660 filesystem\n");
|
||||
print_iso9660_recurse (p_cdio, "/", fs);
|
||||
}
|
||||
|
||||
#define print_vd_info(title, fn) \
|
||||
|
||||
Reference in New Issue
Block a user