I am connecting a USB mass storage removeable drive to Solaris 10 x86 machine.
The device is detected and i am able to perform standard read and write functions.
But i want to use a code to send IOCTL based SCSI commands to the same device to read and write the data. Which i am unable to do so.
I use SCSI.dll on Windows OS based PC and SCSI.h and SG.h on Linux OS based PC to do SCSI command set communication with USB Mass Storage devices. Typically READ10 and WRITE10 SCSI commands are excuted with ease using IOCTL on both OS's. I want to do the same on Solaris x86 please guide me....I have learned from internet that this is not possible due to MPXI/O can anyone tell me a way out.....
I can send files to/from the device i.e. read/write to device with standard copy/paste/cut opreations on JDE on solaris 10 but if i compile the code on gcc and run it on terminal for scsi communication using ioctl with the device the open command works but the ioctl command returns negative value.
Code:
int fd, res, i;
const int t_length = 512; // 512 bytes transferred
const unsigned char blocks = 1; // Blocks transferred
unsigned char rdCmdBlk[SCSI_CDB_LEN] = { 0x28, // Command
0, 0, 0, 0, 0, 0, 0, 0, 0 };
unsigned char sense_b[SENSE_BUFF_LEN];
sg_io_hdr_t io_hdr;
// Open device
fd = open(deviceName , O_RDWR|O_SYNC);
printf("fd in write is : %d\n" , fd);
// Prepare SCSI READ (10) command
rdCmdBlk[2] = 0x00; // LBA
rdCmdBlk[3] = 0x00; // LBA
rdCmdBlk[4] = 0x00; // LBA
rdCmdBlk[5] = 0x66; // LBA
rdCmdBlk[8] = blocks; // transfer length
// Prepare the sg_io_hdr_t structure
memset(&io_hdr, 0, sizeof(sg_io_hdr_t));
io_hdr.interface_id = 'S';
io_hdr.cmd_len = sizeof(rdCmdBlk);
io_hdr.mx_sb_len = sizeof(sense_b);
io_hdr.dxfer_direction = SG_DXFER_FROM_DEV;
io_hdr.dxfer_len = t_length;
io_hdr.dxferp = dataTxChallenge;
io_hdr.cmdp = rdCmdBlk;
io_hdr.sbp = sense_b;
io_hdr.timeout = 5000;
// Sends the command to device
if ((res = ioctl(fd, SG_IO, &io_hdr)) < 0)
{
close(fd);
}
printf("IOCTL RESULT : %d",res);
printf("ERROR NO : %d",errno);
_______________________________________________________
The return value of ioctl is -1 and errno is 25 which is
Code:
#define ENOTTY 25 /* Inappropriate ioctl for device */