Joliet filename detection for CD images is now done.

Various valgrind-caught errors fixed
Output changed: we no longer print root block number.
(It is still shown when XA attributes are printed.)
This commit is contained in:
rocky
2004-10-26 01:21:05 +00:00
parent 1d0bca626b
commit 8b895d0ba1
14 changed files with 105 additions and 87 deletions

View File

@@ -1,5 +1,5 @@
/*
$Id: cdio.c,v 1.74 2004/10/24 23:42:39 rocky Exp $
$Id: cdio.c,v 1.75 2004/10/26 01:21:05 rocky Exp $
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
@@ -39,7 +39,7 @@
#include <cdio/logging.h>
#include "cdio_private.h"
static const char _rcsid[] = "$Id: cdio.c,v 1.74 2004/10/24 23:42:39 rocky Exp $";
static const char _rcsid[] = "$Id: cdio.c,v 1.75 2004/10/26 01:21:05 rocky Exp $";
const char *track_format2str[6] =
@@ -765,7 +765,7 @@ cdio_get_joliet_level(const CdIo *p_cdio)
if (!p_cdio) return 0;
{
const generic_img_private_t *p_env
= (generic_img_private_t *)&(p_cdio->env);
= (generic_img_private_t *) (p_cdio->env);
return p_env->i_joliet_level;
}
}

View File

@@ -1,5 +1,5 @@
/*
$Id: bincue.c,v 1.44 2004/10/24 23:42:39 rocky Exp $
$Id: bincue.c,v 1.45 2004/10/26 01:21:05 rocky Exp $
Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com>
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
@@ -26,7 +26,7 @@
(*.cue).
*/
static const char _rcsid[] = "$Id: bincue.c,v 1.44 2004/10/24 23:42:39 rocky Exp $";
static const char _rcsid[] = "$Id: bincue.c,v 1.45 2004/10/26 01:21:05 rocky Exp $";
#include "image.h"
#include "cdio_assert.h"
@@ -1066,16 +1066,17 @@ cdio_is_cuefile(const char *psz_cue_name)
if (parse_cuefile(NULL, psz_cue_name))
return psz_bin_name;
else
return NULL;
goto error;
}
else if (psz_cue_name[i]=='C' && psz_cue_name[i+1]=='U' && psz_cue_name[i+2]=='E') {
psz_bin_name[i++]='B'; psz_bin_name[i++]='I'; psz_bin_name[i++]='N';
if (parse_cuefile(NULL, psz_cue_name))
return psz_bin_name;
else
return NULL;
goto error;
}
}
error:
free(psz_bin_name);
return NULL;
}

View File

