home *** CD-ROM | disk | FTP | other *** search
- /*
- fileystems.c - aquire and print descriptions of all MOUNTed filesystems
-
- Copyright © 1990, Ethan Dicks, all rights reserved.
-
- This program is *not* in the public domain, but may be freely
- redistributed on the condition that it is not sold, nor used in any
- commercial or shareware package without the express written permission
- of the author. This program may be included in a freely redistributable
- library, including, but not limited to the Fred Fish library collection.
- In other words, selling this program is right out, but giving it away is
- encouraged.
-
- V 1.0 27-Jan-1990
- - Obtain a pointer to the chain of DeviceNodes via the
- DOSBase entry for RootNode, which contains a pointer
- to the list of DeviceNodes.
-
- V 1.1 25-Feb-1990
- - Print out the device driver name
-
- */
-
- /*
-
- How it works...
-
- The RootBlock structure pointed to by the DosLibrary structure
- contains a BPTR to the DosInfo structure. One of the elements of the
- DosInfo structure is the DeviceNode. This is a list of all "devices"
- known to AmigaDOS; this list includes all volume names, device names
- and logical names. We are only interested in device names which have
- filesystems associated with them. The element dn_Type of the
- DeviceNode is defined to be zero if this name is a device.
- Furthermore, we are only interested in DeviceNodes which have exec
- tasks associated with them. Once we have established that this
- DeviceNode is appropriate, we print out its name (stored as a BSTR in
- the element dn_Name) and check dn_Startup for a FileSysStartupMsg. If
- there is not one, we tell the user that and get the next DeviceNode,
- until they are all gone. If there is a FileSysStartupMsg, it contains
- pointers to all sorts of interesting information: the name of the exec
- device to call when accessing this device, the exec unit number, and a
- pointer to a DosEnvec block. The DosEnvec block contains the same
- information you would find in a Mountlist entry. We are concerned
- with number of heads, number of sectors per track, starting track,
- ending track and the proper memory type to request for buffers for
- this device. This information is collected and displayed, and then,
- the dn_Next element of the DeviceNode is checked. If is it non-zero,
- it is a pointer to the next DeviceNode. If it is zero, our work is
- finished.
-
- */
-
- # include <libraries/dosextens.h>
- # include <libraries/filehandler.h>
- # include <exec/memory.h>
-
- void main()
- {
- extern struct DosLibrary *DOSBase;
-
- struct RootNode *RootNode;
- struct DosInfo *DosInfo;
- struct FileSysStartupMsg *StartupMsg;
- register struct DosEnvec *DosEnvec;
- register struct DeviceNode *DeviceNode;
-
- RootNode = (struct RootNode *)DOSBase->dl_Root;
- DosInfo = (struct DosInfo *)BADDR(RootNode->rn_Info);
-
- DeviceNode = (struct DeviceNode *)BADDR(DosInfo->di_DevInfo);
-
- printf("\n");
-
- while (DeviceNode)
- {
- if ( (DeviceNode->dn_Type == DLT_DEVICE) && DeviceNode->dn_Task)
- {
- printf("AmigaDOS device ");
- bcpl_print((char *)BADDR(DeviceNode->dn_Name));
- StartupMsg = (struct FileSysStartupMsg *)
- BADDR(DeviceNode->dn_Startup);
- if (StartupMsg)
- {
- printf(": is unit %d of the exec device ",
- StartupMsg->fssm_Unit);
- bcpl_print((char *)BADDR(StartupMsg->fssm_Device));
- printf(".\n");
- DosEnvec = (struct DosEnvec *)
- BADDR(StartupMsg->fssm_Environ);
- printf(" Disk Geometry = %d X %d X %d (Cyls %d - %d)\n",
- DosEnvec->de_Surfaces,
- DosEnvec->de_BlocksPerTrack,
- ( (DosEnvec->de_HighCyl - DosEnvec->de_LowCyl) + 1),
- DosEnvec->de_LowCyl,
- DosEnvec->de_HighCyl);
- printf(" BufMemType = %s %s %s\n",
- ( (DosEnvec->de_BufMemType) & MEMF_PUBLIC ?
- "MEMF_PUBLIC" : ""),
- ( (DosEnvec->de_BufMemType) & MEMF_CHIP ?
- "MEMF_CHIP" : ""),
- ( (DosEnvec->de_BufMemType) & MEMF_FAST ?
- "MEMF_FAST" : ""));
- }
- else
- printf(": has no FileSysStartupMsg.\n");
- printf("\n");
- }
- DeviceNode = (struct DeviceNode *)BADDR(DeviceNode->dn_Next);
- }
- }
-
- /*
- bcpl_print - write a BCPL string to stdout
- */
- bcpl_print(p)
- char *p; /* APTR to a valid BCPL string (length byte first) */
- {
- register int i;
-
- for (i = *p++;i;i--)
- putchar(*p++);
- return(0);
- }
-