Storage & filesystems

One VFS, three very different backends.

The kernel keeps filesystem policy thin: a mount table and an fs_ops vtable. FAT provides persistent read/write storage, the command-pack ramfs is a read-only system image, and /share is a writable RAM filesystem for network uploads.

FAT12/16/32 read-only ramfs /share · 16 MB WebDAV

VFS layer

vfs.c mounts every detected FAT device under /, keeps the two memory filesystems available throughout the boot scan, and dispatches file operations through struct fs_ops. The shell, the file service and the WebDAV server never call fat_* directly.

VFS and filesystem backends The shell, sys_fs and WebDAV use the VFS mount table, which dispatches to FAT, ramfs or share through fs_ops. FAT sits on the block-device registry. shell / commands ls, cat, save, files sys_fs · WebDAV ring-3 file service vfs.c mount table · fs_ops directory cache last 64 FAT entries FAT12/16/32 read + write · 8.3 names ramfs read-only · command pack /share writable · RAM only block devices floppy · ide · sata
Same operations, different storage. Each backend implements read, load/release, stat, write, unlink, mkdir, rmdir and index-based directory listing. Paths passed to the backend are relative to the mount; the VFS has already normalised them.

vfs_resolve() drops . components, collapses and trims slashes, and resolves .. against the mount. The shell's working directory is per-process and inherited across commands, so relative paths keep working after cd.

FAT

fat.c supports FAT12, FAT16 and FAT32 on any registered block device. It reads the BPB, validates the media byte and mounts partitions as separate entries such as ide0p1 or sata0p2.

fatdetect.c and fatformat.c back the format command. A disk can be formatted in binary units (format ide0 100mb, 1gb) or whole-disk.

FAT32 limits. The FSInfo free-count is not updated, and a completely full FAT32 directory is not grown: new cluster allocation for directories is not implemented.

ramfs & the command pack

The system root is a compressed command pack, not a disk image. Every ring-3 command is a static ELF linked at 0x40000000, packed as bin/<name>, gzipped and wrapped in a one-sector NBROOT1 header. At boot the path loads the pack into RAM and ramfs.c inflates it into a private page-allocated copy mounted read-only at /ramfs.

Command pack build and boot pipeline ucmd ELFs are packed by mkpack, gzipped, wrapped by mkrootfs, loaded by the boot path into RAM, then inflated by ramfs_init and mounted at /ramfs. ucmd_*.c 42 UCMDS + 3 app ELFs mkpack NBPAK1 · bin/name gzip -12 cmds_pack_gz.bin mkrootfs NBROOT1 header boot path pack_addr / pack_size ramfs_init inflate + validate /ramfs read-only · bin/command Runtime replacement: KXNP packs replace /ramfs in place. Existing processes keep their loaded ELFs.
The pack is the root filesystem. The kernel no longer embeds it, so command growth does not move _end. The high-memory legacy loader caps the compressed pack at 512 KB; the 8 MB rootfs partition and ramfs cap remain the larger limits.
ContainerFormatPurpose
cmds.packNBPAK1Raw command archive: bin/<name> entries.
cmds_pack_gz.bingzipCompressed pack; libdeflate-gzip -12 when available.
rootfs.binNBROOT1 + gzipFloppy append (header + pack).
cmds.imgNBROOT1 padded to 8 MBUSB rootfs partition image.
/shareRAM entriesWritable upload target; not part of the pack.

The pack build is part of the normal Makefile. Add a ucmd_<name>.c to UCMDS and the pack, the mount and the PATH listing pick it up automatically. Runtime replacement uses make cmds-dev or make net-cmds and validates the pack before swapping it.

/share

share.c is a writable, page-backed in-memory filesystem for network uploads. It matters on boards with no writable disk, or when the only writable medium is a floppy. Entries are full relative paths plus explicit directory entries, so empty directories work; names are plain strings up to 63 bytes.

File service ABI

Ring-3 commands use SYS_READ_FILE, SYS_WRITE_FILE, SYS_LIST_DIR, SYS_LIST_MOUNTS, SYS_UNLINK, SYS_MKDIR, SYS_RMDIR, SYS_FS_STAT and SYS_GETCWD. sys_fs.c validates the path, resolves it against the caller's cwd, calls the VFS and maps backend errors to the stable SYS_E* values.

The file service reads whole files, not streams. The shell loads an ELF through vfs_load_file and spawns it; FAT ELFs are loaded through kmalloc under sys_fs_enter/exit, since the floppy needs IRQ 6.

Directory entries carry a 64-byte display name plus raw_83, so FAT's space-padded names and the string-named memory filesystems share one ABI.

WebDAV

websrv is a ring-3 HTTP/1.1 + WebDAV server built on the kernel TCP listener. It serves the VFS: / lists mounts, /ramfs is read-only, FAT mounts accept only names that round-trip to 8.3, and /share is the writable target.

The WebDAV server and the packet-level ping/curl/ netrecv commands are mutually exclusive: both need the single NIC receiver. Starting websrv while another command owns the receiver fails.

Capacity chart

Different limits for different paths. The legacy boot stage's compressed-pack cap is much smaller than the 8 MB ramfs cap; UEFI and kexec avoid the low-gap bottleneck.

Limits

Source map