@@ -1,5 +1,5 @@
/*
$Id: iso9660.c,v 1.20 2004/10/25 01:41:07 rocky Exp $
$Id: iso9660.c,v 1.21 2004/10/26 01:21:05 rocky Exp $
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -37,7 +37,7 @@
#include <stdio.h>
#endif
static const char _rcsid[] = "$Id: iso9660.c,v 1.20 2004/10/25 01:41:07 rocky Exp $";
static const char _rcsid[] = "$Id: iso9660.c,v 1.21 2004/10/26 01:21:05 rocky Exp $";
/* some parameters... */
#define SYSTEM_ID "CD-RTOS CD-BRIDGE"
@@ -90,6 +90,7 @@ iso9660_get_dtime (const iso9660_dtime_t *idr_date, bool b_localtime,
if (!idr_date) return;
memset(p_tm, 0, sizeof(struct tm));
p_tm->tm_year = idr_date->dt_year;
p_tm->tm_mon = idr_date->dt_month - 1;
p_tm->tm_mday = idr_date->dt_day;
@@ -97,6 +98,15 @@ iso9660_get_dtime (const iso9660_dtime_t *idr_date, bool b_localtime,
p_tm->tm_min = idr_date->dt_minute;
p_tm->tm_sec = idr_date->dt_second;
#ifdef HAVE_TM_GMTOFF
if (b_localtime) {
tzset();
p_tm->tm_isdst = daylight;
p_tm->tm_gmtoff = timezone;
p_tm->tm_zone = (char *) tzname;
}
#endif
/* Recompute tm_wday and tm_yday via mktime. */
t = mktime(p_tm);

View File

@@ -1,5 +1,5 @@
/*
$Id: iso9660_fs.c,v 1.31 2004/10/24 23:42:39 rocky Exp $
$Id: iso9660_fs.c,v 1.32 2004/10/26 01:21:05 rocky Exp $
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -49,7 +49,7 @@
#include <stdio.h>
static const char _rcsid[] = "$Id: iso9660_fs.c,v 1.31 2004/10/24 23:42:39 rocky Exp $";
static const char _rcsid[] = "$Id: iso9660_fs.c,v 1.32 2004/10/26 01:21:05 rocky Exp $";
/* Implementation of iso9660_t type */
struct _iso9660 {
@@ -140,7 +140,7 @@ check_pvd (const iso9660_pvd_t *p_pvd)
}
static bool
ucs2be_to_locale(const char *psz_ucs2be, size_t i_inlen,
ucs2be_to_locale(char *psz_ucs2be, size_t i_inlen,
char **p_psz_out, size_t i_outlen)
{
iconv_t ic = iconv_open(nl_langinfo(CODESET), "UCS-2BE");
@@ -149,6 +149,7 @@ ucs2be_to_locale(const char *psz_ucs2be, size_t i_inlen,
char *psz_buf2;
int i_outlen_save = i_outlen;
#if 0
if (errno) {
cdio_warn("Failed to get conversion table for locale, trying ASCII");
ic = iconv_open("ASCII", "UCS-2BE");
@@ -157,6 +158,7 @@ ucs2be_to_locale(const char *psz_ucs2be, size_t i_inlen,
return false;
}
}
#endif
psz_buf = (char *) realloc(psz_buf, i_outlen);
psz_buf2 = psz_buf;
@@ -427,10 +429,25 @@ bool
iso9660_fs_read_pvd(const CdIo *p_cdio, /*out*/ iso9660_pvd_t *p_pvd)
{
/* A bit of a hack, we'll assume track 1 contains ISO_PVD_SECTOR.*/
bool b_mode2 = cdio_get_track_green(p_cdio, 1);
bool b_mode2;
char buf[CDIO_CD_FRAMESIZE_RAW] = { 0, };
int i_rc;
switch(cdio_get_track_format(p_cdio, 1)) {
case TRACK_FORMAT_CDI:
case TRACK_FORMAT_XA:
b_mode2 = true;
break;
case TRACK_FORMAT_DATA:
b_mode2 = false;
break;
case TRACK_FORMAT_AUDIO:
case TRACK_FORMAT_PSX:
case TRACK_FORMAT_ERROR:
default:
return false;
}
i_rc = b_mode2
? cdio_read_mode2_sector (p_cdio, buf, ISO_PVD_SECTOR, false)
: cdio_read_mode1_sector (p_cdio, buf, ISO_PVD_SECTOR, false);
@@ -467,11 +484,25 @@ iso9660_fs_read_superblock (CdIo *p_cdio,
iso9660_pvd_t *p_pvd = &(p_env->pvd);
iso9660_svd_t *p_svd = &(p_env->svd);
char buf[CDIO_CD_FRAMESIZE_RAW] = { 0, };
/* A bit of a hack, we'll assume track 1 contains ISO_PVD_SECTOR.*/
bool b_mode2 = cdio_get_track_green(p_cdio, 1);
bool b_mode2;
int i_rc;
/* A bit of a hack, we'll assume track 1 contains ISO_PVD_SECTOR.*/
switch(cdio_get_track_format(p_cdio, 1)) {
case TRACK_FORMAT_CDI:
case TRACK_FORMAT_XA:
b_mode2 = true;
break;
case TRACK_FORMAT_DATA:
b_mode2 = false;
break;
case TRACK_FORMAT_AUDIO:
case TRACK_FORMAT_PSX:
case TRACK_FORMAT_ERROR:
default:
return false;
}
if ( !iso9660_fs_read_pvd(p_cdio, p_pvd) )
return false;
@@ -481,7 +512,7 @@ iso9660_fs_read_superblock (CdIo *p_cdio,
? cdio_read_mode2_sector (p_cdio, buf, ISO_PVD_SECTOR+1, false)
: cdio_read_mode1_sector (p_cdio, buf, ISO_PVD_SECTOR+1, false);
if (0 != i_rc) {
if (0 == i_rc) {
/* The size of a PVD or SVD is smaller than a sector. So we
allocated a bigger block above (buf) and now we'll copy just
the part we need to save.
@@ -653,7 +684,7 @@ _fs_stat_root (CdIo *p_cdio)
bool b_mode2 = cdio_get_track_green(p_cdio, 1);
/* FIXME try also with Joliet.*/
if ( !iso9660_fs_read_superblock (p_cdio, 0 /*ISO_EXTENSION_ALL*/) ) {
if ( !iso9660_fs_read_superblock (p_cdio, ISO_EXTENSION_ALL) ) {
cdio_warn("Could not read ISO-9660 Superblock.");
return NULL;
}
@@ -684,19 +715,20 @@ _fs_stat_iso_root (iso9660_t *p_iso)
}
static iso9660_stat_t *
_fs_stat_traverse (const CdIo *cdio, const iso9660_stat_t *_root,
_fs_stat_traverse (const CdIo *p_cdio, const iso9660_stat_t *_root,
char **splitpath, bool b_mode2, bool translate)
{
unsigned offset = 0;
uint8_t *_dirbuf = NULL;
iso9660_stat_t *stat;
iso9660_stat_t *p_stat;
generic_img_private_t *p_env = (generic_img_private_t *) p_cdio->env;
if (!splitpath[0])
{
unsigned int len=sizeof(iso9660_stat_t) + strlen(_root->filename)+1;
stat = _cdio_malloc(len);
memcpy(stat, _root, len);
return stat;
p_stat = _cdio_malloc(len);
memcpy(p_stat, _root, len);
return p_stat;
}
if (_root->type == _STAT_FILE)
@@ -714,11 +746,11 @@ _fs_stat_traverse (const CdIo *cdio, const iso9660_stat_t *_root,
_dirbuf = _cdio_malloc (_root->secsize * ISO_BLOCKSIZE);
if (b_mode2) {
if (cdio_read_mode2_sectors (cdio, _dirbuf, _root->lsn, false,
if (cdio_read_mode2_sectors (p_cdio, _dirbuf, _root->lsn, false,
_root->secsize))
return NULL;
} else {
if (cdio_read_mode1_sectors (cdio, _dirbuf, _root->lsn, false,
if (cdio_read_mode1_sectors (p_cdio, _dirbuf, _root->lsn, false,
_root->secsize))
return NULL;
}
@@ -726,7 +758,7 @@ _fs_stat_traverse (const CdIo *cdio, const iso9660_stat_t *_root,
while (offset < (_root->secsize * ISO_BLOCKSIZE))
{
iso9660_dir_t *p_iso9660_dir = (void *) &_dirbuf[offset];
iso9660_stat_t *stat;
iso9660_stat_t *p_stat;
int cmp;
if (!iso9660_get_dir_len(p_iso9660_dir))
@@ -735,34 +767,36 @@ _fs_stat_traverse (const CdIo *cdio, const iso9660_stat_t *_root,
continue;
}
stat = _iso9660_dir_to_statbuf (p_iso9660_dir, b_mode2, 0);
p_stat = _iso9660_dir_to_statbuf (p_iso9660_dir, b_mode2,
p_env->i_joliet_level);
if (translate) {
char *trans_fname = malloc(strlen(stat->filename));
char *trans_fname = malloc(strlen(p_stat->filename));
int trans_len;
if (trans_fname == NULL) {
cdio_warn("can't allocate %lu bytes",
(long unsigned int) strlen(stat->filename));
(long unsigned int) strlen(p_stat->filename));
return NULL;
}
trans_len = iso9660_name_translate(stat->filename, trans_fname);
trans_len = iso9660_name_translate_ext(p_stat->filename, trans_fname,
p_env->i_joliet_level);
cmp = strcmp(splitpath[0], trans_fname);
free(trans_fname);
} else {
cmp = strcmp(splitpath[0], stat->filename);
cmp = strcmp(splitpath[0], p_stat->filename);
}
if (!cmp) {
iso9660_stat_t *ret_stat
= _fs_stat_traverse (cdio, stat, &splitpath[1], b_mode2,
= _fs_stat_traverse (p_cdio, p_stat, &splitpath[1], b_mode2,
translate);
free(stat);
free(p_stat);
free (_dirbuf);
return ret_stat;
}
free(stat);
free(p_stat);
offset += iso9660_get_dir_len(p_iso9660_dir);
}
@@ -974,6 +1008,7 @@ CdioList *
iso9660_fs_readdir (CdIo *p_cdio, const char pathname[], bool b_mode2)
{
iso9660_stat_t *p_stat;
generic_img_private_t *p_env = (generic_img_private_t *) p_cdio->env;
if (!p_cdio) return NULL;
if (!pathname) return NULL;
@@ -1021,7 +1056,8 @@ iso9660_fs_readdir (CdIo *p_cdio, const char pathname[], bool b_mode2)
continue;
}
p_iso9660_stat = _iso9660_dir_to_statbuf(p_iso9660_dir, b_mode2, 0);
p_iso9660_stat = _iso9660_dir_to_statbuf(p_iso9660_dir, b_mode2,
p_env->i_joliet_level);
_cdio_list_append (retval, p_iso9660_stat);
offset += iso9660_get_dir_len(p_iso9660_dir);

View File

@@ -1,5 +1,5 @@
/*
$Id: cd-info.c,v 1.92 2004/10/24 23:42:39 rocky Exp $
$Id: cd-info.c,v 1.93 2004/10/26 01:21:05 rocky Exp $
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
Copyright (C) 1996, 1997, 1998 Gerd Knorr <kraxel@bytesex.org>
@@ -544,6 +544,7 @@ print_iso9660_recurse (CdIo *p_cdio, const char pathname[],
CdioList *entlist;
CdioList *dirlist = _cdio_list_new ();
CdioListNode *entnode;
uint8_t i_joliet_level = cdio_get_joliet_level(p_cdio);
entlist = iso9660_fs_readdir (p_cdio, pathname, b_mode2);
@@ -565,7 +566,7 @@ print_iso9660_recurse (CdIo *p_cdio, const char pathname[],
#define DATESTR_SIZE 30
char date_str[DATESTR_SIZE];
iso9660_name_translate(iso_name, translated_name);
iso9660_name_translate_ext(iso_name, translated_name, i_joliet_level);
snprintf (_fullname, sizeof (_fullname), "%s%s", pathname,
iso_name);
@@ -614,51 +615,22 @@ print_iso9660_recurse (CdIo *p_cdio, const char pathname[],
_cdio_list_free (dirlist, true);
}
static bool
read_iso9660_pvd(const CdIo *p_cdio, track_format_t track_format, /*out*/
iso9660_pvd_t *p_pvd) {
switch (track_format) {
case TRACK_FORMAT_CDI:
case TRACK_FORMAT_XA:
if (0 != cdio_read_mode2_sector (p_cdio, p_pvd, ISO_PVD_SECTOR, false))
return false;
break;
case TRACK_FORMAT_DATA:
if (0 != cdio_read_mode1_sector (p_cdio, p_pvd, ISO_PVD_SECTOR, false))
return false;
break;
case TRACK_FORMAT_AUDIO:
case TRACK_FORMAT_PSX:
case TRACK_FORMAT_ERROR:
default:
return false;
}
return true;
}
static void
print_iso9660_fs (CdIo *p_cdio, cdio_fs_anal_t fs,
track_format_t track_format)
{
iso9660_pvd_t pvd;
bool b_mode2 = false;
if (fs & CDIO_FS_ANAL_XA) track_format = TRACK_FORMAT_XA;
if ( !read_iso9660_pvd(p_cdio, track_format, &pvd) )
if ( !iso9660_fs_read_superblock(p_cdio, ISO_EXTENSION_ALL) )
return;
b_mode2 = ( TRACK_FORMAT_CDI == track_format
|| TRACK_FORMAT_XA == track_format );
{
const lsn_t extent = iso9660_get_root_lsn(&pvd);
printf ("ISO9660 filesystem\n");
printf (" root dir in PVD set to lsn %lu\n\n", (long unsigned) extent);
print_iso9660_recurse (p_cdio, "/", fs, b_mode2);
}
}
@@ -736,7 +708,7 @@ print_analysis(int ms_offset, cdio_iso_analysis_t cdio_iso_analysis,
{
iso9660_pvd_t pvd;
if ( read_iso9660_pvd(p_cdio, track_format, &pvd) ) {
if ( iso9660_fs_read_pvd(p_cdio, &pvd) ) {
fprintf(stdout, "Application: %s\n",
iso9660_get_application_id(&pvd));
fprintf(stdout, "Preparer : %s\n", iso9660_get_preparer_id(&pvd));

View File

@@ -1,4 +1,4 @@
# $Id: Makefile.am,v 1.29 2004/10/24 12:26:28 rocky Exp $
# $Id: Makefile.am,v 1.30 2004/10/26 01:21:05 rocky Exp $
#
# Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
#
@@ -69,6 +69,8 @@ XFAIL_TESTS = testassert
MOSTLYCLEANFILES = core.* *.dump
test: check
# This is a really bad hack to make sure check_nrg and check_cue.sh
# are executable. Automake will remake check_nrg.sh and check_cue.sh
# but not run the configure default commands for them to make sure

View File

@@ -19,8 +19,6 @@ System : LINUX
Volume : CDROM
Volume Set :
ISO9660 filesystem
root dir in PVD set to lsn 23
/:
Apr 20 2003 07:26 .
Apr 20 2003 07:26 ..

View File

@@ -21,8 +21,6 @@ System : CD-RTOS CD-BRIDGE
Volume : MONVOISIN
Volume Set :
ISO9660 filesystem
root dir in PVD set to lsn 18
/:
d d---1xrxrxr 0 0 [fn 00] [LSN 18] 2048 Dec 31 1969 23:59 .
d d---1xrxrxr 0 0 [fn 00] [LSN 18] 2048 Dec 31 1969 23:59 ..

View File

@@ -20,8 +20,6 @@ System : CD-RTOS CD-BRIDGE
Volume : SVCD_OGT_TEST_NTSC
Volume Set :
ISO9660 filesystem
root dir in PVD set to lsn 18
/:
d d---1xrxrxr 0 0 [fn 00] [LSN 18] 2048 Jul 14 1978 00:00 .
d d---1xrxrxr 0 0 [fn 00] [LSN 18] 2048 Jul 14 1978 00:00 ..

View File

@@ -21,8 +21,6 @@ System : S_VCD30 DISC of EnReach
Volume : SVCD
Volume Set : SVCD01
ISO9660 filesystem
root dir in PVD set to lsn 20
/:
d d---1xrxrxr 0 0 [fn 00] [LSN 20] 2048 Jan 06 2001 21:29 .
d d---1xrxrxr 0 0 [fn 00] [LSN 20] 2048 Jan 06 2001 21:29 ..

View File

@@ -1,5 +1,5 @@
/*
$Id: testbincue.c,v 1.4 2004/10/23 20:55:09 rocky Exp $
$Id: testbincue.c,v 1.5 2004/10/26 01:21:05 rocky Exp $
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
@@ -68,29 +68,33 @@ main(int argc, const char *argv[])
psz_cuefile[sizeof(psz_cuefile)-1] = '\0';
cdio_loglevel_default = (argc > 1) ? CDIO_LOG_DEBUG : CDIO_LOG_INFO;
for (i=0; i<NUM_GOOD_CUES; i++) {
char *psz_binfile;
snprintf(psz_cuefile, sizeof(psz_cuefile)-1,
"%s/%s", TEST_DIR, cue_file[i]);
if (!cdio_is_cuefile(psz_cuefile)) {
psz_binfile = cdio_is_cuefile(psz_cuefile);
if (!psz_binfile) {
printf("Incorrect: %s doesn't parse as a CDRWin CUE file.\n",
cue_file[i]);
ret=i+1;
} else {
printf("Correct: %s parses as a CDRWin CUE file.\n",
cue_file[i]);
free(psz_binfile);
}
}
for (i=0; i<NUM_BAD_CUES; i++) {
char *psz_binfile;
snprintf(psz_cuefile, sizeof(psz_cuefile)-1,
"%s/%s", TEST_DIR, badcue_file[i]);
if (!cdio_is_cuefile(psz_cuefile)) {
psz_binfile=cdio_is_cuefile(psz_cuefile);
if (!psz_binfile) {
printf("Correct: %s doesn't parse as a CDRWin CUE file.\n",
badcue_file[i]);
} else {
printf("Incorrect: %s parses as a CDRWin CUE file.\n",
badcue_file[i]);
free(psz_binfile);
ret+=50*i+1;
break;
}

View File

@@ -1,5 +1,5 @@
/*
$Id: testiso9660.c,v 1.2 2003/09/21 01:14:30 rocky Exp $
$Id: testiso9660.c,v 1.3 2004/10/26 01:21:05 rocky Exp $
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
@@ -24,6 +24,9 @@
#endif
#include <ctype.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
@@ -121,8 +124,10 @@ main (int argc, const char *argv[])
dst_p = iso9660_pathname_isofy ("this/file.ext", 1);
if ( 0 != strncmp(dst_p, "this/file.ext;1", 16) ) {
printf("Failed iso9660_pathname_isofy\n");
free(dst_p);
return 10;
}
free(dst_p);
/* Test get/set date */
{

View File

@@ -21,8 +21,6 @@ System : CD-RTOS CD-BRIDGE
Volume : V0469
Volume Set :
ISO9660 filesystem
root dir in PVD set to lsn 18
/:
d d---1xrxrxr 0 0 [fn 00] [LSN 18] 2048 Jul 14 1978 00:00 .
d d---1xrxrxr 0 0 [fn 00] [LSN 18] 2048 Jul 14 1978 00:00 ..

View File

@@ -24,8 +24,6 @@ System : CD-RTOS CD-BRIDGE
Volume : SVIDEOCD
Volume Set :
ISO9660 filesystem
root dir in PVD set to lsn 18
/:
d d---1xrxrxr 0 0 [fn 00] [LSN 18] 2048 Jul 14 1978 00:00 .
d d---1xrxrxr 0 0 [fn 00] [LSN 18] 2048 Jul 14 1978 00:00 ..