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

s
sioc_io(7) sioc_io(7)
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.
Very large (or infinite) timeout values can cause a parallel SCSI bus (potentially the entire system) to
hang.
Device and/or bus reset operations can be used to regain a device’s attention when a timeout expires.
Resetting a device can cause I/O errors and/or loss of cached data. This can result in loss of data and/or
system panics.
Obtaining SCSI INQUIRY data by use of the
SIOC_INQUIRY ioctl instead of by use of the SIOC_IO
ioctl is generally preferable since SCSI implementations on the HP-UX operating system synchronize
Section 7148 Hewlett-Packard Company 3 HP-UX 11i Version 2: September 2004