Skip to content

Commit d4b056a

Browse files
committed
feat: add write support to virtual file-system
1 parent 9a5bb2a commit d4b056a

File tree

2 files changed

+828
-18
lines changed

2 files changed

+828
-18
lines changed

host/src/vfs/limits.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@ pub struct VfsLimits {
1919
///
2020
/// Keep this to a rather small size to prevent super-linear complexity due to string hashing.
2121
pub max_path_segment_size: u64,
22+
23+
/// Maximum total VFS storage in bytes.
24+
///
25+
/// This limits the total amount of data that can be stored in the VFS to prevent DoS attacks.
26+
pub max_storage_bytes: u64,
27+
28+
/// Maximum size of a single file in bytes.
29+
///
30+
/// This prevents a single file from consuming all available storage.
31+
pub max_file_size: u64,
32+
33+
/// Maximum number of write operations per second.
34+
///
35+
/// This rate-limits write operations to prevent DoS attacks through excessive I/O.
36+
pub max_write_ops_per_sec: u32,
2237
}
2338

2439
impl Default for VfsLimits {
@@ -27,6 +42,9 @@ impl Default for VfsLimits {
2742
inodes: 10_000,
2843
max_path_length: 255,
2944
max_path_segment_size: 50,
45+
max_storage_bytes: 100 * 1024 * 1024, // 100MB total storage
46+
max_file_size: 10 * 1024 * 1024, // 10MB per file
47+
max_write_ops_per_sec: 1000, // 1000 write ops/sec
3048
}
3149
}
3250
}

0 commit comments

Comments
 (0)