2008年1月6日 星期日
SG_IO ioctl, sg_io_hdr_t structure and to_scsi_device
evpd(enable vital product data):
the server shall return VPD specified by Page Code when evpd=1
The SG_IO ioctl permits user applications to send SCSI commands to a device
defined in /scsi/sg.h
sg_io_hdr_t structure is the main control structure for the version 3 SCSI generic driver
typedef struct sg_io_hdr
{
int interface_id; /* [i] 'S' (required) */
int dxfer_direction; /* [i] */
unsigned char cmd_len; /* [i] */
unsigned char mx_sb_len; /* [i] */
unsigned short iovec_count; /* [i] */
unsigned int dxfer_len; /* [i] */
// If 'iovec_count' is zero then this value is a pointer to user memory of at least 'dxfer_len' bytes in
// length. If there is a data
//transfer associated with the command then the data will be transferred to or from this user memory.
void * dxferp; /* [i], [*io] */
// This value points to the SCSI command to be executed. The command is assumed to be 'cmd_len'
// bytes long.
unsigned char * cmdp; /* [i], [*i] */
//This value points to user memory of at least 'mx_sb_len' bytes length where the SCSI sense buffer will
//be output. Most successful commands do not output a sense buffer and this will be indicated by
// 'sb_len_wr' being zero
unsigned char * sbp; /* [i], [*o] */
unsigned int timeout; /* [i] unit: millisecs */
unsigned int flags; /* [i] */
int pack_id; /* [i->o] */
void * usr_ptr; /* [i->o] */
unsigned char status; /* [o] */
unsigned char masked_status;/* [o] */
unsigned char msg_status; /* [o] */
unsigned char sb_len_wr; /* [o] */
unsigned short host_status; /* [o] */
unsigned short driver_status;/* [o] */
int resid; /* [o] */
unsigned int duration; /* [o] */
unsigned int info; /* [o] */
} sg_io_hdr_t; /* 64 bytes long (on i386) */
ex:
struct sg_io_hdr io_hdr;
ioctl(fd, SG_IO, &io_hdr)
in scsi_device.h
#define to_scsi_device ( d ) container_of(d, struct scsi_device, sdev_gendev)
unsigned char * cmdp;
ex: Inquiry Command: 0x12
command code:
inquiry 0x12
send diagnostic 1d
receive diagnostic results 1c
page code:
00: Supported vital product data pages
80: Unit Serial Number Page
83: Device Identification
c0: Vendor specific, Physical Device Identification
c1: Vendor specific, Logical Drive Geometry
vpd( vital projuct data) page:
ex:
unit serial number VPD page:
The PAGE LENGTH field specifies the length of the product serial number
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言