I am working with tape drives. I am facing a problem with Scsi Erase for the tape devices. Its giving an Error Code as 1117 representing “The request could not be performed because of an I/O device error”. But i am able to execute the SCSI commands like read, write, rewind and so on. Have anyone faced the problem if so Please let me know the solution for the same. The Code is as follows:
int GetScsiErase_SPTD(HANDLE hTapehandle, BYTE bEraseType)
{
printf(" ***** ERASE - SCSI_PASS_THROUGH_DIRECT *****\n");
ZeroMemory(&sptdwb,sizeof(SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER));
ZeroMemory(&bCDB,sizeof(bCDB));
bCDB[0] = SCSIOP_ERASE; // Erase command 19h
bCDB[1] = bEraseType;
sptdwb.sptd.Length = sizeof(SCSI_PASS_THROUGH_DIRECT);
sptdwb.sptd.CdbLength = CDB6GENERIC_LENGTH;
sptdwb.sptd.DataIn = SCSI_IOCTL_DATA_UNSPECIFIED;
sptdwb.sptd.SenseInfoLength = sizeof(sptdwb.ucSenseBuf);
sptdwb.sptd.DataTransferLength = 0;
sptdwb.sptd.TimeOutValue = 5;
sptdwb.sptd.DataBuffer = NULL;
sptdwb.sptd.SenseInfoOffset = offsetof(SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER, ucSenseBuf);
memcpy(sptdwb.sptd.Cdb, bCDB, CDB6GENERIC_LENGTH);
status = DeviceIoControl(hTapehandle,
IOCTL_SCSI_PASS_THROUGH_DIRECT,
&sptdwb,
sizeof(SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER),
&sptdwb,
sizeof(SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER),
&returned,
FALSE);
if (!status)
{
printf( “Error Erase information; error was %d\n”,
errorCode = GetLastError());
return 0;
}
if ((sptdwb.sptd.ScsiStatus == 0) && (status != 0))
printf(“\n Space Success\n”);
else
printf( “Scsi Status : %d\n\n”,sptdwb.sptd.ScsiStatus);
return 1;
}
I am opening the device handle with
hTapehandle = CreateFile( TEXT(“\\.\Tape0”), // tape dev to open
GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE,// read/write access
NULL,
OPEN_EXISTING, // req for tape devs
0,
NULL
);
Can anyone help me out?