Expand description
Building a TFS image on the host.
The guest driver reads and writes an image; this builds one. A filesystem needs to exist before a driver can be tested against it, and formatting a disk from inside a machine that cannot yet read a disk is a bootstrap problem better solved on the host.
§Why fields are stored in base 243
A stored word is three trytes, and every tryte crossing to the image must be a byte: 0 to 255. That leaves a choice of radix for spreading a value across the three.
The obvious choice is 256, which is what a binary filesystem would use. It
is a poor one here. Reassembling a field would mean computing
t0 + 256*t1 + 65536*t2, and 256 is not a power of three, so each of those
is a genuine multiply on every metadata access.
Base 243 is used instead. It is 3^5, so it is a power of three, and it is
below 256, so every digit is still a valid byte. Reassembling a field
becomes t0 + (t1 << 5) + (t2 << 10) in trit shifts, which the machine does
with shl in one instruction each.
The cost is range: a stored word reaches 243^3 - 1 rather than 256^3 - 1, a loss of about 15 per cent. The fields this format stores are block numbers, inode numbers and file sizes, all far below either limit.
Structs§
- Builder
- Builds a TFS image.
Enums§
- Build
Error - Something the builder could not do.
Constants§
- MAX_
STORED - Largest value a stored word can hold.
- RADIX
- How a value is split across the trytes of a word.
- RADIX_
TRITS - Trits per stored digit:
RADIXis 3 to this power.