Code layout

Repository layout and the kernel source map β€” convention (main 2e5667a6b, recounted 2026-11-16, git ls-files + wc -l): kernel/ 626 files Β· 398,905 lines (392,245 Rust); kernel/src 456 files Β· 369,486 lines

Β§1The kernel source map (kernel/src/)

DirectoryLinesShareContents
fs/69,82119.2%ext4 (12 files), jbd2, VFS, dcache, page_cache, bio/buffer, procfs/sysfs/debugfs/tracefs/tmpfs, pipe, xattr, inotify, locks, io_uring, elf
arch/48,81213.4%riscv64 / x86_64 / aarch64: boot, trap, mm (page_fault), cpu, uaccess, intc, SBI/MSR/registers
syscall/41,08311.3%the dispatch tables and implementations (the capsule boundary: user-pointer validation/translation, uaccess_safe typed copy_in/out)
drivers/25,4367.0%virtio (blk/net/gpu/input; queue + PCI transport), blkdev, intc, pci, gpu/drm, input, timer
ipc/21,7586.0%binder (14,144 lines, the largest single file), access_token, SysV sem/msg/shm, POSIX MQ
net/20,8575.7%SkBuff, eth, arp, ipv4/ipv6, icmp, udp, tcp (5,250 lines), unix (4,372 lines), netlink, raw
sync/19,8435.5%spinlocks/sleep-locks/futex (incl. PI), CpuLocal (D-7), typed lock keys (D-11)
mm/19,4325.3%memblock, buddy, slab, small_alloc, page fault, VMA, page-cache cooperation, kswapd, rmap
dfx/19,3955.3%syscost, kallsyms, debugfs, taskdump, watchdog, memwatch, ledger (the diagnostics layer, unsafe tracked separately)
process/17,7094.9%task structures, fork/exit, signals, wait, pid, cgroup
sched/17,2914.7%the GRQ, fair/rt/deadline classes, wakewatch, census/heal
tests/15,2414.2%76 in-guest test files (the make test host)
other (interrupt/timer/io_uring/perf/security/module + top-level .rs)23,4636.4%interrupt subsystem, timer wheel, the io_uring stub, perf counters, LSM/capabilities, module stub, and 13 top-level files (init/panic/console etc.)
trace/3,7951.0%the unified trace-event framework: the event side + the tracefs file side (69 events / 17 groups)
verify/ (kernel/verify, outside the kernel/src total)28,216β€”the formal-verification crate: 157 Kani harnesses, 1104 proptests, 4 SPIN models, Miri/loom mirrors

Β§2Layering and unsafe governance

docs/architecture/kernel-layers.md defines the longest-prefix-match layering: unmatched files default into the safest bucket.

  • Framework layer (arch/mm primitives/interrupt/virtio core/trace/perf): unsafe allowed, every block requiring a // SAFETY: comment (3,207/5,009 = 64% covered).
  • Service layer: targets 100% forbid(unsafe_code) β€” 47 files already forbid it at compile time, 56 more contain none; the first named shrink target syscall/io.rs went 69 unsafe tokens β†’ 0 (typed entries + uaccess_safe).
  • The syscall boundary is the capsule boundary: entries validate and translate user pointers; uaccess_safe.rs provides typed copy_in/copy_out.
  • 7.1% of lines are unsafe (14.0% on the dual series); the trace module bans unsafe entirely.

Β§3Top-level repository layout

Rux/
β”œβ”€β”€ kernel/       # kernel sources (table above)
β”œβ”€β”€ userspace/    # mrsh, toybox, linux-ltp, probes/ (tarball+extract.sh), fio, geekbench, lmbench, stress
β”œβ”€β”€ test/         # guest-side C probe sources (pbench.c etc.) + suite dirs (ubuntu-gnome, ltpscan, stressng…)
β”œβ”€β”€ scripts/      # host-side: extract-probes.sh, test/ (run.sh, run-x86-ub.sh, oh-boot.sh…)
β”œβ”€β”€ toolchain/    # self-built musl cross toolchains (build-musl.sh, riscv64-rux-linux-musl/, x86_64 sysroot tarball)
β”œβ”€β”€ build/        # build/config tooling (build/Makefile, menuconfig.sh, current-platform.sh)
β”œβ”€β”€ work/         # runtime artifacts (gnome-x86.img, rootfs, pbench disks)
β”œβ”€β”€ docs/         # documentation: guides/ architecture/ development/ test/ progress/
β”œβ”€β”€ AGENTS.md     # the binding development workflow (the de-facto contribution guide)
β”œβ”€β”€ Kernel.toml   # kernel configuration β†’ kernel/src/config.rs
└── Makefile      # top-level entry (forwards to build/Makefile)
The probe-tarball policy: guest test-case sources are archived only as userspace/probes/probes.tar.gz + extract.sh; make user / make test restore them idempotently via scripts/extract-probes.sh β€” loose guest C sources are never committed.

Β§4Language composition

The kernel itself is 100% Rust (no_std, plus the necessary platform assembly); userspace probes are C (musl cross-compiled); repository language statistics use the git ls-files basis (vendored toybox is marked linguist-vendored).