HP-UX Reference (11i v1 00/12) - 5 Miscellaneous Topics, 7 Device (Special) Files, 9 General Information, Index (vol 9)

__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man7/!!!intro.7
________________________________________________________________
___ ___
s
scsi_ctl(7) scsi_ctl(7)
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 &&
sctl_io.sense_status == S_GOOD &&
sctl_io.sense_xfer>2&&
(sctl_io.sense[2] & 0x0F) == 2)) /* can use sense_data */
{
/* device is not ready */
Section 7120 6 HP-UX Release 11i: December 2000
___
___