Straighten out mode1 vs mode2 mess.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: _cdio_bincue.c,v 1.22 2003/07/27 22:52:22 rocky Exp $
|
||||
$Id: _cdio_bincue.c,v 1.23 2003/08/31 14:26:06 rocky Exp $
|
||||
|
||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
Copyright (C) 2002,2003 Rocky Bernstein <rocky@panix.com>
|
||||
@@ -28,7 +28,7 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
static const char _rcsid[] = "$Id: _cdio_bincue.c,v 1.22 2003/07/27 22:52:22 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: _cdio_bincue.c,v 1.23 2003/08/31 14:26:06 rocky Exp $";
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
@@ -508,7 +508,7 @@ _cdio_read_mode2_sector (void *user_data, void *data, lsn_t lsn,
|
||||
*/
|
||||
static int
|
||||
_cdio_read_mode2_sectors (void *user_data, void *data, uint32_t lsn,
|
||||
bool mode2_form2, unsigned nblocks)
|
||||
bool mode2_form2, unsigned int nblocks)
|
||||
{
|
||||
_img_private_t *_obj = user_data;
|
||||
int i;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: cd_types.c,v 1.2 2003/08/31 03:35:36 rocky Exp $
|
||||
$Id: cd_types.c,v 1.3 2003/08/31 14:26:06 rocky Exp $
|
||||
|
||||
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -136,7 +136,7 @@ _cdio_read_block(CdIo *cdio, int superblock, uint32_t offset, uint8_t bufnum,
|
||||
offset+superblock, false))
|
||||
return -1;
|
||||
} else {
|
||||
if (0 > cdio_read_yellow_sector(cdio, buffer[bufnum],
|
||||
if (0 > cdio_read_mode1_sector(cdio, buffer[bufnum],
|
||||
offset+superblock, false))
|
||||
return -1;
|
||||
}
|
||||
|
||||
73
lib/cdio.c
73
lib/cdio.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: cdio.c,v 1.21 2003/06/22 22:41:29 rocky Exp $
|
||||
$Id: cdio.c,v 1.22 2003/08/31 14:26:06 rocky Exp $
|
||||
|
||||
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
@@ -35,7 +35,7 @@
|
||||
#include <cdio/logging.h>
|
||||
#include "cdio_private.h"
|
||||
|
||||
static const char _rcsid[] = "$Id: cdio.c,v 1.21 2003/06/22 22:41:29 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: cdio.c,v 1.22 2003/08/31 14:26:06 rocky Exp $";
|
||||
|
||||
|
||||
const char *track_format2str[6] =
|
||||
@@ -495,13 +495,13 @@ cdio_read_audio_sector (CdIo *obj, void *buf, lsn_t lsn)
|
||||
}
|
||||
|
||||
/*!
|
||||
Reads a single yellow mode1 or mode2 sector from cd device
|
||||
Reads a single mode1 form1 or form2 sector from cd device
|
||||
into data starting from lsn. Returns 0 if no error.
|
||||
*/
|
||||
int
|
||||
cdio_read_yellow_sector (CdIo *obj, void *data, uint32_t lsn, bool mode1)
|
||||
cdio_read_mode1_sector (CdIo *obj, void *data, lsn_t lsn, bool is_form2)
|
||||
{
|
||||
uint32_t size = mode1 ? CDIO_CD_FRAMESIZE : M2RAW_SECTOR_SIZE;
|
||||
uint32_t size = is_form2 ? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE ;
|
||||
char buf[M2RAW_SECTOR_SIZE] = { 0, };
|
||||
int ret;
|
||||
|
||||
@@ -516,7 +516,7 @@ cdio_read_yellow_sector (CdIo *obj, void *data, uint32_t lsn, bool mode1)
|
||||
memcpy (data, buf, size);
|
||||
return 0;
|
||||
} else {
|
||||
ret = cdio_read_mode2_sector(obj, data, lsn, mode1);
|
||||
ret = cdio_read_mode2_sector(obj, data, lsn, is_form2);
|
||||
if (ret == 0)
|
||||
memcpy (data, buf+CDIO_CD_SUBHEADER_SIZE, size);
|
||||
}
|
||||
@@ -524,6 +524,46 @@ cdio_read_yellow_sector (CdIo *obj, void *data, uint32_t lsn, bool mode1)
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
cdio_read_mode1_sectors (CdIo *obj, void *data, lsn_t lsn, bool is_form2,
|
||||
unsigned int num_sectors)
|
||||
{
|
||||
uint32_t size = is_form2 ? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE ;
|
||||
int retval;
|
||||
int i;
|
||||
|
||||
cdio_assert (obj != NULL);
|
||||
|
||||
for (i = 0; i < num_sectors; i++) {
|
||||
if ( (retval = cdio_read_mode1_sector (obj,
|
||||
((char *)data) + (size * i),
|
||||
lsn + i, is_form2)) )
|
||||
return retval;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Reads a single mode2 sector from cd device into data starting
|
||||
from lsn. Returns 0 if no error.
|
||||
*/
|
||||
int
|
||||
cdio_read_mode2_sector (CdIo *obj, void *buf, uint32_t lsn, bool is_form2)
|
||||
{
|
||||
cdio_assert (obj != NULL);
|
||||
cdio_assert (buf != NULL);
|
||||
cdio_assert (obj->op.read_mode2_sector != NULL
|
||||
|| obj->op.read_mode2_sectors != NULL);
|
||||
|
||||
if (obj->op.read_mode2_sector)
|
||||
return obj->op.read_mode2_sector (obj->user_data, buf, lsn, is_form2);
|
||||
|
||||
/* fallback */
|
||||
if (obj->op.read_mode2_sectors != NULL)
|
||||
return cdio_read_mode2_sectors (obj, buf, lsn, is_form2, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
cdio_read_mode2_sectors (CdIo *obj, void *buf, lsn_t lsn, bool mode2raw,
|
||||
unsigned num_sectors)
|
||||
@@ -536,27 +576,6 @@ cdio_read_mode2_sectors (CdIo *obj, void *buf, lsn_t lsn, bool mode2raw,
|
||||
mode2raw, num_sectors);
|
||||
}
|
||||
|
||||
/*!
|
||||
Reads a single mode2 sector from cd device into data starting
|
||||
from lsn. Returns 0 if no error.
|
||||
*/
|
||||
int
|
||||
cdio_read_mode2_sector (CdIo *obj, void *buf, uint32_t lsn, bool mode2raw)
|
||||
{
|
||||
cdio_assert (obj != NULL);
|
||||
cdio_assert (buf != NULL);
|
||||
cdio_assert (obj->op.read_mode2_sector != NULL
|
||||
|| obj->op.read_mode2_sectors != NULL);
|
||||
|
||||
if (obj->op.read_mode2_sector)
|
||||
return obj->op.read_mode2_sector (obj->user_data, buf, lsn, mode2raw);
|
||||
|
||||
/* fallback */
|
||||
if (obj->op.read_mode2_sectors != NULL)
|
||||
return cdio_read_mode2_sectors (obj, buf, lsn, mode2raw, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
cdio_stat_size (CdIo *obj)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: iso9660_fs.c,v 1.3 2003/08/31 09:11:25 rocky Exp $
|
||||
$Id: iso9660_fs.c,v 1.4 2003/08/31 14:26:06 rocky Exp $
|
||||
|
||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "bytesex.h"
|
||||
#include "ds.h"
|
||||
|
||||
static const char _rcsid[] = "$Id: iso9660_fs.c,v 1.3 2003/08/31 09:11:25 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: iso9660_fs.c,v 1.4 2003/08/31 14:26:06 rocky Exp $";
|
||||
|
||||
static void
|
||||
_idr2statbuf (const iso9660_dir_t *idr, iso9660_stat_t *buf)
|
||||
@@ -107,14 +107,19 @@ _idr2name (const iso9660_dir_t *idr)
|
||||
|
||||
|
||||
static void
|
||||
_fs_stat_root (CdIo *obj, iso9660_stat_t *buf)
|
||||
_fs_stat_root (CdIo *obj, iso9660_stat_t *buf, bool is_mode2)
|
||||
{
|
||||
char block[ISO_BLOCKSIZE] = { 0, };
|
||||
const iso9660_pvd_t *pvd = (void *) █
|
||||
const iso9660_dir_t *idr = (void *) pvd->root_directory_record;
|
||||
|
||||
if (cdio_read_mode2_sector (obj, &block, ISO_PVD_SECTOR, false))
|
||||
cdio_assert_not_reached ();
|
||||
if (is_mode2) {
|
||||
if (cdio_read_mode2_sector (obj, &block, ISO_PVD_SECTOR, false))
|
||||
cdio_assert_not_reached ();
|
||||
} else {
|
||||
if (cdio_read_mode1_sector (obj, &block, ISO_PVD_SECTOR, false))
|
||||
cdio_assert_not_reached ();
|
||||
}
|
||||
|
||||
_idr2statbuf (idr, buf);
|
||||
}
|
||||
@@ -187,8 +192,8 @@ _fs_stat_traverse (CdIo *obj, const iso9660_stat_t *_root, char **splitpath,
|
||||
}
|
||||
|
||||
int
|
||||
iso9660_fs_stat (CdIo *obj, const char pathname[],
|
||||
iso9660_stat_t *buf)
|
||||
iso9660_fs_stat (CdIo *obj, const char pathname[], iso9660_stat_t *buf,
|
||||
bool is_mode2)
|
||||
{
|
||||
iso9660_stat_t _root;
|
||||
int retval;
|
||||
@@ -198,7 +203,7 @@ iso9660_fs_stat (CdIo *obj, const char pathname[],
|
||||
cdio_assert (pathname != NULL);
|
||||
cdio_assert (buf != NULL);
|
||||
|
||||
_fs_stat_root (obj, &_root);
|
||||
_fs_stat_root (obj, &_root, is_mode2);
|
||||
|
||||
splitpath = _cdio_strsplit (pathname, '/');
|
||||
retval = _fs_stat_traverse (obj, &_root, splitpath, buf);
|
||||
@@ -208,14 +213,14 @@ iso9660_fs_stat (CdIo *obj, const char pathname[],
|
||||
}
|
||||
|
||||
void * /* list of char* -- caller must free it */
|
||||
iso9660_fs_readdir (CdIo *obj, const char pathname[])
|
||||
iso9660_fs_readdir (CdIo *obj, const char pathname[], bool is_mode2)
|
||||
{
|
||||
iso9660_stat_t _stat;
|
||||
|
||||
cdio_assert (obj != NULL);
|
||||
cdio_assert (pathname != NULL);
|
||||
|
||||
if (iso9660_fs_stat (obj, pathname, &_stat))
|
||||
if (iso9660_fs_stat (obj, pathname, &_stat, is_mode2))
|
||||
return NULL;
|
||||
|
||||
if (_stat.type != _STAT_DIR)
|
||||
@@ -234,9 +239,15 @@ iso9660_fs_readdir (CdIo *obj, const char pathname[])
|
||||
|
||||
_dirbuf = _cdio_malloc (_stat.secsize * ISO_BLOCKSIZE);
|
||||
|
||||
if (cdio_read_mode2_sectors (obj, _dirbuf, _stat.lsn, false,
|
||||
if (is_mode2) {
|
||||
if (cdio_read_mode2_sectors (obj, _dirbuf, _stat.lsn, false,
|
||||
_stat.secsize))
|
||||
cdio_assert_not_reached ();
|
||||
cdio_assert_not_reached ();
|
||||
} else {
|
||||
if (cdio_read_mode1_sectors (obj, _dirbuf, _stat.lsn, false,
|
||||
_stat.secsize))
|
||||
cdio_assert_not_reached ();
|
||||
}
|
||||
|
||||
while (offset < (_stat.secsize * ISO_BLOCKSIZE))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user