Skip to main content

arcbox_fs/
lib.rs

1//! # arcbox-fs
2//!
3//! High-performance filesystem service for `ArcBox`.
4//!
5//! This crate implements VirtioFS-based file sharing between host and guest,
6//! providing near-native file I/O performance.
7//!
8//! ## Key Features
9//!
10//! - **Zero-copy**: Direct memory mapping when possible
11//! - **Parallel I/O**: Concurrent request handling
12//! - **Intelligent caching**: Host-side metadata and data caching
13//! - **FUSE protocol**: Compatible with standard virtiofs drivers
14//!
15//! ## Architecture
16//!
17//! ```text
18//! Guest: mount -t virtiofs arcbox /mnt/arcbox
19//!                    │
20//!                    ▼
21//! ┌─────────────────────────────────────────┐
22//! │              arcbox-fs                   │
23//! │  ┌─────────────────────────────────┐   │
24//! │  │         FuseServer               │   │
25//! │  │  - Request dispatch              │   │
26//! │  │  - Reply handling                │   │
27//! │  └─────────────────────────────────┘   │
28//! │  ┌─────────────────────────────────┐   │
29//! │  │        PassthroughFs             │   │
30//! │  │  - Direct host filesystem access │   │
31//! │  │  - File handle management        │   │
32//! │  └─────────────────────────────────┘   │
33//! └─────────────────────────────────────────┘
34//! ```
35pub mod cache;
36pub mod dispatcher;
37pub mod error;
38pub mod fuse;
39pub mod passthrough;
40pub mod server;
41
42pub use cache::{NegativeCache, NegativeCacheConfig, NegativeCacheStats};
43pub use dispatcher::{DispatcherConfig, FuseDispatcher, RequestContext, ResponseBuilder};
44pub use error::{FsError, Result};
45pub use fuse::{FuseAttr, FuseInHeader, FuseOpcode, FuseOutHeader, StatFs};
46pub use passthrough::{DirEntry, FileType, PassthroughConfig, PassthroughFs};
47pub use server::FsServer;
48
49/// Filesystem configuration.
50#[derive(Debug, Clone)]
51pub struct FsConfig {
52    /// Tag for virtiofs mount.
53    pub tag: String,
54    /// Host directory to share.
55    pub source: String,
56    /// Number of worker threads.
57    pub num_threads: usize,
58    /// Enable writeback caching.
59    pub writeback_cache: bool,
60    /// Cache timeout for directory entries (seconds).
61    pub cache_timeout: u64,
62}
63
64impl Default for FsConfig {
65    fn default() -> Self {
66        Self {
67            tag: "arcbox".to_string(),
68            source: String::new(),
69            num_threads: 4,
70            writeback_cache: true,
71            cache_timeout: 1,
72        }
73    }
74}