User:Bellezzasolo/CFS
Filesystems |
---|
Virtual Filesystems |
Disk Filesystems |
CD/DVD Filesystems |
Network Filesystems |
Flash Filesystems |
Tera File System (TFS)
TFS64
Introduction
TFS64 is my file system (Bellezzasolo's). It uses 64 bit addressing, which is the 64. It currently hasn't been implemented, but a Win16 formatter is in active development.
It is currently at version 1.00 FINAL
Note: all fileds are little-endian
Features
- User security
- Flags
- Inode style tables
- Fixed size
- Tree-based
Limitations
There are few limitations. Here are the only ones:
- One is the 64 bit addressing, which will (one day) be changed in TFS128; but for now it's plenty
- There have to be 10 times the number of directories possible as files possible. This is because there isn't room in the master table for this data, but can be calculated by the space between the DTable pointer and the FTable pointer.
- File and Directory Name lengths.
If you spot any more, add them here
Structure
TFS64 is structured in the follwing way:
- MASTER Table - logical sector 0 of the partition. Bootloader and essential data
- Cluster Availability Table - a bit representing every cluster on the partition, in logical order
- Directory Table - directory name and a pointer to the directory entry
- File Table - a filename and a pointer to the file entry
- Directory Entries - an inode-style list of directory entries in no particular order. Variable size, and pointed to by the directory table
- File Entries - similar to directory entries, but for files and pointed to by the file table
For error checking multiple copies of the tables can be kept
Detail
MASTER Table
Name | Offset (from the start of the MASTER Table) | Length (in bytes) | Meaning |
---|---|---|---|
Jump | 0 | 2 | A jump to the bootloader if bootable, 0 otherwise. Normally disassembles to JMP SHORT 3E |
Creation Date | 2 | 8 | The creation time and date, encoded in TeraTime. TeraTime is Unix time, except the epoch is 1st Jan 2011 |
Creator ID | 10 | 4 | The creator's ID. This is normally 0, but could be set to a range of values for future use |
Disk Size (Clusters) | 14 | 8 | The number of clusters on the partition. Need I say any more? |
Bytes per Cluster | 22 | 2 | The number of bytes in a cluster. Could be the same as the disk, but then again might not be :) |
Number of Tables | 24 | 1 | The number of Copies of the tables. 1 if no backup, another number for backups. 0 is invalid |
Major Version | 25 | 2 | The major FS version. Can be any 2 byte value |
Minor Version | 27 | 1 | The minor FS version. Is the .xy after the major version. Can only be between 0 and 99 inclusive |
Directory Table Pointer | 28 | 7 | A cluster of the Directory Table. 7 bytes to save space and make an 0x3E jump. Besides, I thought the FS is pretty early ;) |
File Table Pointer | 35 | 8 | A cluster of the File Table. I'm not that stingy :) |
FS ID | 43 | 8 | The FS string. Only "TFS64 " is acceptable |
Volume Label | 51 | 11 | The volume label. 11 characters only (ASCII) |
Bootloader | 62 (or 0x3E) | 448 | The bootloader. Duh! :) |
Boot Signature | 510 | 2 | The old 0xAA55 |
Cluster Availability Table (CAT)
This is just an array of bits. Each bit represents a cluster on the partition. If it's set to 1, the custer is used. Otherwise it's free. The bit's offset from the start of the CAT is the cluster at that offset from the start of the partition. FS data is included (even itself!).
Directory Table
The directory table has an entry for each directory. Not to be confused with directory entries. The entry takes this structure:
Name | Offset | Size | Meaning |
---|---|---|---|
Directory Name | 0 | 246 | A Unicode (UTF-16) directory name |
Entry Cluster | 246 | 8 | A cluster pointer to the directory entry |
Entry Byte | 254 | 2 | A byte offset into the cluster |
File Table
The file table has an entry for each file. The entry takes this structure:
Name | Offset | Size | Meaning |
---|---|---|---|
Filename | 0 | 502 | A Unicode (UTF-16) filename |
Entry Cluster | 502 | 8 | A cluster pointer to the file entry |
Entry Byte | 510 | 2 | A byte offset into the cluster |
Directory Entry
The directory entries are pointed to by the directory table. They are similar to Ext inodes. The structure is as follows:
Name | Offset | Size | Meaning |
---|---|---|---|
Creation Date | 0 | 8 | A TeraTime creation date |
Permissions | 8 | 4 | The permissions of the directory. Bitflags |
Symbol | 12 | 2 | A registry-style database of symbols. This is the index into it |
Flags | 14 | 1 | The directory flags |
Size | 15 | 4 | The number of entries in the next two arrays |
Clusters | 19 | Size*8 | The cluster pointers to the tables for items in the directory |
Bytes | 19+Size*8 | Size*2 | The byte index into those clusters |
File Entries
The file entry is pointeed to by the file table like an Ext inode. The structure is as follows:
Name | Offset | Size | Meaning |
---|---|---|---|
Creation Date | 0 | 8 | A TeraTime creation date |
Modification Date | 8 | 8 | A TeraTime modification date |
Permissions | 16 | 4 | The permissions of the file. Bitflags |
Symbol | 20 | 2 | A registry-style database of symbols. This is the index into it |
Flags | 22 | 1 | The file flags |
Size | 23 | 4 | The number of entries in the next array |
Clusters | 27 | Size*8 | The clusters of the file |
Special Fields
Here are decriptions of the bit-flags fields:
Permissions
Other user groups (31-2) | Administrator (1) | Owner user (0) |
The user groups are defined by the OS. On a portable device these will change, so most of these fields will be unusable. The owner user is inherited from the directory, and is the only non-grouped user. The origion of the owner user is if the entry is in their personal directory.
Flags
Flags are the general attributes, such as read-only, hidden and similar.
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|
SF | AH | NW | MO | NR | CH | HI | DO |
Meanings:
- DO: Delete Only (Read only field modify protect)
- HI: Hidden
- CH: Contents Hidden (dir-only)
- NR: Non-Privileged Read - read ability for people without permissions
- MO: Modify Only (Read-only deletion protect)
- NW: Non-Privileged Write - write version of NR
- NX: Non-Privileged Execute - execute version of NW
- SF: System File - ultimate protection. Cannot be changed under TeraOS (my, Bellezzasolo's OS). Drivers should be installed to a special directory.
Flags that apply to all users
- DO
- HI
- CH
- MO
- SF
Other flag's behaviour
The NR,NW and NX flags only apply to non-privileged users, i.e those who don't have their permissions bit set.