Originally posted by: SystemAdmin
Thank you for your reply.
>>
It is not at all clear what you are trying to do or why.
AIX 4.3 is very very old and which AIX 5 are you using?
>>
I am trying to send a Inquiry to a tape drive. This is just a snippet of the src. I need to port our (Sony) Tape diagnostics to AIX. The 5L build and test was done 5.1.
>>
What is the device you are opening with openx() and do you know the device itself supports this operation or not.
>>
A Sony AIT tape drive. I am not getting error when opening the device.
>>
STIOCMD is defined in /usr/include/sys/tape.h
Assuming you are doing some tape Diagnostics !!
Your code does not define inq_data
EFAULT sounds like this address is bad.
>>
The STIOCMD documentation doesn't show anything different for 5L vs. 4.3. I am not clear why my src works on 4.3 and not 5L.
char inq_data
56; (see complete src below).
The error occurs when the STIOCMD ioctl is sent.
int get_nori (int fd)
{
unsigned int nLength=0, nLength2=0, bcount=0, bcount2, offset=0, i=0, more=0;
unsigned int nBufSize = 0x8000, nBufSize2 = 0x8000, bufferlen = 0x8000, key, asc, ascq;
unsigned int mode0=0, mode1=0, bufid=0;
unsigned int status=0;
time_t ltime;
char inq_data
56;
/*char * rbuf_data;
char buffer
32768; */
char rq_buf
26, buf_data4[4];
int rc;
FILE * trace;
/* rbuf_data = (char *) buffer; */
char rbuf_data
32768;
struct sc_iocmd scmd;
(void) memset((char *)&scmd, 0, sizeof(scmd));
scmd.scsi_cdb[0] = 0x12;
scmd.scsi_cdb[1] = 0x0;
scmd.scsi_cdb[2] = 0x0;
scmd.scsi_cdb[3] = 0x0;
scmd.scsi_cdb[4] = 0x38;
scmd.scsi_cdb[5] = 0x0;
scmd.command_length = 0x06;
scmd.buffer = inq_data;
scmd.data_length = sizeof (inq_data);
scmd.flags = B_READ;
scmd.timeout_value = 60;
/* scmd.scsi_id = 0;
*/
/* scmd.lun_id = 0;
*/
if ( ioctl(fd, STIOCMD, &scmd) < 0 ) {
printf( "ioctl error on inquiry\n");
printf( "Errno: %d\n", errno);
switch (scmd.scsi_bus_status)
{
case SC_GOOD_STATUS:
printf("Good Status\n");
break;
case SC_BUSY_STATUS:
printf("Busy\n");
break;
case SC_CHECK_CONDITION:
printf("Check Condition\n");
break;
default:
printf("Unknown\n");
}
return (-1);
}
if ((inq_data[8] == 0x53 &&
inq_data[9] == 0x4f &&
inq_data
10 == 0x4e &&
inq_data
11 == 0x59 &&
inq_data
16 == 0x53 &&
inq_data
17 == 0x44 ) ||
(inq_data[8] == 0x53 &&
inq_data[9] == 0x4f &&
inq_data
10 == 0x4e &&
inq_data
11 == 0x59 &&
inq_data
16 == 0x54 &&
inq_data
17 == 0x53 &&
inq_data
18 == 0x4c))
{ printf ("SONY tape device detected.\n"); }
else {
printf ("SONY tape device not detected.\n");
return (-1);
}
printf ("%c%c%c%c", inq_data[8],inq_data[9],inq_data
10,inq_data
11);
printf (" %c%c%c%c%c%c%c%c%c", inq_data
16,inq_data
17,inq_data
18,
inq_data
19,inq_data
20,inq_data
21,inq_data
22,inq_data
23,inq_data
24);
printf (" Revision: %c%c%c%c\n", inq_data
32,inq_data
33,inq_data
34,
inq_data
35);
}
int main (int argc, char * argv[])
{
int fd;
unsigned int nLength=0, bcount=0, offset=0, i=0, source_address;
unsigned int nBufSize = 0x8000, bufferlen = 0x18, destination_address;
time_t ltime;
char inq_data
56;
char * wbuf_data;
char buffer
32768;
char curswitch;
FILE * trace;
int fw, dc_change;
if (argc < 3)
{
printf ("noritrace version 1.0, Sony Electronics 2005\n");
printf ("Usage: sonytape <device name> <-switches>\n");
printf ("switches: -h help\n");
/*printf (" -d <data compression> 1=enable 0=disable\n");
printf (" -e erase tape\n");
printf (" -f <file name> upgrade firmware\n");
printf (" -g <file name> spectra upgrade firmware\n");
printf (" -i change inquiry\n");
printf (" -m move medium <source> <destination>\n");
printf (" -p format tape\n");
printf (" -r read element status\n");
printf (" -s make firmware tape\n"); */
printf (" -t dump diagnostic trace\n");
/*printf (" -u unload tape\n");
printf (" -w <file name> write & read function check\n");
printf (" -x <file name> extended write & read function check\n"); */
printf ("Done.\n");
return (-1);
}
if ((fd = openx(argv[1], O_RDWR | O_NDELAY, NULL, SC_DIAGNOSTIC)) < 0)
{ printf ("Failed to open device.\n", argv[1]);
printf ("Done.\n");
return (-1);
}
if (argv[2][0] != '-')
{
printf ("Missing switch '-' argument.\n");
printf ("Done.\n");
return (-1);
}
curswitch = argv[2][1];
switch (curswitch)
{
case 'h':
printf ("noritrace version 1.0, Sony Electronics 2005\n");
printf ("Usage: sonytape <device name> <-switches>\n");
printf ("switches: -h help\n");
/*printf (" -d <data compression> 1=enable 0=disable\n");
printf (" -e erase tape\n");
printf (" -f <file name> upgrade firmware\n");
printf (" -i change inquiry\n");
printf (" -m move medium <source> <destination>\n");
printf (" -p format tape\n");
printf (" -r read element status\n");
printf (" -s make firmware tape\n"); */
printf (" -t dump diagnostic trace\n");
/*printf (" -u unload tape\n");
printf (" -w <file name> write & read function check\n");
printf (" -x <file name> extended write & read function check\n"); */
printf ("Done.\n");
return (-1);
case 't':
get_nori (fd);
break;
default:
printf ("Invalid switch: -%c\n", curswitch);
printf ("Done.\n");
return (-1);
}
printf ("Done.\n");
return (-1);
}
#AIX-Forum