HP-UX Reference (11i v2 04/09) - 7 Device (Special) Files, 9 General Information, Index (vol 10)
s
scsi_ctl(7) scsi_ctl(7)
unsigned data_length;
unsigned max_msecs;
unsigned data_xfer;
unsigned cdb_status;
unsigned char sense[256];
unsigned sense_status;
unsigned char sense_xfer;
unsigned char reserved[64];
};
EXAMPLES
Assume that fildes is a valid file descriptor for a
SCSI device. The first example attempts a SCSI
INQUIRY command:
#include <sys/scsi.h>
struct sctl_io sctl_io;
#define MAX_LEN 255
unsigned char inquiry_data[MAX_LEN];
memset(sctl_io, 0, sizeof(sctl_io)); /* clear reserved fields */
sctl_io.flags = SCTL_READ; /* input data expected */
sctl_io.cdb[0] = 0x12; /* can use scsi.h CMDinquiry */
sctl_io.cdb[1] = 0x00;
sctl_io.cdb[2] = 0x00;
sctl_io.cdb[3] = 0x00;
sctl_io.cdb[4] = MAX_LEN; /* allocation length */
sctl_io.cdb[5] = 0x00;
sctl_io.cdb_length = 6; /* 6 byte command */
sctl_io.data = &inquiry_data[0]; /* data buffer location */
sctl_io.data_length = MAX_LEN; /* maximum transfer length */
sctl_io.max_msecs = 10000; /* allow 10 seconds for cmd */
if (ioctl(fildes, SIOC_IO, &sctl_io) < 0)
{
/* request is invalid */
}
The following example attempts a
SCSI TEST UNIT READY command and checks to see if the device is
ready, not ready, or in some other state.
#include <sys/scsi.h>
struct sctl_io sctl_io;
memset(sctl_io, 0, sizeof(sctl_io)); /* clear reserved fields */
sctl_io.flags = 0; /* no data transfer expected */
sctl_io.cdb[0] = 0x00; /* can use CMDtest_unit_ready */
sctl_io.cdb[1] = 0x00;
sctl_io.cdb[2] = 0x00;
sctl_io.cdb[3] = 0x00;
sctl_io.cdb[4] = 0x00;
sctl_io.cdb[5] = 0x00;
sctl_io.cdb_length = 6; /* 6 byte command */
sctl_io.data = NULL; /* no data buffer is provided */
sctl_io.data_length = 0; /* do not transfer data */
sctl_io.max_msecs = 10000; /* allow 10 seconds for cmd */
if (ioctl(fildes, SIOC_IO, &sctl_io) < 0)
{
/* request is invalid */
}
else if (sctl_io.cdb_status == S_GOOD)
{
/* device is ready */
}
else if (sctl_io.cdb_status == S_BUSY ||
(sctl_io.cdb_status == S_CHECK_CONDITION &&
HP-UX 11i Version 2: September 2004 − 6 − Hewlett-Packard Company Section 7−−139