File: /usr/src/linux/drivers/scsi/cpqioctl.c
1 // Test program for CPQFCTS ioctl calls
2 // build with:
3 // gcc -o cpqioctl cpqioctl.c
4 // ld -o cpqioctl /lib/crt0.o cpqioctl.o -lc
5
6 #include <stdio.h>
7 #include <sys/stat.h>
8 #include <sys/ioctl.h>
9 #include <fcntl.h>
10 #include <unistd.h>
11 #include <linux/types.h>
12 #include "../../include/scsi/scsi.h"
13 #include "cpqfcTSioctl.h"
14
15 typedef struct scsi_fctargaddress {
16 unsigned long host_port_id;
17 unsigned char host_wwn[8];
18 } Scsi_FCTargAddress;
19
20 int main(int argc, char **argv) {
21
22 int fd, i;
23 Scsi_FCTargAddress targ;
24 int uselect=0;
25
26
27
28 if ( argc < 2 ) {
29 printf("usage: cpqioctl <Devfile>\n");
30 exit(1);
31 }
32
33 if ( (fd = open(argv[1], O_RDONLY)) == -1) {
34 perror("open");
35 exit(1);
36 }
37
38 if ( ioctl(fd, SCSI_IOCTL_FC_TARGET_ADDRESS, &targ) ) {
39 perror("ioctl");
40 exit(1);
41 }
42
43
44 printf("portid: %08x. wwn: ", targ.host_port_id);
45
46 for (i=0;i<8;i++) printf(" %02x", targ.host_wwn[i]);
47 printf("\n");
48
49 while( uselect != 27 ) // not ESC key
50 {
51 printf("\n IOCTL \n");
52 printf( "1. Get PCI info\n");
53 printf( "2. Send Passthru\n");
54 printf( " ==> ");
55 scanf("%c", &uselect);
56
57 switch( uselect )
58 {
59 case '1':
60 {
61 cciss_pci_info_struct pciinfo;
62
63 if( ioctl( fd, CCPQFCTS_GETPCIINFO ,&pciinfo ))
64 perror("ioctl");
65 else
66 printf( "\nPCI bus %d, dev_fn %d, board_id %Xh\n",
67 pciinfo.bus, pciinfo.dev_fn, pciinfo.board_id);
68 }
69
70 }
71 }
72
73
74 close(fd);
75 return 0;
76 }
77