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;
an installed disk adds a persistent FAT data volume at
/data.
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, sata0p2 or usb0p1.
USB mass-storage devices are registered by
usbmsc.c and mount exactly like an
internal disk; the install command is separate and
clones raw image sectors without parsing FAT.
- 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 file operation runs in a non-preemptible section because the FAT driver has static state and the floppy needs IRQ 6;
vfs_scan_busy/format_busymake it sleep first while a mount scan or a format owns the disks. A format releases the BKL for its raw-sector loop, and only disk-backed mounts wait for it, so/ramfsand/sharestay usable. A rescan (thebootscanthread or thestoragecommand) re-adds/ramfs//sharefirst and is skipped by their operations too (vfs_mount_is_ram); it runs preemptible, and the floppy/ATA/AHCI/SDHCI wait loops (including the SDHCI command and CMD1 power-up polls) callvfs_scan_poll/vfs_scan_relax, which sleep (dropping the BKL) once a wait passes 2 ms and only for the scan's owning process. A USB disk read by the rescan claims the USB bus (usb_bus_claim()), so its host-controller waits yield too;storageno longer freezes the WM. The floppy probe is skipped for a drive whose CMOS type (register0x10) is 0.
fatdetect.c and fatformat.c
back the format command. A disk can be formatted in
binary units (format ide0 100mb, 1gb) or
whole-disk; the Chromebook eMMC is format mmc0.
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.
The whole-buffer helpers in inflate.c
(inflate_gzip_mem and friends, also used by the image
decoders) decode with 10-bit Huffman lookup tables straight into the
output buffer and checksum once at the end, about five times faster
than the bit-at-a-time streaming decoder that HTTP bodies still use.
_end.
The high-memory legacy loader caps the compressed pack at 1 MB;
the 8 MB rootfs partition and ramfs cap remain the larger limits.
| 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. |
rootfs-full.bin | NBROOT1 + full gzip | Network persistent-install payload. |
/share | RAM entries | Writable upload target; not part of the pack. |
/data | FAT32/16, label NEBOSDATA | Partition 4 on the installed disk; persistent user files. |
The pack build is part of the normal Makefile. Add a
user/apps/<name>/ucmd_<name>.c and its name 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.
/data
The installer creates a fourth partition after the 8 MB ESP and
formats it as FAT with the label NEBOSDATA. It fills
the rest of the disk and is mounted at /data; the VFS
recognises the label in the FAT boot sector, not the device name, so
the path is stable on mmc0, sata0 or
ide0.
- Persistent. A reinstall or
install <target> selfreplaces the OS partitions (P1 kernel, P2 rootfs pack, P3 ESP) and keeps P4.net-installwrites only P1/P2. - First install is destructive. Creating P4 formats the rest of the target disk; an existing
NEBOSDATAvolume is detected and left untouched. - 8.3 names. The FAT driver creates and reads short names only; long names need VFAT LFN write support.
- WiFi credentials. A successful WiFi connect adds the network to a most-recently-used list of up to 16 SSID/passphrase records in
WIFI.CFG; the boot-timewifi autoconnecthelper scans and joins the strongest saved network it finds.wifi savedlists them andwifi forget [ssid]removes one. The file is plaintext and 8.3, like the rest of the volume. - Chat session. The Chat client stores its server and session cookie in
CHAT.CFGwhen this volume is mounted; without it the client falls back to the RAM-only/share/chat.cfg. The cookie is a bearer credential, and the password is never stored. - Fixed start. P4 starts at LBA 34816. A BIOS-only install leaves the space between P2 and P4 unpartitioned, and a later disk clone does not resize P4.
- Mount settings. The
disksapp saves the mount policies inMOUNTS.CFG; the boot scan applies them (see below). - No fsck. Like the other FAT mounts, the volume has no journal, repair tool or permissions; it is writable by every process.
Storage manager & mount policies
disks (ucmd_disks.c, also the
top-bar Disks launcher and the Disks button in
files) is the ngui front end to
storage; storage stays the text view. It lists every
present block device (SYS_BLKDEV), reads sector 0 and
each partition's first sector through SYS_BLK_READ
(119) to show the MBR, the NebOS boot partition, the rootfs, FAT
types and labels, and shows all mounts with their source volume.
Floppies are never read raw (no media means seconds of retries).
- Mount policies.
SYS_MOUNT_CTL(120) sets or reads astruct sys_mount_policy: a mount name,SYS_MOUNT_ROandSYS_MOUNT_NOAUTO, keyed by the volume's default name (ide0p1, orusb0/floppy1for a whole-device volume). vfs.c keeps up to 16 in RAM;mount_one()honours them on every scan and a set remounts the device at once. Names are 1–15 of[a-z0-9_-];ramfs/shareare refused and a name already in use falls back to the default. - Read-only. Write, unlink, mkdir and rmdir on a mount with
roset returnSYS_EROFSbefore reaching the backend (this also covers the ramfs). - Persistence. The app writes the table to
MOUNTS.CFGon theNEBOSDATAvolume ("NBMNT1\n\0"then the records); thebootscanthread reads/data/MOUNTS.CFGaftervfs_mount_all()and applies it. Without/datathe settings last until reboot. The data volume itself cannot be edited, since it stores the file. - Format and install. The app confirms in its own dialog, then runs
format -y <dev> [size]orinstall -y <dev> [self]throughSYS_SPAWN_KCMDon a private tty and shows the output;-yskips the commands' raw-keyboard y/n prompt. An installed disk offers Update (self) and Reinstall (clone), a blank one Install.
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; the storage
manager adds SYS_BLK_READ and
SYS_MOUNT_CTL. struct sys_mount carries the
source device and the volume key.
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 and /data are the writable
targets (RAM and persistent respectively).
- 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 still takes the raw NIC lease, so it is mutually
exclusive with packet-level commands and with TCP client connections
(curl and the browser workers). Starting
websrv while another raw owner exists fails; TCP clients
fail to connect while it owns the receiver.
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 volatile data and/datafor persistent files. - 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
kernel/vfs.c,kernel/vfs.h— mounts and dispatchkernel/fat.c,kernel/fat.h— FAT12/16/32kernel/ramfs.c,kernel/ramfs.h— pack inflatekernel/share.c,kernel/share.h— /sharekernel/sys_fs.c— ring-3 file service, raw sector read, mount policies andMOUNTS.CFGloaderuser/apps/disks/ucmd_disks.c— storage manager apptools/mkpack.c,tools/mkrootfs.c,include/rootfs.hcommon/inflate.c— DEFLATE/gzipuser/apps/websrv/ucmd_websrv.c— HTTP/WebDAVkernel/fatdetect.c,kernel/fatformat.c— formatkernel/usbmsc.c,kernel/usbmsc.h— USB mass-storage block deviceskernel/install.c,kernel/install.h— clone, self-update and net-install writerinclude/rootfs.h— installed image geometry and NBROOT1 header