2.0 File System Media Control Structures

The Flash File System uses several control structures for its data access operations. The Block Allocation Structure is stored at the end of a flash erase block and grows towards the beginning of the erase block. The various file control structures and file data start at the beginning of a flash erase block and grow towards the end of the flash erase block. Figure 1 describes this scheme.

Figure 1

The following control structures are used by FFS:

Boot Record - contains general file system information such as the total number of blocks and the number of spare blocks. The boot record also contains a pointer to the partition's root directory.

Block Allocation structure - contains information about a specific erase block such as the number of times the block was erased and how the space in the block is allocated. The structure includes some fixed-length members and a variable size array of allocation structures. Each of the allocation structures in the array pertains to a specific file control structure (such as FileInfo, FileEntry, DirEntry, or Boot Record), or extent of file data stored in the block. The block allocation structure is located at the end of each erase block.

DirEntry structure - contains information on a specific directory on the flash media. The directory entry points to a link list of FileEntry and/or DirEntry structures at the same level of the hierarchy or its children

FileEntry structure - contains information on a specific file. The file entry points to a link list of FileInfo structures for this file. The file entry also points to other File Entry and/or DirEntry structures at the same level of the hierarchy.

FileInfo structure - this is the lowest level control structure. It contains info on a specific file extent such as modification time/date and compressed or uncompressed length.

Figure 2 describes an example of the relationship between the various control structures. Note that the order of the allocation structures does not necessarily reflect the order of the corresponding file control structures or data.

Figure 2

The following is a brief description of how the file system uses its various control structures.

1. The file system scans the block allocation structure present in each block of the partition when the file system initializes on installation or whenever new memory media is inserted in a slot. The block allocation structure contains information that translates the physical position of each block within the partition into the block's logical sequence as viewed by the file system. The block allocation structure also contains information about the block's frequency of use (erasure) and whether the block contains the boot record pointer.

2. The file system uses the partition's boot record pointer to obtain the location of the boot record. The boot record contains the characteristics (total block count and block size) of the partition to be managed. The boot record also contains a pointer to the root directory entry for the partition. The file system uses this pointer to obtain the location of the root directory.

3. The file system uses the DirEntry and FileEntry data structures to define the hierarchy of directories and files in the partition. These structures are used to implement a linked list of linked lists that are used to emulate a tree structure.

4. The file system uses a linked list of FileInfo data structures to describe each file's data content. A file's data is the concatenation of all extents referred to by a FileInfo structure in the list, in list order.