Block availability map


In computer file systems, a block availability map is a data structure used to track disk blocks that are considered free. It is used along with a directory to manage files on a disk.
In terms of Commodore DOS compatible disk drives, the BAM was a data structure stored in a reserved area of the disk. For each track, the BAM consisted of a bitmap of available blocks and a count of the available blocks. The count was held in a single byte, as all formats had 256 or fewer blocks per track. The count byte was simply the sum of all 1-bits in the bitmap of bytes for the current track.
The following table illustrates the layout of Commodore 1541 BAM. The table would be larger for higher-capacity disks.
Total byteBitmap byte 1Bitmap byte 2Bitmap byte 3
Track 1blocks availableBlocks 0-7Blocks 8-15Blocks 16-23
Track 2blocks availableBlocks 0-7Blocks 8-15Blocks 16-23
...............
Track 35blocks availableBlocks 0-7Blocks 8-15Blocks 16-23

The bitmap was contained in 3 bytes for Commodore 1541 format disks because it had 17 to 20 sectors per track. Similarly, the Commodore 1571 used 3 bytes for the bitmap of each track, but the BAM was twice the size because there were twice as many tracks when formatted as double-sided. In contrast, the Commodore 1581 disk drive used 5 bytes for the bitmap because the disk format had 40 blocks per track.
In the bitmap of any format, a 1 bit indicated the block was available, while a 0 bit indicated the block was not available, and the bitmap data was stored low-byte first. So the first byte held a map for blocks 0 to 7, the second byte held a map for blocks 8 to 15, and so on. Within a byte, the bitmap was ordered low-bit first. For example, the first byte would represent block 0 with the least significant bit and block 7 with the most significant bit.
Storage devices by Creative Micro Designs, intended for use with CBM computers, also used a Block Availability Map which served the same purpose. However, these devices did not include a count byte, and the bits in each byte were reversed. Although the bits were reversed, the bytes were still stored in the same order.
Bitmap byte 1Bitmap byte 2...Bitmap byte 32
Track 1Blocks 0-7Blocks 8-15...Blocks 248-255
Track 2Blocks 0-7Blocks 8-15...Blocks 248-255
...............