Fix bugs in getting drive capabilities;

This commit is contained in:
rocky
2004-04-24 19:15:34 +00:00
parent f1675ad319
commit ba9830766f

View File

@@ -1,5 +1,5 @@
/* /*
$Id: ioctl.c,v 1.7 2004/04/24 11:48:37 rocky Exp $ $Id: ioctl.c,v 1.8 2004/04/24 19:15:34 rocky Exp $
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
@@ -26,7 +26,7 @@
# include "config.h" # include "config.h"
#endif #endif
static const char _rcsid[] = "$Id: ioctl.c,v 1.7 2004/04/24 11:48:37 rocky Exp $"; static const char _rcsid[] = "$Id: ioctl.c,v 1.8 2004/04/24 19:15:34 rocky Exp $";
#include <cdio/cdio.h> #include <cdio/cdio.h>
#include <cdio/sector.h> #include <cdio/sector.h>
@@ -206,8 +206,8 @@ win32ioctl_read_raw_sector (_img_private_t *env, void *buf, lsn_t lsn)
sptd.Lun=0; /* SCSI lun ID will also be filled in */ sptd.Lun=0; /* SCSI lun ID will also be filled in */
sptd.CdbLength=12; /* CDB size is 12 for ReadCD MMC1 command */ sptd.CdbLength=12; /* CDB size is 12 for ReadCD MMC1 command */
sptd.SenseInfoLength=0; /* Don't return any sense data */ sptd.SenseInfoLength=0; /* Don't return any sense data */
sptd.DataIn=SCSI_IOCTL_DATA_IN; //There will be data from drive sptd.DataIn = SCSI_IOCTL_DATA_IN;
sptd.DataTransferLength=CDIO_CD_FRAMESIZE_RAW; sptd.DataTransferLength= CDIO_CD_FRAMESIZE_RAW;
sptd.TimeOutValue=60; /*SCSI timeout value (60 seconds - sptd.TimeOutValue=60; /*SCSI timeout value (60 seconds -
maybe it should be longer) */ maybe it should be longer) */
sptd.DataBuffer= (PVOID) buf; sptd.DataBuffer= (PVOID) buf;
@@ -407,7 +407,7 @@ win32ioctl_get_mcn (_img_private_t *env) {
&mcn, sizeof(mcn), &mcn, sizeof(mcn),
&dwBytesReturned, NULL ) == 0 ) { &dwBytesReturned, NULL ) == 0 ) {
cdio_warn( "could not read Q Channel at track %d", 1); cdio_warn( "could not read Q Channel at track %d", 1);
} else if (mcn.Mcval) } else if (mcn.Mcval)
return strdup(mcn.MediaCatalog); return strdup(mcn.MediaCatalog);
return NULL; return NULL;
} }
@@ -441,9 +441,10 @@ win32ioctl_get_track_format(_img_private_t *env, track_t track_num)
*/ */
cdio_drive_cap_t cdio_drive_cap_t
win32ioctl_get_drive_cap (const void *env) { win32ioctl_get_drive_cap (const void *env)
{
const _img_private_t *_obj = env; const _img_private_t *_obj = env;
int32_t i_drivetype; int32_t i_drivetype = 0;
SCSI_PASS_THROUGH_WITH_BUFFERS sptwb; SCSI_PASS_THROUGH_WITH_BUFFERS sptwb;
ULONG returned = 0; ULONG returned = 0;
ULONG length; ULONG length;
@@ -468,7 +469,8 @@ win32ioctl_get_drive_cap (const void *env) {
sptwb.Spt.SenseInfoOffset = sptwb.Spt.SenseInfoOffset =
offsetof(SCSI_PASS_THROUGH_WITH_BUFFERS,SenseBuf); offsetof(SCSI_PASS_THROUGH_WITH_BUFFERS,SenseBuf);
sptwb.Spt.Cdb[0] = CDIO_MMC_MODE_SENSE; sptwb.Spt.Cdb[0] = CDIO_MMC_MODE_SENSE;
sptwb.Spt.Cdb[1] = 0x08; /* doesn't return block descriptors */ /*sptwb.Spt.Cdb[1] = 0x08; /+ doesn't return block descriptors */
sptwb.Spt.Cdb[1] = 0x0;
sptwb.Spt.Cdb[2] = 0x2a; /*MODE_PAGE_CAPABILITIES*/; sptwb.Spt.Cdb[2] = 0x2a; /*MODE_PAGE_CAPABILITIES*/;
sptwb.Spt.Cdb[3] = 0; /* Not used */ sptwb.Spt.Cdb[3] = 0; /* Not used */
sptwb.Spt.Cdb[4] = 128; sptwb.Spt.Cdb[4] = 128;
@@ -485,15 +487,16 @@ win32ioctl_get_drive_cap (const void *env) {
&returned, &returned,
FALSE) ) FALSE) )
{ {
unsigned int n=sptwb.DataBuf[3]+4;
/* Reader? */ /* Reader? */
i_drivetype |= CDIO_DRIVE_CD_AUDIO; if (sptwb.DataBuf[n+5] & 0x01) i_drivetype |= CDIO_DRIVE_CD_AUDIO;
if (sptwb.DataBuf[6] & 0x02) i_drivetype |= CDIO_DRIVE_CD_RW; if (sptwb.DataBuf[n+2] & 0x02) i_drivetype |= CDIO_DRIVE_CD_RW;
if (sptwb.DataBuf[6] & 0x08) i_drivetype |= CDIO_DRIVE_DVD; if (sptwb.DataBuf[n+2] & 0x08) i_drivetype |= CDIO_DRIVE_DVD;
/* Writer? */ /* Writer? */
if (sptwb.DataBuf[7] & 0x01) i_drivetype |= CDIO_DRIVE_CD_R; if (sptwb.DataBuf[n+3] & 0x01) i_drivetype |= CDIO_DRIVE_CD_R;
if (sptwb.DataBuf[7] & 0x10) i_drivetype |= CDIO_DRIVE_DVD_R; if (sptwb.DataBuf[n+3] & 0x10) i_drivetype |= CDIO_DRIVE_DVD_R;
if (sptwb.DataBuf[7] & 0x20) i_drivetype |= CDIO_DRIVE_DVD_RAM; if (sptwb.DataBuf[n+3] & 0x20) i_drivetype |= CDIO_DRIVE_DVD_RAM;
return i_drivetype; return i_drivetype;
} else { } else {