A Shared Memory File System (part 2)

Last time I presented the idea of a memory file system that is FAT based. I would now like to describe the design of our FAT.

Memory File System & The Boot Block

Any decent memory file system starts with a Boot Block. This is the first disk block on the file system partition. The Boot Block contains the file system data structure. And here is what it looks like:

*) Magic number.

We use magic numbers to help detect file system corruption.

*) Number of disk blocks.

The total number of disk blocks that is used by the file system.

*) Disk Block Table.

The Disk Block Table is an array that contains an entry for every disk block in the file system.

Disk Block Table

As previously noted, the Disk Block Table is an array that contains an entry for every disk block in the file system. If an array entry is -1, then the disk block is free and thus not used. Otherwise, the entry contains the index for the next disk block in a linked list of disk blocks for a file or directory. An entry of -2 indicates the end of a linked list of disk blocks.

So the first entry in the Disk Block Table describes disk block 0, which is the Boot Block. Normally this entry contains a -2, indicating that the Boot Block resides on a single disk block. But we can (if need be) extend the size of the Boot Block. In such case, entry 0 would point to the next block in the linked list.

So what have we accomplished so far? We have presented the idea of a memory file system, that is FAT based. The FAT consists of a Boot Block and a Disk Block Table.
In the next blog post I will finish up this discussion when I describe:

*) Directory Blocks.

*) Extending a FAT in place.

*) File Locking.