PSF2 Virtual Filesystem
The
PSF2 virtual filesystem is a directory hierarchy with filenames of up to 36 characters each.
Filenames are case-insensitive and must consist exclusively of characters in the ASCII 32-126 range, with the exception of the forward slash, backslash, and colon (/, \, :) characters. The total length of a path must be no longer than 255 bytes.
All quantities are stored in little-endian unsigned format. All offsets are relative to the beginning of the Reserved section.
Starting at offset 0 is the root directory.
Directory Format
A directory has the following format:
- First 4 bytes: Number of directory entries (N)
- Next 48*N bytes: N directory entries
N may be zero to indicate the directory is empty.
Directory Entries
The format of a directory entry is as follows:
- First 36 bytes: Filename
- Must have nonzero length
- Must be padded with null (0x00) bytes
- Does not have to be null-terminated if it's exactly 36 characters
- Next 4 bytes: Offset (O) of the file data or subdirectory
- Next 4 bytes: Uncompressed size (U)
- Next 4 bytes: Block size (B)
If U, B, and O are all zero, then the entry describes a zero-length file. In this case, there is no data.
If U and B are zero and O is nonzero, the entry describes a subdirectory.
Otherwise, the entry describes a regular file.
File Data Format
File data is stored as a sequence of consecutive zlib compress()-format blocks.
- First 4*X bytes: Size table
- Each entry contains the size of a compressed block
- X = (U + B - 1) / B;
- Remainder of file data: Compressed blocks
- The uncompressed size of all blocks (except the last) must equal B
- The last block may have an uncompressed size less than or equal to B
Consistency
The offset of any subdirectory or file must be greater than the offset of its directory entry. This provides for easier consistency checks.
CategoryPSF