home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #1 / Amiga Plus CD - 2000 - No. 1.iso / Tools / HD / SmartFileSystem / V1.58 / Sources / SFSquery / SFSquery.c
Encoding:
C/C++ Source or Header  |  1999-01-30  |  4.0 KB  |  139 lines

  1. #include <dos/dos.h>
  2. #include <dos/dosextens.h>
  3. #include <proto/dos.h>
  4. #include <proto/exec.h>
  5. #include <utility/tagitem.h>
  6. #include <stdio.h>
  7.  
  8. #include "/fs/packets.h"
  9. #include "/fs/query.h"
  10.  
  11. static const char version[]={"\0$VER: SFSquery 1.0 " __AMIGADATE__ "\r\n"};
  12.  
  13. LONG main() {
  14.   struct RDArgs *readarg;
  15.   UBYTE template[]="DEVICE/A\n";
  16.  
  17.   struct {char *name;} arglist={NULL};
  18.  
  19.   if((DOSBase=(struct DosLibrary *)OpenLibrary("dos.library",37))!=0) {
  20.     if((readarg=ReadArgs(template,(LONG *)&arglist,0))!=0) {
  21.       struct MsgPort *msgport;
  22.       struct DosList *dl;
  23.       UBYTE *devname=arglist.name;
  24.  
  25.       while(*devname!=0) {
  26.         if(*devname==':') {
  27.           *devname=0;
  28.           break;
  29.         }
  30.         devname++;
  31.       }
  32.  
  33.       dl=LockDosList(LDF_DEVICES|LDF_READ);
  34.       if((dl=FindDosEntry(dl,arglist.name,LDF_DEVICES))!=0) {
  35.         LONG errorcode;
  36.  
  37.         msgport=dl->dol_Task;
  38.         UnLockDosList(LDF_DEVICES|LDF_READ);
  39.  
  40.         {
  41.           struct TagItem tags[]={ASQ_CACHE_ACCESSES, 0,
  42.                                  ASQ_CACHE_MISSES, 0,
  43.  
  44.                                  ASQ_START_BYTEH, 0,
  45.                                  ASQ_START_BYTEL, 0,
  46.                                  ASQ_END_BYTEH, 0,
  47.                                  ASQ_END_BYTEL, 0,
  48.                                  ASQ_DEVICE_API, 0,
  49.  
  50.                                  ASQ_BLOCK_SIZE, 0,
  51.                                  ASQ_TOTAL_BLOCKS, 0,
  52.  
  53.                                  ASQ_ROOTBLOCK, 0,
  54.                                  ASQ_ROOTBLOCK_OBJECTNODES, 0,
  55.                                  ASQ_ROOTBLOCK_EXTENTS, 0,
  56.                                  ASQ_FIRST_BITMAP_BLOCK, 0,
  57.                                  ASQ_FIRST_ADMINSPACE, 0,
  58.  
  59.                                  ASQ_CACHE_LINES, 0,
  60.                                  ASQ_CACHE_READAHEADSIZE, 0,
  61.                                  ASQ_CACHE_MODE, 0,
  62.                                  ASQ_CACHE_BUFFERS, 0,
  63.  
  64.                                  ASQ_IS_CASESENSITIVE, 0,
  65.                                  ASQ_HAS_RECYCLED, 0};
  66.  
  67.  
  68.           printf("SFSquery information for %s:\n", arglist.name);
  69.  
  70.           if((errorcode=DoPkt(msgport, ACTION_SFS_QUERY, (LONG)&tags, 0, 0, 0, 0))!=DOSFALSE) {
  71.             ULONG perc;
  72.  
  73.             if(tags[0].ti_Data!=0) {
  74.               perc=tags[1].ti_Data*100 / tags[0].ti_Data;
  75.             }
  76.             else {
  77.               perc=0;
  78.             }
  79.  
  80.             printf("Start/end-offset : 0x%08lx:%08lx - 0x%08lx:%08lx bytes\n", tags[2].ti_Data, tags[3].ti_Data, tags[4].ti_Data, tags[5].ti_Data);
  81.             printf("Device API       : ");
  82.  
  83.             switch(tags[6].ti_Data) {
  84.             case ASQDA_NSD:
  85.               printf("NSD (64-bit)\n");
  86.               break;
  87.             case ASQDA_TD64:
  88.               printf("TD64\n");
  89.               break;
  90.             case ASQDA_SCSIDIRECT:
  91.               printf("SCSI direct\n");
  92.               break;
  93.             default:
  94.               printf("(standard)\n");
  95.               break;
  96.             }
  97.  
  98.             printf("Bytes/block      : %-8ld   Total blocks : %ld\n", tags[7].ti_Data, tags[8].ti_Data);
  99.             printf("Cache accesses   : %-8ld   Cache misses : %ld (%ld%%)\n", tags[0].ti_Data, tags[1].ti_Data, perc);
  100.             printf("Read-ahead cache : %ldx %ld bytes ",tags[14].ti_Data, tags[15].ti_Data);
  101.  
  102.             if(tags[16].ti_Data!=0) {
  103.               printf("(Copyback)\n");
  104.             }
  105.             else {
  106.               printf("(Write-through)\n");
  107.             }
  108.  
  109.             printf("DOS buffers      : %-8ld\n", tags[17].ti_Data);
  110.  
  111.             printf("SFS settings     : ");
  112.  
  113.             if(tags[18].ti_Data!=0) {
  114.               printf("[CASE SENSITIVE] ");
  115.             }
  116.  
  117.             if(tags[19].ti_Data!=0) {
  118.               printf("[RECYCLED] ");
  119.             }
  120.  
  121.             printf("\n");
  122.           }
  123.         }
  124.       }
  125.       else {
  126.         VPrintf("Couldn't find device '%s:'.\n",&arglist.name);
  127.         UnLockDosList(LDF_DEVICES|LDF_READ);
  128.       }
  129.  
  130.       FreeArgs(readarg);
  131.     }
  132.     else {
  133.       PutStr("Wrong arguments!\n");
  134.     }
  135.     CloseLibrary((struct Library *)DOSBase);
  136.   }
  137.   return(0);
  138. }
  139.