2003-03-24 19:01:09 +00:00
|
|
|
|
/*
|
2004-08-16 00:52:53 +00:00
|
|
|
|
$Id: _cdio_sunos.c,v 1.73 2004/08/16 00:52:53 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
|
|
|
|
|
|
|
2003-04-22 12:09:08 +00:00
|
|
|
|
#include <cdio/logging.h>
|
|
|
|
|
|
#include <cdio/sector.h>
|
|
|
|
|
|
#include <cdio/util.h>
|
2004-05-10 03:28:51 +00:00
|
|
|
|
#include <cdio/scsi_mmc.h>
|
2003-03-24 19:01:09 +00:00
|
|
|
|
#include "cdio_assert.h"
|
|
|
|
|
|
#include "cdio_private.h"
|
|
|
|
|
|
|
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-08-16 00:52:53 +00:00
|
|
|
|
static const char _rcsid[] = "$Id: _cdio_sunos.c,v 1.73 2004/08/16 00:52:53 rocky Exp $";
|
2004-06-13 20:38:58 +00:00
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_GLOB_H
|
|
|
|
|
|
#include <glob.h>
|
|
|
|
|
|
#endif
|
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>
|
2004-07-15 04:03:52 +00:00
|
|
|
|
#include "cdtext_private.h"
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
2004-08-03 11:30:42 +00:00
|
|
|
|
/* not defined in dkio.h yet */
|
|
|
|
|
|
#define DK_DVDRW 0x13
|
|
|
|
|
|
|
2003-03-24 19:01:09 +00:00
|
|
|
|
/* reader */
|
|
|
|
|
|
|
2004-04-30 06:54:15 +00:00
|
|
|
|
typedef enum {
|
2003-03-24 19:01:09 +00:00
|
|
|
|
_AM_NONE,
|
|
|
|
|
|
_AM_SUN_CTRL_ATAPI,
|
|
|
|
|
|
_AM_SUN_CTRL_SCSI
|
|
|
|
|
|
#if FINISHED
|
|
|
|
|
|
_AM_READ_CD,
|
|
|
|
|
|
_AM_READ_10
|
|
|
|
|
|
#endif
|
2004-04-30 06:54:15 +00:00
|
|
|
|
} access_mode_t;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
2003-03-29 17:32:00 +00:00
|
|
|
|
|
2004-04-30 06:54:15 +00:00
|
|
|
|
typedef struct {
|
|
|
|
|
|
/* Things common to all drivers like this.
|
|
|
|
|
|
This must be first. */
|
|
|
|
|
|
generic_img_private_t gen;
|
|
|
|
|
|
|
|
|
|
|
|
access_mode_t access_mode;
|
|
|
|
|
|
|
2004-07-15 04:03:52 +00:00
|
|
|
|
/* Some of the more OS specific things. */
|
2004-08-10 03:03:27 +00:00
|
|
|
|
/* Entry info for each track, add 1 for leadout. */
|
|
|
|
|
|
struct cdrom_tocentry tocent[CDIO_CD_MAX_TRACKS+1];
|
|
|
|
|
|
|
2003-03-24 19:01:09 +00:00
|
|
|
|
/* Track information */
|
|
|
|
|
|
struct cdrom_tochdr tochdr;
|
|
|
|
|
|
} _img_private_t;
|
|
|
|
|
|
|
2004-07-27 01:36:37 +00:00
|
|
|
|
static track_format_t get_track_format_solaris(void *p_user_data,
|
|
|
|
|
|
track_t i_track);
|
|
|
|
|
|
|
2004-04-30 06:54:15 +00:00
|
|
|
|
static access_mode_t
|
|
|
|
|
|
str_to_access_mode_sunos(const char *psz_access_mode)
|
|
|
|
|
|
{
|
2004-04-30 07:07:49 +00:00
|
|
|
|
const access_mode_t default_access_mode = _AM_SUN_CTRL_SCSI;
|
2004-04-30 06:54:15 +00:00
|
|
|
|
|
|
|
|
|
|
if (NULL==psz_access_mode) return default_access_mode;
|
|
|
|
|
|
|
2004-04-30 07:07:49 +00:00
|
|
|
|
if (!strcmp(psz_access_mode, "ATAPI"))
|
|
|
|
|
|
return _AM_SUN_CTRL_SCSI; /* force ATAPI to be SCSI */
|
|
|
|
|
|
else if (!strcmp(psz_access_mode, "SCSI"))
|
|
|
|
|
|
return _AM_SUN_CTRL_SCSI;
|
2004-04-30 06:54:15 +00:00
|
|
|
|
else {
|
|
|
|
|
|
cdio_warn ("unknown access type: %s. Default SCSI used.",
|
|
|
|
|
|
psz_access_mode);
|
|
|
|
|
|
return default_access_mode;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-03-24 19:01:09 +00:00
|
|
|
|
/*!
|
|
|
|
|
|
Initialize CD device.
|
|
|
|
|
|
*/
|
|
|
|
|
|
static bool
|
2004-07-23 02:23:49 +00:00
|
|
|
|
init_solaris (_img_private_t *env)
|
2003-03-24 19:01:09 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
2004-05-31 12:29:09 +00:00
|
|
|
|
if (!cdio_generic_init(env)) return false;
|
2003-03-30 13:01:22 +00:00
|
|
|
|
|
2004-05-31 12:29:09 +00:00
|
|
|
|
env->access_mode = _AM_SUN_CTRL_SCSI;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2004-07-23 02:23:49 +00:00
|
|
|
|
/*!
|
|
|
|
|
|
Run a SCSI MMC command.
|
|
|
|
|
|
|
2004-07-23 03:48:16 +00:00
|
|
|
|
p_user_data internal CD structure.
|
2004-07-28 01:09:59 +00:00
|
|
|
|
i_timeout_ms time in milliseconds we will wait for the command
|
|
|
|
|
|
to complete.
|
2004-07-23 03:48:16 +00:00
|
|
|
|
i_cdb Size of p_cdb
|
|
|
|
|
|
p_cdb CDB bytes.
|
2004-07-23 02:23:49 +00:00
|
|
|
|
e_direction direction the transfer is to go.
|
2004-07-23 03:48:16 +00:00
|
|
|
|
i_buf Size of buffer
|
|
|
|
|
|
p_buf Buffer for data, both sending and receiving
|
2004-07-23 02:23:49 +00:00
|
|
|
|
|
2004-07-23 03:48:16 +00:00
|
|
|
|
Return 0 if no error.
|
2004-07-23 02:23:49 +00:00
|
|
|
|
*/
|
|
|
|
|
|
static int
|
2004-07-28 01:09:59 +00:00
|
|
|
|
run_scsi_cmd_solaris( const void *p_user_data, unsigned int i_timeout_ms,
|
|
|
|
|
|
unsigned int i_cdb, const scsi_mmc_cdb_t *p_cdb,
|
|
|
|
|
|
scsi_mmc_direction_t e_direction,
|
|
|
|
|
|
unsigned int i_buf, /*in/out*/ void *p_buf )
|
2004-07-23 02:23:49 +00:00
|
|
|
|
{
|
|
|
|
|
|
const _img_private_t *p_env = p_user_data;
|
|
|
|
|
|
struct uscsi_cmd cgc;
|
|
|
|
|
|
|
|
|
|
|
|
memset (&cgc, 0, sizeof (struct uscsi_cmd));
|
|
|
|
|
|
cgc.uscsi_cdb = (caddr_t) p_cdb;
|
|
|
|
|
|
|
|
|
|
|
|
cgc.uscsi_flags = SCSI_MMC_DATA_READ == e_direction ?
|
|
|
|
|
|
USCSI_READ : USCSI_WRITE;
|
|
|
|
|
|
|
2004-07-28 01:09:59 +00:00
|
|
|
|
cgc.uscsi_timeout = msecs2secs(i_timeout_ms);
|
2004-07-23 02:23:49 +00:00
|
|
|
|
cgc.uscsi_bufaddr = p_buf;
|
|
|
|
|
|
cgc.uscsi_buflen = i_buf;
|
|
|
|
|
|
cgc.uscsi_cdblen = i_cdb;
|
|
|
|
|
|
|
|
|
|
|
|
return ioctl(p_env->gen.fd, USCSICMD, &cgc);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2003-03-24 19:01:09 +00:00
|
|
|
|
/*!
|
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-07-23 02:23:49 +00:00
|
|
|
|
_read_audio_sectors_solaris (void *p_user_data, void *data, lsn_t lsn,
|
2004-03-06 05:04:41 +00:00
|
|
|
|
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
|
|
|
|
|
2004-07-23 02:23:49 +00:00
|
|
|
|
_img_private_t *env = p_user_data;
|
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);
|
|
|
|
|
|
|
2004-05-31 12:29:09 +00:00
|
|
|
|
if (env->gen.ioctls_debugged == 75)
|
2003-03-24 19:01:09 +00:00
|
|
|
|
cdio_debug ("only displaying every 75th ioctl from now on");
|
|
|
|
|
|
|
2004-05-31 12:29:09 +00:00
|
|
|
|
if (env->gen.ioctls_debugged == 30 * 75)
|
2003-03-24 19:01:09 +00:00
|
|
|
|
cdio_debug ("only displaying every 30*75th ioctl from now on");
|
|
|
|
|
|
|
2004-05-31 12:29:09 +00:00
|
|
|
|
if (env->gen.ioctls_debugged < 75
|
|
|
|
|
|
|| (env->gen.ioctls_debugged < (30 * 75)
|
|
|
|
|
|
&& env->gen.ioctls_debugged % 75 == 0)
|
|
|
|
|
|
|| env->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
|
|
|
|
|
2004-05-31 12:29:09 +00:00
|
|
|
|
env->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;
|
2004-05-31 12:29:09 +00:00
|
|
|
|
if (ioctl (env->gen.fd, CDROMCDDA, &cdda) == -1) {
|
2004-03-16 12:18:32 +00:00
|
|
|
|
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
|
2004-07-17 22:16:46 +00:00
|
|
|
|
_read_mode1_sector_solaris (void *env, void *data, lsn_t lsn,
|
|
|
|
|
|
bool b_form2)
|
2004-03-06 05:04:41 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
#if FIXED
|
|
|
|
|
|
do something here.
|
|
|
|
|
|
#else
|
2004-06-27 21:57:45 +00:00
|
|
|
|
return cdio_generic_read_form1_sector(env, data, lsn);
|
2004-03-06 05:04:41 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
|
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
|
2004-07-23 02:23:49 +00:00
|
|
|
|
_read_mode1_sectors_solaris (void *p_user_data, void *p_data, lsn_t lsn,
|
2004-07-17 22:16:46 +00:00
|
|
|
|
bool b_form2, unsigned int nblocks)
|
2004-03-06 05:04:41 +00:00
|
|
|
|
{
|
2004-07-23 02:23:49 +00:00
|
|
|
|
_img_private_t *p_env = p_user_data;
|
2004-03-06 05:04:41 +00:00
|
|
|
|
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++) {
|
2004-07-23 02:23:49 +00:00
|
|
|
|
if ( (retval = _read_mode1_sector_solaris (p_env,
|
|
|
|
|
|
((char *)p_data) + (blocksize * i),
|
2004-07-17 22:16:46 +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-07-23 02:23:49 +00:00
|
|
|
|
_read_mode2_sector_solaris (void *p_user_data, void *p_data, lsn_t lsn,
|
2004-07-17 22:16:46 +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
|
|
|
|
|
2004-07-23 02:23:49 +00:00
|
|
|
|
_img_private_t *p_env = p_user_data;
|
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);
|
|
|
|
|
|
|
2004-07-23 02:23:49 +00:00
|
|
|
|
if (p_env->gen.ioctls_debugged == 75)
|
2003-04-10 04:13:41 +00:00
|
|
|
|
cdio_debug ("only displaying every 75th ioctl from now on");
|
|
|
|
|
|
|
2004-07-23 02:23:49 +00:00
|
|
|
|
if (p_env->gen.ioctls_debugged == 30 * 75)
|
2003-04-10 04:13:41 +00:00
|
|
|
|
cdio_debug ("only displaying every 30*75th ioctl from now on");
|
|
|
|
|
|
|
2004-07-23 02:23:49 +00:00
|
|
|
|
if (p_env->gen.ioctls_debugged < 75
|
|
|
|
|
|
|| (p_env->gen.ioctls_debugged < (30 * 75)
|
|
|
|
|
|
&& p_env->gen.ioctls_debugged % 75 == 0)
|
|
|
|
|
|
|| p_env->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
|
|
|
|
|
2004-07-23 02:23:49 +00:00
|
|
|
|
p_env->gen.ioctls_debugged++;
|
2003-04-10 04:13:41 +00:00
|
|
|
|
|
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;
|
2004-07-23 02:23:49 +00:00
|
|
|
|
if (ioctl (p_env->gen.fd, CDROMCDXA, &cd_read) == -1) {
|
2004-03-16 12:18:32 +00:00
|
|
|
|
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-07-23 02:23:49 +00:00
|
|
|
|
memcpy (p_data, buf + (offset-CDIO_CD_SUBHEADER_SIZE), M2RAW_SECTOR_SIZE);
|
2004-03-06 05:04:41 +00:00
|
|
|
|
else
|
2004-07-23 02:23:49 +00:00
|
|
|
|
memcpy (((char *)p_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-07-23 02:23:49 +00:00
|
|
|
|
_read_mode2_sectors_solaris (void *p_user_data, void *data, lsn_t lsn,
|
2004-07-17 22:16:46 +00:00
|
|
|
|
bool b_form2, unsigned int nblocks)
|
2003-03-24 19:01:09 +00:00
|
|
|
|
{
|
2004-07-23 02:23:49 +00:00
|
|
|
|
_img_private_t *env = p_user_data;
|
2003-09-26 09:11:19 +00:00
|
|
|
|
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-07-17 22:16:46 +00:00
|
|
|
|
if ( (retval = _read_mode2_sector_solaris (env,
|
2004-03-06 05:04:41 +00:00
|
|
|
|
((char *)data) + (blocksize * i),
|
2004-07-17 22:16:46 +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
|
2004-07-23 02:23:49 +00:00
|
|
|
|
_cdio_stat_size (void *p_user_data)
|
2003-03-24 19:01:09 +00:00
|
|
|
|
{
|
2004-07-23 02:23:49 +00:00
|
|
|
|
_img_private_t *env = p_user_data;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
|
|
|
|
|
struct cdrom_tocentry tocent;
|
|
|
|
|
|
uint32_t size;
|
|
|
|
|
|
|
2004-07-17 15:43:57 +00:00
|
|
|
|
tocent.cdte_track = CDIO_CDROM_LEADOUT_TRACK;
|
|
|
|
|
|
tocent.cdte_format = CDIO_CDROM_LBA;
|
2004-05-31 12:29:09 +00:00
|
|
|
|
if (ioctl (env->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
|
2004-07-23 02:23:49 +00:00
|
|
|
|
_set_arg_solaris (void *p_user_data, const char key[], const char value[])
|
2003-03-24 19:01:09 +00:00
|
|
|
|
{
|
2004-07-23 02:23:49 +00:00
|
|
|
|
_img_private_t *env = p_user_data;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
|
|
|
|
|
if (!strcmp (key, "source"))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!value)
|
|
|
|
|
|
return -2;
|
|
|
|
|
|
|
2004-05-31 12:29:09 +00:00
|
|
|
|
free (env->gen.source_name);
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
2004-05-31 12:29:09 +00:00
|
|
|
|
env->gen.source_name = strdup (value);
|
2003-03-24 19:01:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
else if (!strcmp (key, "access-mode"))
|
|
|
|
|
|
{
|
2004-05-31 12:29:09 +00:00
|
|
|
|
env->access_mode = str_to_access_mode_sunos(key);
|
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
|
2004-07-29 02:16:20 +00:00
|
|
|
|
read_toc_solaris (void *p_user_data)
|
2003-03-24 19:01:09 +00:00
|
|
|
|
{
|
2004-07-29 02:16:20 +00:00
|
|
|
|
_img_private_t *p_env = p_user_data;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
|
|
/* read TOC header */
|
2004-07-27 01:36:37 +00:00
|
|
|
|
if ( ioctl(p_env->gen.fd, CDROMREADTOCHDR, &p_env->tochdr) == -1 ) {
|
2004-06-25 21:10:36 +00:00
|
|
|
|
cdio_warn("%s: %s\n",
|
2003-03-24 19:01:09 +00:00
|
|
|
|
"error in ioctl CDROMREADTOCHDR", strerror(errno));
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2004-07-27 01:06:01 +00:00
|
|
|
|
p_env->gen.i_first_track = p_env->tochdr.cdth_trk0;
|
2004-07-29 02:16:20 +00:00
|
|
|
|
p_env->gen.i_tracks = p_env->tochdr.cdth_trk1;
|
2004-07-27 01:06:01 +00:00
|
|
|
|
|
2003-03-24 19:01:09 +00:00
|
|
|
|
/* read individual tracks */
|
2004-07-29 02:27:04 +00:00
|
|
|
|
for (i=p_env->gen.i_first_track; i<=p_env->gen.i_tracks; i++) {
|
2004-07-27 01:36:37 +00:00
|
|
|
|
p_env->tocent[i-1].cdte_track = i;
|
|
|
|
|
|
p_env->tocent[i-1].cdte_format = CDIO_CDROM_MSF;
|
|
|
|
|
|
if ( ioctl(p_env->gen.fd, CDROMREADTOCENTRY, &p_env->tocent[i-1]) == -1 ) {
|
2004-06-25 21:10:36 +00:00
|
|
|
|
cdio_warn("%s %d: %s\n",
|
2003-03-24 19:01:09 +00:00
|
|
|
|
"error in ioctl CDROMREADTOCENTRY for track",
|
|
|
|
|
|
i, strerror(errno));
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* read the lead-out track */
|
2004-07-27 01:36:37 +00:00
|
|
|
|
p_env->tocent[p_env->tochdr.cdth_trk1].cdte_track = CDIO_CDROM_LEADOUT_TRACK;
|
|
|
|
|
|
p_env->tocent[p_env->tochdr.cdth_trk1].cdte_format = CDIO_CDROM_MSF;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
2004-07-27 01:36:37 +00:00
|
|
|
|
if (ioctl(p_env->gen.fd, CDROMREADTOCENTRY,
|
|
|
|
|
|
&p_env->tocent[p_env->tochdr.cdth_trk1]) == -1 ) {
|
2004-06-25 21:10:36 +00:00
|
|
|
|
cdio_warn("%s: %s\n",
|
2003-03-24 19:01:09 +00:00
|
|
|
|
"error in ioctl CDROMREADTOCENTRY for lead-out",
|
|
|
|
|
|
strerror(errno));
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2004-07-27 01:36:37 +00:00
|
|
|
|
p_env->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
|
2004-07-27 02:45:16 +00:00
|
|
|
|
eject_media_solaris (void *p_user_data) {
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
2004-07-23 02:23:49 +00:00
|
|
|
|
_img_private_t *env = p_user_data;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
int ret;
|
|
|
|
|
|
|
2004-05-31 12:29:09 +00:00
|
|
|
|
close(env->gen.fd);
|
|
|
|
|
|
env->gen.fd = -1;
|
|
|
|
|
|
if (env->gen.fd > -1) {
|
|
|
|
|
|
if ((ret = ioctl(env->gen.fd, CDROMEJECT)) != 0) {
|
|
|
|
|
|
cdio_generic_free((void *) env);
|
2004-06-25 21:10:36 +00:00
|
|
|
|
cdio_warn ("CDROMEJECT failed: %s\n", strerror(errno));
|
2003-03-24 19:01:09 +00:00
|
|
|
|
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) {
|
2004-06-25 21:10:36 +00:00
|
|
|
|
cdio_warn("malloc() failed: %s", strerror(errno));
|
2003-03-24 19:01:09 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
memset(ptr, 0, size);
|
|
|
|
|
|
return ptr;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
|
Return the value associated with the key "arg".
|
|
|
|
|
|
*/
|
|
|
|
|
|
static const char *
|
2004-07-27 02:45:16 +00:00
|
|
|
|
get_arg_solaris (void *p_user_data, const char key[])
|
2003-03-24 19:01:09 +00:00
|
|
|
|
{
|
2004-07-23 02:23:49 +00:00
|
|
|
|
_img_private_t *env = p_user_data;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
|
|
|
|
|
if (!strcmp (key, "source")) {
|
2004-05-31 12:29:09 +00:00
|
|
|
|
return env->gen.source_name;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
} else if (!strcmp (key, "access-mode")) {
|
2004-05-31 12:29:09 +00:00
|
|
|
|
switch (env->access_mode) {
|
2003-03-24 19:01:09 +00:00
|
|
|
|
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;
|
|
|
|
|
|
}
|
2004-08-03 11:30:42 +00:00
|
|
|
|
/* Check if it could be a Solaris media*/
|
|
|
|
|
|
if((stat(DEFAULT_CDIO_DEVICE, &stb) == 0) && S_ISDIR(stb.st_mode)) {
|
|
|
|
|
|
device = _cdio_malloc_and_zero(strlen(DEFAULT_CDIO_DEVICE) + 4);
|
|
|
|
|
|
sprintf(device, "%s/s0", DEFAULT_CDIO_DEVICE);
|
|
|
|
|
|
return device;
|
|
|
|
|
|
}
|
2003-03-24 19:01:09 +00:00
|
|
|
|
return strdup(DEFAULT_CDIO_DEVICE);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2004-08-03 11:30:42 +00:00
|
|
|
|
/*!
|
|
|
|
|
|
Get disc type associated with cd object.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
static discmode_t
|
|
|
|
|
|
get_discmode_solaris (void *p_user_data)
|
|
|
|
|
|
{
|
|
|
|
|
|
_img_private_t *p_env = p_user_data;
|
|
|
|
|
|
track_t i_track;
|
|
|
|
|
|
discmode_t discmode=CDIO_DISC_MODE_NO_INFO;
|
|
|
|
|
|
struct dk_minfo media;
|
|
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
|
|
|
|
/* Get the media info */
|
|
|
|
|
|
if((ret = ioctl(p_env->gen.fd, DKIOCGMEDIAINFO, &media)) != 0) {
|
|
|
|
|
|
cdio_warn ("DKIOCGMEDIAINFO failed: %s\n", strerror(errno));
|
|
|
|
|
|
return CDIO_DISC_MODE_NO_INFO;
|
|
|
|
|
|
}
|
|
|
|
|
|
switch(media.dki_media_type) {
|
|
|
|
|
|
case DK_CDROM:
|
|
|
|
|
|
case DK_CDR:
|
|
|
|
|
|
case DK_CDRW:
|
|
|
|
|
|
/* Do cdrom detection */
|
|
|
|
|
|
break;
|
|
|
|
|
|
case DK_DVDROM: return CDIO_DISC_MODE_DVD_ROM;
|
|
|
|
|
|
case DK_DVDR: discmode = CDIO_DISC_MODE_DVD_R;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case DK_DVDRAM: discmode = CDIO_DISC_MODE_DVD_RAM;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case DK_DVDRW:
|
|
|
|
|
|
case DK_DVDRW+1: discmode = CDIO_DISC_MODE_DVD_RW;
|
|
|
|
|
|
break;
|
|
|
|
|
|
default: /* no valid match */
|
|
|
|
|
|
return CDIO_DISC_MODE_NO_INFO;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if((discmode == CDIO_DISC_MODE_DVD_RAM ||
|
|
|
|
|
|
discmode == CDIO_DISC_MODE_DVD_RW ||
|
|
|
|
|
|
discmode == CDIO_DISC_MODE_DVD_R)) {
|
|
|
|
|
|
/* Fallback to uscsi if we can */
|
|
|
|
|
|
if(geteuid() == 0)
|
|
|
|
|
|
return get_discmode_solaris(p_user_data);
|
|
|
|
|
|
return discmode;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!p_env->gen.toc_init)
|
|
|
|
|
|
read_toc_solaris (p_env);
|
|
|
|
|
|
|
|
|
|
|
|
if (!p_env->gen.toc_init)
|
|
|
|
|
|
return CDIO_DISC_MODE_NO_INFO;
|
|
|
|
|
|
|
|
|
|
|
|
for (i_track = p_env->gen.i_first_track;
|
|
|
|
|
|
i_track < p_env->gen.i_first_track + p_env->tochdr.cdth_trk1 ;
|
|
|
|
|
|
i_track ++) {
|
|
|
|
|
|
track_format_t track_fmt=get_track_format_solaris(p_env, i_track);
|
|
|
|
|
|
|
|
|
|
|
|
switch(track_fmt) {
|
|
|
|
|
|
case TRACK_FORMAT_AUDIO:
|
|
|
|
|
|
switch(discmode) {
|
|
|
|
|
|
case CDIO_DISC_MODE_NO_INFO:
|
|
|
|
|
|
discmode = CDIO_DISC_MODE_CD_DA;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case CDIO_DISC_MODE_CD_DA:
|
|
|
|
|
|
case CDIO_DISC_MODE_CD_MIXED:
|
|
|
|
|
|
case CDIO_DISC_MODE_ERROR:
|
|
|
|
|
|
/* No change*/
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
discmode = CDIO_DISC_MODE_CD_MIXED;
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case TRACK_FORMAT_XA:
|
|
|
|
|
|
switch(discmode) {
|
|
|
|
|
|
case CDIO_DISC_MODE_NO_INFO:
|
|
|
|
|
|
discmode = CDIO_DISC_MODE_CD_XA;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case CDIO_DISC_MODE_CD_XA:
|
|
|
|
|
|
case CDIO_DISC_MODE_CD_MIXED:
|
|
|
|
|
|
case CDIO_DISC_MODE_ERROR:
|
|
|
|
|
|
/* No change*/
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
discmode = CDIO_DISC_MODE_CD_MIXED;
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case TRACK_FORMAT_DATA:
|
|
|
|
|
|
switch(discmode) {
|
|
|
|
|
|
case CDIO_DISC_MODE_NO_INFO:
|
|
|
|
|
|
discmode = CDIO_DISC_MODE_CD_DATA;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case CDIO_DISC_MODE_CD_DATA:
|
|
|
|
|
|
case CDIO_DISC_MODE_CD_MIXED:
|
|
|
|
|
|
case CDIO_DISC_MODE_ERROR:
|
|
|
|
|
|
/* No change*/
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
discmode = CDIO_DISC_MODE_CD_MIXED;
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case TRACK_FORMAT_ERROR:
|
|
|
|
|
|
default:
|
|
|
|
|
|
discmode = CDIO_DISC_MODE_ERROR;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return discmode;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2003-03-24 19:01:09 +00:00
|
|
|
|
/*!
|
|
|
|
|
|
Get format of track.
|
|
|
|
|
|
*/
|
|
|
|
|
|
static track_format_t
|
2004-07-27 01:36:37 +00:00
|
|
|
|
get_track_format_solaris(void *p_user_data, track_t i_track)
|
2003-03-24 19:01:09 +00:00
|
|
|
|
{
|
2004-07-23 02:23:49 +00:00
|
|
|
|
_img_private_t *p_env = p_user_data;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
2004-07-29 02:16:20 +00:00
|
|
|
|
if ( (i_track > p_env->gen.i_tracks+p_env->gen.i_first_track)
|
2004-07-27 01:06:01 +00:00
|
|
|
|
|| i_track < p_env->gen.i_first_track)
|
2003-03-24 19:01:09 +00:00
|
|
|
|
return TRACK_FORMAT_ERROR;
|
|
|
|
|
|
|
2004-07-27 01:06:01 +00:00
|
|
|
|
i_track -= p_env->gen.i_first_track;
|
2004-06-02 00:43:53 +00:00
|
|
|
|
|
2003-03-24 19:01:09 +00:00
|
|
|
|
/* This is pretty much copied from the "badly broken" cdrom_count_tracks
|
|
|
|
|
|
in linux/cdrom.c.
|
|
|
|
|
|
*/
|
2004-07-23 02:23:49 +00:00
|
|
|
|
if (p_env->tocent[i_track].cdte_ctrl & CDROM_DATA_TRACK) {
|
|
|
|
|
|
if (p_env->tocent[i_track].cdte_format == CDIO_CDROM_CDI_TRACK)
|
2003-03-24 19:01:09 +00:00
|
|
|
|
return TRACK_FORMAT_CDI;
|
2004-07-23 02:23:49 +00:00
|
|
|
|
else if (p_env->tocent[i_track].cdte_format == CDIO_CDROM_XA_TRACK)
|
2003-03-24 19:01:09 +00:00
|
|
|
|
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
|
2004-07-23 02:23:49 +00:00
|
|
|
|
_cdio_get_track_green(void *p_user_data, track_t i_track)
|
2003-03-24 19:01:09 +00:00
|
|
|
|
{
|
2004-07-23 02:23:49 +00:00
|
|
|
|
_img_private_t *p_env = p_user_data;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
2004-07-23 02:23:49 +00:00
|
|
|
|
if (!p_env->gen.init) init_solaris(p_env);
|
2004-07-27 01:36:37 +00:00
|
|
|
|
if (!p_env->gen.toc_init) read_toc_solaris (p_env) ;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
2004-07-29 02:16:20 +00:00
|
|
|
|
if (i_track >= p_env->gen.i_tracks+p_env->gen.i_first_track
|
2004-07-27 01:06:01 +00:00
|
|
|
|
|| i_track < p_env->gen.i_first_track)
|
2003-03-24 19:01:09 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
|
2004-07-27 01:06:01 +00:00
|
|
|
|
i_track -= p_env->gen.i_first_track;
|
2004-06-06 10:50:55 +00:00
|
|
|
|
|
2003-03-24 19:01:09 +00:00
|
|
|
|
/* FIXME: Dunno if this is the right way, but it's what
|
2004-06-06 10:50:55 +00:00
|
|
|
|
I was using in cd-info for a while.
|
2003-03-24 19:01:09 +00:00
|
|
|
|
*/
|
2004-07-23 02:23:49 +00:00
|
|
|
|
return ((p_env->tocent[i_track].cdte_ctrl & 2) != 0);
|
2003-03-24 19:01:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
|
Return the starting MSF (minutes/secs/frames) for track number
|
2004-06-06 11:44:51 +00:00
|
|
|
|
track_num in obj. Track numbers usually start at something
|
2004-06-06 11:37:59 +00:00
|
|
|
|
greater than 0, usually 1.
|
|
|
|
|
|
|
2003-03-24 19:01:09 +00:00
|
|
|
|
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
|
2004-07-23 02:23:49 +00:00
|
|
|
|
_cdio_get_track_msf(void *p_user_data, track_t i_track, msf_t *msf)
|
2003-03-24 19:01:09 +00:00
|
|
|
|
{
|
2004-07-23 02:23:49 +00:00
|
|
|
|
_img_private_t *p_env = p_user_data;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
|
|
|
|
|
if (NULL == msf) return false;
|
|
|
|
|
|
|
2004-07-23 02:23:49 +00:00
|
|
|
|
if (!p_env->gen.init) init_solaris(p_env);
|
2004-07-27 01:36:37 +00:00
|
|
|
|
if (!p_env->gen.toc_init) read_toc_solaris (p_env) ;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
2004-06-06 11:37:59 +00:00
|
|
|
|
if (i_track == CDIO_CDROM_LEADOUT_TRACK)
|
2004-07-29 02:16:20 +00:00
|
|
|
|
i_track = p_env->gen.i_tracks + p_env->gen.i_first_track;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
2004-07-29 02:16:20 +00:00
|
|
|
|
if (i_track > (p_env->gen.i_tracks+p_env->gen.i_first_track)
|
2004-07-27 01:06:01 +00:00
|
|
|
|
|| i_track < p_env->gen.i_first_track) {
|
2003-03-24 19:01:09 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
} else {
|
2004-07-23 02:23:49 +00:00
|
|
|
|
struct cdrom_tocentry *msf0 = &p_env->tocent[i_track-1];
|
2003-03-24 19:01:09 +00:00
|
|
|
|
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
|
2004-08-03 11:30:42 +00:00
|
|
|
|
char volpath[256];
|
|
|
|
|
|
struct stat st;
|
2003-10-03 02:46:32 +00:00
|
|
|
|
char **drives = NULL;
|
2004-08-03 11:30:42 +00:00
|
|
|
|
int num_files=0;
|
2003-10-03 02:46:32 +00:00
|
|
|
|
#ifdef HAVE_GLOB_H
|
|
|
|
|
|
unsigned int i;
|
|
|
|
|
|
glob_t globbuf;
|
2004-08-03 11:30:42 +00:00
|
|
|
|
|
2003-10-03 02:46:32 +00:00
|
|
|
|
globbuf.gl_offs = 0;
|
|
|
|
|
|
glob("/vol/dev/aliases/cdrom*", GLOB_DOOFFS, NULL, &globbuf);
|
|
|
|
|
|
for (i=0; i<globbuf.gl_pathc; i++) {
|
2004-08-03 11:30:42 +00:00
|
|
|
|
if(stat(globbuf.gl_pathv[i], &st) < 0)
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
/* Check if this is a directory, if so it's probably Solaris media */
|
|
|
|
|
|
if(S_ISDIR(st.st_mode)) {
|
|
|
|
|
|
sprintf(volpath, "%s/s0", globbuf.gl_pathv[i]);
|
|
|
|
|
|
if(stat(volpath, &st) == 0)
|
|
|
|
|
|
cdio_add_device_list(&drives, volpath, &num_files);
|
|
|
|
|
|
}else
|
|
|
|
|
|
cdio_add_device_list(&drives, globbuf.gl_pathv[i], &num_files);
|
2003-10-03 02:46:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
globfree(&globbuf);
|
|
|
|
|
|
#else
|
2004-08-03 11:30:42 +00:00
|
|
|
|
if(stat(DEFAULT_CDIO_DEVICE, &st) == 0) {
|
|
|
|
|
|
/* Check if this is a directory, if so it's probably Solaris media */
|
|
|
|
|
|
if(S_ISDIR(st.st_mode)) {
|
|
|
|
|
|
sprintf(volpath, "%s/s0", DEFAULT_CDIO_DEVICE);
|
|
|
|
|
|
if(stat(volpath, &st) == 0)
|
|
|
|
|
|
cdio_add_device_list(&drives, volpath, &num_files);
|
|
|
|
|
|
}else
|
|
|
|
|
|
cdio_add_device_list(&drives, DEFAULT_CDIO_DEVICE, &num_files);
|
|
|
|
|
|
}
|
2003-10-03 02:46:32 +00:00
|
|
|
|
#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 *
|
2004-04-30 06:54:15 +00:00
|
|
|
|
cdio_open_solaris (const char *psz_source_name)
|
|
|
|
|
|
{
|
|
|
|
|
|
return cdio_open_am_solaris(psz_source_name, NULL);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
|
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 *
|
2004-05-06 01:08:43 +00:00
|
|
|
|
cdio_open_am_solaris (const char *psz_orig_source, const char *access_mode)
|
2003-03-24 19:01:09 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_SOLARIS_CDROM
|
|
|
|
|
|
CdIo *ret;
|
|
|
|
|
|
_img_private_t *_data;
|
2004-05-06 01:08:43 +00:00
|
|
|
|
char *psz_source;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
|
|
|
|
|
cdio_funcs _funcs = {
|
2004-07-27 02:45:16 +00:00
|
|
|
|
.eject_media = eject_media_solaris,
|
2003-03-29 17:32:00 +00:00
|
|
|
|
.free = cdio_generic_free,
|
2004-07-27 02:45:16 +00:00
|
|
|
|
.get_arg = get_arg_solaris,
|
2004-08-10 11:58:14 +00:00
|
|
|
|
.get_cdtext = get_cdtext_generic,
|
2003-04-10 04:13:41 +00:00
|
|
|
|
.get_default_device = cdio_get_default_device_solaris,
|
2004-07-27 01:36:37 +00:00
|
|
|
|
.get_devices = cdio_get_devices_solaris,
|
2004-08-03 11:30:42 +00:00
|
|
|
|
.get_discmode = get_discmode_solaris,
|
2004-07-27 02:45:16 +00:00
|
|
|
|
.get_drive_cap = scsi_mmc_get_drive_cap_generic,
|
2004-07-29 02:16:20 +00:00
|
|
|
|
.get_first_track_num= get_first_track_num_generic,
|
2004-07-27 02:45:16 +00:00
|
|
|
|
.get_mcn = scsi_mmc_get_mcn_generic,
|
2004-07-29 02:16:20 +00:00
|
|
|
|
.get_num_tracks = get_num_tracks_generic,
|
2004-07-27 01:36:37 +00:00
|
|
|
|
.get_track_format = get_track_format_solaris,
|
2003-03-24 19:01:09 +00:00
|
|
|
|
.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,
|
2004-07-17 22:16:46 +00:00
|
|
|
|
.read_audio_sectors = _read_audio_sectors_solaris,
|
|
|
|
|
|
.read_mode1_sector = _read_mode1_sector_solaris,
|
|
|
|
|
|
.read_mode1_sectors = _read_mode1_sectors_solaris,
|
|
|
|
|
|
.read_mode2_sector = _read_mode2_sector_solaris,
|
|
|
|
|
|
.read_mode2_sectors = _read_mode2_sectors_solaris,
|
2004-08-16 00:52:53 +00:00
|
|
|
|
.read_toc = read_toc_solaris,
|
|
|
|
|
|
.run_scsi_mmc_cmd = run_scsi_cmd_solaris,
|
2003-03-24 19:01:09 +00:00
|
|
|
|
.stat_size = _cdio_stat_size,
|
2004-05-06 01:08:43 +00:00
|
|
|
|
.set_arg = _set_arg_solaris
|
2003-03-24 19:01:09 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
_data = _cdio_malloc (sizeof (_img_private_t));
|
2004-04-30 06:54:15 +00:00
|
|
|
|
|
2004-04-30 07:07:49 +00:00
|
|
|
|
_data->access_mode = _AM_SUN_CTRL_SCSI;
|
2004-04-30 06:54:15 +00:00
|
|
|
|
_data->gen.init = false;
|
2003-03-29 20:28:05 +00:00
|
|
|
|
_data->gen.fd = -1;
|
2004-08-07 22:58:51 +00:00
|
|
|
|
_data->gen.b_cdtext_init = false;
|
|
|
|
|
|
_data->gen.b_cdtext_error = false;
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
2004-05-06 01:08:43 +00:00
|
|
|
|
if (NULL == psz_orig_source) {
|
2004-07-18 03:35:07 +00:00
|
|
|
|
psz_source = cdio_get_default_device_solaris();
|
2004-05-06 01:08:43 +00:00
|
|
|
|
if (NULL == psz_source) return NULL;
|
|
|
|
|
|
_set_arg_solaris(_data, "source", psz_source);
|
|
|
|
|
|
free(psz_source);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if (cdio_is_device_generic(psz_orig_source))
|
|
|
|
|
|
_set_arg_solaris(_data, "source", psz_orig_source);
|
|
|
|
|
|
else {
|
|
|
|
|
|
/* The below would be okay if all device drivers worked this way. */
|
|
|
|
|
|
#if 0
|
|
|
|
|
|
cdio_info ("source %s is a not a device", psz_orig_source);
|
|
|
|
|
|
#endif
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2003-03-24 19:01:09 +00:00
|
|
|
|
|
2004-07-27 01:36:37 +00:00
|
|
|
|
ret = cdio_new ( (void *) _data, &_funcs );
|
2003-03-24 19:01:09 +00:00
|
|
|
|
if (ret == NULL) return NULL;
|
|
|
|
|
|
|
2004-07-23 02:23:49 +00:00
|
|
|
|
if (init_solaris(_data))
|
2003-03-24 19:01:09 +00:00
|
|
|
|
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 */
|
|
|
|
|
|
}
|