Operating System - Linux
1752577 Members
4588 Online
108788 Solutions
New Discussion

Re: Want to know more about SG_IO

 
Masthan
Advisor

Want to know more about SG_IO

Hi All,

Please let me know what all information we can get by using SG_IO inquiry ioctl.

By using SCSI_IOCTL_SEND_COMMAND inquiry ioctl will get the folloing info.
1) vendor ID 2) Product ID 3)device type (disk,tape..) 4)firmware version 5)ISO version 6) ANSI Version 7)ECMA version 8) response format 9) device connectivity (whether device is removable or not).. Will get the following structure info with SCSI IOCTL SEND COMMAND inquiry ioctl.


typedef struct _inqd {
uchar type; /* byte 0 */
uchar rmvm; /* byte 1 */
uchar versions; /* byte 2 */
uchar rdf_etc; /* byte 3 */
uchar addlLen; /* byte 4 (n - 4) */
uchar rsvd1[3]; /* bytes 5-7 */
uchar vid[8]; /* bytes 8-15 */
uchar pid[16]; /* bytes 16-31 */
uchar rev[4]; /* bytes 32-35 */
uchar vndr1[20]; /* bytes 36-55 */
uchar rsvd2[40]; /* bytes 56-95*/ uchar vndr2[159]; /* bytes 96-n (pad out to 255) */
}

Like this what all info we can get by using SG_IO inquiry ioctl.

From my knowledge we can get Vendor ID and Product ID and firmware revison level..what about other info ?

Your help is appreciated
1 REPLY 1
Matti_Kurkela
Honored Contributor

Re: Want to know more about SG_IO

SG_IO is a generic IOCTL for sending "raw" SCSI commands and getting their responses back. "Inquiry" is a SCSI command that all SCSI devices should understand and respond to. So, your question is more about the SCSI standards family than about Linux.

Disclaimer: I'm not a SCSI guru. Everything below this is a result of some quick Web browsing. I may have misunderstood something.

The beginning of linux/include/scsi/sg.h (in the Linux kernel source tree) has some documentation and pointers for more:

Linux SG_IO ioctl in 2.6 kernel series:
http://sg.torque.net/sg/sg_io.html

SCSI standards drafts (drafts are free, but you must pay to get the final versions)
http://www.t10.org/

From there, you can find the most recent description of the INQUIRY command in the "SCSI Primary Commands - 4" (SPC-4) document:

http://www.t10.org/ftp/t10/drafts/spc4/spc4r09.pdf

See chapter 6.4.2 for a description of the INQUIRY response data. As far as I understand, when you use the SG_IO ioctl to send an inquiry command, this is what you'll get written into the memory location you specified in the sg_io_hdr structure.

Chapter 7.6 describes the Vital Product Data pages you can optionally request with an INQUIRY command. These will contain a lot of information, but all kinds of SCSI devices don't have the same pages available: you must first request the VPD page 00h to get a list of available VPD pages. Then your program must decide what pages to request, based on what's available and what's sensible to request given the generic type of the device.
MK