Documentation Index
Fetch the complete documentation index at: https://mintlify.com/CRISTOP-bot/cris-os-v2/llms.txt
Use this file to discover all available pages before exploring further.
tools/build_rootfs.py converts the rootfs/ directory into a flat CRFS binary image written to iso/boot/rootfs.bin. GRUB loads this image as a Multiboot module alongside the kernel, and the kernel’s VFS layer mounts it as the root filesystem at boot. Every file placed under rootfs/ during development is automatically visible inside the OS the next time the image is rebuilt.
CRFS image format
CRFS (CrisOS Root FileSystem) is a simple, read-only flat archive — conceptually similar to an initramfs cpio archive, but with a fixed 16-byte header and uniform 64-byte name fields. The entire format is defined intools/build_rootfs.py.
Header
| Offset | Size | Field | Value |
|---|---|---|---|
| 0 | 4 bytes | Magic | CRFS (ASCII) |
| 4 | 4 bytes | Version | 1 (little-endian) |
| 8 | 4 bytes | File count | Number of file entries |
| 12 | 4 bytes | Reserved | 0 |
Per-file entry
| Offset | Size | Field | Description |
|---|---|---|---|
| 0 | 64 bytes | Name | Null-terminated UTF-8 path, zero-padded to 64 bytes |
| 64 | 4 bytes | Offset | Byte offset of file data from start of image |
| 68 | 4 bytes | Size | File size in bytes |
Alignment
All file data regions are 4-byte aligned. The builder pads each file’s data with\x00 bytes to reach the next 4-byte boundary before writing the next file. The table of entries itself is also padded to a 4-byte boundary before the first byte of file data begins.
Build logic (abridged)
File names are truncated to 63 bytes (the 64th byte is always
\x00). A file whose relative path encodes to more than 63 UTF-8 bytes causes the builder to raise a ValueError and abort. Keep paths short or use short directory names.Building the image
Direct invocation
iso/boot/rootfs.bin, overwriting any existing file.Rootfs directory contents
Therootfs/ tree is the source of truth for everything the OS can read at runtime. The current contents are:
| Path | Description |
|---|---|
README.txt | Welcome message displayed or read via cat at the shell |
info.txt | CrisOS version and build information |
lcp_repo.txt | LCP package repository in the in-kernel text format, parsed by lcp_init() at boot |
bin/hello.txt | Example file under bin/; demonstrates that binary-like paths work in CRFS |
boot/hello.boot | Example boot entry unit; parsed by boot_init() when scanning boot/ for .boot files |
share/nano-cris/help.txt | Help text for the nano-cris editor package |
systemd/hello.service | Example systemd-like service unit file |
Adding files to the rootfs
Place the file under rootfs/
Copy or create any file anywhere within the
rootfs/ tree. Subdirectories are created automatically during the walk — you do not need to add empty directory entries.Rebuild the image
rootfs/ directory and writes a fresh iso/boot/rootfs.bin. The new file is immediately visible to the kernel VFS on the next boot.How the kernel mounts the image
GRUB’s Multiboot specification lets a bootloader pass one or more binary modules to the kernel alongside the ELF image itself. The CrisOS v2 GRUB configuration addsiso/boot/rootfs.bin as a module. At kernel startup:
- The Multiboot info structure is inspected for module entries.
- The first module is treated as the CRFS image.
- The kernel reads the 16-byte header, validates the
CRFSmagic and version1, then iterates over the file-entry table to populate the in-memory VFS. - From that point on, every
fs_find()call resolves paths against the CRFS entry table.