diff --git a/lib/iso9660_fs.c b/lib/iso9660_fs.c index ad428a9b..f521185c 100644 --- a/lib/iso9660_fs.c +++ b/lib/iso9660_fs.c @@ -1,5 +1,5 @@ /* - $Id: iso9660_fs.c,v 1.4 2003/08/31 14:26:06 rocky Exp $ + $Id: iso9660_fs.c,v 1.5 2003/08/31 15:52:56 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel Copyright (C) 2003 Rocky Bernstein @@ -36,42 +36,42 @@ #include "bytesex.h" #include "ds.h" -static const char _rcsid[] = "$Id: iso9660_fs.c,v 1.4 2003/08/31 14:26:06 rocky Exp $"; +static const char _rcsid[] = "$Id: iso9660_fs.c,v 1.5 2003/08/31 15:52:56 rocky Exp $"; static void -_idr2statbuf (const iso9660_dir_t *idr, iso9660_stat_t *buf) +_idr2statbuf (const iso9660_dir_t *idr, iso9660_stat_t *buf, bool is_mode2) { iso9660_xa_t *xa_data = NULL; - int su_length = 0; + uint8_t dir_len= iso9660_get_dir_len(idr); memset ((void *) buf, 0, sizeof (iso9660_stat_t)); - if (!iso9660_get_dir_len(idr)) - return; + if (!dir_len) return; - cdio_assert (iso9660_get_dir_len(idr) >= sizeof (iso9660_dir_t)); - - buf->type = (idr->flags & ISO_DIRECTORY) ? _STAT_DIR : _STAT_FILE; - buf->lsn = from_733 (idr->extent); - buf->size = from_733 (idr->size); + buf->type = (idr->flags & ISO_DIRECTORY) ? _STAT_DIR : _STAT_FILE; + buf->lsn = from_733 (idr->extent); + buf->size = from_733 (idr->size); buf->secsize = _cdio_len2blocks (buf->size, ISO_BLOCKSIZE); - su_length = iso9660_get_dir_len(idr) - sizeof (iso9660_dir_t); - su_length -= idr->name_len; + cdio_assert (dir_len >= sizeof (iso9660_dir_t)); - if (su_length % 2) - su_length--; - - if (su_length < 0 || su_length < sizeof (iso9660_xa_t)) - return; - - xa_data = (void *) (((char *) idr) + (iso9660_get_dir_len(idr) - su_length)); - - if (xa_data->signature[0] != 'X' - || xa_data->signature[1] != 'A') + if (is_mode2) { + int su_length = iso9660_get_dir_len(idr) - sizeof (iso9660_dir_t); + su_length -= idr->name_len; + + if (su_length % 2) + su_length--; + + if (su_length < 0 || su_length < sizeof (iso9660_xa_t)) + return; + + xa_data = (void *) (((char *) idr) + (iso9660_get_dir_len(idr) - su_length)); + + if (xa_data->signature[0] != 'X' + || xa_data->signature[1] != 'A') { cdio_warn ("XA signature not found in ISO9660's system use area;" - " ignoring XA attributes for this file entry."); + " ignoring XA attributes for this file entry."); cdio_debug ("%d %d %d, '%c%c' (%d, %d)", iso9660_get_dir_len(idr), idr->name_len, su_length, @@ -79,8 +79,9 @@ _idr2statbuf (const iso9660_dir_t *idr, iso9660_stat_t *buf) xa_data->signature[0], xa_data->signature[1]); return; } - - buf->xa = *xa_data; + buf->xa = *xa_data; + } + } static char * @@ -121,12 +122,12 @@ _fs_stat_root (CdIo *obj, iso9660_stat_t *buf, bool is_mode2) cdio_assert_not_reached (); } - _idr2statbuf (idr, buf); + _idr2statbuf (idr, buf, is_mode2); } static int _fs_stat_traverse (CdIo *obj, const iso9660_stat_t *_root, char **splitpath, - iso9660_stat_t *buf) + iso9660_stat_t *buf, bool is_mode2) { unsigned offset = 0; uint8_t *_dirbuf = NULL; @@ -150,10 +151,16 @@ _fs_stat_traverse (CdIo *obj, const iso9660_stat_t *_root, char **splitpath, _dirbuf = _cdio_malloc (_root->secsize * ISO_BLOCKSIZE); - if (cdio_read_mode2_sectors (obj, _dirbuf, _root->lsn, false, - _root->secsize)) - cdio_assert_not_reached (); - + if (is_mode2) { + if (cdio_read_mode2_sectors (obj, _dirbuf, _root->lsn, false, + _root->secsize)) + cdio_assert_not_reached (); + } else { + if (cdio_read_mode1_sectors (obj, _dirbuf, _root->lsn, false, + _root->secsize)) + cdio_assert_not_reached (); + } + while (offset < (_root->secsize * ISO_BLOCKSIZE)) { const iso9660_dir_t *idr @@ -169,11 +176,12 @@ _fs_stat_traverse (CdIo *obj, const iso9660_stat_t *_root, char **splitpath, } _name = _idr2name (idr); - _idr2statbuf (idr, &_stat); + _idr2statbuf (idr, &_stat, is_mode2); if (!strcmp (splitpath[0], _name)) { - int retval = _fs_stat_traverse (obj, &_stat, &splitpath[1], buf); + int retval = _fs_stat_traverse (obj, &_stat, &splitpath[1], buf, + is_mode2); free (_name); free (_dirbuf); return retval; @@ -206,7 +214,7 @@ iso9660_fs_stat (CdIo *obj, const char pathname[], iso9660_stat_t *buf, _fs_stat_root (obj, &_root, is_mode2); splitpath = _cdio_strsplit (pathname, '/'); - retval = _fs_stat_traverse (obj, &_root, splitpath, buf); + retval = _fs_stat_traverse (obj, &_root, splitpath, buf, is_mode2); _cdio_strfreev (splitpath); return retval; diff --git a/src/cd-info.c b/src/cd-info.c index 8a3d2e5b..a493f9ee 100644 --- a/src/cd-info.c +++ b/src/cd-info.c @@ -1,5 +1,5 @@ /* - $Id: cd-info.c,v 1.27 2003/08/31 14:26:06 rocky Exp $ + $Id: cd-info.c,v 1.28 2003/08/31 15:52:56 rocky Exp $ Copyright (C) 2003 Rocky Bernstein Copyright (C) 1996,1997,1998 Gerd Knorr @@ -671,6 +671,7 @@ static void print_iso9660_fs (CdIo *cdio, cdio_fs_anal_t fs, track_format_t track_format) { iso9660_pvd_t pvd; + bool is_mode2; switch (track_format) { case TRACK_FORMAT_AUDIO: @@ -681,10 +682,12 @@ print_iso9660_fs (CdIo *cdio, cdio_fs_anal_t fs, track_format_t track_format) case TRACK_FORMAT_XA: if (cdio_read_mode2_sector (cdio, &pvd, ISO_PVD_SECTOR, false)) return; + is_mode2 = true; break; case TRACK_FORMAT_DATA: - if (cdio_read_mode1_sector (cdio, &pvd, ISO_PVD_SECTOR, true)) + if (cdio_read_mode1_sector (cdio, &pvd, ISO_PVD_SECTOR, false)) return; + is_mode2 = false; } { @@ -693,7 +696,7 @@ print_iso9660_fs (CdIo *cdio, cdio_fs_anal_t fs, track_format_t track_format) printf ("ISO9660 filesystem\n"); printf (" root dir in PVD set to lsn %d\n\n", extent); - print_iso9660_recurse (cdio, "/", fs, track_format); + print_iso9660_recurse (cdio, "/", fs, is_mode2); } } diff --git a/test/check_cue.sh.in b/test/check_cue.sh.in index 71f98319..8b1876dc 100644 --- a/test/check_cue.sh.in +++ b/test/check_cue.sh.in @@ -1,5 +1,5 @@ #!/bin/sh -#$Id: check_cue.sh.in,v 1.6 2003/08/31 08:32:40 rocky Exp $ +#$Id: check_cue.sh.in,v 1.7 2003/08/31 15:52:56 rocky Exp $ if test -z "@CDDB_LIB@" ; then cddb_opt='--no-cddb' fi @@ -37,7 +37,7 @@ check_result $RC "cdinfo BIN test $testnum" fname=isofs-m1 testnum='ISO 9660 mode1' if test -f ${srcdir}/${fname}.bin ; then - test_cdinfo "--cue-file ${srcdir}/${fname}.cue" \ + test_cdinfo "--cue-file ${srcdir}/${fname}.cue --iso9660 " \ ${fname}.dump ${srcdir}/${fname}.right RC=$? check_result $RC "cdinfo CUE test $testnum" diff --git a/test/isofs-m1.right b/test/isofs-m1.right index 331f2135..cc2b2227 100644 --- a/test/isofs-m1.right +++ b/test/isofs-m1.right @@ -10,3 +10,17 @@ __________________________________ CD Analysis Report CD-ROM with ISO 9660 filesystem ISO 9660: 64 blocks, label `CDROM ' +ISO9660 filesystem + root dir in PVD set to lsn 23 + +/: + . + .. + COPYING.;1 + DOC + +/DOC/: + . + .. + README.TXT;1 +