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.
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_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.
- Read/write. Read, write, delete, mkdir and rmdir are implemented; FAT32 allocation uses an FSInfo-seeded free-cluster hint.
- 8.3 names. The on-disk name is the canonical one. The shell and
filesdisplay the space-padded form; a long name cannot be created. - Directory cache. The last FAT directory's first 64 entries are cached in
vfs.c, so WebDAV's index sequence is one walk instead of N. Any write invalidates the cache. - Serialization. A FAT operation sets
sys_fs_busy; the scheduler does not switch processes during it because the driver has static state and the floppy needs IRQ 6.
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.
_end.
The legacy boot path still caps the compressed pack at about 255 KB;
UEFI and kexec can carry more.
| Container | Format | Purpose |
|---|---|---|
cmds.pack | NBPAK1 | Raw command archive: bin/<name> entries. |
cmds_pack_gz.bin | gzip | Compressed pack; libdeflate-gzip -12 when available. |
rootfs.bin | NBROOT1 + gzip | Floppy append (header + pack). |
cmds.img | NBROOT1 padded to 8 MB | USB rootfs partition image. |
/share | RAM entries | Writable 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.
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.
- Concurrency. One active connection plus a small backlog (three backlog/closing slots in the current TCP server). Parallel clients queue with a zero window until the active request finishes.
- Bodies. Whole-file buffering, 4 MB normally and 1 MB when the heap cannot provide the larger buffer. A larger PUT gets 413.
- Methods. GET, PUT, DELETE, MKCOL, PROPFIND and MOVE to the extent described; directory
MOVEis 501 andPROPPATCHis answered 200 without persisting. - No auth. This is a trusted-LAN service;
/shareis writable by anyone who can reach it.
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
Limits
- Whole-file service. Commands read a complete file into memory; there is no stream API for general files.
- FAT names. No long filename creation or lookup. WebDAV refuses names that cannot be represented exactly in 8.3.
- ramfs is read-only. Writes return
SYS_EROFS; use/sharefor mutable data. - Pack volatile at runtime. Runtime pack replacement is RAM only; a cold boot uses the flashed rootfs.
- Directory listing cache. Only the first 64 entries of the last FAT directory are cached; a very large directory still costs a walk.
Source map
vfs.c,vfs.h— mounts and dispatchfat.c,fat.h— FAT12/16/32ramfs.c,ramfs.h— pack inflateshare.c,share.h— /sharesys_fs.c— ring-3 file servicemkpack.c,mkrootfs.c,rootfs.hinflate.c— DEFLATE/gzipucmd_websrv.c— HTTP/WebDAVfatdetect.c,fatformat.c— format