monty_fs/lib.rs
1//! Filesystem mounting system for sandboxed execution.
2//!
3//! Provides [`MountTable`], which maps virtual paths to real host directories
4//! with configurable access modes. When sandbox code calls filesystem methods
5//! like `Path.read_text()`, the mount table intercepts the operation, resolves
6//! the virtual path, and executes it according to the mount mode.
7//!
8//! This crate is HOST-side code: it performs real `std::fs` I/O and is linked
9//! only by host/parent crates (`monty-pool`, the CLI, bindings). The `monty`
10//! interpreter crate deliberately does not depend on it — sandboxed code can
11//! only *request* filesystem operations by suspending with an
12//! [`OsFunctionCall`](monty_types::OsFunctionCall), which a host holding a
13//! [`MountTable`] services via [`MountTable::handle_os_call`].
14//!
15//! # Security
16//!
17//! **The monty runtime MUST NEVER read, write, or obtain any information about
18//! any file or directory outside the specific directory that is mounted.**
19//!
20//! Enforced by `path_security::resolve_path` via path canonicalization,
21//! boundary checks, and symlink escape detection.
22//! Each mount has an aggregate memory budget, defaulting to
23//! [`DEFAULT_MEMORY_USAGE_LIMIT`], for retained overlay data and results.
24//!
25//! # Mount Modes
26//!
27//! - [`MountMode::ReadWrite`] — full read/write access to the host directory
28//! - [`MountMode::ReadOnly`] — reads work, writes raise `PermissionError`
29//! - [`MountMode::OverlayMemory`] — reads fall through to host; writes stored in memory
30
31pub use error::MountError;
32pub use mount_mode::MountMode;
33pub use mount_table::{DEFAULT_MEMORY_USAGE_LIMIT, Mount, MountCallOutcome, MountTable};
34pub use overlay_state::OverlayState;
35
36mod common;
37mod direct;
38mod dispatch;
39mod error;
40mod mount_mode;
41mod mount_table;
42mod overlay;
43mod overlay_state;
44mod path_security;