Skip to main content

Crate ternaria_fs

Crate ternaria_fs 

Source
Expand description

TFS, the Ternaria filesystem.

§What this is for

A filesystem the guest can implement in assembly, so that a shell exists before a compiler does. Every structure is sized to a whole number of trytes, every field is a whole word, and nothing needs multiplication by a number that is not a power of three to reach.

It is deliberately plain: no journal, no extents, no indirection. Those are not the interesting part of a ternary machine, and a format that can be driven by a few hundred instructions is worth more right now than one that cannot be driven at all.

§Layout

The unit is the block, which is one device sector: 243 trytes.

  block 0        superblock
  block 1..4     allocation map, one tryte per block
  block 4..13    inode table, 9 inodes per block
  block 13..     data

Every one of those boundaries is recorded in the superblock, so a driver reads them rather than assuming them.

§Sizes

An inode is 27 trytes, so nine fit a block with nothing left over. A directory entry is also 27 trytes, so a directory block holds nine entries. Both numbers are 3^2, and a block is 3^5 trytes, so dividing an offset by an entry size is a trit shift rather than a division.

Re-exports§

pub use image::Builder;

Modules§

image
Building a TFS image on the host.
ino
Word offsets within an inode.
kind
What an inode describes.
sb
Word offsets within the superblock, which is block 0.

Constants§

BLOCK_TRYTES
Trytes per block. One device sector.
BLOCK_WORDS
Words per block.
DIRECT_BLOCKS
Direct block pointers in an inode.
DIRENTS_PER_BLOCK
Directory entries per block.
DIRENT_TRYTES
Trytes in one directory entry. The same as an inode, so a driver walking either steps by the same amount.
INODES_PER_BLOCK
Inodes per block: 3^2.
INODE_TRYTES
Trytes in one inode: 3^3.
MAGIC
Value identifying a TFS image, in word 0 of the superblock.
MAX_FILE_TRYTES
Largest file the format can express, in trytes.
NAME_TRYTES
Trytes of name in a directory entry.
ROOT_INODE
Inode number of the root directory. Inode 0 means “none”.
WORD_TRYTES
Trytes per word.

Functions§

prelude
Assembler .equ lines naming every constant a driver needs.