SCSI Pass-Through Programmer's Guide

Program Setup for SPT I/O
The programming example is derived from a program which was written in “C” to perform
SCSI pass-through commands to a tape device connected to an HP-UX system.
Appendix-A includes a listing and sample output of a C program that issues the SCSI Inquiry
command using the MPE/iX SPT interface. The appendix also has a snapshot of the output
from the inquiry command on various device types.
Overview
The following is an outline of important steps performed by the example program:
1. Validate input parameters
2. Create device file via mknod().
3. Open device file via open().
4. Issue SCSI Inquiry (hex 12) via ioctl()
a. Check command status
b. Print returned information.
5. Interpreting results.
In addition to the SCSI INQUIRY command the program also sends an illegal command to
provide an example of error handling.
Input parameter validation.
MPE/iX manages devices in a hierarchical manner by using a physical path for each device.
This hierarchical ordering results in an “I/O tree” structure similar to the HP-UX ioscan
output. Knowing a SCSI device’s physical path, one can create a device file and then issue
SCSI commands directly to it via the MPE/iX SPT interface.
Following the HP-UX convention, SPT routines were originally defined to use the I/O Path
as a “key”. The SPT enhancements to MPE/iX include also the ability to use the more
common MPE/iX Logical Device or LDEV to look up an I/O Path for use with SPT.
Once the device file for a SCSI device is ready, it can be used to issue SCSI commands to it
directly in application programs. The file needs to be opened using the open() call, SCSI
commands are sent to the devices using ioctl(). Please note that all HP-UX ioctl features are
not supported.
SPT Device File Creation
The SPT device file is created by mknod(). Before calling mknod(), a unique file name
should be assigned to the file. A clear convention is to name the devices using the actual
logical path OR ldev number and place these files in a unique location. In this program the
- 6 -