How peaspilaf/keksule works
Project type and purpose
• This is a command‐line, system‐level container manager written in C.
• It provides a small library (libcapsule) plus a main.c wrapper that uses Linux namespaces, cgroups, pivot_root, and mount syscalls to launch an isolated “container” process.
• There’s also an example shell script (unshare_example.sh) showing a manual namespace setup.
File structure
• Top‐level:
• control_group.md & namespaces.md – docs on cgroups & namespaces
• README.md – project overview & build/run instructions
• /src:
• libcapsule/ – C API (libcapsule.h) and implementation (libcapsule.c) for container setup
• main.c – CLI entry point that calls into libcapsule
• unshare_example.sh – standalone shell demo using unshare
Key architectural insights from the README
• The system is a single executable + a library that wraps low‐level Linux features.
• No networked microservices or databases—everything lives on one host.
• Relies on kernel subsystems: namespaces, cgroups, pivot_root, devtmpfs, procfs.
Diagramming the architecture
a. Main components:
1. User (invokes CLI)
2. Capsule CLI binary (main.c)
3. libcapsule library:
• Namespace manager
• Cgroup manager
• Filesystem manager (pivot_root, mounts)
4. Linux kernel subsystems:
• Namespaces (PID, MNT, NET, IPC, UTS, USER)
• Cgroups (via cgroup filesystem)
• VFS (pivot_root, mount)
• devtmpfs, procfs
5. Containerized process (the target command + its children)
6. unshare_example.sh (side‐by‐side manual demo)
b. Relationships & interactions:
• User → invokes capsule binary
• CLI → calls into libcapsule API
• libcapsule → makes syscall wrappers to:
• unshare() → isolates namespaces
• mount()/pivot_root() → builds new root FS, mounts devtmpfs+proc
• write to cgroup fs → limit resources
• Kernel → applies isolation, returns a PID in new namespace
• Capsule (via execve) → launches final container process
c. Architectural patterns/design principles:
• Separation of concerns: CLI vs. library vs. kernel interface
• Layered design: User → User-space library → Kernel
• Single‐binary, minimal dependencies
d. Relevant technologies/frameworks:
• C standard library
• Linux syscalls: unshare, mount, pivot_root, setns, chroot (via pivot_root)
• cgroup v1/v2 interfaces in /sys/fs/cgroup
• devtmpfs, procfs mounts