SCSI Pass-Through Programmer's Guide

Appendix A
Program listing to execute a SCSI Inquiry command by SPT via TM_Diag
tmdiag.c
#pragma width 132
#define _POSIX_SOURCE
/* tmdiag.c */
/* Given an MPE SCSI Device Path, attempt to mknod a device file and */
/* then open, ioctl(two times), close, unlink the file. . . */
/* Open with parameters that will have us go through the tm_diag TM */
/* */
/* Original SCSI ioctl() code written by Chris Moore of HP-UX GSC */
/* ported from HP-UX to MPE/iX POSIX by Jim Hawkins MPE-iX Lab. . . */
/* */
/* */
/*c89 -P LTMDIAG -o TMDIAG -Wc,+e,+m,+o,-C "-WL,XL=LIBIOXL.LIB.SYS" tmdiag.c */
/* */
/* it appears on 7.5 you may have to use HFS syntax for the library */
/*c89 -P LTMDIAG -o TMDIAG -Wc,+e,+m,+o,-C "-WL,XL=/SYS/LIB/LIBIOXL" tmdiag.c*/
/* */
/* -P -- listing file name (MPE name space only) */
/* -o -- program name (MPE or posix name space) */
/* -Wc, -- pass the next options to the ccxl compiler */
/* +e -- turn on long pointer support */
/* +m -- turn on identifier maps */
/* +o -- turn on code offsets */
/* -C -- Retain comments */
/* -WL, -- pass the next option to the linker */
/* XL=LIBIOXL.LIB.SYS" -- link the program with this library */
/* tmdiag.c -- program to compile */
/* */
/* The resuling “TMDIAG” program can be run */
/* :RUN TMDIAG;info=”0/0/1/1.15.0” */
/* ^^^^^ or other valid path on your system */
/* program. . . . */
#include <stdio.h> /* basic terminal I/O */
#include <errno.h> /* for file I/O errors */
#include <sys/libIO.h> /* for io_search, io_query */
#include <sys/stat.h> /* for mknod parms */
#include <sys/sysmacros.h> /* for mknod "dev" macros */
#include <fcntl.h> /* for ioctl */
#include <unistd.h> /* for ANSI/POSIX */
#include <sys/scsi.h> /* for SCSI stuff */
/* global variables */
struct sctl_io command;
struct sense_2_aligned sense_data;
unsigned char buf[64*1024];
/* print the command structure as hex integer values */
void print_command ( struct sctl_io x )
{ int i;
unsigned int *j; /* pointer to some, yet to be specified location */
j = (unsigned int *) &x;
- 17 -