Skip to main content

kaish_kernel/vfs/
mod.rs

1//! Virtual Filesystem (VFS) for kaish.
2//!
3//! The VFS provides a unified interface over multiple filesystem backends:
4//!
5//! - **MemoryFs**: In-memory ephemeral storage (for `/v`, tests)
6//! - **LocalFs**: Real filesystem access (for mounted worktrees)
7//! - **VfsRouter**: Routes paths to mounted backends
8//!
9//! # Design
10//!
11//! Kaish kernels own `/` in their VFS. Backends are mounted at paths:
12//!
13//! ```text
14//! /                      # kernel root
15//! ├── /v/                # MemoryFs (blobs, jobs)
16//! ├── /mnt/project/      # LocalFs (worktree, rw)
17//! └── /mnt/reference/    # LocalFs (repo, ro)
18//! ```
19//!
20//! The router finds the longest matching mount point and delegates operations.
21
22mod builtin_fs;
23mod jobfs;
24mod router;
25
26pub use builtin_fs::BuiltinFs;
27// GitVfs + git types live in the kaish-tools-git crate (keeps libgit2 out
28// of the kernel). Re-exported so `crate::vfs::GitVfs` paths keep working.
29#[cfg(feature = "git")]
30pub use kaish_tools_git::{FileStatus, GitVfs, LogEntry, StatusSummary, WorktreeInfo};
31pub use jobfs::JobFs;
32pub use router::{MountInfo, VfsRouter};
33
34// The `Filesystem` trait + `LocalFs` + `MemoryFs` moved to the leaf `kaish-vfs`
35// crate so out-of-tree backends (notably `GitVfs`, which wraps a `LocalFs`
36// worktree) and overlay consumers can implement/compose the trait without
37// depending on the kernel. Re-exported here so existing
38// `crate::vfs::{Filesystem, DirEntry, LocalFs, MemoryFs}` paths keep working.
39// `ByteBudget` rides along so a `with_backend` embedder can name the type it
40// hands to `MemoryFs::with_budget` without a direct kaish-vfs dependency.
41pub use kaish_vfs::{ByteBudget, DirEntry, DirEntryKind, Filesystem, MemoryFs};
42#[cfg(feature = "localfs")]
43pub use kaish_vfs::LocalFs;