B.3 dump_ioconfig.c

     
 

 root@hpeos002[] #  cat dump_ioconfig.c  #include <stdio.h> #include <limits.h> #include <errno.h> #include <sys/ioparams.h> main(argc,argv) int argc; char *argv[]; {         char hwpath[LINE_MAX];         char *iofilename;         FILE *iofile;         int i,j,cookie;         union ioconfig_record record;         if ( argc < 2 )         {                 iofilename = IOCONFIG_FILE;         }         else         {                 iofilename = argv[1];         }         if ( ( iofile = fopen(iofilename,"r") ) == NULL )         {                 perror(iofilename);                 exit(errno);         }         if ( fread(&cookie,sizeof(cookie),1,iofile) != 1 )         {                 perror("fread cookie (1)");                 exit(errno);         }         if ( cookie != IOCONFIG_MAGIC )         {               fprintf(stderr,"%s s not a valid ioconfig file.  Bad magic(0x%08X).\n", graphics/ccc.gif iofilename, cookie);                 exit(EINVAL);         }         if ( fread(&cookie,sizeof(cookie),1,iofile) != 1 )         {                 perror("fread cookie (2)");                 exit(errno);         }         fprintf(stdout,"Class       Instance  H/W Path                 Driver\n");         fprintf(stdout,"=====================================================\n");         while ( fread(&record,sizeof(record),1,iofile) == 1 )         {                 if ( record.rec_name[0] != '_' )                 {                         memset(hwpath,NULL,sizeof(hwpath));                         if ( !IS_NULL_HW_PATH(&record.ioc.hw_path) &&                         VERIFY_HW_PATH(&record.ioc.hw_path)     )                         {                                 for ( j = 0, i = record.ioc.hw_path.first_index;                          i <= record.ioc.hw_path.last_index; ++i,j+=3 )                                 sprintf(&hwpath[j],"%3d",record.ioc.hw_path.addr[i]);                         }                         printf("%-12s",record.ioc.class);                         printf("%-8d",record.ioc.instance);                         printf("%-27s",hwpath);                         printf("%-17s\n",record.ioc.name);                 }                 else                 {                         if ( !strcmp(record.rec_name,DYN_MAJOR_REC) )                         {                                 printf("%-13s b:%3d  c:%3d     %-17s\n",                                         record.dm.rec_name,                                         record.dm.b_major,                                         record.dm.c_major,                                         record.dm.name);                                 continue;                         }                 }         }         fclose(iofile); } root@hpeos002[] # root@hpeos002[] #  make dump_ioconfig  cc -O dump_ioconfig.c  -o dump_ioconfig root@hpeos002[] #  ./dump_ioconfig  Class       Instance  H/W Path                 Driver ===================================================== graphics    0         1                        graph3 ext_bus     0         2  0  1                  c720 disk        0         2  0  1  0  0            sdisk disk        1         2  0  1  1  0            sdisk disk        2         2  0  1  2  0            sdisk tape        0         2  0  1  3  0            stape disk        3         2  0  1  6  0            sdisk lan         0         2  0  2                  lan2 tty         0         2  0  4                  asio0 ext_bus     1         2  0  6                  CentIf audio       0         2  0  8                  audio pc          0         2  0 10                  fdc ps2         0         2  0 11                  ps2 lan         1         4  0  1                  lan2 hil         0         5  0  1                  hil tty         1         5  0  2                  asio0 ctl         0         2  0  1  7  0            sctl _DYN_MAJOR    b: -1  c:  2     devkrs _DYN_MAJOR    b: -1  c:  4     lpr0 _DYN_MAJOR    b: -1  c:  5     td _DYN_MAJOR    b: -1  c:  6     btlan _DYN_MAJOR    b: -1  c:  7     ip _DYN_MAJOR    b: -1  c:  8     arp _DYN_MAJOR    b: -1  c: 10     rawip _DYN_MAJOR    b: -1  c: 11     tcp _DYN_MAJOR    b: -1  c: 12     udp _DYN_MAJOR    b: -1  c: 13     stcpmap _DYN_MAJOR    b: -1  c: 14     nuls _DYN_MAJOR    b: -1  c: 15     netqa _DYN_MAJOR    b: -1  c: 18     tun _DYN_MAJOR    b: -1  c: 19     telm _DYN_MAJOR    b: -1  c: 20     tels _DYN_MAJOR    b: -1  c: 21     tlclts _DYN_MAJOR    b: -1  c: 22     tlcots _DYN_MAJOR    b: -1  c: 23     tlcotsod _DYN_MAJOR    b: -1  c: 25     fcT1_cntl _DYN_MAJOR    b: -1  c: 26     fcp _DYN_MAJOR    b: -1  c: 31     fddi4 _DYN_MAJOR    b: -1  c: 32     btlan0 _DYN_MAJOR    b: -1  c: 33     fddi0 _DYN_MAJOR    b: -1  c: 36     fddi3 _DYN_MAJOR    b: -1  c: 37     btlan1 _DYN_MAJOR    b: -1  c: 44     pcitr _DYN_MAJOR    b: -1  c: 45     cxperf _DYN_MAJOR    b: -1  c: 48     maclan _DYN_MAJOR    b:  0  c: 49     dmp _DYN_MAJOR    b:  1  c: 50     vol _DYN_MAJOR    b: -1  c: 51     vols _DYN_MAJOR    b: -1  c: 54     cifs _DYN_MAJOR    b: -1  c: 57     krm _DYN_MAJOR    b: -1  c: 58     ip6 _DYN_MAJOR    b: -1  c: 61     udp6 _DYN_MAJOR    b: -1  c: 62     rawip6 _DYN_MAJOR    b: -1  c: 63     tcp6 _DYN_MAJOR    b: -1  c: 67     idds root@hpeos002[] # 



HP-UX CSE(c) Official Study Guide and Desk Reference
HP-UX CSE(c) Official Study Guide and Desk Reference
ISBN: N/A
EAN: N/A
Year: 2006
Pages: 434

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net