LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.

Notices


Reply
  Search this Thread
Old 02-26-2015, 02:48 AM   #1
danish2012
LQ Newbie
 
Registered: Feb 2015
Posts: 1

Rep: Reputation: Disabled
Unable to send SCSI commands to USB Drive


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 */
 
Old 02-26-2015, 05:35 PM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
You are using Linux (or at list GLIBC) specific ioctls with Solaris. This can't work. Your code shouldn't even compile under Solaris.

Use the proper Solaris API, uscsi
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to move files to SCSI USB enclosure matte85 Linux - Hardware 1 11-22-2007 10:00 PM
send and receive hex commands to and from USB...? sixgunz2 Linux - Software 1 09-15-2006 03:44 AM
USB flash drive and SCSI DiscoStoo Linux - Hardware 5 12-19-2005 08:47 PM
USB thumb drive detected by usb but not by scsi ashlock Linux - Hardware 6 06-02-2005 02:58 PM
unable to access scsi drive Homzz Slackware 1 04-12-2004 08:36 PM

LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris

All times are GMT -5. The time now is 10:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration