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/)
| Directory | Lines | Share | Contents |
|---|---|---|---|
| fs/ | 69,821 | 19.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,812 | 13.4% | riscv64 / x86_64 / aarch64: boot, trap, mm (page_fault), cpu, uaccess, intc, SBI/MSR/registers |
| syscall/ | 41,083 | 11.3% | the dispatch tables and implementations (the capsule boundary: user-pointer validation/translation, uaccess_safe typed copy_in/out) |
| drivers/ | 25,436 | 7.0% | virtio (blk/net/gpu/input; queue + PCI transport), blkdev, intc, pci, gpu/drm, input, timer |
| ipc/ | 21,758 | 6.0% | binder (14,144 lines, the largest single file), access_token, SysV sem/msg/shm, POSIX MQ |
| net/ | 20,857 | 5.7% | SkBuff, eth, arp, ipv4/ipv6, icmp, udp, tcp (5,250 lines), unix (4,372 lines), netlink, raw |
| sync/ | 19,843 | 5.5% | spinlocks/sleep-locks/futex (incl. PI), CpuLocal (D-7), typed lock keys (D-11) |
| mm/ | 19,432 | 5.3% | memblock, buddy, slab, small_alloc, page fault, VMA, page-cache cooperation, kswapd, rmap |
| dfx/ | 19,395 | 5.3% | syscost, kallsyms, debugfs, taskdump, watchdog, memwatch, ledger (the diagnostics layer, unsafe tracked separately) |
| process/ | 17,709 | 4.9% | task structures, fork/exit, signals, wait, pid, cgroup |
| sched/ | 17,291 | 4.7% | the GRQ, fair/rt/deadline classes, wakewatch, census/heal |
| tests/ | 15,241 | 4.2% | 76 in-guest test files (the make test host) |
| other (interrupt/timer/io_uring/perf/security/module + top-level .rs) | 23,463 | 6.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,795 | 1.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 targetsyscall/io.rswent 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).