diff --git a/lib/_cdio_linux.c b/lib/_cdio_linux.c index b9263320..b7e9f868 100644 --- a/lib/_cdio_linux.c +++ b/lib/_cdio_linux.c @@ -1,5 +1,5 @@ /* - $Id: _cdio_linux.c,v 1.35 2004/04/25 01:19:58 rocky Exp $ + $Id: _cdio_linux.c,v 1.36 2004/04/25 03:52:37 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel Copyright (C) 2002, 2003, 2004 Rocky Bernstein @@ -27,7 +27,7 @@ # include "config.h" #endif -static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.35 2004/04/25 01:19:58 rocky Exp $"; +static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.36 2004/04/25 03:52:37 rocky Exp $"; #include @@ -810,7 +810,7 @@ _cdio_get_first_track_num(void *env) */ static char * -_cdio_get_mcn_linux (void *env) { +_cdio_get_mcn_linux (const void *env) { struct cdrom_mcn mcn; const _img_private_t *_obj = env; diff --git a/lib/_cdio_sunos.c b/lib/_cdio_sunos.c index c4d86ba2..56e7fd1d 100644 --- a/lib/_cdio_sunos.c +++ b/lib/_cdio_sunos.c @@ -1,5 +1,5 @@ /* - $Id: _cdio_sunos.c,v 1.25 2004/03/16 12:18:32 rocky Exp $ + $Id: _cdio_sunos.c,v 1.26 2004/04/25 03:52:37 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel Copyright (C) 2002, 2003, 2004 Rocky Bernstein @@ -41,7 +41,7 @@ #ifdef HAVE_SOLARIS_CDROM -static const char _rcsid[] = "$Id: _cdio_sunos.c,v 1.25 2004/03/16 12:18:32 rocky Exp $"; +static const char _rcsid[] = "$Id: _cdio_sunos.c,v 1.26 2004/04/25 03:52:37 rocky Exp $"; #include #include @@ -481,6 +481,123 @@ cdio_get_default_device_solaris(void) return strdup(DEFAULT_CDIO_DEVICE); } +/*! + 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? */ + if (buf[n+5] & 0x01) i_drivetype |= CDIO_DRIVE_CD_AUDIO; + if (buf[n+2] & 0x02) i_drivetype |= CDIO_DRIVE_CD_RW; + if (buf[n+2] & 0x08) i_drivetype |= CDIO_DRIVE_DVD; + + /* Writer? */ + if (buf[n+3] & 0x01) i_drivetype |= CDIO_DRIVE_CD_R; + if (buf[n+3] & 0x10) i_drivetype |= CDIO_DRIVE_DVD_R; + if (buf[n+3] & 0x20) i_drivetype |= CDIO_DRIVE_DVD_RAM; + + if (buf[n+6] & 0x08) i_drivetype |= CDIO_DRIVE_OPEN_TRAY; + if (buf[n+6] >> 5 != 0) i_drivetype |= CDIO_DRIVE_CLOSE_TRAY; + + } else { + i_drivetype = CDIO_DRIVE_CD_AUDIO | CDIO_DRIVE_UNKNOWN; + } + return i_drivetype; + +#else + return CDIO_DRIVE_UNKNOWN | CDIO_DRIVE_CD_AUDIO | CDIO_DRIVE_CD_RW; +#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 +} + + /*! Return the number of of the first track. CDIO_INVALID_TRACK is returned on error. @@ -495,6 +612,7 @@ _cdio_get_first_track_num(void *env) return FIRST_TRACK_NUM; } + /*! Return the number of tracks in the current medium. */ @@ -603,6 +721,7 @@ cdio_get_default_device_solaris(void) { return strdup(DEFAULT_CDIO_DEVICE); } + #endif /* HAVE_SOLARIS_CDROM */ /*! @@ -652,8 +771,9 @@ cdio_open_solaris (const char *source_name) .get_arg = _cdio_get_arg, .get_devices = cdio_get_devices_solaris, .get_default_device = cdio_get_default_device_solaris, + .get_drive_cap = _cdio_get_drive_cap_solaris, .get_first_track_num= _cdio_get_first_track_num, - .get_mcn = NULL, + .get_mcn = _cdio_get_mcn_solaris, .get_num_tracks = _cdio_get_num_tracks, .get_track_format = _cdio_get_track_format, .get_track_green = _cdio_get_track_green, diff --git a/lib/cdio_private.h b/lib/cdio_private.h index 7f4ffb81..cc13b638 100644 --- a/lib/cdio_private.h +++ b/lib/cdio_private.h @@ -1,5 +1,5 @@ /* - $Id: cdio_private.h,v 1.20 2004/04/22 03:24:38 rocky Exp $ + $Id: cdio_private.h,v 1.21 2004/04/25 03:52:37 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein @@ -80,7 +80,7 @@ extern "C" { Return the media catalog number MCN from the CD or NULL if there is none or we don't have the ability to get it. */ - char * (*get_mcn) (void *env); + char * (*get_mcn) (const void *env); /*! Return the number of of the first track. diff --git a/lib/image_common.h b/lib/image_common.h index e7dcd5ea..996f225a 100644 --- a/lib/image_common.h +++ b/lib/image_common.h @@ -1,5 +1,5 @@ /* - $Id: image_common.h,v 1.2 2004/04/25 00:46:34 rocky Exp $ + $Id: image_common.h,v 1.3 2004/04/25 03:52:37 rocky Exp $ Copyright (C) 2004 Rocky Bernstein @@ -28,9 +28,9 @@ string when done with it. */ static char * -_cdio_image_get_mcn(void *env) +_cdio_image_get_mcn(const void *env) { - _img_private_t *_obj = env; + const _img_private_t *_obj = env; if (NULL == _obj->mcn) return NULL; return strdup(_obj->mcn); diff --git a/lib/scsi_mmc.h b/lib/scsi_mmc.h index 9b692583..60494fa8 100644 --- a/lib/scsi_mmc.h +++ b/lib/scsi_mmc.h @@ -1,5 +1,5 @@ /* - $Id: scsi_mmc.h,v 1.6 2004/04/24 19:18:52 rocky Exp $ + $Id: scsi_mmc.h,v 1.7 2004/04/25 03:52:37 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein @@ -36,11 +36,12 @@ /*! The generic packet command opcodes for CD/DVD Logical Units. */ -#define CDIO_MMC_MODE_SENSE_10 0x5a -#define CDIO_MMC_MODE_SENSE 0x1a -#define CDIO_MMC_GPCMD_READ_CD 0xbe -#define CDIO_MMC_GPCMD_READ_10 0x28 -#define CDIO_MMC_GPCMD_READ_12 0xa8 +#define CDIO_MMC_MODE_SENSE 0x1a +#define CDIO_MMC_GPCMD_READ_10 0x28 +#define CDIO_MMC_GPCMD_READ_SUBCHANNEL 0x42 +#define CDIO_MMC_MODE_SENSE_10 0x5a +#define CDIO_MMC_GPCMD_READ_12 0xa8 +#define CDIO_MMC_GPCMD_READ_CD 0xbe #define CDIO_MMC_SET_READ_TYPE(rec, sector_type) \ rec[1] = (sector_type << 2) diff --git a/src/cd-drive.c b/src/cd-drive.c index bc7b2d0d..6e166bfd 100644 --- a/src/cd-drive.c +++ b/src/cd-drive.c @@ -1,5 +1,5 @@ /* - $Id: cd-drive.c,v 1.1 2004/04/25 00:46:34 rocky Exp $ + $Id: cd-drive.c,v 1.2 2004/04/25 03:52:37 rocky Exp $ Copyright (C) 2004 Rocky Bernstein @@ -191,18 +191,21 @@ main(int argc, const char *argv[]) char *default_device; cdio = cdio_open (NULL, DRIVER_UNKNOWN); - default_device = cdio_get_default_device(cdio); - printf("The driver selected is %s\n", cdio_get_driver_name(cdio)); + if (NULL != cdio) { + default_device = cdio_get_default_device(cdio); + + printf("The driver selected is %s\n", cdio_get_driver_name(cdio)); - if (default_device) { - printf("The default device for this driver is %s\n", default_device); - } + if (default_device) { + printf("The default device for this driver is %s\n", default_device); + } - free(default_device); - cdio_destroy(cdio); - cdio=NULL; - printf("\n"); + free(default_device); + cdio_destroy(cdio); + cdio=NULL; + printf("\n"); + } } /* Print out a drivers available */ diff --git a/src/util.c b/src/util.c index 09024842..7233a947 100644 --- a/src/util.c +++ b/src/util.c @@ -1,5 +1,5 @@ /* - $Id: util.c,v 1.5 2004/04/25 00:46:34 rocky Exp $ + $Id: util.c,v 1.6 2004/04/25 03:52:37 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein @@ -94,7 +94,7 @@ print_drive_capabilities(cdio_drive_cap_t i_drive_cap) printf("Error in getting drive properties\n"); } else { printf("Hardware : %s\n", - i_drive_cap & CDIO_DRIVE_FILE ? "Disk Image" : "CD-ROM/DVD"); + i_drive_cap & CDIO_DRIVE_FILE ? "Disk Image" : "CD-ROM or DVD"); printf("Can open tray : %s\n", i_drive_cap & CDIO_DRIVE_OPEN_TRAY ? "Yes" : "No"); printf("Can close tray : %s\n\n",