jakel
jakel is the filesystem. files and directories are stored in the same parallel-array table the rest of the kernel uses for tasks and windows. an ata pio driver underneath persists the entire filesystem to a raw disk image, so files survive reboots.
nodes
every file and directory is a node in a fixed-size table. each node has a type (file or directory), a name, a parent id, a size, and a pointer to a heap buffer. for files the buffer holds raw bytes. for directories it holds an array of child node ids. the root directory is node zero, and it is its own parent.
directory children are stored as a contiguous array of 8-byte ids that grows on each add. a new buffer is allocated, the old children copied in, the new one appended, and the old buffer freed. the same allocate-copy-free pattern handles extending files on write.
paths
paths are slash-separated. an absolute path starts with / and resolves from the
root. anything else resolves from the current working directory, which starts at the root and
stays there until change moves it. .. goes up one level and there
is no . yet. path resolution walks one component at a time, looking each up in the
current directory's child table. if a non-directory appears before the last component the
path is rejected.
api
the low-level interface is available to any kernel code, not just the shell.
jakel_mkdir(parent, name)create a directoryjakel_make_file(parent, name)create an empty filejakel_remove(id)delete a node (directories must be empty)jakel_lookup(parent, name)find a child by name, returns id or -1jakel_open(parent, path)resolve a path string, returns node idjakel_read(id, offset, buf, len)read bytes from a filejakel_write(id, offset, buf, len)write bytes, extending the file if needed
shell
skalman gained four builtins that drive jakel.
listshow the current directory's contentslist /some/pathshow a specific directorychange /some/pathchange the current working directorychange ..go up one levelwhereprint the full path of the current directorymake readme.txtcreate an empty filemake projectscreate an empty directorymake projects/readme.txtnested paths create intermediate directoriesremove readme.txtdelete a file or empty directoryecho --file readme.txtprint a file's contents to the consolewrite readme.txt hello worldwrite text into a filesyncpersist all files to disk
disk persistence
the filesystem can be written to and loaded from an ata disk.
jakel_sync serialises the entire state (a superblock, a node table with
inline names, and raw file data) into 512-byte sectors on the disk.
jakel_load reads it back at boot and reconstructs the in-memory tree.
directory children are not serialised, they are rebuilt from parent pointers on load,
which is simpler and harder to get wrong. the sync shell command triggers a manual
flush, and the initial fresh filesystem is auto-synced so the second boot always loads
from disk.