* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * U N E R A Z * * * * A ZCPR3-Compatible File Unerasing Utility * * * * * * by * * Terry Hazen * * 21460 Bear Creek Road * * Los Gatos, CA 95030 * * (408) 354-7188 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Latest Revision --------------- Version 1.1 - 05/06/88. See UNERAZ11.HIS for revision details. ================================================================= Overview -------- UNERAZ is an enhanced Z80 file erasing utility for use with ZCPR3 and CP/M 2.2 or ZRDOS. UNERAZ has not been tested with CP/M 3.0. UNERAZ was designed as a general purpose file unerasing utility as well as a companion to the ACOPY, DD, RENAMZ, and ERAZ series of file utilities. It can help reduce the ALIAS command line length required to unerase groups of files with unrelated names by optionally unerasing only those files that have been tagged with any combination of the file attributes F1 through F7 (unerase if ANY of the selected attributes are set). For example, UNERAZ can be used with the /2 option to recover a group of files with the F2 attribute set that had been accidentally erased by ERAZ using the /2 option. Files may be tagged using the ZRDOS utility SFA (Set File Attributes) or a similar CP/M Public Domain utility such as DA. UNERAZ also has a number of other options which are described below. UNERAZ is fully ZCPR3 compatible when operating in a ZCPR3 environment, accepting both the DIR: and the DU: forms and checking the environment to obtain the maximum drive and user that will be accepted, and the name under which the program was called for use in the HELP message. Errors will cause the ZCPR3 program error flag to be set. ŠWhen UNERAZ operates in a non-ZCPR3 environment, the required information is obtained from internal locations, which may be patched as described below. UNERAZ will not accept the DIR: form when operating in a non-ZCPR3 environment. Background ---------- Under CP/M and ZRDOS, a file is erased by replacing the first byte (which normally contains the user number) in each directory entry for that file by the 'erased file' hexidecimal character 'E5'. That character marks the entry as free so that the disk operating system can reuse it for other files written to the disk later. Each directory entry for a file specifies up to eight of the data allocation blocks that make up the file. Since allocation block size can vary from 1k to 16k depending on your disk format, each directory entry can specify from 8k to 128k of data. When a directory entry has been marked as erased, the blocks specified in that entry are also considered to be free, and can be overwritten by later file write operations. If nothing has been written to the disk after a file has been erased and none of the 'erased' directory entries or allocation blocks have been overwritten, UNERAZ can recover a file by replacing the 'erased file' character in each directory entry for that file with the user number specified in the command line. Recovering erased files can yield mixed results, however, if any disk write operations have taken place after the files have been erased and before recovery is attempted. If a directory entry belonging to an erased file has been overwritten, the recovered file will be missing the allocation blocks specified in the missing entry. Recovery of the missing blocks, if they still exist, is an exercise in the use of a disk utility such as DU or PATCH, and will not be discussed here. If any blocks belonging to the erased file have been overwritten, even if the directory entry specifying those blocks is intact, the directory entries for the recovered file will specify blocks that no longer belong to it and have actually been allocated to another file (possibly of quite a different type). In an attempt to avoid recovering fatally garbled files, UNERAZ will not attempt to recover an erased file if its first entry is not present in the directory. If the first entry is present, UNERAZ will recover subsequent entries as long as they continue to appear in ascending sequence, as entries out of sequence probably belong to another version of the file. To avoid problems with existing files, UNERAZ will not attempt to recover an erased file that already has an unerased counterpart Šlisted in the directory. Instead, it will inform you that a file of the same name already exists. In such cases, if you still want to recover the erased file, rename the existing file and attempt the unerasing again. If there is more than one erased file of the same name in the directory, UNERAZ will recover only the first occurence of the first directory entry for the file and will list each other occurrence separately and flag it as '- Exists'. Since UNERAZ has no way of differentiating various erased versions having the same filename, the recovered file will include all directory entries for that file appearing in sequence, no matter which version they originally belonged to. If an improperly recovered file is a text file, recovery of any part of that file might be very useful, but if the file is a COM file, it will probably be useless and perhaps even dangerous. The of such files could cause severe problems. Any recovered files should be carefully checked before attempting to use them. To avoid the problems that may occur when attempting to recover files when the directory contains a large number of erased entries, it is a good idea to keep your disks 'clean' by the regular use of CLEANDIR, SAP, or a similar utility during your work sessions when you know that you will no longer need to recover any of the erased entries in the directory. This can easily be done just after routinely backing up your work files. These utilities 'clean' by sorting the directory, removing any entries marked as erased, and rewriting the directory back to disk. Since the cleaned directory will not contain any erased entries, UNERAZ cannot recover any files at this point, even if the file still exists in allocation blocks on the disk. The directory is now a 'clean slate' so that any file that is subsequently erased may be recovered cleanly if necessary. Installation ------------ The distribution version of UNERAZ is supplied with an AMPRO standard Z3ENV address of FE00H. ZCPR3.0 users with other Z3ENV locations should install UNERAZ using Z3INS.COM and SYS.ENV in the normal manner. No installation is required for operation in ZCPR3.3 or non-ZCPR3 environments. For operation in a non-ZCPR3 environment, the maximum drive and user that will be accepted may be patched as described below. Syntax ------ UNERAZ [dir:]afn [/option(s)] Š UNERAZ will use the drive specified in the DIR: (or DU:) prefix as the drive on which the attempted file unerasing will take place. It will place the recovered file in the user area specified in the DIR: (or DU:) prefix. If no user area is specified, UNERAZ will place recovered files in the current user area on the selected drive. Recovered files will retain their original attributes. If you specify only one option (but no drive, user, or filename) on the command line, UNERAZ will automatically use the wildcard filename mask '*.*'. For example: A0>UNERAZ /L Lists ALL erased files on the logged drive. A0>UNERAZ /2 Recovers ALL erased files on the logged drive with the F2 attribute set. If you wish to specify more than one option or a different drive or user, an ambiguous or unambiguous filename specification must also be given. You may also use a filename specification in all cases if you prefer. Options ------- UNERAZ has several command line options, which must be preceded by the option flag character '/'. The option letters or numbers may appear in any order and may appear anywhere in the command line. Options may be combined in any combination. Options are toggled as they are read, so that an option appearing twice will cancel itself. All of the following command lines have the same meaning: A0>uneraz /12 afn A0>uneraz afn /1 /2 A0>uneraz /12 afn A0>uneraz /2 /2 afn /21 The options are: L - Lists all specified files. No files are unerased. 1 - 7 options. Unerases only those specified files which also have the selected combination of the F1 through the F7 attributes set. Optional UNERAZ Modifications ----------------------------- UNERAZ has several locations near the beginning of the program that can be patched using DDT, PATCH, ZPATCH, etc, to alter the Šoperation of the program to suit the user. The following table lists their locations and the distribution defaults. If you are operating in a ZCPR3 environment and wish to rename the program, the name by which the program is invoked will automatically appear in the HELP message, and no patching need be done. If you are primarily operating in a non-ZCPR3 environment, the program name, 'UNERAZ', at location 010BH-0112H, may be patched to any desired new name, which will then appear at the proper places in the HELP message when it is called. A maximum of eight characters are available. Spaces characters in any of the eight locations will be ignored. For example, to change the name of the program from UNERAZ to UNERA, you may simply patch the 'Z' in 'UNERAZ' to a space character (20H) and the HELP message will then display 'UNERA' without extra spaces. The option flag and the default option characters may be changed if you prefer other mnemonics. The changed characters will automatically appear in the HELP message. The options are all OFF-ON toggles. The default settings for the options may be changed from OFF (00H) to ON (0FFH) to allow, for example, always listing erased files without having to use the /L option. Note that if you then use the /L option, it will turn OFF the default file listing, or in other words, unerase the specified files. In such a case, the option letter should probably be patched to 'U' (for UNERASE specified files), since normal operation of that option has been reversed. If you change the option default settings by patching, the HELP message will automatically try to reflect these changes. If it is desired to eliminate ALL option choices following a given option, patch the FIRST undesired option letter or number to a 00H (for example, to eliminate the F1-F7 options, change the F1 byte at 0121H from '1' to 00H). All subsequent option choices will no longer operate. When UNERAZ steps through a number of files, it may generate more than a screenful of display. To help summarize what has happened, UNERAZ displays the total number of files listed or unerased on completion of the program. If you prefer not to have this display, patch location 0119H from FFH (display total number of files copied) to 00H (no display). Location Default Purpose ================================================================ 010BH 'UNERAZ ' Program name (8 characters maximum) -0112H - Appears in HELP message 0114H '/' Option flag character 0115H 10H Maximum drive allowed (A=1H, P=10H) Š 0116H 0FH Maximum user area allowed (15D=0FH) 0117H ON (FFH) Display the number of files copied 0118H 'L' List all specified files character 0119H OFF (00H) List all specified files default setting 011AH '1' F1 attribute option character 011BH OFF (00H) F1 attribute default setting 011CH '2' F2 attribute option character 011DH OFF (00H) F2 attribute default setting 011EH '3' F3 attribute option character O11FH OFF (00H) F3 attribute default setting 0120H '4' F4 attribute option character 0121H OFF (00H) F4 attribute default setting 0122H '5' F5 attribute option character 0123H OFF (00H) F5 attribute default setting 0124H '6' F6 attribute option character 0125H OFF (00H) F6 attribute default setting 0126H '7' F7 attribute option character 0127H OFF (00H) F7 attribute default setting ================================================================