DiskInfo Version 1.20 03 October 1992 Written by Gregg Giles Security Leak Publications 3330 Kinsrow Avenue 217 Eugene, OR 97401-8824, USA Internet: ggiles@cie.uoregon.edu BIX: ggiles AmigaX: 503/342-2144 Thanks to Andy Finkel and Michael Sinz for their help. This program is public domain. Spread it at will - populate the world! Donations and contributions will be accepted, but are not demanded. Suggestions and ideas are always welcomed. PURPOSE DiskInfo is a tool which can be used to display information about any Amiga storage media, including disks, hard disks and memory. It is capable of creating global environmental variables which can be used by any AmigaDOS or ARexx script. It can be executed as an AmigaDOS command from either the Workbench or the Shell. The goal of this program is to evolve into worthy replacement for the Workbench "c:Info" command. FEATURES The following are the main features of this program: - Displays device capacity, usage, and available space in bytes and blocks (also shows bytes per block) - Creates global environmental variables usable by ARexx and AmigaDOS - Recognizes and displays the following Amiga file systems: DOS0: Standard ("Old") File System (OFS) DOS1: Fast File System (FFS) DOS2: Standard File System, International mode (OFS) DOS3: Fast File System, International mode (FFS) DOS4: Directory Caching Standard File System, International mode (DC-OFS) DOS5: Directory Caching Fast File System, International mode (DC-FFS) - Shows current device status (validated, validating, read only) - Workbench 2.04, 2.1, and 3.0 compatible - Standard command line parsing conforming to "Amiga User Interface Style Guide" - Enforcer "Hit Free" REQUIREMENTS For this program to operate properly, you must have the following: - An Amiga (any model) - Workbench 2.04, Workbench 2.1, or Workbench 3.0 - A working knowledge of the Workbench or Shell environments - The DiskInfo program USAGE This program may be executed from the Workbench using the "Workbench/ Execute Command..." option, or from the Shell. Usage is the same from either environment: DiskInfo [SETENV [BytesPerBlock][DiskName][DiskStatus] [DiskType][Errors][FreeBlocks][FreeBytes][InUnit][InUse] [PercentFull][SizeBlocks][SizeBytes][UsedBlocks] [UsedBytes][All]] [QUIET] The "", of course, is the name of any storage device or volume. The other arguments shown below are explained later in this manual. If no device is specified or if any argument is improperly used, the following will be displayed: DiskInfo (Version 1.20) by Gregg Giles Purpose: Gives a complete status report on any mounted AmigaDOS device. Usage : DiskInfo [SETENV [BytesPerBlock][DiskName][DiskStatus] [DiskType][Errors][FreeBlocks][FreeBytes][InUnit][InUse] [PercentFull][SizeBlocks][SizeBytes][UsedBlocks][UsedBytes][All]] [QUIET] USAGE EXAMPLES These examples assume that you have booted from your Workbench 2.04 distribution disk, and your Extras disk is in DF1:. Issue this command: 1> DiskInfo DF0: Most information of interest to the average user will be displayed, and will appear like this (or similar to it): Name : Workbench2.0: Errors : 0 Bytes Blocks Status: Write Protected Full : 94.20 % Size: 857904 1758 Type : Amiga OFS (DOS0) In Unit: 0 Used: 808128 1656 Block : 488 bytes In Use : Yes Free: 49776 102 Issuing the following command will show what resides on the Extras disk: 1> DiskInfo DF1: Something similar to the following will appear: Name : Extras2.0: Errors : 0 Bytes Blocks Status: Write Protected Full : 84.64 % Size: 857904 1758 Type : Amiga OFS (DOS0) In Unit: 0 Used: 726144 1488 Block : 488 bytes In Use : Yes Free: 131760 270 This, of course, is assuming that no errors occur. Further explanation of each field can be found in the section "Explanation Of Fields". Logical devices created using the "Assign" command may be used in place of a physical storage device (ie: "c:", "libs:", "devs:", etc.) However, in such cases, information about the physical media on which that logical device resides will be displayed. For example, assuming you booted from your Workbench 2.04 distribution disk, use this command and view the ensuing results (notice that the "name" field gives the complete path to the logical device specified): 1> DiskInfo C: Name : Workbench2.0:C Errors : 0 Bytes Blocks Status: Write Protected Full : 94.20 % Size: 857904 1758 Type : Amiga OFS (DOS0) In Unit: 0 Used: 808128 1656 Block : 488 bytes In Use : Yes Free: 49776 102 In order to quiet all output to the console, use the QUIET flag. Only error messages and usages templates are not suppressed by this flag. The following example has the result of accomplishing nothing (even redirection of output would be pointless here): 1> DiskInfo WORK: QUIET To create environmental variables, the argument SETENV must always be supplied. The following example will create variables for the disk's name, the disk's type, the number of blocks used, the number of bytes free, and the number of errors on the disk: 1> DiskInfo WORK: SETENV DiskName DiskType UsedBlocks FreeBytes Errors Global environmental variables of the same names will then be created automatically in the "ENV:DiskInfo" directory. If there are any errors, then you will be notified. In order to create all possible environmental variables, use the following command. This time, we wish to make sure there is no output to the console (ie: the screen), so we'll use the QUIET flag: 1> DiskInfo SYSTEM: SETENV ALL QUIET Other examples of using DiskInfo include:  Command Shows information about... DiskInfo DF0: Disk in unit 0 (DF0:) DiskInfo DF1: Disk in unit 1 (DF1:) DiskInfo DF2: Disk in unit 2 (DF2:) DiskInfo DH0: Hard disk partition DH0: DiskInfo DH1: Hard disk partition DH1: DiskInfo RAM: The RAM: disk DiskInfo RAD: The RAD: disk DiskInfo Extras2.0: A volume named "Extras2.0" DiskInfo Pictures1: A volume name "Pictures1" EXPLANATION OF FIELDS AND GLOBAL ENVIRONMENTAL VARIABLES The program displays rougly a dozen fields when executed (assuming there are no errors). "Field" refers to the name of the field shown when the program is executed normally. "Variable" shows the complete path of the global environmental variable created when "Argument" is supplied by the user as part of the command line. (For more information on how to create and make use of global environmental variables, see the sections "Usage Examples", "Using Global Environmental Variables (AmigaDOS and ARexx)", "Appendix 1: Using DiskInfo With An ARexx script", and "Appendix 2: Using DiskInfo With An AmigaDOS Script" in this manual.) All possible fields and their corresponding environmental variables are described as follows. Field : NAME Argument: DiskName Variable: ENV:DiskInfo/DiskName Purpose : Name of the disk (or volume) being examined. Output : A valid Amiga disk name. If a logical device name is given, a full path name will be displayed. Field : STATUS Argument: DiskStatus Variable: ENV:DiskInfo/DiskStatus Purpose : Physical status of the disk. Output : Possible results include: "Write Protected": Disk is write protected and can only be read from, not written to. This also means that files on the disk can not be edited or deleted. "Validating": The disk's structure has been corrupted, and AmigaDOS is attempting to correct the problem. "Validated": The disk's structure is stable, and thus can be written to or read from. Files can be edited and deleted. "Unknown": The disk's status cannot be determined. Field : TYPE Argument: DiskType Variable: ENV:DiskInfo/DiskType Purpose : Type of disk. Output : Possible results include: "Amiga OFS (DOS0)": The Standard File System format which appeared on the original Amiga 1000 and which is still in use. Also known as the "Old File System" (OFS). All disks formatted using the "Format" command under Workbench 1.0-2.04 were, by default, OFS format disks. OFS uses 488 bytes per block, and is rather slow. "Amiga FFS (DOS1)": The Fast File System (FFS) format introduced in Workbench 1.3 (for hard disk users only). Workbench 2.04 introduced the capability to format disks using FFS. The main goal of FFS was to speed up seek times. Workbench 2.04-3.0 are capable of formatting FFS disks. FFS uses 512 bytes per block, and is faster than FFS. "Amiga OFS (DOS2)": The "International" version of the Standard File System (OFS). This version of the filesystem resolves bugs present in the original OFS (DOS0). Has the same features of OFS (DOS0). Introduced in Workbench 2.1, and present in Workbench 3.0. "Amiga FFS (DOS3)": The "International" version of the Fast File System (FFS). This version of the filesystem resolves bugs present in the original FFS (DOS1). Has the same features of FFS (DOS1). Introduced in Workbench 2.1, and present in Workbench 3.0. "Amiga DC-OFS (DOS4)": The Disk Caching version of the Standard File System (OFS) introduced in Workbench 3.0. The main goal of DC-OFS is to speed up 3.5" disk access times. Uses 488 bytes per block. "Amiga DC-FFS (DOS5):" The Disk Caching version of the Fast File System (FFS) introduced in Workbench 3.0. The main goal of DC-FFS is to speed up 3.5" disk access times. Uses 512 bytes per block. "Unknown (????)": The format of the disk cannot be determined. Possibly a disk format not known about at the time of the creation of this program. Note: Subsequent versions of this program may be able to recognize the following disk types: BAD (unreadable/corrupted), KICK (Amiga Kickstart disk), NDOS (format of the disk is good, but it does not use any known AmigaDOS format; possibly a proprietary file format such as those often used as copy protection for games). Field : BLOCK Argument: BytesPerBlock Variable: ENV:DiskInfo/BytesPerBlock Purpose : The number of bytes that compose one block on the disk. Output : A positive numeric value. Field : ERRORS Argument: Errors Variable: ENV:DiskInfo/Errors Purpose : Number of read/write errors on the disk. Output : A positive numeric value. Field : FULL Argument: PercentFull Variable: ENV:DiskInfo/PercentFull Purpose : Percentage of the disk which is full. Output : A positive numeric percentage (accurate to the hundredth of a percent). Field : IN UNIT Argument: InUnit Variable: ENV:DiskInfo/InUnit Purpose : AmigaDOS unit number in which the disk resides. Output : Possible results include: -1: The RAM: device 0 : Floppy disk DF0: 1 : Floppy disk DF1: 2 : Floppy disk DF2: x : Any unknown unit number, where (x) is the number of that unit. (Note: Some hard disk partitions may appear as unit 0.) Field : IN USE Argument: InUse Variable: ENV:DiskInfo/InUse Purpose : Message telling if the disk is currently in use. Output : Possible results include: "Yes": The disk is in use. "No" : The disk is not in use. Field : SIZE (BYTES) Argument: SizeBytes Variable: ENV:DiskInfo/SizeBytes Purpose : Total byte storage capacity of the disk. Output : A positive numeric value. Note that this is the total actual storage possible. The Amiga file system will reduce the total available free storage space. Field : SIZE (BLOCKS) Argument: SizeBlocks Variable: ENV:DiskInfo/SizeBlocks Purpose : Total block storage capacity of the disk. Output : A positive numeric value. Field : USED (BYTES) Argument: UsedBytes Variable: ENV:DiskInfo/UsedBytes Purpose : Number of bytes of the disk which have been used. Output : A positive numeric value. Field : USED (BLOCKS) Argument: UsedBlocks Variable: ENV:DiskInfo/UsedBlocks Purpose : Number of blocks of the disk which have been used. Output : A positive numeric value. Field : FREE (BYTES) Argument: FreeBytes Variable: ENV:DiskInfo/FreeBytes Purpose : Number of bytes of the disk which are not yet used. Output : A positive numeric value. Field : FREE (BLOCKS) Argument: FreeBlocks Variable: ENV:DiskInfo/FreeBlocks Purpose : Number of blocks of the disk which are not yet used. Output : A positive numeric value. USING GLOBAL ENVIRONMENTAL VARIABLES (AMIGADOS AND AREXX) Global environmental variables were introduced to the Amiga operating system under Workbench 1.3, and are becoming commonly used by more and more applications. These variables are created by various applications so that other applications and scripts can make use of their contents. For example, the Workbench creates two environmental variables: "Workbench" and "Kickstart". The environmental variable "Workbench" contains the version number of the Workbench software, and the "Kickstart" version contains the version number of the Kickstart ROM chip. (These two variables are useful for applications that want to quickly know what version of the operating system is being run.) If you would like to view the contents of these variables, give the following command in a Shell: 1> echo Workbench version: $Workbench. Kickstart version: $Kickstart. All environmental variables are stored in the "ENV:" directory. Some applications will create their own directories in ENV: which will store variables specific only to that application; DiskInfo does just this. The format used to view these variables is as follows (where "Directory_Name" is the name of the directory containing the variable, and "Variable_Name" is the actual name of the variable): echo ${ENV:[Directory_Name]/[Variable_Name]} DiskInfo stores all of its variables in the "ENV:DiskInfo" directory. If this directory doesn't exist when the user wants DiskInfo to create variables, then it will be automatically created (note: this directory and all variables within it are lost when the machine is reset or powered-down.) The following Shell commands will create some variables and then display them: 1> DiskInfo RAM: SETENV DISKNAME DISKTYPE USEDBYTES QUIET 1> echo ${env:diskinfo/DiskName} 1> echo ${env:diskinfo/DiskType} 1> echo ${env:diskinfo/UsedBytes} The first command will tell DiskInfo to create three environmental variables called DiskName, DiskType, and UsedBytes (DiskInfo argument names will always correspond to the name of the variable created; ie: Supplying the argument "DISKNAME" creates a variable called "DiskName", which contains the name of the disk in question.) The QUIET flag prevents output to the Shell. (This is not necessary in order to create or read variables - it is only done here to stop output to the console; that is, to reduce clutter on the screen.) The second through fourth commands will display (one by one) each of the three variables just created. This is the exact method that should be used in AmigaDOS scripts to create and show DiskInfo variables. The variables which this program creates are global in scope, which means that they can be accessed by any application or any Shell running on the system. ("Local" environmental variables have a scope which is limited to the Shell from which they were created.) This means that any application or script (be it AmigaDOS or ARexx) can quickly make use of the information stored in these variables with great ease. The "Using The System Software" manual provided with your Amiga is the definitive resource on environmental variables and how they can be used. For that reason, this manual will only detail how to use the variables created by this program. One practical application for the variables created by DiskInfo is in script-based disk-catalog programs. If, for example, you created a script which was to catalog the names and storage capacity of all of your disks, you could have DiskInfo create two variables: one containing the disk name, and the other containing the disk capacity. You could then have your script read these variables and use them as you desire. (An example of how to create and display these variables from an AmigaDOS script is provided in Appendix 2.) ARexx is in itself a powerful and easy-to-use interpreted scripting language that is provided with the Amiga operating system (Workbench 2.04 and later). Using ARexx, users can quite literally design a powerful disk-catalog program using the functions made available to them with DiskInfo. All the user must do is create the interface using ARexx, and use the environmental variables created by DiskInfo to fill in the information. For a complete list of disk contents, this user can simply have ARexx call the "c:Dir" command - no special programming talent is required! An example of how to create and display these variables from an ARexx script is provided in Appendix 1.) For additional information on ARexx and how it works, refer to the "Using The System Software" manual provided with your Amiga system. Appendix 1 provides a complete example of using DiskInfo's environmental variables from an ARexx script. Appendix 2 gives an example of using those same variables from an AmigaDOS script. More examples of creating environmental variables can be found in the "Usage Examples" section. PROGRAM INTEGRITY AND BUGS It is the author's goal to keep this program as stable, correct, and as bug-free as possible. For this reason it employs careful error checking techniques, particularly when dealing with locks and memory. Everything which is opened is closed, even when errors occur. As an Amiga user himself, the author loves cleanly written programs, particularly those that don't suck up system resources when they screw up. This program has its own built-in error messages, and all are largely self-explanitory. These error messages generally only appear when the user has done something incorrectly (ie: trying to examine a disk in a drive when no disk is present). However, should you discover any bugs in this program, please record them and contact me immediately so that they may be corrected and the fixed version of the program released. REVISIONS AND PLANNED ENHANCEMENTS Planned Enhancements: Enable recognition of disk formats other than AmigaDOS, including MS-DOS disks (720k and 1.44MB). Enable display of all mounted devices simultaneously, much like the AmigaDOS Info command when used with no flags. A Workbench window interface. Due to the increasing number of features that will eventually make its way into this code, it might be necessary. CD-ROM (ISO-9660) support. Changes since the previous version:  Recognition of new Amiga-specific file systems added: DOS2, DOS3, DOS4, and DOS5. Added Workbench 2.04 standard command line parsing which conforms to the "Amiga User Interface Style Guide". This had the effect of reducing code size, system overhead requirements, and permitting the display of a standardized template when issuing "DiskInfo ?" at the command line. Ability to create global environmental variables added. A user may now specify any of the following command line parameters (when using the SETENV parameter), and a corresponding variable will be created in the "ENV:DiskInfo" directory: BYTESPERBLOCK, DISKNAME, DISKSTATUS, DISKTYPE, ERRORS, FREEBLOCKS, FREEBYTES, INUNIT, INUSE, PERCENTFULL, SIZEBLOCKS, SIZEBYTES, USEDBLOCKS, and USEDBYTES. The argument ALL will prevent users from having to type all of the arguments in order to create all possible environmental variables. New argument: QUIET. This argument stops all output to the console, with the exception of error messages, the template, and the usage message. Compatible with Workbench 2.1 and 3.0. APPENDIX 1: USING DISKINFO WITH AN AREXX SCRIPT While DiskInfo itself does not have an ARexx port, it can be used by ARexx as a normal AmigaDOS command. The global environmental variables which DiskInfo creates can also be easily read and manipulated by any ARexx script. The following is an example of how an ARexx script can both run DiskInfo as well as manipulate the global environmental variables which it can create. This ARexx script will run DiskInfo to find information about a disk in DF0:, get the DiskName and FreeBytes variables, and then print their values to the Shell. (Requires ARexx and Workbench 2.04 or better.) --- cut here (begin) --- /* ARexx script */ address command echo echo "Disk information" /* Get the name of the disk */ result = open('MyFile', 'env:DiskInfo/DiskName', 'R') NameOfDisk = readln('MyFile') result = close('MyFile') /* Get the bytes free information */ result = open('MyFile', 'env:DiskInfo/FreeBytes', 'R') FreeBytesOnDisk = readln('MyFile') result = close('MyFile') echo "The disk named" NameOfDisk "has" FreeBytesOnDisk "bytes free." --- cut here (end) --- APPENDIX 2: USING DISKINFO WITH AN AMIGADOS SCRIPT While AmigaDOS scripts are not quite as powerful as their ARexx counterparts, they are still useful in manipulating environmental variables. The following script will use DiskInfo to get the name of a disk and the number of bytes free on it. This information will then be put into two environmental variables, which will then be printed to the Shell. --- cut here (begin) --- DiskInfo >nil: df0: SETENV DISKNAME FREEBYTES echo "The disk named ${ENV:DiskInfo/DiskName}" echo "has ${ENV:DiskInfo/DiskInfoName} bytes free." --- cut here (end) --- The following example is a bit more involved than the first, but it is still based upon the same principles of the first: make DiskInfo create all of its global environmental variables, and then display them. This script, however, does error checking. It a certain variable doesn't exist, then a message saying that the variable doesn't exist will be shown. --- cut here (begin) --- ; "ShowEnv" (script) ; by Gregg Giles, 01-OCT-1992 ; For use with DiskInfo v1.20 ; ; This is an AmigaDOS script which shows the values of all of the ; environmental variables created by DiskInfo. Those which do not exist ; will have a message displayed saying so. ; This script applies only to DiskInfo; it is not useful to show ; other environmental variables. Feel free to study this script in order ; to learn how to use environmental variables. failat 20 DiskInfo DF0: SETENV ALL QUIET echo "BytesPerBlock = " noline if exists env:DiskInfo/BytesPerBlock echo ${env:DiskInfo/BytesPerBlock} else echo "(doesn't exist)" endif echo "DiskName = " noline if exists env:DiskInfo/DiskName echo ${env:DiskInfo/DiskName} else echo "(doesn't exist)" endif echo "DiskStatus = " noline if exists env:DiskInfo/DiskStatus echo ${env:DiskInfo/DiskStatus} else echo "(doesn't exist)" endif echo "DiskType = " noline if exists env:DiskInfo/DiskType echo ${env:DiskInfo/DiskType} else echo "(doesn't exist)" endif echo "Errors = " noline if exists env:DiskInfo/Errors echo ${env:DiskInfo/Errors} else echo "(doesn't exist)" endif echo "FreeBlocks = " noline if exists env:DiskInfo/FreeBlocks echo ${env:DiskInfo/FreeBlocks} else echo "(doesn't exist)" endif echo "FreeBytes = " noline if exists env:DiskInfo/FreeBytes echo ${env:DiskInfo/FreeBytes} else echo "(doesn't exist)" endif echo "InUnit = " noline if exists env:DiskInfo/InUnit echo ${env:DiskInfo/InUnit} else echo "(doesn't exist)" endif echo "InUse = " noline if exists env:DiskInfo/InUse echo ${env:DiskInfo/InUse} else echo "(doesn't exist)" endif echo "PercentFull = " noline if exists env:DiskInfo/PercentFull echo ${env:DiskInfo/PercentFull} else echo "(doesn't exist)" endif echo "SizeBlocks = " noline if exists env:DiskInfo/SizeBlocks echo ${env:DiskInfo/SizeBlocks} else echo "(doesn't exist)" endif echo "SizeBytes = " noline if exists env:DiskInfo/SizeBytes echo ${env:DiskInfo/SizeBytes} else echo "(doesn't exist)" endif echo "UsedBlocks = " noline if exists env:DiskInfo/UsedBlocks echo ${env:DiskInfo/UsedBlocks} else echo "(doesn't exist)" endif echo "UsedBytes = " noline if exists env:DiskInfo/UsedBytes echo ${env:DiskInfo/UsedBytes} else echo "(doesn't exist)" endif --- cut here (end) --- APPENDIX 3: FINDING DISKINFO'S VERSION DiskInfo's version number can easily be found by using the AmigaDOS "c:Version" command as well as by using a question-mark as the only argument in the command line. Using the AmigaDOS Version command: 1> VERSION DiskInfo Using DiskInfo to find its own version: 1> DiskInfo ? When the argument template appears, simply press RETURN, and information about the program will appear (including the version number). *END OF DOCUMENT*