Scor­pio News

  

April–June 1987 – Volume 1. Issue 2.

Page 41 of 51

The characters shown between the asterisks are the ASCII representation of the Hex characters on the left. A full stop is used to show unprintable characters.

The format for the directory entry corresponds almost exactly to that of a CP/M file control block and for good reason. Apart from the first byte, the directory entry is a direct copy of the first 32 bytes of the FCB.

The disk directory information is stored on the data tracks of the disk (as opposed to the system tracks) and occupies the first one or two (usually) blocks on the disk. Each directory entry requires 32 bytes and so it follows that for a 1K Block size, each block will hold 32 directory entries. If you should wish to double the number of directory entries available to 64, then 2 blocks will have to be set aside for the directory. Therefore, the number of directory entries available and consequently the maximum number of files that may be stored on a disk is a trade off against the size of the disk and the number of blocks that can be spared for directory information. Gemini opted for 128 directory entries per disk with a 4K block size, so only one block is lost to the directory leaving 196 blocks for the files themselves.

Looking at the entry for TESTFILE.COM, the first byte tells us that the file is stored in user area 0. The user number is held in the lover four bits of the byte. The upper four bits are reserved by Digital Research and although they are unused in CP/M versions up to 2.2, CP/M 3 does use them so, if anyone was thinking of having 256 user areas, think again if you wish to remain compatible with future releases of CP/M.

A value of 0E5H in this position indicates to the BDOS that the file has been erased. This makes utilities such as Unerase possible as, to restore a file, all that is necessary is to change this byte to a value between 0 and 15 depending upon which user area is required co hold the file. Unfortunately, this may not always work as if a file has been written to the disk since erasure, some of the data blocks used in the erased file may have been reallocated to the new file. For users of CP/M 1.4, it is not possible to unerase a file as the ERA command completely wipes the directory entries for the erased file by filling them with 0E5H bytes.

CP/M 3 uses different values of the first byte of the directory entry to identify disk labels, password information and date/​time stamps, all of which occupy directory space and consequently reduce the number of files that may be stored on the disk. The disk Label occupies one directory entry and may be identified by a 20H value for the first byte. Date/​Time stamps and passwords are invoked by formatting the directory using the utility INITDIR.COM which reserves one directory entry for every three file entries in the directory; reserved entries being identified by the value 21H in their first byte. You will see that if Date/​Time stamping is invoked under CP/M 3, the maximum number of files that may be stored on the disk it immediately reduced by one quarter.

Next in the directory entry comes the 11 bytes for the file name and type. The last four bytes in the top row give file size information and will be looked at later. Lastly, the 16 bytes in the bottom row contain the block numbers that have been allocated to the file. CP/M gets clever here and the block numbers are stored differently depending on whether the disk has more than 255 or less than 256 blocks available. If there are less than 256 blocks on the disk, CP/M stores the block numbers as 8 bit values and can consequently hold information on 16 blocks. If, however, the disk has 256 of more blocks, the numbers are stored as 16 bit values (stored in Low-High order) with the result that only 8 blocks may be allocated per directory entry. In the example given we can see that only one block has been allocated to the file although it isn’t apparent from the entry whether 8 or 16 bit numbers are being used. The decision as to whether 8 or 16-bit numbers are used is made by the CP/M BDOS and is totally transparent to the user but the manufacturers of the Tatung Einstein force their implementation of CP/M to use 16 bit values, even though their disks have less than 256 blocks. This, presumably, was an attempt to make their disks unreadable on other systems (Didn’t fool Dave Hunt though).

Page 41 of 51