-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(virtualfs): Add NFS server and improve overlayfs impl (#141)
* feat(virtualfs): Add NFS server implementation - Add NFS server implementation with full NFSv3 protocol support - Implement path-to-fileid mapping and bidirectional lookups - Add Unix-specific metadata support (uid/gid/permissions) - Update MemoryFileSystem to handle empty paths and directory removal - Add example showing NFS server usage - Add workspace-level dependencies for nfsserve, intaglio and users crates * refactor(virtualfs): improve directory handling and OCI compatibility - Add recursive directory copy-up functionality for renames - Enhance directory listing to properly handle whiteouts and opaque markers - Update documentation to clarify OCI whiteout compatibility - Add comprehensive tests for directory operations with markers - Improve metadata preservation during directory operations The changes make the overlay filesystem more robust when handling directories, especially during rename operations, while maintaining compatibility with OCI-style whiteouts and opaque markers. * refactor: cargo fmt
- Loading branch information
Showing
15 changed files
with
2,553 additions
and
226 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
//! This example demonstrates running a simple NFS server using monofs. | ||
//! | ||
//! The example shows how to: | ||
//! - Set up and configure an NFS server | ||
//! - Serve a monofs filesystem over NFS | ||
//! - Handle server configuration options | ||
//! | ||
//! Operations demonstrated: | ||
//! 1. Parsing command line arguments for server configuration | ||
//! 2. Setting up the NFS server | ||
//! 3. Binding to a specified port | ||
//! 4. Serving the filesystem | ||
//! | ||
//! To run the example: | ||
//! ```bash | ||
//! cargo run --example nfs -- /path/to/store --port 2049 | ||
//! ``` | ||
use anyhow::Result; | ||
use clap::Parser; | ||
use std::path::PathBuf; | ||
use virtualfs::{MemoryFileSystem, VirtualFileSystemServer, DEFAULT_HOST, DEFAULT_NFS_PORT}; | ||
|
||
//-------------------------------------------------------------------------------------------------- | ||
// Types | ||
//-------------------------------------------------------------------------------------------------- | ||
|
||
/// Simple NFS server that serves the monofs filesystem. | ||
#[derive(Parser, Debug)] | ||
#[command(author, long_about = None)] | ||
struct Args { | ||
/// Paths to the layers to overlay | ||
layers: Vec<PathBuf>, | ||
|
||
/// Host address to bind to | ||
#[arg(short = 'H', long, default_value = DEFAULT_HOST)] | ||
host: String, | ||
|
||
/// Port to listen on | ||
#[arg(short = 'P', long, default_value_t = DEFAULT_NFS_PORT)] | ||
port: u32, | ||
} | ||
|
||
//-------------------------------------------------------------------------------------------------- | ||
// Functions: main | ||
//-------------------------------------------------------------------------------------------------- | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
// Parse command line arguments | ||
let args = Args::parse(); | ||
|
||
// Initialize logging | ||
tracing_subscriber::fmt::init(); | ||
|
||
// Create and start the server | ||
// let fs = OverlayFileSystem::new()?; | ||
let fs = MemoryFileSystem::new(); | ||
let server = VirtualFileSystemServer::new(fs, args.host, args.port); | ||
tracing::info!( | ||
"Starting NFS server on {}:{}", | ||
server.get_host(), | ||
server.get_port() | ||
); | ||
|
||
server.start().await?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
//-------------------------------------------------------------------------------------------------- | ||
// Constants | ||
//-------------------------------------------------------------------------------------------------- | ||
|
||
/// The default host address to bind to. | ||
pub const DEFAULT_HOST: &str = "127.0.0.1"; | ||
|
||
/// The default NFS port number to use. | ||
pub const DEFAULT_NFS_PORT: u32 = 2049; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.