Physical Media Abstraction Layer
- This layer abstracts the physical format of the media into equal-sized logical allocation units called Logical Sectors using the following guidelines:Logical Sector Allocation
- This layer exists to keep track of which logical sectors have been allocated to hold data, which are available, and which are unusable (bad).
FSDLT Free Space Descriptors (FSDs)
.----.
1 | o--------->|100010010...100101| Allocation map for sectors 0 - 4095
|----|
2 | o--------->|000010101...110001| Allocation map for sectors 4096 - 8091
|----|
3 | o--------->|100100101...001000| Allocation map for sectors 8092 - 12287
|----|
. .
. .
|----|
N | o--------->|001001000...001001| Allocation map for sectors 4096*N - 4096*(N-1)-1
`----'
Where N is the number of entries in the
Free Space Descriptor table (equal to NumLogicalSectors / SectorsPerFSD,
or in this example, NumLogicalSectors / 4096).
| LogicalSectorSize | SectorsPerFSD | Bytes accounted for per FSD | FSD location entries per sector of Free Space Descriptor Location Table | Sectors accountable per sector of Free Space Descriptor Location Table | Bytes accountable per sector of Free Space Descriptor Location Table |
| 256 bytes | 2048 sectors | 16,384 bytes | 32 entries | 65,536 sectors | 16,777,216 bytes |
| 512 bytes | 4096 sectors | 32,768 bytes | 64 entries | 262,144 sectors | 134,217,728 bytes |
| 1024 bytes | 8192 sectors | 65,536 bytes | 128 entries | 1,048,576 sectors | 1,073,741,824 bytes |
| 2048 bytes | 16384 sectors | 131,072 bytes | 256 entries | 4,194,304 sectors | 8,589,934,592 bytes |
| 4096 bytes | 32768 sectors | 262,144 bytes | 512 entries | 16,777,216 sectors | 68,719,476,736 bytes |
| 8192 bytes | 65536 sectors | 524,288 bytes | 1024 entries | 67,108,864 sectors | 549,755,813,888 bytes |
File Allocation Layer
- This layer exists to group logical sectors into units called files, a file is a collection of information that logically related. In the Phoenix File System, files are described using a tree structure where that tree leafs hold the actual file information. Each node and leaf of the data tree is described using a Tree Node Descriptor:
Structure of a Tree Node Descriptor:
Offset Size Field Name Description
0h QWORD
bit 0: Type (1) Descriptor refers to SubTree block (internal node)
(0) Descriptor refers to data block (leaf)
bits 1-63: Location Logical Sector number for block location
8h QWORD Length If Type is 1, is total number of bytes described by SubTree
If Type is 0, is number of bytes in data block
----------------
Total: 16 bytes
Where each block of information is exactly 1 logical sector in size and can hold information
either about the files contents (a tree leaf) or about the location of additional blocks (a
tree node). If a sector is a data block, Length bytes
of the sector are considered to be part of the file's contents. If a sector is a SubTree block,
it is simply a consecutive list of Tree Node Descriptors and the Length
field represents the total number of bytes of the file's information that is described by
all data blocks in or under the SubTree.
Structure of a File Node:
Offset Size Field Name Description
00h DWORD MagicNumber Special number to help discern a File Node from other
data should the file system become corrupt, equal to
31534650h
04h DWORD HardLinks Number of references made from Directories to this file
08h DWORD Flags Low-level file flags
bits 0,1 : InternalFlag Indicates what file information, if any, is stored
internally if the File Node
00 = no internal data
01 = internal rights information
10 = internal extended attributes
11 = internal file data
bits 2,3 : (reserved) must be 0
bit 4 : NodeSize Indicates whether or not the File Node occupies the full
logical sector
0 = File Node is half the size of the logical sector
1 = File Node occupies the entire logical sector
bits 5-63: (reserved) must be 0
0Ch DWORD (reserved) must be 0
10h QWORD FileSize Total length of file data
18h 1 TND Rights Rights list data tree
28h 2 TNDs EAs Extended Attributes data tree
48h 7 TNDs FileData File contents data tree
B8h x BYTES InternalData minimum of 72 bytes of space specifically set aside for
storing small amounts of data inside the File Node
without using data trees. The InternalFlag determines
which information, if any, is stored internally.
A file node is always at most 1 logical sector in size and at least 256 bytes in size, as such,
the amount of space reserved for internal data with a File Node can vary from 72 bytes to
LogicalSectorSize-184
bytes in size. A File Node may occupy an entire sector or only half of a sector, the latter
only being valid for LogicalSectorSizes of 512-bytes or
more (since one half of 512 bytes is 256 bytes, the minimum size of a File Node). Furthermore,
each File Node is identified using a File Node Number of which bits 1-63 indicate the
logical sector number the File Node resides in, and bit 0 is clear if the File Node is in the
first half of the sector and is 1 if the File Node is in the second half of the sector. The
following table summarizes the minimum and maximum sizes of File Nodes and the amount of space
reserved in each File Node for internal data, based on the size of a logical sector.
| LogicalSectorSize | Supports halfing logical sector | Minimum File Node Size | Maximum File Node Size | Minimum Internal Data Reserve | Maximum Internal Data Reserve |
| 256 bytes | No | 256 bytes | 256 bytes | 72 bytes | 72 bytes |
| 512 bytes | Yes | 256 bytes | 512 bytes | 72 bytes | 328 bytes |
| 1024 bytes | Yes | 512 bytes | 1024 bytes | 328 bytes | 840 bytes |
| 2048 bytes | Yes | 1024 bytes | 2048 bytes | 840 bytes | 1864 bytes |
| 4096 bytes | Yes | 2048 bytes | 4096 bytes | 1864 bytes | 3912 bytes |
| 8192 bytes | Yes | 4096 bytes | 8192 bytes | 3912 bytes | 8008 bytes |
| LogicalSectorSize | Maximum Internal Data Reserve | Maximum Internal Rights Info | Maximum Internal Extended Attributes | Minimum Internal File Data |
| 256 bytes | 72 bytes | 86 bytes (88 total) | 102 bytes (104 total) | 184 bytes |
| 512 bytes | 328 bytes | 342 bytes (344 total) | 358 bytes (360 total) | 440 bytes |
| 1024 bytes | 840 bytes | 854 bytes (856 total) | 870 bytes (872 total) | 952 bytes |
| 2048 bytes | 1864 bytes | 1878 bytes (1880 total) | 1894 bytes (1896 total) | 1976 bytes |
| 4096 bytes | 3912 bytes | 3926 bytes (3928 total) | 3942 bytes (3944 total) | 4024 bytes |
| 8192 bytes | 8008 bytes | 8022 bytes (8024 total) | 8038 bytes (8040 total) | 8120 bytes |