home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff329.lzh / FileSystems / FileSystems.c < prev    next >
C/C++ Source or Header  |  1990-03-02  |  4KB  |  125 lines

  1. /*
  2.     fileystems.c - aquire and print descriptions of all MOUNTed filesystems
  3.  
  4.     Copyright © 1990, Ethan Dicks, all rights reserved.  
  5.  
  6. This program is *not* in the public domain, but may be freely
  7. redistributed on the condition that it is not sold, nor used in any
  8. commercial or shareware package without the express written permission
  9. of the author.  This program may be included in a freely redistributable
  10. library, including, but not limited to the Fred Fish library collection.
  11. In other words, selling this program is right out, but giving it away is
  12. encouraged.
  13.  
  14.     V 1.0  27-Jan-1990
  15.         - Obtain a pointer to the chain of DeviceNodes via the
  16.           DOSBase entry for RootNode, which contains a pointer
  17.           to the list of DeviceNodes.
  18.  
  19.     V 1.1  25-Feb-1990
  20.         - Print out the device driver name
  21.  
  22. */
  23.  
  24. /*
  25.  
  26. How it works...
  27.  
  28. The RootBlock structure pointed to by the DosLibrary structure
  29. contains a BPTR to the DosInfo structure.  One of the elements of the
  30. DosInfo structure is the DeviceNode.  This is a list of all "devices"
  31. known to AmigaDOS; this list includes all volume names, device names
  32. and logical names.  We are only interested in device names which have
  33. filesystems associated with them.  The element dn_Type of the
  34. DeviceNode is defined to be zero if this name is a device. 
  35. Furthermore, we are only interested in DeviceNodes which have exec
  36. tasks associated with them.  Once we have established that this
  37. DeviceNode is appropriate, we print out its name (stored as a BSTR in
  38. the element dn_Name) and check dn_Startup for a FileSysStartupMsg.  If
  39. there is not one, we tell the user that and get the next DeviceNode,
  40. until they are all gone.  If there is a FileSysStartupMsg, it contains
  41. pointers to all sorts of interesting information: the name of the exec
  42. device to call when accessing this device, the exec unit number, and a
  43. pointer to a DosEnvec block.  The DosEnvec block contains the same
  44. information you would find in a Mountlist entry.  We are concerned
  45. with number of heads, number of sectors per track, starting track,
  46. ending track and the proper memory type to request for buffers for
  47. this device.  This information is collected and displayed, and then,
  48. the dn_Next element of the DeviceNode is checked.  If is it non-zero,
  49. it is a pointer to the next DeviceNode.  If it is zero, our work is
  50. finished.
  51.  
  52. */
  53.  
  54. # include <libraries/dosextens.h>
  55. # include <libraries/filehandler.h>
  56. # include <exec/memory.h>
  57.  
  58. void main()
  59. {
  60. extern struct DosLibrary *DOSBase;
  61.  
  62. struct RootNode *RootNode;
  63. struct DosInfo *DosInfo;
  64. struct FileSysStartupMsg *StartupMsg;
  65. register struct DosEnvec *DosEnvec;
  66. register struct DeviceNode *DeviceNode;
  67.  
  68. RootNode = (struct RootNode *)DOSBase->dl_Root;
  69. DosInfo = (struct DosInfo *)BADDR(RootNode->rn_Info);
  70.  
  71. DeviceNode = (struct DeviceNode *)BADDR(DosInfo->di_DevInfo);
  72.  
  73. printf("\n");
  74.  
  75. while (DeviceNode)
  76.     {
  77.     if ( (DeviceNode->dn_Type == DLT_DEVICE) && DeviceNode->dn_Task)
  78.         {
  79.         printf("AmigaDOS device ");
  80.         bcpl_print((char *)BADDR(DeviceNode->dn_Name));
  81.         StartupMsg = (struct FileSysStartupMsg *)
  82.             BADDR(DeviceNode->dn_Startup);
  83.         if (StartupMsg)
  84.             {
  85.             printf(": is unit %d of the exec device ",
  86.                 StartupMsg->fssm_Unit);
  87.             bcpl_print((char *)BADDR(StartupMsg->fssm_Device));
  88.             printf(".\n");
  89.             DosEnvec = (struct DosEnvec *)
  90.                 BADDR(StartupMsg->fssm_Environ);
  91.             printf(" Disk Geometry = %d X %d X %d (Cyls %d - %d)\n",
  92.                DosEnvec->de_Surfaces,
  93.                DosEnvec->de_BlocksPerTrack,
  94.                ( (DosEnvec->de_HighCyl - DosEnvec->de_LowCyl) + 1),
  95.                DosEnvec->de_LowCyl,
  96.                DosEnvec->de_HighCyl);
  97.             printf(" BufMemType = %s  %s  %s\n",
  98.                ( (DosEnvec->de_BufMemType) & MEMF_PUBLIC ?
  99.                     "MEMF_PUBLIC" : ""),
  100.                ( (DosEnvec->de_BufMemType) & MEMF_CHIP ?
  101.                     "MEMF_CHIP" : ""),
  102.                ( (DosEnvec->de_BufMemType) & MEMF_FAST ?
  103.                     "MEMF_FAST" : ""));
  104.             }
  105.         else
  106.             printf(": has no FileSysStartupMsg.\n");
  107.         printf("\n");
  108.         }
  109.     DeviceNode = (struct DeviceNode *)BADDR(DeviceNode->dn_Next);
  110.     }
  111. }
  112.  
  113. /*
  114.     bcpl_print - write a BCPL string to stdout
  115. */
  116. bcpl_print(p)
  117. char *p;    /* APTR to a valid BCPL string (length byte first) */
  118. {
  119. register int i;
  120.  
  121. for (i = *p++;i;i--)
  122.     putchar(*p++);
  123. return(0);
  124. }
  125.