Status: Accepted
Date: 2025-02-12
Last reviewed: 2026-05-02 — still current. MemoryVfs, RealVfs, and GameAssetVfs ship today in crates/oasis-vfs/; the Vfs trait surface is unchanged in spirit.
OASIS_OS runs on three very different platforms:
- Desktop (SDL): Full filesystem access via
std::fs. - Unreal Engine 5: Read-only game assets with overlay writes.
- PSP: Memory stick I/O via
sceIo*syscalls.
Terminal commands like ls, cat, mkdir need to work identically across all
platforms. The browser engine needs to load pages from virtual paths. Apps need
to save/load state.
We use a Vfs trait (oasis-vfs) as the sole file system interface.
Core code never calls std::fs directly. Three implementations exist:
MemoryVfs-- in-RAM tree. Default for testing and UE5/FFI embedding.RealVfs-- delegates tostd::fs. Used by the SDL desktop backend.GameAssetVfs-- read-only base layer + writable overlay. Used by UE5.
- Platform independence. Terminal commands work on PSP, desktop, and UE5
without
#[cfg]conditionals in business logic. - Security. Path traversal attacks are blocked at the trait boundary. The
MemoryVfscannot escape its virtual root.RealVfsnormalizes and rejects..traversal. - Testability. All file operations are testable with
MemoryVfs-- no temp directories, no cleanup, deterministic behavior. - Embedding. FFI consumers populate
MemoryVfsviaoasis_add_vfs_file()before any OS code runs. No host filesystem exposure.
- Memory cost for
MemoryVfs. All file content is in RAM. Acceptable for the typical use case (small utility files, HTML pages, configs). - No mmap or streaming. Large files must be fully read. The 480x272 UI rarely handles files larger than a few KB.
- Every crate that does file I/O depends on
oasis-vfsand accepts&mut dyn Vfs. - The
Environmentstruct in the terminal carries&mut dyn Vfs. - The FFI layer wraps a
MemoryVfsinside the opaqueOasisInstance. - Path security is enforced in the
Vfsimplementations, not in callers.