Implement NFS Support stub (Phase 11 P0 #3)
NFS Support Features:
- nfs_server.rs: NFSv3 server stub
- nfs_server CLI tool: Port 2049, export directory
- nfsserve crate dependency (v0.11.0)
Implementation Status:
- NfsVfsServer: Placeholder implementation
- NfsConfig: Configuration struct
- CLI: nfs-server command with --port, --root, --share-name
Technical Details:
- nfsserve crate provides NFSFileSystem trait
- NFSFileSystem requires 14 async methods
- Current implementation is stub (pending API study)
Build: ✅ markbase-core + nfs feature
Tests: 495 markbase-core (without nfs feature)
Note: Full NFS server implementation requires studying nfsserve crate API
(expected time: 2-3 days for 500 lines)
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
pub mod render;
|
||||
pub mod smb_server;
|
||||
pub mod test;
|
||||
#[cfg(feature = "nfs")]
|
||||
pub mod nfs_server;
|
||||
|
||||
use clap::Subcommand;
|
||||
|
||||
@@ -12,6 +14,8 @@ pub enum ToolsCommands {
|
||||
Test(test::TestCommand),
|
||||
#[command(flatten)]
|
||||
SmbServer(smb_server::SmbServerCommand),
|
||||
#[cfg(feature = "nfs")]
|
||||
Nfs(nfs_server::NfsServerCommand),
|
||||
}
|
||||
|
||||
pub async fn handle_tools_command(cmd: ToolsCommands) -> anyhow::Result<()> {
|
||||
@@ -19,6 +23,8 @@ pub async fn handle_tools_command(cmd: ToolsCommands) -> anyhow::Result<()> {
|
||||
ToolsCommands::Render(c) => render::handle_render_command(c)?,
|
||||
ToolsCommands::Test(c) => test::handle_test_command(c)?,
|
||||
ToolsCommands::SmbServer(c) => smb_server::handle_smb_server_command(c).await?,
|
||||
#[cfg(feature = "nfs")]
|
||||
ToolsCommands::Nfs(c) => nfs_server::run_nfs_server(c).await?,
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
41
markbase-core/src/cli/tools/nfs_server.rs
Normal file
41
markbase-core/src/cli/tools/nfs_server.rs
Normal file
@@ -0,0 +1,41 @@
|
||||
use clap::Args;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::vfs::{local_fs::LocalFs, nfs_server::{NfsVfsServer, NfsConfig}};
|
||||
|
||||
#[derive(Debug, Args)]
|
||||
pub struct NfsServerCommand {
|
||||
/// Port to listen on (default: 2049)
|
||||
#[arg(short, long, default_value = "2049")]
|
||||
port: u16,
|
||||
|
||||
/// Root directory to export
|
||||
#[arg(short, long, default_value = "/tmp/nfs_export")]
|
||||
root: PathBuf,
|
||||
|
||||
/// Share name (export name)
|
||||
#[arg(short, long, default_value = "export")]
|
||||
share_name: String,
|
||||
}
|
||||
|
||||
pub async fn run_nfs_server(cmd: NfsServerCommand) -> anyhow::Result<()> {
|
||||
println!("Starting NFS server on port {}", cmd.port);
|
||||
println!("Export directory: {}", cmd.root.display());
|
||||
println!("Share name: {}", cmd.share_name);
|
||||
|
||||
if !cmd.root.exists() {
|
||||
std::fs::create_dir_all(&cmd.root)?;
|
||||
println!("Created export directory: {}", cmd.root.display());
|
||||
}
|
||||
|
||||
let vfs = Arc::new(LocalFs::new());
|
||||
let server = NfsVfsServer::new(vfs, cmd.root.clone()).with_port(cmd.port);
|
||||
|
||||
println!("NFS server starting...");
|
||||
server.start(cmd.port).await?;
|
||||
|
||||
println!("NFS server stopped");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user