2003-03-24 19:01:09 +00:00
|
|
|
|
/*
|
2004-04-25 14:07:23 +00:00
|
|
|
|
$Id: _cdio_sunos.c,v 1.27 2004/04/25 14:07:23 rocky Exp $
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
|
|
|
|
|
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
2004-03-06 18:22:07 +00:00
|
|
|
|
Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
|
# include "config.h"
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2003-10-03 02:35:33 +00:00
|
|
|
|
#ifdef HAVE_STRING_H
|
2003-04-11 17:31:50 +00:00
|
|
|
|
#include <string.h>
|
2003-10-03 02:35:33 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
#ifdef HAVE_GLOB_H
|
|
|
|
|
|
#include <glob.h>
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2003-04-22 12:09:08 +00:00
|
|
|
|
#include <cdio/logging.h>
|
|
|
|
|
|
#include <cdio/sector.h>
|
|
|
|
|
|
#include <cdio/util.h>
|
2003-03-24 19:01:09 +00:00
|
|
|
|
#include "cdio_assert.h"
|
|
|
|
|
|
#include "cdio_private.h"
|
2003-09-14 09:34:17 +00:00
|
|
|
|
#include "scsi_mmc.h"
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
2003-04-10 04:13:41 +00:00
|
|
|
|
#define DEFAULT_CDIO_DEVICE "/vol/dev/aliases/cdrom0"
|
|
|
|
|
|
|
2003-03-24 19:01:09 +00:00
|
|
|
|
#ifdef HAVE_SOLARIS_CDROM
|
|
|
|
|
|
|
2004-04-25 14:07:23 +00:00
|
|
|
|
static const char _rcsid[] = "$Id: _cdio_sunos.c,v 1.27 2004/04/25 14:07:23 rocky Exp $";
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_CDIO_H
|
|
|
|
|
|
# include <sys/cdio.h> /* CDIOCALLOW etc... */
|
|
|
|
|
|
#else
|
|
|
|
|
|
#error "You need <sys/cdio.h> to have CDROM support"
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#include <sys/dkio.h>
|
|
|
|
|
|
#include <sys/scsi/generic/commands.h>
|
|
|
|
|
|
#include <sys/scsi/impl/uscsi.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
|
|
|
|
|
|
|
#define TOTAL_TRACKS (_obj->tochdr.cdth_trk1)
|
|
|
|
|
|
#define FIRST_TRACK_NUM (_obj->tochdr.cdth_trk0)
|
|
|
|
|
|
|
|
|
|
|
|
/* reader */
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
2003-03-29 17:32:00 +00:00
|
|
|
|
/* Things common to all drivers like this.
|
|
|
|
|
|
This must be first. */
|
|
|
|
|
|
generic_img_private_t gen;
|
|
|
|
|
|
|
2003-03-24 19:01:09 +00:00
|
|
|
|
enum {
|
|
|
|
|
|
_AM_NONE,
|
|
|
|
|
|
_AM_SUN_CTRL_ATAPI,
|
|
|
|
|
|
_AM_SUN_CTRL_SCSI
|
|
|
|
|
|
#if FINISHED
|
|
|
|
|
|
_AM_READ_CD,
|
|
|
|
|
|
_AM_READ_10
|
|
|
|
|
|
#endif
|
|
|
|
|
|
} access_mode;
|
|
|
|
|
|
|
2003-03-29 17:32:00 +00:00
|
|
|
|
|
2003-03-24 19:01:09 +00:00
|
|
|
|
/* Track information */
|
|
|
|
|
|
struct cdrom_tochdr tochdr;
|
|
|
|
|
|
struct cdrom_tocentry tocent[100]; /* entry info for each track */
|
|
|
|
|
|
|
|
|
|
|
|
} _img_private_t;
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
|
Initialize CD device.
|
|
|
|
|
|
*/
|
|
|
|
|
|
static bool
|
|
|
|
|
|
_cdio_init (_img_private_t *_obj)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
2003-03-30 13:01:22 +00:00
|
|
|
|
if (!cdio_generic_init(_obj)) return false;
|
|
|
|
|
|
|
2004-03-16 12:18:32 +00:00
|
|
|
|
_obj->access_mode = _AM_SUN_CTRL_SCSI;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2004-03-06 05:04:41 +00:00
|
|
|
|
Reads audio sectors from CD device into data starting from lsn.
|
2003-03-24 19:01:09 +00:00
|
|
|
|
Returns 0 if no error.
|
2004-03-06 05:04:41 +00:00
|
|
|
|
|
|
|
|
|
|
May have to check size of nblocks. There may be a limit that
|
|
|
|
|
|
can be read in one go, e.g. 25 blocks.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2003-03-24 19:01:09 +00:00
|
|
|
|
static int
|
2004-03-06 05:04:41 +00:00
|
|
|
|
_cdio_read_audio_sectors (void *env, void *data, lsn_t lsn,
|
|
|
|
|
|
unsigned int nblocks)
|
2003-03-24 19:01:09 +00:00
|
|
|
|
{
|
2004-03-06 05:04:41 +00:00
|
|
|
|
char buf[CDIO_CD_FRAMESIZE_RAW] = { 0, };
|
2003-03-24 19:01:09 +00:00
|
|
|
|
struct cdrom_msf *msf = (struct cdrom_msf *) &buf;
|
|
|
|
|
|
msf_t _msf;
|
2004-03-16 12:18:32 +00:00
|
|
|
|
struct cdrom_cdda cdda;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
2003-09-26 09:11:19 +00:00
|
|
|
|
_img_private_t *_obj = env;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
|
|
|
|
|
cdio_lba_to_msf (cdio_lsn_to_lba(lsn), &_msf);
|
2004-03-06 05:04:41 +00:00
|
|
|
|
msf->cdmsf_min0 = from_bcd8(_msf.m);
|
|
|
|
|
|
msf->cdmsf_sec0 = from_bcd8(_msf.s);
|
2003-03-24 19:01:09 +00:00
|
|
|
|
msf->cdmsf_frame0 = from_bcd8(_msf.f);
|
|
|
|
|
|
|
2003-03-30 13:01:22 +00:00
|
|
|
|
if (_obj->gen.ioctls_debugged == 75)
|
2003-03-24 19:01:09 +00:00
|
|
|
|
cdio_debug ("only displaying every 75th ioctl from now on");
|
|
|
|
|
|
|
2003-03-30 13:01:22 +00:00
|
|
|
|
if (_obj->gen.ioctls_debugged == 30 * 75)
|
2003-03-24 19:01:09 +00:00
|
|
|
|
cdio_debug ("only displaying every 30*75th ioctl from now on");
|
|
|
|
|
|
|
2003-03-30 13:01:22 +00:00
|
|
|
|
if (_obj->gen.ioctls_debugged < 75
|
|
|
|
|
|
|| (_obj->gen.ioctls_debugged < (30 * 75)
|
|
|
|
|
|
&& _obj->gen.ioctls_debugged % 75 == 0)
|
|
|
|
|
|
|| _obj->gen.ioctls_debugged % (30 * 75) == 0)
|
2004-03-06 05:04:41 +00:00
|
|
|
|
cdio_debug ("reading %d", lsn);
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
2003-03-30 13:01:22 +00:00
|
|
|
|
_obj->gen.ioctls_debugged++;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
2004-03-16 12:18:32 +00:00
|
|
|
|
cdda.cdda_addr = lsn;
|
|
|
|
|
|
cdda.cdda_length = nblocks;
|
|
|
|
|
|
cdda.cdda_data = (caddr_t) data;
|
|
|
|
|
|
if (ioctl (_obj->gen.fd, CDROMCDDA, &cdda) == -1) {
|
|
|
|
|
|
perror ("ioctl(..,CDROMCDDA,..)");
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
/* exit (EXIT_FAILURE); */
|
|
|
|
|
|
}
|
|
|
|
|
|
memcpy (data, buf, CDIO_CD_FRAMESIZE_RAW);
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2003-09-26 09:11:19 +00:00
|
|
|
|
/*!
|
2004-03-06 05:04:41 +00:00
|
|
|
|
Reads a single mode1 sector from cd device into data starting
|
|
|
|
|
|
from lsn. Returns 0 if no error.
|
|
|
|
|
|
*/
|
|
|
|
|
|
static int
|
|
|
|
|
|
_cdio_read_mode1_sector (void *env, void *data, lsn_t lsn,
|
2004-03-06 18:22:07 +00:00
|
|
|
|
bool b_form2)
|
2004-03-06 05:04:41 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
char buf[M2RAW_SECTOR_SIZE] = { 0, };
|
|
|
|
|
|
#if FIXED
|
|
|
|
|
|
do something here.
|
|
|
|
|
|
#else
|
|
|
|
|
|
if (0 > cdio_generic_lseek(env, CDIO_CD_FRAMESIZE*lsn, SEEK_SET))
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
if (0 > cdio_generic_read(env, buf, CDIO_CD_FRAMESIZE))
|
|
|
|
|
|
return -1;
|
2004-03-06 18:22:07 +00:00
|
|
|
|
memcpy (data, buf, b_form2 ? M2RAW_SECTOR_SIZE: CDIO_CD_FRAMESIZE);
|
2004-03-06 05:04:41 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
|
Reads nblocks of mode2 sectors from cd device into data starting
|
|
|
|
|
|
from lsn.
|
2003-09-26 09:11:19 +00:00
|
|
|
|
Returns 0 if no error.
|
2004-03-06 05:04:41 +00:00
|
|
|
|
*/
|
|
|
|
|
|
static int
|
|
|
|
|
|
_cdio_read_mode1_sectors (void *env, void *data, lsn_t lsn,
|
2004-03-06 18:22:07 +00:00
|
|
|
|
bool b_form2, unsigned int nblocks)
|
2004-03-06 05:04:41 +00:00
|
|
|
|
{
|
|
|
|
|
|
_img_private_t *_obj = env;
|
|
|
|
|
|
unsigned int i;
|
|
|
|
|
|
int retval;
|
2004-03-06 18:22:07 +00:00
|
|
|
|
unsigned int blocksize = b_form2 ? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE;
|
2003-09-26 09:11:19 +00:00
|
|
|
|
|
2004-03-06 05:04:41 +00:00
|
|
|
|
for (i = 0; i < nblocks; i++) {
|
|
|
|
|
|
if ( (retval = _cdio_read_mode1_sector (_obj,
|
|
|
|
|
|
((char *)data) + (blocksize * i),
|
2004-03-06 18:22:07 +00:00
|
|
|
|
lsn + i, b_form2)) )
|
2004-03-06 05:04:41 +00:00
|
|
|
|
return retval;
|
|
|
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
2003-09-26 09:11:19 +00:00
|
|
|
|
|
2004-03-06 05:04:41 +00:00
|
|
|
|
/*!
|
|
|
|
|
|
Reads a single mode2 sector from cd device into data starting from lsn.
|
|
|
|
|
|
Returns 0 if no error.
|
|
|
|
|
|
*/
|
2003-09-20 12:34:02 +00:00
|
|
|
|
static int
|
2004-03-06 05:04:41 +00:00
|
|
|
|
_cdio_read_mode2_sector (void *env, void *data, lsn_t lsn,
|
2004-03-06 18:22:07 +00:00
|
|
|
|
bool b_form2)
|
2003-09-20 12:34:02 +00:00
|
|
|
|
{
|
2004-03-16 12:18:32 +00:00
|
|
|
|
char buf[CDIO_CD_FRAMESIZE_RAW] = { 0, };
|
2003-10-14 04:44:52 +00:00
|
|
|
|
struct cdrom_msf *msf = (struct cdrom_msf *) &buf;
|
|
|
|
|
|
msf_t _msf;
|
2004-03-16 12:18:32 +00:00
|
|
|
|
int offset = 0;
|
|
|
|
|
|
struct cdrom_cdxa cd_read;
|
2003-10-14 04:44:52 +00:00
|
|
|
|
|
2003-09-26 09:11:19 +00:00
|
|
|
|
_img_private_t *_obj = env;
|
2003-09-20 12:34:02 +00:00
|
|
|
|
|
2003-10-14 04:44:52 +00:00
|
|
|
|
cdio_lba_to_msf (cdio_lsn_to_lba(lsn), &_msf);
|
2004-03-06 05:04:41 +00:00
|
|
|
|
msf->cdmsf_min0 = from_bcd8(_msf.m);
|
|
|
|
|
|
msf->cdmsf_sec0 = from_bcd8(_msf.s);
|
2003-10-14 04:44:52 +00:00
|
|
|
|
msf->cdmsf_frame0 = from_bcd8(_msf.f);
|
|
|
|
|
|
|
2003-04-10 04:13:41 +00:00
|
|
|
|
if (_obj->gen.ioctls_debugged == 75)
|
|
|
|
|
|
cdio_debug ("only displaying every 75th ioctl from now on");
|
|
|
|
|
|
|
|
|
|
|
|
if (_obj->gen.ioctls_debugged == 30 * 75)
|
|
|
|
|
|
cdio_debug ("only displaying every 30*75th ioctl from now on");
|
|
|
|
|
|
|
|
|
|
|
|
if (_obj->gen.ioctls_debugged < 75
|
|
|
|
|
|
|| (_obj->gen.ioctls_debugged < (30 * 75)
|
|
|
|
|
|
&& _obj->gen.ioctls_debugged % 75 == 0)
|
|
|
|
|
|
|| _obj->gen.ioctls_debugged % (30 * 75) == 0)
|
2004-03-06 05:04:41 +00:00
|
|
|
|
cdio_debug ("reading %2.2d:%2.2d:%2.2d",
|
|
|
|
|
|
msf->cdmsf_min0, msf->cdmsf_sec0, msf->cdmsf_frame0);
|
2003-04-10 04:13:41 +00:00
|
|
|
|
|
|
|
|
|
|
_obj->gen.ioctls_debugged++;
|
|
|
|
|
|
|
2004-03-16 12:18:32 +00:00
|
|
|
|
/* Using CDROMXA ioctl will actually use the same uscsi command
|
|
|
|
|
|
* as ATAPI, except we don't need to be root
|
|
|
|
|
|
*/
|
|
|
|
|
|
offset = CDIO_CD_XA_SYNC_HEADER;
|
|
|
|
|
|
cd_read.cdxa_addr = lsn;
|
|
|
|
|
|
cd_read.cdxa_data = buf;
|
|
|
|
|
|
cd_read.cdxa_length = 1;
|
|
|
|
|
|
cd_read.cdxa_format = CDROM_XA_SECTOR_DATA;
|
|
|
|
|
|
if (ioctl (_obj->gen.fd, CDROMCDXA, &cd_read) == -1) {
|
|
|
|
|
|
perror ("ioctl(..,CDROMCDXA,..)");
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
/* exit (EXIT_FAILURE); */
|
|
|
|
|
|
}
|
2004-03-06 05:04:41 +00:00
|
|
|
|
|
2004-03-06 18:22:07 +00:00
|
|
|
|
if (b_form2)
|
2004-03-16 12:18:32 +00:00
|
|
|
|
memcpy (data, buf + (offset-CDIO_CD_SUBHEADER_SIZE), M2RAW_SECTOR_SIZE);
|
2004-03-06 05:04:41 +00:00
|
|
|
|
else
|
2004-03-16 12:18:32 +00:00
|
|
|
|
memcpy (((char *)data), buf + offset, CDIO_CD_FRAMESIZE);
|
2003-04-10 04:13:41 +00:00
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2003-03-24 19:01:09 +00:00
|
|
|
|
/*!
|
|
|
|
|
|
Reads nblocks of mode2 sectors from cd device into data starting
|
|
|
|
|
|
from lsn.
|
|
|
|
|
|
Returns 0 if no error.
|
|
|
|
|
|
*/
|
|
|
|
|
|
static int
|
2004-03-06 05:04:41 +00:00
|
|
|
|
_cdio_read_mode2_sectors (void *env, void *data, lsn_t lsn,
|
2004-03-06 18:22:07 +00:00
|
|
|
|
bool b_form2, unsigned int nblocks)
|
2003-03-24 19:01:09 +00:00
|
|
|
|
{
|
2003-09-26 09:11:19 +00:00
|
|
|
|
_img_private_t *_obj = env;
|
|
|
|
|
|
unsigned int i;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
int retval;
|
2004-03-06 18:22:07 +00:00
|
|
|
|
unsigned int blocksize = b_form2 ? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < nblocks; i++) {
|
2004-03-06 05:04:41 +00:00
|
|
|
|
if ( (retval = _cdio_read_mode2_sector (_obj,
|
|
|
|
|
|
((char *)data) + (blocksize * i),
|
2004-03-06 18:22:07 +00:00
|
|
|
|
lsn + i, b_form2)) )
|
2004-03-06 05:04:41 +00:00
|
|
|
|
return retval;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2004-03-06 05:04:41 +00:00
|
|
|
|
|
2003-03-24 19:01:09 +00:00
|
|
|
|
/*!
|
|
|
|
|
|
Return the size of the CD in logical block address (LBA) units.
|
|
|
|
|
|
*/
|
|
|
|
|
|
static uint32_t
|
2003-09-26 09:11:19 +00:00
|
|
|
|
_cdio_stat_size (void *env)
|
2003-03-24 19:01:09 +00:00
|
|
|
|
{
|
2003-09-26 09:11:19 +00:00
|
|
|
|
_img_private_t *_obj = env;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
|
|
|
|
|
struct cdrom_tocentry tocent;
|
|
|
|
|
|
uint32_t size;
|
|
|
|
|
|
|
2003-04-06 17:57:20 +00:00
|
|
|
|
tocent.cdte_track = CDIO_CDROM_LEADOUT_TRACK;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
tocent.cdte_format = CDROM_LBA;
|
2003-03-29 17:32:00 +00:00
|
|
|
|
if (ioctl (_obj->gen.fd, CDROMREADTOCENTRY, &tocent) == -1)
|
2003-03-24 19:01:09 +00:00
|
|
|
|
{
|
|
|
|
|
|
perror ("ioctl(CDROMREADTOCENTRY)");
|
|
|
|
|
|
exit (EXIT_FAILURE);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
size = tocent.cdte_addr.lba;
|
|
|
|
|
|
|
|
|
|
|
|
return size;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2003-09-27 23:29:29 +00:00
|
|
|
|
Set the arg "key" with "value" in the source device.
|
|
|
|
|
|
Currently "source" and "access-mode" are valid keys.
|
|
|
|
|
|
"source" sets the source device in I/O operations
|
|
|
|
|
|
"access-mode" sets the the method of CD access
|
|
|
|
|
|
|
|
|
|
|
|
0 is returned if no error was found, and nonzero if there as an error.
|
2003-03-24 19:01:09 +00:00
|
|
|
|
*/
|
|
|
|
|
|
static int
|
2003-09-26 09:11:19 +00:00
|
|
|
|
_cdio_set_arg (void *env, const char key[], const char value[])
|
2003-03-24 19:01:09 +00:00
|
|
|
|
{
|
2003-09-26 09:11:19 +00:00
|
|
|
|
_img_private_t *_obj = env;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
|
|
|
|
|
if (!strcmp (key, "source"))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!value)
|
|
|
|
|
|
return -2;
|
|
|
|
|
|
|
2003-03-29 21:13:55 +00:00
|
|
|
|
free (_obj->gen.source_name);
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
2003-03-29 21:13:55 +00:00
|
|
|
|
_obj->gen.source_name = strdup (value);
|
2003-03-24 19:01:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
else if (!strcmp (key, "access-mode"))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!strcmp(value, "ATAPI"))
|
2004-03-16 12:18:32 +00:00
|
|
|
|
_obj->access_mode = _AM_SUN_CTRL_SCSI; /* force ATAPI to be SCSI */
|
2003-03-24 19:01:09 +00:00
|
|
|
|
else if (!strcmp(value, "SCSI"))
|
|
|
|
|
|
_obj->access_mode = _AM_SUN_CTRL_SCSI;
|
|
|
|
|
|
else
|
2003-09-27 23:29:29 +00:00
|
|
|
|
cdio_warn ("unknown access type: %s. ignored.", value);
|
2003-03-24 19:01:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
|
Read and cache the CD's Track Table of Contents and track info.
|
|
|
|
|
|
Return true if successful or false if an error.
|
|
|
|
|
|
*/
|
|
|
|
|
|
static bool
|
|
|
|
|
|
_cdio_read_toc (_img_private_t *_obj)
|
|
|
|
|
|
{
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
|
|
/* read TOC header */
|
2003-03-29 17:32:00 +00:00
|
|
|
|
if ( ioctl(_obj->gen.fd, CDROMREADTOCHDR, &_obj->tochdr) == -1 ) {
|
2003-03-24 19:01:09 +00:00
|
|
|
|
cdio_error("%s: %s\n",
|
|
|
|
|
|
"error in ioctl CDROMREADTOCHDR", strerror(errno));
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* read individual tracks */
|
|
|
|
|
|
for (i=_obj->tochdr.cdth_trk0; i<=_obj->tochdr.cdth_trk1; i++) {
|
|
|
|
|
|
_obj->tocent[i-1].cdte_track = i;
|
|
|
|
|
|
_obj->tocent[i-1].cdte_format = CDROM_MSF;
|
2003-03-29 17:32:00 +00:00
|
|
|
|
if ( ioctl(_obj->gen.fd, CDROMREADTOCENTRY, &_obj->tocent[i-1]) == -1 ) {
|
2003-03-24 19:01:09 +00:00
|
|
|
|
cdio_error("%s %d: %s\n",
|
|
|
|
|
|
"error in ioctl CDROMREADTOCENTRY for track",
|
|
|
|
|
|
i, strerror(errno));
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* read the lead-out track */
|
2003-04-06 17:57:20 +00:00
|
|
|
|
_obj->tocent[_obj->tochdr.cdth_trk1].cdte_track = CDIO_CDROM_LEADOUT_TRACK;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
_obj->tocent[_obj->tochdr.cdth_trk1].cdte_format = CDROM_MSF;
|
|
|
|
|
|
|
2003-03-29 17:32:00 +00:00
|
|
|
|
if (ioctl(_obj->gen.fd, CDROMREADTOCENTRY,
|
2003-03-24 19:01:09 +00:00
|
|
|
|
&_obj->tocent[_obj->tochdr.cdth_trk1]) == -1 ) {
|
|
|
|
|
|
cdio_error("%s: %s\n",
|
|
|
|
|
|
"error in ioctl CDROMREADTOCENTRY for lead-out",
|
|
|
|
|
|
strerror(errno));
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2003-09-01 15:11:36 +00:00
|
|
|
|
_obj->gen.toc_init = true;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
|
Eject media in CD drive. If successful, as a side effect we
|
|
|
|
|
|
also free obj.
|
|
|
|
|
|
*/
|
|
|
|
|
|
static int
|
2003-09-26 09:11:19 +00:00
|
|
|
|
_cdio_eject_media (void *env) {
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
2003-09-26 09:11:19 +00:00
|
|
|
|
_img_private_t *_obj = env;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
int ret;
|
|
|
|
|
|
|
2003-05-16 07:18:27 +00:00
|
|
|
|
close(_obj->gen.fd);
|
|
|
|
|
|
_obj->gen.fd = -1;
|
2003-03-29 17:32:00 +00:00
|
|
|
|
if (_obj->gen.fd > -1) {
|
|
|
|
|
|
if ((ret = ioctl(_obj->gen.fd, CDROMEJECT)) != 0) {
|
|
|
|
|
|
cdio_generic_free((void *) _obj);
|
2003-03-24 19:01:09 +00:00
|
|
|
|
cdio_error ("CDROMEJECT failed: %s\n", strerror(errno));
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return 2;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void *
|
|
|
|
|
|
_cdio_malloc_and_zero(size_t size) {
|
|
|
|
|
|
void *ptr;
|
|
|
|
|
|
|
|
|
|
|
|
if( !size ) size++;
|
|
|
|
|
|
|
|
|
|
|
|
if((ptr = malloc(size)) == NULL) {
|
|
|
|
|
|
cdio_error("malloc() failed: %s", strerror(errno));
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
memset(ptr, 0, size);
|
|
|
|
|
|
return ptr;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
|
Return the value associated with the key "arg".
|
|
|
|
|
|
*/
|
|
|
|
|
|
static const char *
|
2003-09-26 09:11:19 +00:00
|
|
|
|
_cdio_get_arg (void *env, const char key[])
|
2003-03-24 19:01:09 +00:00
|
|
|
|
{
|
2003-09-26 09:11:19 +00:00
|
|
|
|
_img_private_t *_obj = env;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
|
|
|
|
|
if (!strcmp (key, "source")) {
|
2003-03-29 21:13:55 +00:00
|
|
|
|
return _obj->gen.source_name;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
} else if (!strcmp (key, "access-mode")) {
|
|
|
|
|
|
switch (_obj->access_mode) {
|
|
|
|
|
|
case _AM_SUN_CTRL_ATAPI:
|
|
|
|
|
|
return "ATAPI";
|
|
|
|
|
|
case _AM_SUN_CTRL_SCSI:
|
|
|
|
|
|
return "SCSI";
|
|
|
|
|
|
case _AM_NONE:
|
|
|
|
|
|
return "no access method";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2003-09-26 09:11:19 +00:00
|
|
|
|
Return a string containing the default CD device if none is specified.
|
2003-03-24 19:01:09 +00:00
|
|
|
|
*/
|
2003-04-10 04:13:41 +00:00
|
|
|
|
char *
|
|
|
|
|
|
cdio_get_default_device_solaris(void)
|
2003-03-24 19:01:09 +00:00
|
|
|
|
{
|
|
|
|
|
|
char *volume_device;
|
|
|
|
|
|
char *volume_name;
|
|
|
|
|
|
char *volume_action;
|
|
|
|
|
|
char *device;
|
|
|
|
|
|
struct stat stb;
|
|
|
|
|
|
|
|
|
|
|
|
if ((volume_device = getenv("VOLUME_DEVICE")) != NULL &&
|
|
|
|
|
|
(volume_name = getenv("VOLUME_NAME")) != NULL &&
|
|
|
|
|
|
(volume_action = getenv("VOLUME_ACTION")) != NULL &&
|
|
|
|
|
|
strcmp(volume_action, "insert") == 0) {
|
|
|
|
|
|
|
|
|
|
|
|
device = _cdio_malloc_and_zero(strlen(volume_device)
|
|
|
|
|
|
+ strlen(volume_name) + 2);
|
|
|
|
|
|
if (device == NULL)
|
|
|
|
|
|
return strdup(DEFAULT_CDIO_DEVICE);
|
|
|
|
|
|
sprintf(device, "%s/%s", volume_device, volume_name);
|
|
|
|
|
|
if (stat(device, &stb) != 0 || !S_ISCHR(stb.st_mode)) {
|
|
|
|
|
|
free(device);
|
|
|
|
|
|
return strdup(DEFAULT_CDIO_DEVICE);
|
|
|
|
|
|
}
|
|
|
|
|
|
return device;
|
|
|
|
|
|
}
|
|
|
|
|
|
return strdup(DEFAULT_CDIO_DEVICE);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2004-04-25 03:52:37 +00:00
|
|
|
|
/*!
|
|
|
|
|
|
Return the the kind of drive capabilities of device.
|
|
|
|
|
|
|
|
|
|
|
|
Note: string is malloc'd so caller should free() then returned
|
|
|
|
|
|
string when done with it.
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
static cdio_drive_cap_t
|
|
|
|
|
|
_cdio_get_drive_cap_solaris (const void *env)
|
|
|
|
|
|
{
|
|
|
|
|
|
#if 1
|
|
|
|
|
|
struct uscsi_cmd my_cmd;
|
|
|
|
|
|
int32_t i_drivetype = 0;
|
|
|
|
|
|
char buf[192] = { 0, };
|
|
|
|
|
|
unsigned char my_rq_buf[26];
|
|
|
|
|
|
unsigned char my_scsi_cdb[6];
|
|
|
|
|
|
const _img_private_t *_obj = env;
|
|
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
|
|
|
|
memset(&my_scsi_cdb, 0, sizeof(my_scsi_cdb));
|
|
|
|
|
|
memset(&my_rq_buf, 0, sizeof(my_rq_buf));
|
|
|
|
|
|
|
|
|
|
|
|
/* Initialize my_scsi_cdb as a Mode Select(6) */
|
|
|
|
|
|
my_scsi_cdb[0] = CDIO_MMC_MODE_SENSE;
|
|
|
|
|
|
my_scsi_cdb[1] = 0x0;
|
|
|
|
|
|
my_scsi_cdb[2] = 0x2a; /* MODE_PAGE_CAPABILITIES*/;
|
|
|
|
|
|
my_scsi_cdb[3] = 0; /* Not used */
|
|
|
|
|
|
my_scsi_cdb[4] = 128;
|
|
|
|
|
|
my_scsi_cdb[5] = 0; /* Not used */
|
|
|
|
|
|
|
|
|
|
|
|
my_cmd.uscsi_flags = (USCSI_READ|USCSI_RQENABLE); /* We're going get data */
|
|
|
|
|
|
my_cmd.uscsi_timeout = 15; /* Allow 15 seconds for completion */
|
|
|
|
|
|
my_cmd.uscsi_cdb = my_scsi_cdb; /* We'll be using the array above for the CDB */
|
|
|
|
|
|
my_cmd.uscsi_bufaddr = buf; /* The block and page data is stored here */
|
|
|
|
|
|
my_cmd.uscsi_buflen = sizeof(buf);
|
|
|
|
|
|
my_cmd.uscsi_cdblen = 6; /* The CDB is 6 bytes long */
|
|
|
|
|
|
my_cmd.uscsi_rqlen = 24; /* The request sense buffer (only valid on a check condition) is 26 bytes long */
|
|
|
|
|
|
my_cmd.uscsi_rqbuf = my_rq_buf; /* Pointer to the request sense buffer */
|
|
|
|
|
|
|
|
|
|
|
|
rc = ioctl(_obj->gen.fd, USCSICMD, &my_cmd);
|
|
|
|
|
|
if(rc == 0) {
|
|
|
|
|
|
unsigned int n=buf[3]+4;
|
|
|
|
|
|
/* Reader? */
|
2004-04-25 14:07:23 +00:00
|
|
|
|
if (buf[n+5] & 0x01) i_drivetype |= CDIO_DRIVE_CAP_CD_AUDIO;
|
|
|
|
|
|
if (buf[n+2] & 0x02) i_drivetype |= CDIO_DRIVE_CAP_CD_RW;
|
|
|
|
|
|
if (buf[n+2] & 0x08) i_drivetype |= CDIO_DRIVE_CAP_DVD;
|
2004-04-25 03:52:37 +00:00
|
|
|
|
|
|
|
|
|
|
/* Writer? */
|
2004-04-25 14:07:23 +00:00
|
|
|
|
if (buf[n+3] & 0x01) i_drivetype |= CDIO_DRIVE_CAP_CD_R;
|
|
|
|
|
|
if (buf[n+3] & 0x10) i_drivetype |= CDIO_DRIVE_CAP_DVD_R;
|
|
|
|
|
|
if (buf[n+3] & 0x20) i_drivetype |= CDIO_DRIVE_CAP_DVD_RAM;
|
2004-04-25 03:52:37 +00:00
|
|
|
|
|
2004-04-25 14:07:23 +00:00
|
|
|
|
if (buf[n+6] & 0x08) i_drivetype |= CDIO_DRIVE_CAP_OPEN_TRAY;
|
|
|
|
|
|
if (buf[n+6] >> 5 != 0) i_drivetype |= CDIO_DRIVE_CAP_CLOSE_TRAY;
|
2004-04-25 03:52:37 +00:00
|
|
|
|
|
|
|
|
|
|
} else {
|
2004-04-25 14:07:23 +00:00
|
|
|
|
i_drivetype = CDIO_DRIVE_CAP_CD_AUDIO | CDIO_DRIVE_CAP_UNKNOWN;
|
2004-04-25 03:52:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
return i_drivetype;
|
|
|
|
|
|
|
|
|
|
|
|
#else
|
2004-04-25 14:07:23 +00:00
|
|
|
|
return CDIO_DRIVE_CAP_UNKNOWN | CDIO_DRIVE_CAP_CD_AUDIO
|
|
|
|
|
|
| CDIO_DRIVE_CAP_CD_RW;
|
2004-04-25 03:52:37 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
|
Return the the kind of drive capabilities of device.
|
|
|
|
|
|
|
|
|
|
|
|
Note: string is malloc'd so caller should free() then returned
|
|
|
|
|
|
string when done with it.
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
static char *
|
|
|
|
|
|
_cdio_get_mcn_solaris (const void *env)
|
|
|
|
|
|
{
|
|
|
|
|
|
#if 0
|
|
|
|
|
|
struct uscsi_cmd my_cmd;
|
|
|
|
|
|
char buf[192] = { 0, };
|
|
|
|
|
|
unsigned char my_rq_buf[32];
|
|
|
|
|
|
unsigned char my_scsi_cdb[6];
|
|
|
|
|
|
const _img_private_t *_obj = env;
|
|
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
|
|
|
|
memset(&my_scsi_cdb, 0, sizeof(my_scsi_cdb));
|
|
|
|
|
|
memset(&my_rq_buf, 0, sizeof(my_rq_buf));
|
|
|
|
|
|
|
|
|
|
|
|
my_scsi_cdb[0] = CDIO_MMC_GPCMD_READ_SUBCHANNEL;
|
|
|
|
|
|
my_scsi_cdb[1] = 0x0;
|
|
|
|
|
|
my_scsi_cdb[2] = 0x40;
|
|
|
|
|
|
my_scsi_cdb[3] = 02; /* Give media catalog number. */
|
|
|
|
|
|
my_scsi_cdb[4] = 0; /* Not used */
|
|
|
|
|
|
my_scsi_cdb[5] = 0; /* Not used */
|
|
|
|
|
|
my_scsi_cdb[6] = 0; /* Not used */
|
|
|
|
|
|
my_scsi_cdb[7] = 0; /* Not used */
|
|
|
|
|
|
my_scsi_cdb[8] = 28;
|
|
|
|
|
|
my_scsi_cdb[9] = 0; /* Not used */
|
|
|
|
|
|
|
|
|
|
|
|
my_cmd.uscsi_flags = (USCSI_READ|USCSI_RQENABLE); /* We're going get data */
|
|
|
|
|
|
my_cmd.uscsi_timeout = 15; /* Allow 15 seconds for completion */
|
|
|
|
|
|
my_cmd.uscsi_cdb = my_scsi_cdb; /* We'll be using the array above for the CDB */
|
|
|
|
|
|
my_cmd.uscsi_bufaddr = buf; /* The block and page data is stored here */
|
|
|
|
|
|
my_cmd.uscsi_buflen = sizeof(buf);
|
|
|
|
|
|
my_cmd.uscsi_cdblen = 6; /* The CDB is 6 bytes long */
|
|
|
|
|
|
my_cmd.uscsi_rqlen = 24; /* The request sense buffer (only valid on a check condition) is 26 bytes long */
|
|
|
|
|
|
my_cmd.uscsi_rqbuf = my_rq_buf; /* Pointer to the request sense buffer */
|
|
|
|
|
|
|
|
|
|
|
|
rc = ioctl(_obj->gen.fd, USCSICMD, &my_cmd);
|
|
|
|
|
|
if(rc == 0) {
|
|
|
|
|
|
return strdup(&buf[9]);
|
|
|
|
|
|
}
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
#else
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-03-24 19:01:09 +00:00
|
|
|
|
/*!
|
|
|
|
|
|
Return the number of of the first track.
|
|
|
|
|
|
CDIO_INVALID_TRACK is returned on error.
|
|
|
|
|
|
*/
|
|
|
|
|
|
static track_t
|
2003-09-26 09:11:19 +00:00
|
|
|
|
_cdio_get_first_track_num(void *env)
|
2003-03-24 19:01:09 +00:00
|
|
|
|
{
|
2003-09-26 09:11:19 +00:00
|
|
|
|
_img_private_t *_obj = env;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
2003-03-30 13:01:22 +00:00
|
|
|
|
if (!_obj->gen.toc_init) _cdio_read_toc (_obj) ;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
|
|
|
|
|
return FIRST_TRACK_NUM;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2004-04-25 03:52:37 +00:00
|
|
|
|
|
2003-03-24 19:01:09 +00:00
|
|
|
|
/*!
|
|
|
|
|
|
Return the number of tracks in the current medium.
|
|
|
|
|
|
*/
|
|
|
|
|
|
static track_t
|
2003-09-26 09:11:19 +00:00
|
|
|
|
_cdio_get_num_tracks(void *env)
|
2003-03-24 19:01:09 +00:00
|
|
|
|
{
|
2003-09-26 09:11:19 +00:00
|
|
|
|
_img_private_t *_obj = env;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
2003-03-30 13:01:22 +00:00
|
|
|
|
if (!_obj->gen.toc_init) _cdio_read_toc (_obj) ;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
|
|
|
|
|
return TOTAL_TRACKS;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
|
Get format of track.
|
|
|
|
|
|
*/
|
|
|
|
|
|
static track_format_t
|
2003-09-26 09:11:19 +00:00
|
|
|
|
_cdio_get_track_format(void *env, track_t track_num)
|
2003-03-24 19:01:09 +00:00
|
|
|
|
{
|
2003-09-26 09:11:19 +00:00
|
|
|
|
_img_private_t *_obj = env;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
2003-03-29 17:32:00 +00:00
|
|
|
|
if (!_obj->gen.init) _cdio_init(_obj);
|
2003-03-30 13:01:22 +00:00
|
|
|
|
if (!_obj->gen.toc_init) _cdio_read_toc (_obj) ;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
|
|
|
|
|
if (track_num > TOTAL_TRACKS || track_num == 0)
|
|
|
|
|
|
return TRACK_FORMAT_ERROR;
|
|
|
|
|
|
|
|
|
|
|
|
/* This is pretty much copied from the "badly broken" cdrom_count_tracks
|
|
|
|
|
|
in linux/cdrom.c.
|
|
|
|
|
|
*/
|
|
|
|
|
|
if (_obj->tocent[track_num-1].cdte_ctrl & CDROM_DATA_TRACK) {
|
|
|
|
|
|
if (_obj->tocent[track_num-1].cdte_format == 0x10)
|
|
|
|
|
|
return TRACK_FORMAT_CDI;
|
|
|
|
|
|
else if (_obj->tocent[track_num-1].cdte_format == 0x20)
|
|
|
|
|
|
return TRACK_FORMAT_XA;
|
|
|
|
|
|
else
|
|
|
|
|
|
return TRACK_FORMAT_DATA;
|
|
|
|
|
|
} else
|
|
|
|
|
|
return TRACK_FORMAT_AUDIO;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
|
Return true if we have XA data (green, mode2 form1) or
|
|
|
|
|
|
XA data (green, mode2 form2). That is track begins:
|
|
|
|
|
|
sync - header - subheader
|
|
|
|
|
|
12 4 - 8
|
|
|
|
|
|
|
|
|
|
|
|
FIXME: there's gotta be a better design for this and get_track_format?
|
|
|
|
|
|
*/
|
|
|
|
|
|
static bool
|
2003-09-26 09:11:19 +00:00
|
|
|
|
_cdio_get_track_green(void *env, track_t track_num)
|
2003-03-24 19:01:09 +00:00
|
|
|
|
{
|
2003-09-26 09:11:19 +00:00
|
|
|
|
_img_private_t *_obj = env;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
2003-03-29 17:32:00 +00:00
|
|
|
|
if (!_obj->gen.init) _cdio_init(_obj);
|
2003-03-30 13:01:22 +00:00
|
|
|
|
if (!_obj->gen.toc_init) _cdio_read_toc (_obj) ;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
2003-04-06 17:57:20 +00:00
|
|
|
|
if (track_num == CDIO_CDROM_LEADOUT_TRACK) track_num = TOTAL_TRACKS+1;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
|
|
|
|
|
if (track_num > TOTAL_TRACKS+1 || track_num == 0)
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
/* FIXME: Dunno if this is the right way, but it's what
|
|
|
|
|
|
I was using in cdinfo for a while.
|
|
|
|
|
|
*/
|
|
|
|
|
|
return ((_obj->tocent[track_num-1].cdte_ctrl & 2) != 0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
|
Return the starting MSF (minutes/secs/frames) for track number
|
|
|
|
|
|
track_num in obj. Tracks numbers start at 1.
|
|
|
|
|
|
The "leadout" track is specified either by
|
|
|
|
|
|
using track_num LEADOUT_TRACK or the total tracks+1.
|
2003-03-29 17:32:00 +00:00
|
|
|
|
False is returned if there is no entry.
|
2003-03-24 19:01:09 +00:00
|
|
|
|
*/
|
|
|
|
|
|
static bool
|
2003-09-26 09:11:19 +00:00
|
|
|
|
_cdio_get_track_msf(void *env, track_t track_num, msf_t *msf)
|
2003-03-24 19:01:09 +00:00
|
|
|
|
{
|
2003-09-26 09:11:19 +00:00
|
|
|
|
_img_private_t *_obj = env;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
|
|
|
|
|
if (NULL == msf) return false;
|
|
|
|
|
|
|
2003-03-29 17:32:00 +00:00
|
|
|
|
if (!_obj->gen.init) _cdio_init(_obj);
|
2003-03-30 13:01:22 +00:00
|
|
|
|
if (!_obj->gen.toc_init) _cdio_read_toc (_obj) ;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
2003-04-06 17:57:20 +00:00
|
|
|
|
if (track_num == CDIO_CDROM_LEADOUT_TRACK) track_num = TOTAL_TRACKS+1;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
|
|
|
|
|
if (track_num > TOTAL_TRACKS+1 || track_num == 0) {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
struct cdrom_tocentry *msf0 = &_obj->tocent[track_num-1];
|
|
|
|
|
|
msf->m = to_bcd8(msf0->cdte_addr.msf.minute);
|
|
|
|
|
|
msf->s = to_bcd8(msf0->cdte_addr.msf.second);
|
|
|
|
|
|
msf->f = to_bcd8(msf0->cdte_addr.msf.frame);
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2003-04-10 04:13:41 +00:00
|
|
|
|
#else
|
|
|
|
|
|
/*!
|
|
|
|
|
|
Return a string containing the default VCD device if none is specified.
|
|
|
|
|
|
*/
|
|
|
|
|
|
char *
|
|
|
|
|
|
cdio_get_default_device_solaris(void)
|
|
|
|
|
|
{
|
|
|
|
|
|
return strdup(DEFAULT_CDIO_DEVICE);
|
|
|
|
|
|
}
|
2004-04-25 03:52:37 +00:00
|
|
|
|
|
2003-03-24 19:01:09 +00:00
|
|
|
|
#endif /* HAVE_SOLARIS_CDROM */
|
|
|
|
|
|
|
2003-10-03 02:46:32 +00:00
|
|
|
|
/*!
|
|
|
|
|
|
Return an array of strings giving possible CD devices.
|
|
|
|
|
|
*/
|
|
|
|
|
|
char **
|
|
|
|
|
|
cdio_get_devices_solaris (void)
|
|
|
|
|
|
{
|
|
|
|
|
|
#ifndef HAVE_SOLARIS_CDROM
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
#else
|
|
|
|
|
|
char **drives = NULL;
|
|
|
|
|
|
unsigned int num_files=0;
|
|
|
|
|
|
#ifdef HAVE_GLOB_H
|
|
|
|
|
|
unsigned int i;
|
|
|
|
|
|
glob_t globbuf;
|
|
|
|
|
|
globbuf.gl_offs = 0;
|
|
|
|
|
|
glob("/vol/dev/aliases/cdrom*", GLOB_DOOFFS, NULL, &globbuf);
|
|
|
|
|
|
for (i=0; i<globbuf.gl_pathc; i++) {
|
|
|
|
|
|
cdio_add_device_list(&drives, globbuf.gl_pathv[i], &num_files);
|
|
|
|
|
|
}
|
|
|
|
|
|
globfree(&globbuf);
|
|
|
|
|
|
#else
|
|
|
|
|
|
cdio_add_device_list(&drives, DEFAULT_CDIO_DEVICE, &num_files);
|
|
|
|
|
|
#endif /*HAVE_GLOB_H*/
|
|
|
|
|
|
cdio_add_device_list(&drives, NULL, &num_files);
|
|
|
|
|
|
return drives;
|
|
|
|
|
|
#endif /*HAVE_SOLARIS_CDROM*/
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2003-03-24 19:01:09 +00:00
|
|
|
|
/*!
|
|
|
|
|
|
Initialization routine. This is the only thing that doesn't
|
|
|
|
|
|
get called via a function pointer. In fact *we* are the
|
|
|
|
|
|
ones to set that up.
|
|
|
|
|
|
*/
|
|
|
|
|
|
CdIo *
|
|
|
|
|
|
cdio_open_solaris (const char *source_name)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_SOLARIS_CDROM
|
|
|
|
|
|
CdIo *ret;
|
|
|
|
|
|
_img_private_t *_data;
|
|
|
|
|
|
|
|
|
|
|
|
cdio_funcs _funcs = {
|
|
|
|
|
|
.eject_media = _cdio_eject_media,
|
2003-03-29 17:32:00 +00:00
|
|
|
|
.free = cdio_generic_free,
|
2003-03-24 19:01:09 +00:00
|
|
|
|
.get_arg = _cdio_get_arg,
|
2003-10-03 02:35:33 +00:00
|
|
|
|
.get_devices = cdio_get_devices_solaris,
|
2003-04-10 04:13:41 +00:00
|
|
|
|
.get_default_device = cdio_get_default_device_solaris,
|
2004-04-25 03:52:37 +00:00
|
|
|
|
.get_drive_cap = _cdio_get_drive_cap_solaris,
|
2003-03-24 19:01:09 +00:00
|
|
|
|
.get_first_track_num= _cdio_get_first_track_num,
|
2004-04-25 03:52:37 +00:00
|
|
|
|
.get_mcn = _cdio_get_mcn_solaris,
|
2003-03-24 19:01:09 +00:00
|
|
|
|
.get_num_tracks = _cdio_get_num_tracks,
|
|
|
|
|
|
.get_track_format = _cdio_get_track_format,
|
|
|
|
|
|
.get_track_green = _cdio_get_track_green,
|
2003-03-29 17:32:00 +00:00
|
|
|
|
.get_track_lba = NULL, /* This could be implemented if need be. */
|
2003-03-24 19:01:09 +00:00
|
|
|
|
.get_track_msf = _cdio_get_track_msf,
|
2003-03-29 17:32:00 +00:00
|
|
|
|
.lseek = cdio_generic_lseek,
|
|
|
|
|
|
.read = cdio_generic_read,
|
2003-09-20 12:34:02 +00:00
|
|
|
|
.read_audio_sectors = _cdio_read_audio_sectors,
|
2004-03-06 05:04:41 +00:00
|
|
|
|
.read_mode1_sector = _cdio_read_mode1_sector,
|
|
|
|
|
|
.read_mode1_sectors = _cdio_read_mode1_sectors,
|
2003-04-10 04:13:41 +00:00
|
|
|
|
.read_mode2_sector = _cdio_read_mode2_sector,
|
|
|
|
|
|
.read_mode2_sectors = _cdio_read_mode2_sectors,
|
2003-03-24 19:01:09 +00:00
|
|
|
|
.stat_size = _cdio_stat_size,
|
|
|
|
|
|
.set_arg = _cdio_set_arg
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
_data = _cdio_malloc (sizeof (_img_private_t));
|
2003-03-29 20:28:05 +00:00
|
|
|
|
_data->gen.fd = -1;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
|
|
|
|
|
_cdio_set_arg(_data, "source", (NULL == source_name)
|
|
|
|
|
|
? DEFAULT_CDIO_DEVICE: source_name);
|
|
|
|
|
|
|
|
|
|
|
|
ret = cdio_new (_data, &_funcs);
|
|
|
|
|
|
if (ret == NULL) return NULL;
|
|
|
|
|
|
|
|
|
|
|
|
if (_cdio_init(_data))
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
else {
|
2003-03-29 17:32:00 +00:00
|
|
|
|
cdio_generic_free (_data);
|
2003-03-24 19:01:09 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
#endif /* HAVE_SOLARIS_CDROM */
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
|
cdio_have_solaris (void)
|
|
|
|
|
|
{
|
|
|
|
|
|
#ifdef HAVE_SOLARIS_CDROM
|
|
|
|
|
|
return true;
|
|
|
|
|
|
#else
|
|
|
|
|
|
return false;
|
|
|
|
|
|
#endif /* HAVE_SOLARIS_CDROM */
|
|
|
|
|
|
}
|
|
|
|
|
|
|