First attempt to extent Joliet to CD reading portion.

This commit is contained in:
rocky
2004-10-24 23:42:39 +00:00
parent fa880ca82a
commit 55de6dfdeb
11 changed files with 466 additions and 341 deletions

View File

@@ -1,5 +1,5 @@
/*
$Id: iso2.c,v 1.1 2004/10/10 00:21:08 rocky Exp $
$Id: iso2.c,v 1.2 2004/10/24 23:42:39 rocky Exp $
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -83,7 +83,7 @@ main(int argc, const char *argv[])
return 1;
}
p_statbuf = iso9660_fs_stat (p_cdio, ISO9660_FILENAME, false);
p_statbuf = iso9660_fs_stat (p_cdio, ISO9660_FILENAME);
if (NULL == p_statbuf)
{

View File

@@ -1,5 +1,5 @@
/* -*- c -*-
$Id: cdio.h,v 1.65 2004/09/04 23:49:47 rocky Exp $
$Id: cdio.h,v 1.66 2004/10/24 23:42:39 rocky Exp $
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -193,6 +193,34 @@ extern "C" {
*/
const cdtext_t *cdio_get_cdtext (CdIo *p_cdio, track_t i_track);
/*!
Get the default CD device.
if p_cdio is NULL (we haven't initialized a specific device driver),
then find a suitable one and return the default device for that.
@param p_cdio the CD object queried
@return a string containing the default CD device or NULL is
if we couldn't get a default device.
In some situations of drivers or OS's we can't find a CD device if
there is no media in it and it is possible for this routine to return
NULL even though there may be a hardware CD-ROM.
*/
char * cdio_get_default_device (const CdIo *p_cdio);
/*! Return an array of device names. If you want a specific
devices for a driver, give that device. If you want hardware
devices, give DRIVER_DEVICE and if you want all possible devices,
image drivers and hardware drivers give DRIVER_UNKNOWN.
NULL is returned if we couldn't return a list of devices.
In some situations of drivers or OS's we can't find a CD device if
there is no media in it and it is possible for this routine to return
NULL even though there may be a hardware CD-ROM.
*/
char ** cdio_get_devices (driver_id_t driver_id);
/*!
Get an array of device names in search_devices that have at least
the capabilities listed by the capabities parameter. If
@@ -224,19 +252,6 @@ extern "C" {
bool b_any,
/*out*/ driver_id_t *p_driver_id);
/*! Return an array of device names. If you want a specific
devices for a driver, give that device. If you want hardware
devices, give DRIVER_DEVICE and if you want all possible devices,
image drivers and hardware drivers give DRIVER_UNKNOWN.
NULL is returned if we couldn't return a list of devices.
In some situations of drivers or OS's we can't find a CD device if
there is no media in it and it is possible for this routine to return
NULL even though there may be a hardware CD-ROM.
*/
char ** cdio_get_devices (driver_id_t driver_id);
/*! Like cdio_get_devices, but we may change the p_driver_id if we
were given DRIVER_DEVICE or DRIVER_UNKNOWN. This is because
often one wants to get a drive name and then *open* it
@@ -246,20 +261,12 @@ extern "C" {
char ** cdio_get_devices_ret (/*in/out*/ driver_id_t *p_driver_id);
/*!
Get the default CD device.
if p_cdio is NULL (we haven't initialized a specific device driver),
then find a suitable one and return the default device for that.
@param p_cdio the CD object queried
@return a string containing the default CD device or NULL is
if we couldn't get a default device.
In some situations of drivers or OS's we can't find a CD device if
there is no media in it and it is possible for this routine to return
NULL even though there may be a hardware CD-ROM.
/*!
Get disc mode - the kind of CD (CD-DA, CD-ROM mode 1, CD-MIXED, etc.
that we've got. The notion of "CD" is extended a little to include
DVD's.
*/
char * cdio_get_default_device (const CdIo *p_cdio);
discmode_t cdio_get_discmode (CdIo *p_cdio);
/*!
Get the what kind of device we've got.
@@ -292,26 +299,6 @@ extern "C" {
cdio_drive_write_cap_t *p_write_cap,
cdio_drive_misc_cap_t *p_misc_cap);
/*!
Get the CD-ROM hardware info via a SCSI MMC INQUIRY command.
False is returned if we had an error getting the information.
*/
bool cdio_get_hwinfo ( const CdIo *p_cdio,
/* out*/ cdio_hwinfo_t *p_hw_info );
/*!
Get the media catalog number (MCN) from the CD.
@return the media catalog number r NULL if there is none or we
don't have the ability to get it.
Note: string is malloc'd so caller has to free() the returned
string when done with it.
*/
char * cdio_get_mcn (const CdIo *p_cdio);
/*!
Get a string containing the name of the driver in use.
@@ -338,11 +325,29 @@ extern "C" {
track_t cdio_get_first_track_num(const CdIo *p_cdio);
/*!
Get disc mode - the kind of CD (CD-DA, CD-ROM mode 1, CD-MIXED, etc.
that we've got. The notion of "CD" is extended a little to include
DVD's.
Get the CD-ROM hardware info via a SCSI MMC INQUIRY command.
False is returned if we had an error getting the information.
*/
discmode_t cdio_get_discmode (CdIo *p_cdio);
bool cdio_get_hwinfo ( const CdIo *p_cdio,
/* out*/ cdio_hwinfo_t *p_hw_info );
/*!
Return the Joliet level recognized for p_cdio.
*/
uint8_t cdio_get_joliet_level(const CdIo *p_cdio);
/*!
Get the media catalog number (MCN) from the CD.
@return the media catalog number r NULL if there is none or we
don't have the ability to get it.
Note: string is malloc'd so caller has to free() the returned
string when done with it.
*/
char * cdio_get_mcn (const CdIo *p_cdio);
/*!
Get the number of tracks on the CD.

View File

@@ -1,5 +1,5 @@
/*
$Id: iso9660.h,v 1.52 2004/10/24 03:29:31 rocky Exp $
$Id: iso9660.h,v 1.53 2004/10/24 23:42:39 rocky Exp $
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -125,6 +125,10 @@ enum strncpy_pad_check {
ISO9660_DCHARS
};
#ifndef EMPTY_ARRAY_SIZE
#define EMPTY_ARRAY_SIZE 0
#endif
PRAGMA_BEGIN_PACKED
/*!
@@ -171,120 +175,6 @@ struct iso9660_ltime {
typedef struct iso9660_ltime iso9660_ltime_t;
/*!
\brief ISO-9660 Primary Volume Descriptor.
*/
struct iso9660_pvd {
uint8_t type; /**< 711 encoded */
char id[5];
uint8_t version; /**< 711 encoded */
char unused1[1];
char system_id[ISO_MAX_SYSTEM_ID]; /**< each char is an achar */
char volume_id[ISO_MAX_VOLUME_ID]; /**< each char is a dchar */
char unused2[8];
uint64_t volume_space_size; /**< 733 encoded */
char unused3[32];
uint32_t volume_set_size; /**< 723 encoded */
uint32_t volume_sequence_number; /**< 723 encoded */
uint32_t logical_block_size; /**< 723 encoded */
uint64_t path_table_size; /**< 733 encoded */
uint32_t type_l_path_table; /**< 731 encoded */
uint32_t opt_type_l_path_table; /**< 731 encoded */
uint32_t type_m_path_table; /**< 732 encoded */
uint32_t opt_type_m_path_table; /**< 732 encoded */
char root_directory_record[34]; /**< See section 9.1 of
ISO 9660 spec. */
char volume_set_id[ISO_MAX_VOLUMESET_ID]; /**< dchars */
char publisher_id[ISO_MAX_PUBLISHER_ID]; /**< achars */
char preparer_id[ISO_MAX_PREPARER_ID]; /**< achars */
char application_id[ISO_MAX_APPLICATION_ID]; /**< achars */
char copyright_file_id[37]; /**< See section 7.5 of
ISO 9660 spec. Each char is
a dchar */
char abstract_file_id[37]; /**< See section 7.5 of
ISO 9660 spec. Each char is
a dchar */
char bibliographic_file_id[37]; /**< See section 7.5 of
ISO 9660 spec. Each char is
a dchar. */
iso9660_ltime_t creation_date; /**< See section 8.4.26.1 of
ISO 9660 spec. */
iso9660_ltime_t modification_date; /**< See section 8.4.26.1 of
ISO 9660 spec. */
iso9660_ltime_t expiration_date; /**< See section 8.4.26.1 of
ISO 9660 spec. */
iso9660_ltime_t effective_date; /**< See section 8.4.26.1 of
ISO 9660 spec. */
uint8_t file_structure_version; /**< 711 encoded */
char unused4[1];
char application_data[512];
char unused5[653];
} GNUC_PACKED;
/*!
\brief ISO-9660 Supplimentary Volume Descriptor.
This is used for Joliet Extentions and is almost the same as the
the primary descriptor but two unused fields, "unused1" and "unused3
become "flags and "escape_sequences" respectively.
*/
struct iso9660_svd {
uint8_t type; /**< 711 encoded */
char id[5];
uint8_t version; /**< 711 encoded */
char flags; /**< 853 */
char system_id[ISO_MAX_SYSTEM_ID]; /**< each char is an achar */
char volume_id[ISO_MAX_VOLUME_ID]; /**< each char is a dchar */
char unused2[8];
uint64_t volume_space_size; /**< 733 encoded */
char escape_sequences[32]; /**< 856 */
uint32_t volume_set_size; /**< 723 encoded */
uint32_t volume_sequence_number; /**< 723 encoded */
uint32_t logical_block_size; /**< 723 encoded */
uint64_t path_table_size; /**< 733 encoded */
uint32_t type_l_path_table; /**< 731 encoded */
uint32_t opt_type_l_path_table; /**< 731 encoded */
uint32_t type_m_path_table; /**< 732 encoded */
uint32_t opt_type_m_path_table; /**< 732 encoded */
char root_directory_record[34]; /**< See section 9.1 of
ISO 9660 spec. */
char volume_set_id[ISO_MAX_VOLUMESET_ID]; /**< dchars */
char publisher_id[ISO_MAX_PUBLISHER_ID]; /**< achars */
char preparer_id[ISO_MAX_PREPARER_ID]; /**< achars */
char application_id[ISO_MAX_APPLICATION_ID]; /**< achars */
char copyright_file_id[37]; /**< See section 7.5 of
ISO 9660 spec. Each char is
a dchar */
char abstract_file_id[37]; /**< See section 7.5 of
ISO 9660 spec. Each char is
a dchar */
char bibliographic_file_id[37]; /**< See section 7.5 of
ISO 9660 spec. Each char is
a dchar. */
iso9660_ltime_t creation_date; /**< See section 8.4.26.1 of
ISO 9660 spec. */
iso9660_ltime_t modification_date; /**< See section 8.4.26.1 of
ISO 9660 spec. */
iso9660_ltime_t expiration_date; /**< See section 8.4.26.1 of
ISO 9660 spec. */
iso9660_ltime_t effective_date; /**< See section 8.4.26.1 of
ISO 9660 spec. */
uint8_t file_structure_version; /**< 711 encoded */
char unused4[1];
char application_data[512];
char unused5[653];
};
typedef struct iso9660_dir iso9660_dir_t;
typedef struct iso9660_pvd iso9660_pvd_t;
typedef struct iso9660_svd iso9660_svd_t;
typedef struct iso9660_stat iso9660_stat_t;
#ifndef EMPTY_ARRAY_SIZE
#define EMPTY_ARRAY_SIZE 0
#endif
/*! \brief Format of an ISO-9660 directory record
This structure may have an odd length depending on how many
@@ -311,6 +201,116 @@ struct iso9660_dir {
char filename[EMPTY_ARRAY_SIZE];
} GNUC_PACKED;
typedef struct iso9660_dir iso9660_dir_t;
/*!
\brief ISO-9660 Primary Volume Descriptor.
*/
struct iso9660_pvd {
uint8_t type; /**< 711 encoded */
char id[5];
uint8_t version; /**< 711 encoded */
char unused1[1];
char system_id[ISO_MAX_SYSTEM_ID]; /**< each char is an achar */
char volume_id[ISO_MAX_VOLUME_ID]; /**< each char is a dchar */
char unused2[8];
uint64_t volume_space_size; /**< 733 encoded */
char unused3[32];
uint32_t volume_set_size; /**< 723 encoded */
uint32_t volume_sequence_number; /**< 723 encoded */
uint32_t logical_block_size; /**< 723 encoded */
uint64_t path_table_size; /**< 733 encoded */
uint32_t type_l_path_table; /**< 731 encoded */
uint32_t opt_type_l_path_table; /**< 731 encoded */
uint32_t type_m_path_table; /**< 732 encoded */
uint32_t opt_type_m_path_table; /**< 732 encoded */
iso9660_dir_t root_directory_record; /**< See section 9.1 of
ISO 9660 spec. */
char root_directory_filename; /**< Is \0 */
char volume_set_id[ISO_MAX_VOLUMESET_ID]; /**< dchars */
char publisher_id[ISO_MAX_PUBLISHER_ID]; /**< achars */
char preparer_id[ISO_MAX_PREPARER_ID]; /**< achars */
char application_id[ISO_MAX_APPLICATION_ID]; /**< achars */
char copyright_file_id[37]; /**< See section 7.5 of
ISO 9660 spec. Each char is
a dchar */
char abstract_file_id[37]; /**< See section 7.5 of
ISO 9660 spec. Each char is
a dchar */
char bibliographic_file_id[37]; /**< See section 7.5 of
ISO 9660 spec. Each char is
a dchar. */
iso9660_ltime_t creation_date; /**< See section 8.4.26.1 of
ISO 9660 spec. */
iso9660_ltime_t modification_date; /**< See section 8.4.26.1 of
ISO 9660 spec. */
iso9660_ltime_t expiration_date; /**< See section 8.4.26.1 of
ISO 9660 spec. */
iso9660_ltime_t effective_date; /**< See section 8.4.26.1 of
ISO 9660 spec. */
uint8_t file_structure_version; /**< 711 encoded */
char unused4[1];
char application_data[512];
char unused5[653];
} GNUC_PACKED;
typedef struct iso9660_pvd iso9660_pvd_t;
/*!
\brief ISO-9660 Supplementary Volume Descriptor.
This is used for Joliet Extentions and is almost the same as the
the primary descriptor but two unused fields, "unused1" and "unused3
become "flags and "escape_sequences" respectively.
*/
struct iso9660_svd {
uint8_t type; /**< 711 encoded */
char id[5];
uint8_t version; /**< 711 encoded */
char flags; /**< 853 */
char system_id[ISO_MAX_SYSTEM_ID]; /**< each char is an achar */
char volume_id[ISO_MAX_VOLUME_ID]; /**< each char is a dchar */
char unused2[8];
uint64_t volume_space_size; /**< 733 encoded */
char escape_sequences[32]; /**< 856 */
uint32_t volume_set_size; /**< 723 encoded */
uint32_t volume_sequence_number; /**< 723 encoded */
uint32_t logical_block_size; /**< 723 encoded */
uint64_t path_table_size; /**< 733 encoded */
uint32_t type_l_path_table; /**< 731 encoded */
uint32_t opt_type_l_path_table; /**< 731 encoded */
uint32_t type_m_path_table; /**< 732 encoded */
uint32_t opt_type_m_path_table; /**< 732 encoded */
iso9660_dir_t root_directory_record; /**< See section 9.1 of
ISO 9660 spec. */
char volume_set_id[ISO_MAX_VOLUMESET_ID]; /**< dchars */
char publisher_id[ISO_MAX_PUBLISHER_ID]; /**< achars */
char preparer_id[ISO_MAX_PREPARER_ID]; /**< achars */
char application_id[ISO_MAX_APPLICATION_ID]; /**< achars */
char copyright_file_id[37]; /**< See section 7.5 of
ISO 9660 spec. Each char is
a dchar */
char abstract_file_id[37]; /**< See section 7.5 of
ISO 9660 spec. Each char is
a dchar */
char bibliographic_file_id[37]; /**< See section 7.5 of
ISO 9660 spec. Each char is
a dchar. */
iso9660_ltime_t creation_date; /**< See section 8.4.26.1 of
ISO 9660 spec. */
iso9660_ltime_t modification_date; /**< See section 8.4.26.1 of
ISO 9660 spec. */
iso9660_ltime_t expiration_date; /**< See section 8.4.26.1 of
ISO 9660 spec. */
iso9660_ltime_t effective_date; /**< See section 8.4.26.1 of
ISO 9660 spec. */
uint8_t file_structure_version; /**< 711 encoded */
char unused4[1];
char application_data[512];
char unused5[653];
};
typedef struct iso9660_svd iso9660_svd_t;
PRAGMA_END_PACKED
@@ -333,6 +333,8 @@ struct iso9660_stat { /* big endian!! */
char filename[EMPTY_ARRAY_SIZE]; /**< filename */
};
typedef struct iso9660_stat iso9660_stat_t;
/** A mask used in iso9660_ifs_read_vd which allows what kinds
of extensions we allow, eg. Joliet, Rock Ridge, etc. */
@@ -383,6 +385,13 @@ typedef struct _iso9660 iso9660_t;
long int iso9660_iso_seek_read (const iso9660_t *p_iso, void *ptr,
lsn_t start, long int i_size);
/*!
Read the Primary Volume Descriptor for a CD.
True is returned if read, and false if there was an error.
*/
bool iso9660_fs_read_pvd ( const CdIo *p_cdio,
/*out*/ iso9660_pvd_t *p_pvd );
/*!
Read the Primary Volume Descriptor for an ISO 9660 image.
True is returned if read, and false if there was an error.
@@ -390,21 +399,22 @@ typedef struct _iso9660 iso9660_t;
bool iso9660_ifs_read_pvd (const iso9660_t *p_iso,
/*out*/ iso9660_pvd_t *p_pvd);
/*!
Read the Super block of an ISO 9660 image. This is the
Primary Volume Descriptor (PVD) and perhaps a Supplemental Volume
Descriptor if (Joliet) extensions are acceptable.
*/
bool iso9660_fs_read_superblock (CdIo *p_cdio,
iso_extension_mask_t iso_extension_mask);
/*!
Read the Supper block of an ISO 9660 image. This is the
Primary Volume Descriptor (PVD) and perhaps a Supplemental Volume
Descriptor if (Joliet) extensions are acceptable.
*/
bool iso9660_ifs_read_super (iso9660_t *p_iso,
iso_extension_mask_t iso_extension_mask);
bool iso9660_ifs_read_superblock (iso9660_t *p_iso,
iso_extension_mask_t iso_extension_mask);
/*!
Read the Primary Volume Descriptor for a CD.
True is returned if read, and false if there was an error.
*/
bool iso9660_fs_read_mode2_pvd (const CdIo *p_cdio,
/*out*/ iso9660_pvd_t *p_pvd,
bool b_form2);
/*====================================================
Time conversion
@@ -554,7 +564,7 @@ iso9660_dir_calc_record_size (unsigned int namelen, unsigned int su_len);
Returns stat_t of entry if we found lsn, or NULL otherwise.
*/
iso9660_stat_t *iso9660_find_fs_lsn(const CdIo *p_cdio, lsn_t lsn);
iso9660_stat_t *iso9660_find_fs_lsn(CdIo *p_cdio, lsn_t i_lsn);
/*!
@@ -563,14 +573,14 @@ iso9660_stat_t *iso9660_find_fs_lsn(const CdIo *p_cdio, lsn_t lsn);
Returns stat_t of entry if we found lsn, or NULL otherwise.
*/
iso9660_stat_t *iso9660_find_ifs_lsn(const iso9660_t *iso, lsn_t lsn);
iso9660_stat_t *iso9660_find_ifs_lsn(const iso9660_t *p_iso, lsn_t i_lsn);
/*!
Get file status for pathname into stat. NULL is returned on error.
*/
iso9660_stat_t *iso9660_fs_stat (const CdIo *obj, const char pathname[],
bool is_mode2);
iso9660_stat_t *iso9660_fs_stat (CdIo *p_cdio, const char pathname[]);
/*!
Get file status for pathname into stat. NULL is returned on error.
@@ -578,14 +588,14 @@ iso9660_stat_t *iso9660_fs_stat (const CdIo *obj, const char pathname[],
name are dropped, i.e. ;1 is removed and if level 1 ISO-9660 names
are lowercased.
*/
iso9660_stat_t *iso9660_fs_stat_translate (const CdIo *obj,
iso9660_stat_t *iso9660_fs_stat_translate (CdIo *p_cdio,
const char pathname[],
bool is_mode2);
bool b_mode2);
/*!
Get file status for pathname into stat. NULL is returned on error.
*/
iso9660_stat_t *iso9660_ifs_stat (iso9660_t *iso, const char pathname[]);
iso9660_stat_t *iso9660_ifs_stat (iso9660_t *p_iso, const char pathname[]);
/*!
@@ -594,15 +604,15 @@ iso9660_stat_t *iso9660_ifs_stat (iso9660_t *iso, const char pathname[]);
name are dropped, i.e. ;1 is removed and if level 1 ISO-9660 names
are lowercased.
*/
iso9660_stat_t *iso9660_ifs_stat_translate (iso9660_t *iso,
iso9660_stat_t *iso9660_ifs_stat_translate (iso9660_t *p_iso,
const char pathname[]);
/*!
Read pathname (a directory) and return a list of iso9660_stat_t
of the files inside that. The caller must free the returned result.
*/
CdioList * iso9660_fs_readdir (const CdIo *obj, const char pathname[],
bool mode2);
CdioList * iso9660_fs_readdir (CdIo *p_cdio, const char pathname[],
bool b_mode2);
/*!
Read pathname (a directory) and return a list of iso9660_stat_t
@@ -624,7 +634,7 @@ bool iso9660_ifs_get_application_id(iso9660_t *p_iso,
/*out*/ char **p_psz_app_id);
/*!
Return the Joliet level recognaized for p_iso.
Return the Joliet level recognized for p_iso.
*/
uint8_t iso9660_ifs_get_joliet_level(iso9660_t *p_iso);

