Scor­pio News

  

April–June 1987 – Volume 1. Issue 2.

Page 40 of 51

Disk Formats and CP/M Disk routines – Part 2

by M.W.T. Waters

Part 2.

File sizes, disk sizes and directories

Having well and truly taken a disk to pieces in Scorpio News V1 I1, we can at last return to CP/M and the questions asked at the beginning of the first part of this article (Can anyone remember what they were?)

Minimum file size on disk is determined by the block size (referred to by Digital Research as BLS). CP/M stores files on disk as one or more blocks of information, where each block may contain 8, 16, 32, 64 or 128 CP/M records (128 bytes long) depending upon the block size. Blocks may be 1K, 2K, 4K, 8K or 16K bytes long, chosen (usually) by the computer manufacturer when deciding upon disk size and format. As an example, there are four commonly used Gemini formats available. The SDDS format uses 1K block size, the DDDS format uses a 2K block size while the QDDS and QDSS formats use 4K block size. The blocks are sometimes referred to as allocation units since disk space is allocated to files as one or more blocks.

The minimum size of a CP/M file is one block. If you imagine that you wish to save a short utility program of, say, 128 byes to disk, that program will appear to be 1K long on a system with a 1K block size or 16K long with a 16K block size. On a system with a 16K block size, there would be 16256 bytes of disk apace wasted after the file was written to disk. Why then do manufacturers, such as Gemini, use larger block sizes? At first sight, it would appear that a 1K block size is the best choice all round. As we shall see later, the problem of which block size to use isn’t quite that simple otherwise all manufacturers would have used 1K blocks (wouldn’t they?)

What then, determines the maximum size of a file or disk? To quote Digital Research, CP/M 1.4 allows a maximum disk size and file size of 256Kbytes. The maximum disk size may be extended by the use of double density but the process is cumbersome and wasteful of directory space. For this reason, few computer manufacturers appear to have made double density CP/M 1.4 systems.

CP/M 2.2 allows a maximum disk size and file of 8MBytes. The reason for this is that a maximum of 65536 records of 128 bytes each may be written to a disk or file. The maximum file size is determined by the maximum value for the random record field of a CP/M 2.2 file control block which may range from 0 to 65535.

Under CP/M 3 (CP/M Plus), the maximum disk size allowed is 512Mbytes made up of a maximum of 32768 blocks. This of course assumes a 16K block size; smaller block sizes reduce the maximum disk size accordingly so that with a 1K block size, the theoretical maximum disk sise is 32Mbytes. In practice, the maximum number of 1K blocks under CP/M 2.2 or CP/M 3 is 256. This is to provide compatibility with CP/M 1.4 disks as we shall see later. The maximum file size allowed by CP/M 3 is 32Mbytes and is determined again by the maximum value for the random record field of the CP/M 3 file control block which may range from 0 to 262143 giving 262144 records of 128 bytes each per file. To accommodate this higher figure, the lower 2 bits of the R2 byte of the FCB are now used to give an 18 bit random record number.

At this point, we need to see how directory information is stored on a disk. For those familiar with DU.COM, this may appear to be revision but don’t skip this section too quickly as a couple of surprises may be in store for you.

A CP/M 2.2 directory entry on disk looks something like the example given below. The format used to show the entry is “borrowed” from DU.COM.

Page 40 of 51