# Block availability map

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Block_availability_map
> Markdown URL: https://mediated.wiki/source/Block_availability_map.md
> Source: https://en.wikipedia.org/wiki/Block_availability_map
> Source revision: 1325694903
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

{{Short description|File system data structure}}
In [computer file system](/source/computer_file_system)s, a '''block availability map''' ('''BAM''')<ref>{{cite book|last=Englisch|first=Lothar|title=The Anatomy of the 1541 Disk Drive|url=https://archive.org/details/The_Anatomy_of_the_1541_Disk_Drive|year=1984|publisher=Abacus Software|location=Grand Rapids, MI|isbn=0-916439-01-1|page=[https://archive.org/details/The_Anatomy_of_the_1541_Disk_Drive/page/n97 89]}}</ref><ref>{{cite book|title=1541 User's Guide|year=1982|publisher=Commodore Business Machines|page=9}}</ref><ref>{{cite book|title=1571 User's Guide|year=1985|publisher=Commodore Business Machines|page=23}}</ref><ref>{{cite book|title=1581 User's Guide|year=1987|publisher=Commodore Business Machines|page=34}}</ref><ref>{{cite book|title=FD Series User's Manual|year=1992|publisher=Creative Micro Designs|page=108}}</ref>   is a [data structure](/source/data_structure) used to track [disk blocks](/source/block_size_(data_storage_and_transmission)) that are considered free (available for new data). It is used along with a [directory](/source/directory_(file_systems)) to manage files on a disk (originally only a [floppy disk](/source/floppy_disk), and later also a [hard disk](/source/hard_disk_drive)).

In terms of [Commodore DOS](/source/Commodore_DOS) ([CBM](/source/Commodore_International) [DOS](/source/disk_operating_system)) compatible [disk drives](/source/disk_storage), the BAM was a data structure stored in a reserved area of the disk (its size and location varied based on the physical characteristics of the disk).  For each track, the BAM consisted of a [bitmap](/source/bitmap) of available [blocks](/source/block_(data_storage)) and (usually) a [count](/source/summation) of the available blocks.  The count was held in a single byte, as all formats had 256 or fewer blocks per [track](/source/track_(disk_drive)). 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](/source/Commodore_1541) BAM.  The table would be larger for higher-capacity disks (described below).
{| class="wikitable"
|-
!   !! Total byte !! Bitmap byte 1 !! Bitmap byte 2 !! Bitmap byte 3
|-
| Track 1 || blocks available || Blocks 0–7 || Blocks 8–15 || Blocks 16–23
|-
| Track 2 || blocks available || Blocks 0–7 || Blocks 8–15 || Blocks 16–23
|-
| ... || ... || ... || ... || ...
|-
| Track 35 || blocks available || Blocks 0–7 || Blocks 8–15 || Blocks 16–23
|}
The bitmap was contained in 3 bytes for Commodore 1541 format ([single-sided](/source/Single-sided_disk)) disks because it had 17 to 20 [sectors](/source/Disk_sector) per track (note 3 bytes can hold at least 20 bits).<ref>{{cite book|title=1541 User's Guide|year=1982|publisher=Commodore Business Machines|page=65}}</ref>  Similarly, the [Commodore 1571](/source/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](/source/Double-sided_disk).<ref>{{cite book|title=1571 User's Guide|year=1985|publisher=Commodore Business Machines|pages=108–109}}</ref>  In contrast, the [Commodore 1581](/source/Commodore_1581) disk drive used 5 bytes for the bitmap because the disk format had 40 blocks per track (note 5 bytes can hold 40 bits).<ref>{{cite book|title=1581 User's Guide|year=1987|publisher=Commodore Business Machines|pages=119–120}}</ref>

In the bitmap of any format, a 1 [bit](/source/bit) indicated the block was available (free), while a 0 bit indicated the block was not available (used), and the bitmap data was stored [low-byte first](/source/Little_endian).  So the first [byte](/source/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](/source/Least_significant_bit) first.  For example, the first byte would represent block 0 with the least significant bit and block 7 with the [most significant bit](/source/most_significant_bit).

Storage devices by [Creative Micro Designs](/source/Creative_Micro_Designs), intended for use with CBM computers, also used a Block Availability Map which served the same purpose.  However, these devices ([FD-2000, FD-4000](/source/CMD_FD_series), and [CMD-HD](/source/CMD_HD_series)) did not include a count byte, and the bits in each byte were reversed (high-bit first).  Although the bits were reversed (compared to CBM formats), the bytes were still stored in the same order (low-byte first).<ref>{{cite book|title=FD Series User's Manual|year=1992|publisher=Creative Micro Designs|pages=112–114}}</ref>
{| class="wikitable"
|-
!   !! Bitmap byte 1 !! Bitmap byte 2 !! ... !! Bitmap byte 32
|-
| Track 1 || Blocks 0–7 || Blocks 8–15 || ... || Blocks 248–255
|-
| Track 2 || Blocks 0–7 || Blocks 8–15 || ... || Blocks 248–255
|-
| ... || ... || ... || ... || ...
|}

==See also==
* [File Allocation Table](/source/File_Allocation_Table) (FAT)
* [Design of the FAT file system](/source/Design_of_the_FAT_file_system)
* [Free space bitmap](/source/Free_space_bitmap)

==References==
{{Reflist}}

{{DEFAULTSORT:Block Availability Map}}
Category:Computer file systems
Category:Data structures

---
Adapted from the Wikipedia article [Block availability map](https://en.wikipedia.org/wiki/Block_availability_map) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Block_availability_map?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
