HP-UX Reference (11i v3 07/02) - 7 Device (Special) Files, 9 General Information, Index (vol 10)

s
sioc_io(7) sioc_io(7)
esctl_io.cdb[5] = 0x00;
esctl_io.cdb_length = 6; /* 6 byte command */
esctl_io.data = &inquiry_data[0]; /* data buffer location */
esctl_io.data_length = MAX_LEN; /* maximum transfer length */
esctl_io.max_msecs = 10000; /* allow 10 seconds for cmd */
if (ioctl(fildes, SIOC_IO_EXT, &esctl_io) < 0) {
/* request is invalid */
} else {
if ( esctl_io.cdb_status == S_GOOD) {
/* success. display inquiry data */
else {
/* failure. process depending on cdb_status */
}
}
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(leg_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 */
} else {
/* unknown state */
}
WARNINGS
Incorrect use of
sioc_io operations (even those attempting access to non-existent devices) can cause data
loss, system panics, and device damage.
The SIOC_EXCLUSIVE ioctl should be used to gain exclusive access to a device prior to attempting
SIOC_IO commands. If exclusive access is not obtained, SIOC_IO commands will be intermixed with
device-specific driver commands, which can lead to undesirable results.
Device-specific drivers can reject inappropriate or troublesome SIOC_IO commands. However, since not
all such operations are known and detected, care should be exercised to avoid disrupting device-specific
drivers when using commands that modify internal device states.
Most SCSI commands have a logical unit number (LUN) field. Parallel SCSI implementations on the HP-
UX operating system select logical units via the SCSI IDENTIFY message. The LUN portion of the cdb
HP-UX 11i Version 3: February 2007 4 Hewlett-Packard Company 181