Skip to content

Instantly share code, notes, and snippets.

@DeclanHoare
Last active September 25, 2017 22:50
Show Gist options
  • Select an option

  • Save DeclanHoare/1ecab7d2e8cea2304c0f4095a03056e0 to your computer and use it in GitHub Desktop.

Select an option

Save DeclanHoare/1ecab7d2e8cea2304c0f4095a03056e0 to your computer and use it in GitHub Desktop.
LLFS design
at the start: "LLFS"
8-byte pointer to first used node or NULL
8-byte pointer to last used node or NULL
8-byte pointer to first free file node or NULL
8-byte pointer to last free file node or NULL
8-byte pointer to first free directory node or NULL
8-byte pointer to last free directory node or NULL
8-byte pointer to end of file system
Each node has:
8-byte pointer to parent node or NULL for top
8-byte pointer to previous node or NULL
8-byte pointer to next node or NULL
1-byte type
Pascal string name
2-byte unix permissions
4-byte owner UID
4-byte owner GID
8-byte created timestamp
8-byte modified timestamp
8-byte accessed timestamp
Each file node then has:
8-byte true length
8-byte initial length
Each directory node then has:
8-byte pointer to first child node or NULL
8-byte pointer to last child node or NULL
The 1-byte type can be:
0 - FILE
1 - DIRECTORY
2 - FREE FILE
3 - FREE DIRECTORY
FREE nodes should only reside on the special list at the top level.
When an entry is being deleted, it is un-linked from the PREVIOUS, NEXT,
and (if necessary) PARENT nodes, its type is changed to the equivalent
FREE type, and it is appended to the free list. When creating a new
directory, an entry is un-linked from the start of the free directory
list and re-linked to the appropriate parent directory if there are any
available - if not, a new one is allocated at the end of the file
system. When creating a new file, the free file list is walked to find
a free file with an initial length high enough to contain the new data.
If it exists, it will be similarly un-linked and re-linked.
When a file grows above its initial length it is effectively deleted
and a new file is created with the new contents.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment