Make mode1 format filesystem print work.

This commit is contained in:
rocky
2003-08-31 15:52:56 +00:00
parent 19c7de3990
commit e801ca8bcd
4 changed files with 65 additions and 40 deletions

View File

@@ -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 <hvr@gnu.org>
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
@@ -36,27 +36,27 @@
#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;
cdio_assert (iso9660_get_dir_len(idr) >= sizeof (iso9660_dir_t));
if (!dir_len) return;
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);
cdio_assert (dir_len >= sizeof (iso9660_dir_t));
if (is_mode2) {
int su_length = iso9660_get_dir_len(idr) - sizeof (iso9660_dir_t);
su_length -= idr->name_len;
if (su_length % 2)
@@ -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;
}
}
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,9 +151,15 @@ _fs_stat_traverse (CdIo *obj, const iso9660_stat_t *_root, char **splitpath,
_dirbuf = _cdio_malloc (_root->secsize * ISO_BLOCKSIZE);
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))
{
@@ -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;

View File

@@ -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 <rocky@panix.com>
Copyright (C) 1996,1997,1998 Gerd Knorr <kraxel@bytesex.org>
@@ -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);
}
}

View File

@@ -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"

View File

@@ -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