Explanation of ftree's on-disk format
=====================================

The file is divided into 16-byte blocks, the first of which is the "head".
The others are part of either "free" records or "nodes", which can span
multiple contiguous blocks (up to 256 or 255, respectively).  All unsigned
integers are stored in little endian order.  In the future, big endian may
be supported via a different magic number in the head record.


Head record
-----------
The head is composed of 3 4-byte unsigned ints, followed by a 3-byte magic
number (in this case 'M', 'T', 0xFF).  The fields are as follows:

	+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
	| tail  | head  | first |magic|
	+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Where tail and head contain the block numbers of the last and first free
records, respectively, first contains the block number of the root of the
tree, magic is the magic number, and the missing byte is used as described
below.


Free record
-----------
A free record is composed of 2 4-byte unsigned ints, followed by a 1-byte
unsigned int, as follows:

	+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
	| prev  | next  |S|  filler   |
	+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Where prev and next are the block numbers of the previous and next free
records, respectively, or 0 if there is no previous or next free block.
S is one less than the size of this free record, as measured in blocks.
The filler area is unused, and the missing byte is used as described below.


Node record
-----------
A node record is composed of 3 4-byte unsigned ints, followed by a string
that can be from 1 to 4067 bytes long, including the terminating null byte.

	+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
	| child | next  | value | str |
	+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

	+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
	| child | next  | value |  str  |
	+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
	|        str continued...       |
	+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
	|        str continued...     |
	+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Where child is the block number of the node "under" this one (or 0 if there
is none), next is the block number of the next node at this same level (or
0 if there is none), value is non-zero iff this is the last node of an
entry, and the missing byte is used as described below.

The missing byte
----------------
The last byte of any record is used to store the size of the following
record when it is a node record, and is 0 when the following record is a
free record.  This allows ftree_free() to find the next free record when
handed a record to be freed.

