Technical Data
==============

Units used here (and through-out stegfs) are in powers of 2---so think
multiples of 1,024 not 1,000.

Each file system block is 2,048 bytes, with 1,984 being used for actual
data, with the rest being used to verify the integrity of the data, and
point to the location of the next block. (Yes this makes it inefficient,
but the possibility of not being able to retrieve data eclipses this
small inconvenience.)

Using 64 bits to represent the block numbers allows up to 1.845e19
blocks. This allows a theoretical maximum partition size of 32ZB, and a
theoretical capacity of over 15EB. Although the maximum file size will
always be 1/8 of the overall capacity due to file replication.

In practice, due to the limits of the open64() function used by the GNU
C Library and the Linux kernel, the maximum usable limit stands as 8EB.
(This is because both GNU and Linux use signed 64 bit integers, whereas
stegfs uses unsigned 64 bit integers). This allows over approximately 4
billion (long scale) blocks, allowing a partition size of 4TB and over
3.8TB of space. (Other limits may exist on other systems.)

RAM requirements for stegfs are a little on the high side too: it will
use between 0.8% and just over 1.6% of the total file system size. This
might not seem like much but if you were to have a 1TB stegfs partition
it would need at least 8GB of RAM to even start, and in excess of 16GB
if you were to fill it to capacity!

Cipher Details
--------------

stegfs is currently (during this development phase) aiming to support
a variety of ciphers and hashes, as well as various key and block
lengths. These will be set when the file system is created and detected
at each mount. The file system block size has been chosen to allow
cipher key lengths of 128, 192, and 256 bits, and hashes up to 256 bits
(excess are discarded).

Example/Explanation
--------------------

A 1GB file system has 524,288 blocks (524,287 are available for file
data, as the first contains file system information). Each of these
blocks can store 1,976 bytes of data, resulting in 988MB of total
capacity.  As each file is duplicated multiple times (8×) the single
largest file size is over 123MB---which is also the maximum available
capacity if everything is stored in the / of the file system.

Block Layout
------------

Total block size = 2KB = 16,384 bits = 1,976 file data bytes + metadata

     Chunk Name                                        Size (in bits)
    +----------------------------------------------------------------+ -+
    | Directory/Path checksum                            32    (256) |  +- hash
    | [Nothing - 0xFF]                                               |  |
    |                                                                |  |
    |                                                                |  |
    +----------------------------------------------------------------+ -+--------+
    | Data                                            1,976 (15,808) |           |
    | (File modification timestamp¹)                                 |           |
    | [File system information]                                      |           |
    |                                                                |           +‐ cipher; blocksize:  64 × 252 blocks
    | ¹ Followed by: - list of first blocks (many 64 bit integers²)  |           |                     128 × 126
    |                - random (not used; variable size)              |           |                     192 ×  84
    |                - start of file data  (1,024 bytes/8,192 bits)  |           |                     256 ×  63
    |                                                                |           |
    | ² The number of copies be vary from 1 to 64, which will use    |           |
    |   between 8 and 512 bytes                                      |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    |                                                                |           |
    +----------------------------------------------------------------+ -+        |
    | Checksum                                           32    (256) |  |        |
    | [Hash of "stegfs-2015.08"]                                     |  +- hash  |
    |                                                                |  |        |
    |                                                                |  |        |
    +----------------------------------------------------------------+ -+        |
    | Next block (File size) [Total blocks]               8     (64) |           |
    +----------------------------------------------------------------+ ----------+
