No description
  • C++ 91.8%
  • CMake 6.4%
  • Shell 1.2%
  • C 0.6%
Find a file
2026-05-26 13:01:58 -04:00
cmake Fix detours 2026-05-26 12:44:44 -04:00
docs Init 2026-05-25 20:08:39 -04:00
include/ramfs Init 2026-05-25 20:08:39 -04:00
src Fix 2026-05-26 13:01:58 -04:00
tests Fix detours 2026-05-26 12:44:44 -04:00
third_party Fix detours 2026-05-26 12:44:44 -04:00
tools Init 2026-05-25 20:08:39 -04:00
.gitignore Init 2026-05-25 20:08:39 -04:00
.gitmodules Fix detours 2026-05-26 12:44:44 -04:00
CMakeLists.txt Fix 2026-05-26 13:01:58 -04:00
README.md Init 2026-05-25 20:08:39 -04:00

injectable-ramfs

An injectable, single-process, volatile RAM filesystem for Windows and Linux. Userspace only — no FUSE, no kernel modules.

  • Windows: a DLL injected at spawn via Microsoft Detours, hooking the Nt*File family in NTDLL.
  • Linux: a .so injected via LD_PRELOAD that uses funchook to inline-detour the libc filesystem wrappers. Regular files are backed by memfd_create() so most fd-level syscalls go straight to the kernel.

A user-supplied list of host paths (e.g. /tmp/build, C:\work\out) is redirected to RAM; everything else falls through to the real OS.

See docs/PLAN.md for the full design and milestone breakdown.

Status

  • M0 — plan + repo scaffold.
  • M1 — Linux PoC: open/read/write/close/stat/mkdir/unlink/rename/getdents64 and dup/dup2/dup3/fcntl(F_DUPFD) hooks installed via funchook. Single-process bash redirection round-trips through ramfs.
  • M3 — Core extracted into ramfs_core; all OS-agnostic logic runs in the unit tests with no injection.
  • M4M5 — Windows skeleton only. ramfs_win.dll builds against Detours when present; NtCreateFile is the single attached hook today and the rest of the Nt* surface is staged out per PLAN §12.
  • M6 — pending.

Build

cmake -S . -B build              # fetches funchook via FetchContent
cmake --build build -j
ctest --test-dir build           # runs 16 unit tests + 1 Linux smoke test

To skip the funchook fetch (core + Windows skeleton + spawn launchers only):

cmake -S . -B build -DRAMFS_USE_FUNCHOOK=OFF

Run

./build/ramfs-spawn --root /tmp/ram -- bash -c '
    printf "hi\n" > /tmp/ram/x
    read -r got < /tmp/ram/x
    echo "got=$got"
'

Repo layout

docs/        design and notes
include/     public C++ headers
src/core/    OS-agnostic ramfs (inodes, namespace, locks, storage)
src/platform/windows/   Detours DLL + Nt* hooks
src/platform/linux/     funchook-based LD_PRELOAD shim
tools/       spawn-time launchers (one per platform)
tests/       core unit tests + per-platform integration
third_party/ git submodules: detours, funchook

Out of scope (v1)

  • Attach to an already-running process.
  • Cross-process / shared-memory state.
  • Copy-on-write overlay from the real filesystem.
  • Snapshot / restore.
  • Full async I/O fidelity on Windows.
  • Static binaries / Go programs that bypass libc on Linux.