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

s
sioc_io(7) sioc_io(7)
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 */
}
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.
It is very easy to cause system deadlock through incorrect use of the SIOC_PRIORITY_MODE ioctl. Nor-
mally it is necessary to lock the calling process into memory (see plock(2)) prior to enabling priority mode.
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
should normally be set to zero, even when the LUN being accessed is not zero.
Use of linked commands is not supported.
Most SCSI commands with a data phase expect the data length information to be included somewhere in
the command bytes. Both the data_length field and any cdb data length values must be correctly
specified to get correct command results.
HP-UX 11i Version 2: December 2007 Update 3 Hewlett-Packard Company 165