View File

@@ -1,5 +1,5 @@
/*
$Id: _cdio_generic.c,v 1.26 2004/09/03 23:20:11 rocky Exp $
$Id: _cdio_generic.c,v 1.27 2004/10/24 23:42:39 rocky Exp $
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -27,7 +27,7 @@
# include "config.h"
#endif
static const char _rcsid[] = "$Id: _cdio_generic.c,v 1.26 2004/09/03 23:20:11 rocky Exp $";
static const char _rcsid[] = "$Id: _cdio_generic.c,v 1.27 2004/10/24 23:42:39 rocky Exp $";
#include <stdio.h>
#include <stdlib.h>
@@ -107,6 +107,7 @@ cdio_generic_init (void *user_data)
p_env->toc_init = false;
p_env->b_cdtext_init = false;
p_env->b_cdtext_error = false;
p_env->i_joliet_level = 0; /* Assume no Joliet extensions initally */
return true;
}

View File

@@ -1,5 +1,5 @@
/*
$Id: _cdio_stream.c,v 1.9 2004/02/07 18:53:02 rocky Exp $
$Id: _cdio_stream.c,v 1.10 2004/10/24 23:42:39 rocky Exp $
Copyright (C) 2000, 2004 Herbert Valerio Riedel <hvr@gnu.org>
@@ -34,7 +34,7 @@
#include <cdio/util.h>
#include "_cdio_stream.h"
static const char _rcsid[] = "$Id: _cdio_stream.c,v 1.9 2004/02/07 18:53:02 rocky Exp $";
static const char _rcsid[] = "$Id: _cdio_stream.c,v 1.10 2004/10/24 23:42:39 rocky Exp $";
/*
* DataSource implementations
@@ -52,18 +52,18 @@ struct _CdioDataSource {
Return false if we hit an error. Errno should be set for that error.
*/
static bool
_cdio_stream_open_if_necessary(CdioDataSource *obj)
_cdio_stream_open_if_necessary(CdioDataSource *p_obj)
{
cdio_assert (obj != NULL);
cdio_assert (p_obj != NULL);
if (!obj->is_open) {
if (obj->op.open(obj->user_data)) {
if (!p_obj->is_open) {
if (p_obj->op.open(p_obj->user_data)) {
cdio_warn ("could not open input stream...");
return false;
} else {
cdio_debug ("opened source...");
obj->is_open = 1;
obj->position = 0;
p_obj->is_open = 1;
p_obj->position = 0;
}
}
return true;
@@ -87,20 +87,20 @@ _cdio_stream_open_if_necessary(CdioDataSource *obj)
cate the error.
*/
long
cdio_stream_seek(CdioDataSource* obj, long offset, int whence)
cdio_stream_seek(CdioDataSource* p_obj, long int offset, int whence)
{
cdio_assert (obj != NULL);
cdio_assert (p_obj != NULL);
if (!_cdio_stream_open_if_necessary(obj))
if (!_cdio_stream_open_if_necessary(p_obj))
/* errno is set by _cdio_stream_open_if necessary. */
return -1;
if (obj->position != offset) {
if (p_obj->position != offset) {
#ifdef STREAM_DEBUG
cdio_warn("had to reposition DataSource from %ld to %ld!", obj->position, offset);
#endif
obj->position = offset;
return obj->op.seek(obj->user_data, offset, whence);
p_obj->position = offset;
return p_obj->op.seek(p_obj->user_data, offset, whence);
}
return 0;

View File

@@ -1,5 +1,5 @@
/*
$Id: cdio.c,v 1.73 2004/09/03 23:20:11 rocky Exp $
$Id: cdio.c,v 1.74 2004/10/24 23:42:39 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.73 2004/09/03 23:20:11 rocky Exp $";
static const char _rcsid[] = "$Id: cdio.c,v 1.74 2004/10/24 23:42:39 rocky Exp $";
const char *track_format2str[6] =
@@ -756,6 +756,20 @@ cdio_have_driver(driver_id_t driver_id)
return (*CdIo_all_drivers[driver_id].have_driver)();
}
/*!
Return the Joliet level recognized for p_cdio.
*/
uint8_t
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);
return p_env->i_joliet_level;
}
}
bool
cdio_is_device(const char *psz_source, driver_id_t driver_id)
{
@@ -843,12 +857,12 @@ cdio_lseek (const CdIo *cdio, off_t offset, int whence)
Similar to (if not the same as) libc's read()
*/
ssize_t
cdio_read (const CdIo *cdio, void *buf, size_t size)
cdio_read (const CdIo *p_cdio, void *buf, size_t size)
{
if (cdio == NULL) return -1;
if (p_cdio == NULL) return -1;
if (cdio->op.read)
return cdio->op.read (cdio->env, buf, size);
if (p_cdio->op.read)
return p_cdio->op.read (p_cdio->env, buf, size);
return -1;
}
@@ -857,14 +871,14 @@ cdio_read (const CdIo *cdio, void *buf, size_t size)
from lsn. Returns 0 if no error.
*/
int
cdio_read_audio_sector (const CdIo *cdio, void *buf, lsn_t lsn)
cdio_read_audio_sector (const CdIo *p_cdio, void *buf, lsn_t lsn)
{
if (NULL == cdio || NULL == buf || CDIO_INVALID_LSN == lsn )
if (NULL == p_cdio || NULL == buf || CDIO_INVALID_LSN == lsn )
return 0;
if (cdio->op.read_audio_sectors != NULL)
return cdio->op.read_audio_sectors (cdio->env, buf, lsn, 1);
if (p_cdio->op.read_audio_sectors != NULL)
return p_cdio->op.read_audio_sectors (p_cdio->env, buf, lsn, 1);
return -1;
}
@@ -873,14 +887,14 @@ cdio_read_audio_sector (const CdIo *cdio, void *buf, lsn_t lsn)
from lsn. Returns 0 if no error.
*/
int
cdio_read_audio_sectors (const CdIo *cdio, void *buf, lsn_t lsn,
cdio_read_audio_sectors (const CdIo *p_cdio, void *buf, lsn_t lsn,
unsigned int nblocks)
{
if ( NULL == cdio || NULL == buf || CDIO_INVALID_LSN == lsn )
if ( NULL == p_cdio || NULL == buf || CDIO_INVALID_LSN == lsn )
return 0;
if (cdio->op.read_audio_sectors != NULL)
return cdio->op.read_audio_sectors (cdio->env, buf, lsn, nblocks);
if (p_cdio->op.read_audio_sectors != NULL)
return p_cdio->op.read_audio_sectors (p_cdio->env, buf, lsn, nblocks);
return -1;
}
@@ -893,20 +907,21 @@ cdio_read_audio_sectors (const CdIo *cdio, void *buf, lsn_t lsn,
into data starting from lsn. Returns 0 if no error.
*/
int
cdio_read_mode1_sector (const CdIo *cdio, void *data, lsn_t lsn, bool b_form2)
cdio_read_mode1_sector (const CdIo *p_cdio, void *data, lsn_t lsn,
bool b_form2)
{
uint32_t size = b_form2 ? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE ;
char buf[M2RAW_SECTOR_SIZE] = { 0, };
if (NULL == cdio || NULL == data || CDIO_INVALID_LSN == lsn )
if (NULL == p_cdio || NULL == data || CDIO_INVALID_LSN == lsn )
return 0;
if (cdio->op.read_mode1_sector && cdio->op.read_mode1_sector) {
return cdio->op.read_mode1_sector(cdio->env, data, lsn, b_form2);
} else if (cdio->op.lseek && cdio->op.read) {
if (0 > cdio_lseek(cdio, CDIO_CD_FRAMESIZE*lsn, SEEK_SET))
if (p_cdio->op.read_mode1_sector) {
return p_cdio->op.read_mode1_sector(p_cdio->env, data, lsn, b_form2);
} else if (p_cdio->op.lseek && p_cdio->op.read) {
char buf[CDIO_CD_FRAMESIZE] = { 0, };
if (0 > cdio_lseek(p_cdio, CDIO_CD_FRAMESIZE*lsn, SEEK_SET))
return -1;
if (0 > cdio_read(cdio, buf, CDIO_CD_FRAMESIZE))
if (0 > cdio_read(p_cdio, buf, CDIO_CD_FRAMESIZE))
return -1;
memcpy (data, buf, size);
return 0;

View File

@@ -1,5 +1,5 @@
/*
$Id: generic.h,v 1.2 2004/08/28 09:15:41 rocky Exp $
$Id: generic.h,v 1.3 2004/10/24 23:42:39 rocky Exp $
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
@@ -30,6 +30,7 @@
#include <cdio/cdio.h>
#include <cdio/cdtext.h>
#include <cdio/iso9660.h>
#ifdef __cplusplus
extern "C" {
@@ -50,13 +51,19 @@ extern "C" {
int ioctls_debugged; /**< for debugging */
/* Only one of the below is used. The first is for CD-ROM devices
and the second for stream reading (bincue, nrg, toc, network).
/* Only one of data_source or fd is used; fd is for CD-ROM
devices and the data_source for stream reading (bincue, nrg, toc,
network).
*/
int fd; /**< File descriptor of device */
CdioDataSource *data_source;
int fd; /**< File descriptor of device */
track_t i_first_track; /**< The starting track number. */
track_t i_tracks; /**< The number of tracks. */
CdioDataSource *data_source;
uint8_t i_joliet_level; /**< 0 = no Joliet extensions.
1-3: Joliet level. */
iso9660_pvd_t pvd;
iso9660_svd_t svd;
CdIo *cdio; /**< a way to call general cdio routines. */
cdtext_t cdtext; /**< CD-Text for disc. */
cdtext_t cdtext_track[CDIO_CD_MAX_TRACKS+1]; /*CD-TEXT for each track*/

View File

@@ -1,5 +1,5 @@
/*
$Id: bincue.c,v 1.43 2004/09/04 00:06:50 rocky Exp $
$Id: bincue.c,v 1.44 2004/10/24 23:42:39 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.43 2004/09/04 00:06:50 rocky Exp $";
static const char _rcsid[] = "$Id: bincue.c,v 1.44 2004/10/24 23:42:39 rocky Exp $";
#include "image.h"
#include "cdio_assert.h"
@@ -835,18 +835,18 @@ _read_audio_sectors_bincue (void *user_data, void *data, lsn_t lsn,
*/
static int
_read_mode1_sector_bincue (void *user_data, void *data, lsn_t lsn,
bool b_form2)
bool b_form2)
{
_img_private_t *env = user_data;
_img_private_t *p_env = user_data;
int ret;
char buf[CDIO_CD_FRAMESIZE_RAW] = { 0, };
int blocksize = CDIO_CD_FRAMESIZE_RAW;
ret = cdio_stream_seek (env->gen.data_source, lsn * blocksize, SEEK_SET);
ret = cdio_stream_seek (p_env->gen.data_source, lsn * blocksize, SEEK_SET);
if (ret!=0) return ret;
/* FIXME: Not completely sure the below is correct. */
ret = cdio_stream_read (env->gen.data_source, buf, CDIO_CD_FRAMESIZE_RAW, 1);
ret = cdio_stream_read (p_env->gen.data_source, buf, CDIO_CD_FRAMESIZE_RAW, 1);
if (ret==0) return ret;
memcpy (data, buf + CDIO_CD_SYNC_SIZE + CDIO_CD_HEADER_SIZE,
@@ -864,13 +864,13 @@ static int
_read_mode1_sectors_bincue (void *user_data, void *data, lsn_t lsn,
bool b_form2, unsigned int nblocks)
{
_img_private_t *env = user_data;
_img_private_t *p_env = user_data;
int i;
int retval;
unsigned int blocksize = b_form2 ? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE;
for (i = 0; i < nblocks; i++) {
if ( (retval = _read_mode1_sector_bincue (env,
if ( (retval = _read_mode1_sector_bincue (p_env,
((char *)data) + (blocksize * i),
lsn + i, b_form2)) )
return retval;
@@ -886,7 +886,7 @@ static int
_read_mode2_sector_bincue (void *user_data, void *data, lsn_t lsn,
bool b_form2)
{
_img_private_t *env = user_data;
_img_private_t *p_env = user_data;
int ret;
char buf[CDIO_CD_FRAMESIZE_RAW] = { 0, };
@@ -898,10 +898,10 @@ _read_mode2_sector_bincue (void *user_data, void *data, lsn_t lsn,
int blocksize = CDIO_CD_FRAMESIZE_RAW;
ret = cdio_stream_seek (env->gen.data_source, lsn * blocksize, SEEK_SET);
ret = cdio_stream_seek (p_env->gen.data_source, lsn * blocksize, SEEK_SET);
if (ret!=0) return ret;
ret = cdio_stream_read (env->gen.data_source, buf, CDIO_CD_FRAMESIZE_RAW, 1);
ret = cdio_stream_read (p_env->gen.data_source, buf, CDIO_CD_FRAMESIZE_RAW, 1);
if (ret==0) return ret;
@@ -924,13 +924,13 @@ static int
_read_mode2_sectors_bincue (void *user_data, void *data, lsn_t lsn,
bool b_form2, unsigned int nblocks)
{
_img_private_t *env = user_data;
_img_private_t *p_env = user_data;
int i;
int retval;
unsigned int blocksize = b_form2 ? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE;
for (i = 0; i < nblocks; i++) {
if ( (retval = _read_mode2_sector_bincue (env,
if ( (retval = _read_mode2_sector_bincue (p_env,
((char *)data) + (blocksize * i),
lsn + i, b_form2)) )
return retval;
@@ -991,12 +991,12 @@ get_hwinfo_bincue ( const CdIo *p_cdio, /*out*/ cdio_hwinfo_t *hw_info)
static track_format_t
_get_track_format_bincue(void *user_data, track_t i_track)
{
_img_private_t *env = user_data;
_img_private_t *p_env = user_data;
if (i_track > env->gen.i_tracks || i_track == 0)
if (i_track > p_env->gen.i_tracks || i_track == 0)
return TRACK_FORMAT_ERROR;
return env->tocent[i_track-env->gen.i_first_track].track_format;
return p_env->tocent[i_track-p_env->gen.i_first_track].track_format;
}
/*!
@@ -1010,14 +1010,14 @@ _get_track_format_bincue(void *user_data, track_t i_track)
static bool
_get_track_green_bincue(void *user_data, track_t i_track)
{
_img_private_t *env = user_data;
_img_private_t *p_env = user_data;
if ( NULL == env ||
( i_track < env->gen.i_first_track
|| i_track >= env->gen.i_tracks + env->gen.i_first_track ) )
if ( NULL == p_env ||
( i_track < p_env->gen.i_first_track
|| i_track >= p_env->gen.i_tracks + p_env->gen.i_first_track ) )
return false;
return env->tocent[i_track-env->gen.i_first_track].track_green;
return p_env->tocent[i_track-p_env->gen.i_first_track].track_green;
}
/*!
@@ -1030,12 +1030,12 @@ _get_track_green_bincue(void *user_data, track_t i_track)
static lba_t
_get_lba_track_bincue(void *user_data, track_t i_track)
{
_img_private_t *env = user_data;
_img_private_t *p_env = user_data;
if (i_track == CDIO_CDROM_LEADOUT_TRACK) i_track = env->gen.i_tracks+1;
if (i_track == CDIO_CDROM_LEADOUT_TRACK) i_track = p_env->gen.i_tracks+1;
if (i_track <= env->gen.i_tracks + env->gen.i_first_track && i_track != 0) {
return env->tocent[i_track-env->gen.i_first_track].start_lba;
if (i_track <= p_env->gen.i_tracks + p_env->gen.i_first_track && i_track != 0) {
return p_env->tocent[i_track-p_env->gen.i_first_track].start_lba;
} else
return CDIO_INVALID_LBA;
}

View File

@@ -1,5 +1,5 @@
/*
$Id: iso9660.c,v 1.18 2004/10/23 20:55:09 rocky Exp $
$Id: iso9660.c,v 1.19 2004/10/24 23:42:39 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.18 2004/10/23 20:55:09 rocky Exp $";
static const char _rcsid[] = "$Id: iso9660.c,v 1.19 2004/10/24 23:42:39 rocky Exp $";
/* some parameters... */
#define SYSTEM_ID "CD-RTOS CD-BRIDGE"
@@ -394,8 +394,9 @@ iso9660_set_pvd(void *pd,
ipd.type_m_path_table = to_732(path_table_m_extent);
cdio_assert (sizeof(ipd.root_directory_record) == 34);
memcpy(ipd.root_directory_record, root_dir, sizeof(ipd.root_directory_record));
ipd.root_directory_record[0] = 34;
memcpy(&(ipd.root_directory_record), root_dir,
sizeof(ipd.root_directory_record));
ipd.root_directory_record.length = 34;
iso9660_strncpy_pad (ipd.volume_set_id, VOLUME_SET_ID, 128, ISO9660_DCHARS);
@@ -920,7 +921,7 @@ iso9660_get_root_lsn(const iso9660_pvd_t *pvd)
if (NULL == pvd)
return CDIO_INVALID_LSN;
else {
iso9660_dir_t *idr = (void *) pvd->root_directory_record;
const iso9660_dir_t *idr = &(pvd->root_directory_record);
if (NULL == idr) return CDIO_INVALID_LSN;
return(from_733 (idr->extent));
}

View File

@@ -1,5 +1,5 @@
/*
$Id: iso9660_fs.c,v 1.30 2004/10/24 13:01:44 rocky Exp $
$Id: iso9660_fs.c,v 1.31 2004/10/24 23:42:39 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.30 2004/10/24 13:01:44 rocky Exp $";
static const char _rcsid[] = "$Id: iso9660_fs.c,v 1.31 2004/10/24 23:42:39 rocky Exp $";
/* Implementation of iso9660_t type */
struct _iso9660 {
@@ -89,7 +89,7 @@ iso9660_open_ext (const char *pathname,
if (NULL == p_iso->stream)
goto error;
if ( !iso9660_ifs_read_super(p_iso, iso_extension_mask) )
if ( !iso9660_ifs_read_superblock(p_iso, iso_extension_mask) )
goto error;
/* Determine if image has XA attributes. */
@@ -220,7 +220,6 @@ uint8_t iso9660_ifs_get_joliet_level(iso9660_t *p_iso)
return p_iso->i_joliet_level;
}
/*!
Return a string containing the preparer id with trailing
blanks removed.
@@ -374,13 +373,13 @@ iso9660_ifs_read_pvd (const iso9660_t *p_iso, /*out*/ iso9660_pvd_t *p_pvd)
/*!
Read the Supper block of an ISO 9660 image. This is the
Read the Super block of an ISO 9660 image. This is the
Primary Volume Descriptor (PVD) and perhaps a Supplemental Volume
Descriptor if (Joliet) extensions are acceptable.
*/
bool
iso9660_ifs_read_super (iso9660_t *p_iso,
iso_extension_mask_t iso_extension_mask)
iso9660_ifs_read_superblock (iso9660_t *p_iso,
iso_extension_mask_t iso_extension_mask)
{
iso9660_svd_t *p_svd; /* Secondary volume descriptor. */
@@ -425,18 +424,102 @@ iso9660_ifs_read_super (iso9660_t *p_iso,
Read the Primary Volume Descriptor for of CD.
*/
bool
iso9660_fs_read_mode2_pvd(const CdIo *cdio, /*out*/ iso9660_pvd_t *p_pvd,
bool b_form2)
iso9660_fs_read_pvd(const CdIo *p_cdio, /*out*/ iso9660_pvd_t *p_pvd)
{
if (cdio_read_mode2_sector (cdio, p_pvd, ISO_PVD_SECTOR, b_form2)) {
/* A bit of a hack, we'll assume track 1 contains ISO_PVD_SECTOR.*/
bool b_mode2 = cdio_get_track_green(p_cdio, 1);
char buf[CDIO_CD_FRAMESIZE_RAW] = { 0, };
int i_rc;
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);
if (i_rc) {
cdio_warn ("error reading PVD sector (%d)", ISO_PVD_SECTOR);
return false;
}
/* 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.
*/
cdio_assert (sizeof(buf) >= sizeof (iso9660_pvd_t));
memcpy(p_pvd, buf, sizeof(iso9660_pvd_t));
return check_pvd(p_pvd);
}
/*!
Read the Super block of an ISO 9660 image. This is the
Primary Volume Descriptor (PVD) and perhaps a Supplemental Volume
Descriptor if (Joliet) extensions are acceptable.
*/
bool
iso9660_fs_read_superblock (CdIo *p_cdio,
iso_extension_mask_t iso_extension_mask)
{
if (!p_cdio) return false;
{
generic_img_private_t *p_env = (generic_img_private_t *) p_cdio->env;
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);
int i_rc;
if ( !iso9660_fs_read_pvd(p_cdio, p_pvd) )
return false;
p_env->i_joliet_level = 0;
i_rc = (b_mode2)
? 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) {
/* 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.
*/
cdio_assert (sizeof(buf) >= sizeof (iso9660_svd_t));
memcpy(p_svd, buf, sizeof(iso9660_svd_t));
if ( ISO_VD_SUPPLEMENTARY == from_711(p_svd->type) ) {
if (p_svd->escape_sequences[0] == 0x25
&& p_svd->escape_sequences[1] == 0x2f) {
switch (p_svd->escape_sequences[2]) {
case 0x40:
if (iso_extension_mask & ISO_EXTENSION_JOLIET_LEVEL1)
p_env->i_joliet_level = 1;
break;
case 0x43:
if (iso_extension_mask & ISO_EXTENSION_JOLIET_LEVEL2)
p_env->i_joliet_level = 2;
break;
case 0x45:
if (iso_extension_mask & ISO_EXTENSION_JOLIET_LEVEL3)
p_env->i_joliet_level = 3;
break;
default:
cdio_info("Supplementary Volume Descriptor found, but not Joliet");
}
if (p_env->i_joliet_level > 0) {
cdio_info("Found Extension: Joliet Level %d",
p_env->i_joliet_level);
}
}
}
}
}
return true;
}
/*!
Seek to a position and then read n blocks. Size read is returned.
*/
@@ -562,27 +645,27 @@ iso9660_dir_to_name (const iso9660_dir_t *iso9660_dir)
Return a pointer to a ISO 9660 stat buffer or NULL if there's an error
*/
static iso9660_stat_t *
_fs_stat_root (const CdIo *cdio, bool b_mode2)
_fs_stat_root (CdIo *p_cdio)
{
char block[ISO_BLOCKSIZE] = { 0, };
const iso9660_pvd_t *pvd = (void *) &block;
iso9660_dir_t *iso9660_dir = (void *) pvd->root_directory_record;
iso9660_stat_t *stat;
generic_img_private_t *p_env;
iso9660_dir_t *p_iso9660_dir;
iso9660_stat_t *p_stat;
bool b_mode2 = cdio_get_track_green(p_cdio, 1);
if (b_mode2) {
if (cdio_read_mode2_sector (cdio, &block, ISO_PVD_SECTOR, false)) {
cdio_warn("Could not read Primary Volume descriptor (PVD).");
return NULL;
}
} else {
if (cdio_read_mode1_sector (cdio, &block, ISO_PVD_SECTOR, false)) {
cdio_warn("Could not read Primary Volume descriptor (PVD).");
return NULL;
}
/* FIXME try also with Joliet.*/
if ( !iso9660_fs_read_superblock (p_cdio, 0 /*ISO_EXTENSION_ALL*/) ) {
cdio_warn("Could not read ISO-9660 Superblock.");
return NULL;
}
stat = _iso9660_dir_to_statbuf (iso9660_dir, b_mode2, 0);
return stat;
p_env = (generic_img_private_t *) p_cdio->env;
p_iso9660_dir = p_env->i_joliet_level
? &(p_env->svd.root_directory_record)
: &(p_env->pvd.root_directory_record) ;
p_stat = _iso9660_dir_to_statbuf (p_iso9660_dir, b_mode2,
p_env->i_joliet_level);
return p_stat;
}
static iso9660_stat_t *
@@ -592,9 +675,9 @@ _fs_stat_iso_root (iso9660_t *p_iso)
iso9660_dir_t *p_iso9660_dir;
p_iso9660_dir = p_iso->i_joliet_level
? (iso9660_dir_t *) p_iso->svd.root_directory_record
: (iso9660_dir_t *) p_iso->pvd.root_directory_record ;
? &(p_iso->svd.root_directory_record)
: &(p_iso->pvd.root_directory_record) ;
p_stat = _iso9660_dir_to_statbuf (p_iso9660_dir, true,
p_iso->i_joliet_level);
return p_stat;
@@ -781,24 +864,27 @@ _fs_iso_stat_traverse (iso9660_t *p_iso, const iso9660_stat_t *_root,
Get file status for pathname into stat. NULL is returned on error.
*/
iso9660_stat_t *
iso9660_fs_stat (const CdIo *cdio, const char pathname[], bool b_mode2)
iso9660_fs_stat (CdIo *p_cdio, const char pathname[])
{
iso9660_stat_t *root;
char **splitpath;
iso9660_stat_t *stat;
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;
if (cdio == NULL) return NULL;
if (pathname == NULL) return NULL;
if (!p_cdio) return NULL;
if (!pathname) return NULL;
root = _fs_stat_root (cdio, b_mode2);
if (NULL == root) return NULL;
p_root = _fs_stat_root (p_cdio);
if (!p_root) return NULL;
splitpath = _cdio_strsplit (pathname, '/');
stat = _fs_stat_traverse (cdio, root, splitpath, b_mode2, false);
free(root);
_cdio_strfreev (splitpath);
b_mode2 = cdio_get_track_green(p_cdio, 1);
p_psz_splitpath = _cdio_strsplit (pathname, '/');
p_stat = _fs_stat_traverse (p_cdio, p_root, p_psz_splitpath, b_mode2, false);
free(p_root);
_cdio_strfreev (p_psz_splitpath);
return stat;
return p_stat;
}
/*!
@@ -808,25 +894,25 @@ iso9660_fs_stat (const CdIo *cdio, const char pathname[], bool b_mode2)
are lowercased.
*/
iso9660_stat_t *
iso9660_fs_stat_translate (const CdIo *cdio, const char pathname[],
iso9660_fs_stat_translate (CdIo *p_cdio, const char pathname[],
bool b_mode2)
{
iso9660_stat_t *root;
char **splitpath;
iso9660_stat_t *stat;
iso9660_stat_t *p_root;
char **p_psz_splitpath;
iso9660_stat_t *p_stat;
if (cdio == NULL) return NULL;
if (pathname == NULL) return NULL;
if (!p_cdio) return NULL;
if (pathname) return NULL;
root = _fs_stat_root (cdio, b_mode2);
if (NULL == root) return NULL;
p_root = _fs_stat_root (p_cdio);
if (!p_root) return NULL;
splitpath = _cdio_strsplit (pathname, '/');
stat = _fs_stat_traverse (cdio, root, splitpath, b_mode2, true);
free(root);
_cdio_strfreev (splitpath);
p_psz_splitpath = _cdio_strsplit (pathname, '/');
p_stat = _fs_stat_traverse (p_cdio, p_root, p_psz_splitpath, b_mode2, true);
free(p_root);
_cdio_strfreev (p_psz_splitpath);
return stat;
return p_stat;
}
/*!
@@ -860,24 +946,24 @@ iso9660_ifs_stat (iso9660_t *p_iso, const char pathname[])
are lowercased.
*/
iso9660_stat_t *
iso9660_ifs_stat_translate (iso9660_t *iso, const char pathname[])
iso9660_ifs_stat_translate (iso9660_t *p_iso, const char pathname[])
{
iso9660_stat_t *p_root;
char **splitpath;
iso9660_stat_t *stat;
char **p_psz_splitpath;
iso9660_stat_t *p_stat;
if (iso == NULL) return NULL;
if (pathname == NULL) return NULL;
if (!p_iso) return NULL;
if (!pathname) return NULL;
p_root = _fs_stat_iso_root (iso);
p_root = _fs_stat_iso_root (p_iso);
if (NULL == p_root) return NULL;
splitpath = _cdio_strsplit (pathname, '/');
stat = _fs_iso_stat_traverse (iso, p_root, splitpath, true);
p_psz_splitpath = _cdio_strsplit (pathname, '/');
p_stat = _fs_iso_stat_traverse (p_iso, p_root, p_psz_splitpath, true);
free(p_root);
_cdio_strfreev (splitpath);
_cdio_strfreev (p_psz_splitpath);
return stat;
return p_stat;
}
/*!
@@ -885,14 +971,14 @@ iso9660_ifs_stat_translate (iso9660_t *iso, const char pathname[])
of the files inside that. The caller must free the returned result.
*/
CdioList *
iso9660_fs_readdir (const CdIo *cdio, const char pathname[], bool b_mode2)
iso9660_fs_readdir (CdIo *p_cdio, const char pathname[], bool b_mode2)
{
iso9660_stat_t *p_stat;
if (NULL == cdio) return NULL;
if (NULL == pathname) return NULL;
if (!p_cdio) return NULL;
if (!pathname) return NULL;
p_stat = iso9660_fs_stat (cdio, pathname, b_mode2);
p_stat = iso9660_fs_stat (p_cdio, pathname);
if (!p_stat) return NULL;
if (p_stat->type != _STAT_DIR) {
@@ -915,11 +1001,11 @@ iso9660_fs_readdir (const CdIo *cdio, const char pathname[], bool b_mode2)
_dirbuf = _cdio_malloc (p_stat->secsize * ISO_BLOCKSIZE);
if (b_mode2) {
if (cdio_read_mode2_sectors (cdio, _dirbuf, p_stat->lsn, false,
if (cdio_read_mode2_sectors (p_cdio, _dirbuf, p_stat->lsn, false,
p_stat->secsize))
cdio_assert_not_reached ();
} else {
if (cdio_read_mode1_sectors (cdio, _dirbuf, p_stat->lsn, false,
if (cdio_read_mode1_sectors (p_cdio, _dirbuf, p_stat->lsn, false,
p_stat->secsize))
cdio_assert_not_reached ();
}
@@ -1014,9 +1100,9 @@ iso9660_ifs_readdir (iso9660_t *p_iso, const char pathname[])
}
static iso9660_stat_t *
find_fs_lsn_recurse (const CdIo *cdio, const char pathname[], lsn_t lsn)
find_fs_lsn_recurse (CdIo *p_cdio, const char pathname[], lsn_t lsn)
{
CdioList *entlist = iso9660_fs_readdir (cdio, pathname, true);
CdioList *entlist = iso9660_fs_readdir (p_cdio, pathname, true);
CdioList *dirlist = _cdio_list_new ();
CdioListNode *entnode;
@@ -1057,7 +1143,7 @@ find_fs_lsn_recurse (const CdIo *cdio, const char pathname[], lsn_t lsn)
_CDIO_LIST_FOREACH (entnode, dirlist)
{
char *_fullname = _cdio_list_node_data (entnode);
iso9660_stat_t *ret_stat = find_fs_lsn_recurse (cdio, _fullname, lsn);
iso9660_stat_t *ret_stat = find_fs_lsn_recurse (p_cdio, _fullname, lsn);
if (NULL != ret_stat) {
_cdio_list_free (dirlist, true);
@@ -1076,9 +1162,9 @@ find_fs_lsn_recurse (const CdIo *cdio, const char pathname[], lsn_t lsn)
Returns stat_t of entry if we found lsn, or NULL otherwise.
*/
iso9660_stat_t *
iso9660_find_fs_lsn(const CdIo *cdio, lsn_t lsn)
iso9660_find_fs_lsn(CdIo *p_cdio, lsn_t i_lsn)
{
return find_fs_lsn_recurse (cdio, "/", lsn);
return find_fs_lsn_recurse (p_cdio, "/", i_lsn);
}
/*!

View File

@@ -1,5 +1,5 @@
/*
$Id: cd-info.c,v 1.91 2004/10/22 01:13:38 rocky Exp $
$Id: cd-info.c,v 1.92 2004/10/24 23:42:39 rocky Exp $
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
Copyright (C) 1996, 1997, 1998 Gerd Knorr <kraxel@bytesex.org>
@@ -537,7 +537,7 @@ print_vcd_info(driver_id_t driver) {
#endif
static void
print_iso9660_recurse (const CdIo *p_cdio, const char pathname[],
print_iso9660_recurse (CdIo *p_cdio, const char pathname[],
cdio_fs_anal_t fs,
bool b_mode2)
{
@@ -639,7 +639,7 @@ read_iso9660_pvd(const CdIo *p_cdio, track_format_t track_format, /*out*/
static void
print_iso9660_fs (const CdIo *p_cdio, cdio_fs_anal_t fs,
print_iso9660_fs (CdIo *p_cdio, cdio_fs_anal_t fs,
track_format_t track_format)
{
iso9660_pvd_t pvd;