$ show hermit-os/hermit-rs
Hermit-rs is a Rust-based unikernel (library OS) that enables applications to run directly on hardware or hypervisors without a traditional operating system. The repository provides the build infrastructure (the `hermit` crate), the system call ABI (`hermit-abi`), and a collection of example applications demonstrating networking, file systems, TLS, WASM execution, and more. The actual kernel is maintained in a separate submodule. The project is actively developed with CI testing across x86_64, aarch64, and riscv64 architectures, and supports running under QEMU, Uhyve, and KVM. It is a hybrid of a system library and an application framework, but its dominant character is an application platform for building unikernel images.
The LLM identified 8 files worth highlighting for reuse:
Defines the complete system call interface for the Hermit unikernel, including data structures (sockaddr, stat, timespec, etc.) and extern "C" function declarations for all syscalls (read, write, open, socket, etc.). This is a self-contained, well-documented ABI that could be reused as a reference or directly in other unikernel projects.
Implements the user-space side of system calls for the Hermit unikernel. Provides a `syscall!` macro that dispatches to architecture-specific assembly, and wraps each syscall with errno handling. The pattern of using a macro to generate syscall wrappers is clean and reusable for any OS project needing a syscall interface.
Contains the actual `syscall` instruction invocations for x86_64 using inline assembly. Provides functions `syscall0` through `syscall6` with proper register constraints. This is a low-level, well-crafted piece of assembly that can be extracted for any bare-metal Rust project needing to invoke system calls.
Implements a simple global allocator using the `talc` crate, wrapped in a spinlock. Demonstrates how to set up a heap allocator in a no_std environment with `take-static` for static memory. The pattern is reusable for any embedded or OS project needing a basic allocator.
Implements the Wasmtime C API for the Hermit unikernel, including TLS management, setjmp/longjmp for trap handling, and virtual memory operations (mmap, munmap, mprotect). This is a non-trivial integration of a complex runtime into a unikernel and demonstrates a reusable pattern for embedding Wasmtime in custom environments.
Implements the WASI preview1 interface for Hermit, mapping WASI syscalls (clock_time_get, args_get, fd_read, fd_write, path_open, etc.) to Hermit OS calls. This is a substantial piece of work that can be reused or adapted for other WASM runtimes needing a WASI implementation on top of a unikernel.
Provides a clean Rust abstraction over the VSOCK protocol, implementing `VsockListener` and `VsockStream` analogous to `TcpListener` and `TcpStream`. Uses raw syscalls (socket, bind, listen, accept, connect, read, write) and handles error mapping. This could be extracted as a standalone crate for VSOCK communication.
Defines a generic `Benchmark` trait with `run` and `log_statistics` methods, and provides helper functions for logging bandwidth and latency statistics. The pattern of using a trait to abstract benchmark execution and statistics is reusable for any performance measurement project.