Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/cargo_nfs3_server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ description = "Simple and easy-to-deploy NFSv3 server"
readme = "README.md"

[dependencies]
nfs3_types = { path = "../nfs3_types", version = "0.3.4" }
nfs3_server = { path = "../nfs3_server", version = "0.6.0", features = ["memfs"] }

clap = { workspace = true, default-features = true, features = ["derive"] }
Expand Down
14 changes: 7 additions & 7 deletions crates/cargo_nfs3_server/src/mirror.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ use intaglio::osstr::SymbolTable;
use nfs3_server::fs_util::{
exists_no_traverse, fattr3_differ, file_setattr, metadata_to_fattr3, path_setattr,
};
use nfs3_server::nfs3_types::nfs3::{
cookie3, createverf3, entryplus3, fattr3, fileid3, filename3, ftype3, nfspath3, nfsstat3,
post_op_attr, post_op_fh3, sattr3,
};
use nfs3_server::vfs::{
FileHandleU64, NextResult, NfsFileSystem, NfsReadFileSystem, ReadDirIterator,
ReadDirPlusIterator,
};
use nfs3_types::nfs3::{
cookie3, createverf3, entryplus3, fattr3, fileid3, filename3, ftype3, nfspath3, nfsstat3,
post_op_attr, post_op_fh3, sattr3,
};
use string_ext::{FromOsString, IntoOsString};
use tokio::fs::{File, OpenOptions};
use tokio::io::{AsyncReadExt, AsyncSeekExt, AsyncWriteExt};
Expand Down Expand Up @@ -530,7 +530,7 @@ impl NfsFileSystem for MirrorFs {
&self,
dirid: &Self::Handle,
filename: &filename3<'_>,
createverf: nfs3_types::nfs3::createverf3,
createverf: createverf3,
) -> Result<Self::Handle, nfsstat3> {
let id = self
.create_fs_object(
Expand Down Expand Up @@ -793,9 +793,9 @@ pub mod string_ext {
#[cfg(unix)]
use std::os::unix::ffi::OsStrExt;

use nfs3_types::nfs3::{filename3, nfspath3};
use nfs3_server::nfs3_types::nfs3::{filename3, nfspath3};
#[cfg(not(unix))]
use nfs3_types::xdr_codec::Opaque;
use nfs3_server::nfs3_types::xdr_codec::Opaque;

pub trait IntoOsString {
fn as_os_str(&self) -> &OsStr;
Expand Down
12 changes: 7 additions & 5 deletions crates/nfs3_client/examples/download_folder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ use std::path::{Component, Path, PathBuf};

use nfs3_client::Nfs3ConnectionBuilder;
use nfs3_client::io::{AsyncRead, AsyncWrite};
use nfs3_client::nfs3_types::nfs3::{self, Nfs3Option, filename3};
use nfs3_client::nfs3_types::portmap::PMAP_PORT;
use nfs3_client::nfs3_types::rpc::{auth_unix, opaque_auth};
use nfs3_client::nfs3_types::xdr_codec::Opaque;
use nfs3_client::tokio::TokioConnector;
use nfs3_types::nfs3::{self, Nfs3Option, filename3};
use nfs3_types::xdr_codec::Opaque;

#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
Expand All @@ -27,16 +29,16 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let portmapper_port = args
.get(5)
.and_then(|port| port.parse::<u16>().ok())
.unwrap_or(nfs3_types::portmap::PMAP_PORT);
.unwrap_or(PMAP_PORT);

let auth_unix = nfs3_types::rpc::auth_unix {
let auth_unix = auth_unix {
stamp: 0xaaaa_aaaa,
machinename: Opaque::borrowed(b"unknown"),
uid: 0xffff_fffe,
gid: 0xffff_fffe,
gids: vec![],
};
let credential = nfs3_types::rpc::opaque_auth::auth_unix(&auth_unix);
let credential = opaque_auth::auth_unix(&auth_unix);

let mut connection = Nfs3ConnectionBuilder::new(TokioConnector, ip, mount_path)
.portmapper_port(portmapper_port)
Expand Down
12 changes: 7 additions & 5 deletions crates/nfs3_client/examples/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ use std::time::{Duration, UNIX_EPOCH};

use chrono::{DateTime, Utc};
use nfs3_client::Nfs3ConnectionBuilder;
use nfs3_client::nfs3_types::nfs3::{self, Nfs3Option};
use nfs3_client::nfs3_types::portmap::PMAP_PORT;
use nfs3_client::nfs3_types::rpc::{auth_unix, opaque_auth};
use nfs3_client::nfs3_types::xdr_codec::Opaque;
use nfs3_client::tokio::TokioConnector;
use nfs3_types::nfs3::{self, Nfs3Option};
use nfs3_types::xdr_codec::Opaque;

#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
Expand All @@ -20,17 +22,17 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let portmapper_port = args
.get(3)
.and_then(|port| port.parse::<u16>().ok())
.unwrap_or(nfs3_types::portmap::PMAP_PORT);
.unwrap_or(PMAP_PORT);

// This auth values are the same that Windows NFS client uses
let auth_unix = nfs3_types::rpc::auth_unix {
let auth_unix = auth_unix {
stamp: 0xaaaa_aaaa,
machinename: Opaque::borrowed(b"unknown"),
uid: 0xffff_fffe,
gid: 0xffff_fffe,
gids: vec![],
};
let credential = nfs3_types::rpc::opaque_auth::auth_unix(&auth_unix);
let credential = opaque_auth::auth_unix(&auth_unix);

let mut connection = Nfs3ConnectionBuilder::new(TokioConnector, ip, mount_path)
.portmapper_port(portmapper_port)
Expand Down
5 changes: 3 additions & 2 deletions crates/nfs3_client/examples/nfs.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
use std::env;

use nfs3_client::Nfs3ConnectionBuilder;
use nfs3_client::nfs3_types::nfs3;
use nfs3_client::nfs3_types::portmap::PMAP_PORT;
use nfs3_client::tokio::TokioConnector;
use nfs3_types::nfs3;

#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let args = env::args().collect::<Vec<_>>();
let ip = args.get(1).map_or("127.0.0.1", String::as_str).to_owned();
let mount_path = args.get(2).map_or("/", String::as_str).to_owned();
let portmaper_port = args.get(3).map_or(nfs3_types::portmap::PMAP_PORT, |port| {
let portmaper_port = args.get(3).map_or(PMAP_PORT, |port| {
port.parse::<u16>().expect("invalid port number")
});

Expand Down
13 changes: 6 additions & 7 deletions crates/nfs3_client/examples/portmap.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use std::env;

use nfs3_client::error::{Error, PortmapError};
use nfs3_client::nfs3_types::mount::{PROGRAM as MOUNT_PROGRAM, VERSION as MOUNT_VERSION};
use nfs3_client::nfs3_types::nfs3::{PROGRAM as NFS3_PROGRAM, VERSION as NFS3_VERSION};
use nfs3_client::nfs3_types::portmap::PMAP_PORT;
use nfs3_client::tokio::TokioIo;
use tokio::net::TcpStream;

Expand All @@ -10,7 +13,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let ip = args.get(1).map_or("127.0.0.1", |ip| ip.as_str());
let port = match args.get(2) {
Some(port) => port.parse::<u16>()?,
None => nfs3_types::portmap::PMAP_PORT,
None => PMAP_PORT,
};

let stream = TcpStream::connect(format!("{ip}:{port}")).await?;
Expand All @@ -20,9 +23,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

portmapper.null().await?;

let result = portmapper
.getport(nfs3_types::mount::PROGRAM, nfs3_types::mount::VERSION)
.await;
let result = portmapper.getport(MOUNT_PROGRAM, MOUNT_VERSION).await;
match result {
Ok(port) => println!("Resolved MOUNT3 port: {port}"),
Err(Error::Portmap(PortmapError::ProgramUnavailable)) => {
Expand All @@ -31,9 +32,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
Err(e) => eprintln!("Failed to resolve MOUNT3 port: {e}"),
}

let result = portmapper
.getport(nfs3_types::nfs3::PROGRAM, nfs3_types::nfs3::VERSION)
.await;
let result = portmapper.getport(NFS3_PROGRAM, NFS3_VERSION).await;
match result {
Ok(port) => println!("Resolved NFSv3 port: {port}"),
Err(Error::Portmap(PortmapError::ProgramUnavailable)) => {
Expand Down
2 changes: 2 additions & 0 deletions crates/nfs3_client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ pub mod tokio;
pub use connect::*;
pub use mount::*;
pub use nfs::*;
/// Re-export of `nfs3_types` for convenience
pub use nfs3_types;
pub use portmapper::*;
11 changes: 11 additions & 0 deletions crates/nfs3_client/tests/reexport_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Test to verify that nfs3_types is properly re-exported from nfs3_client

#[test]
fn test_nfs3_types_reexport_from_client() {
// Test creating types using the re-exported path from nfs3_client
let _handle = nfs3_client::nfs3_types::nfs3::nfs_fh3::default();
let _auth = nfs3_client::nfs3_types::rpc::opaque_auth::default();

// Also test accessing modules - just verify the path compiles
let _ = std::mem::size_of::<nfs3_client::nfs3_types::xdr_codec::Void>();
}
10 changes: 5 additions & 5 deletions crates/nfs3_server/examples/mirrorfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ use intaglio::osstr::SymbolTable;
use nfs3_server::fs_util::{
exists_no_traverse, fattr3_differ, file_setattr, metadata_to_fattr3, path_setattr,
};
use nfs3_server::nfs3_types::nfs3::{
cookie3, createverf3, entryplus3, fattr3, fileid3, filename3, ftype3, nfspath3, nfsstat3,
post_op_attr, post_op_fh3, sattr3,
};
use nfs3_server::tcp::{NFSTcp, NFSTcpListener};
use nfs3_server::vfs::{
FileHandleU64, NextResult, NfsFileSystem, NfsReadFileSystem, ReadDirIterator,
ReadDirPlusIterator,
};
use nfs3_types::nfs3::{
cookie3, entryplus3, fattr3, fileid3, filename3, ftype3, nfspath3, nfsstat3, post_op_attr,
post_op_fh3, sattr3,
};
use tokio::fs::{File, OpenOptions};
use tokio::io::{AsyncReadExt, AsyncSeekExt, AsyncWriteExt};
use tracing::debug;
Expand Down Expand Up @@ -563,7 +563,7 @@ impl NfsFileSystem for MirrorFs {
&self,
dirid: &Self::Handle,
filename: &filename3<'_>,
_createverf: nfs3_types::nfs3::createverf3,
_createverf: createverf3,
) -> Result<Self::Handle, nfsstat3> {
let id = self
.create_fs_object(dirid.as_u64(), filename, &CreateFSObject::Exclusive)
Expand Down
3 changes: 3 additions & 0 deletions crates/nfs3_server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ pub mod vfs;
#[cfg_attr(docsrs, doc(cfg(feature = "memfs")))]
pub mod memfs;

/// Re-export of `nfs3_types` for convenience
pub use nfs3_types;

/// Reexport for test purposes
#[doc(hidden)]
#[cfg(feature = "__test_reexports")]
Expand Down
11 changes: 11 additions & 0 deletions crates/nfs3_server/tests/reexport_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Test to verify that nfs3_types is properly re-exported from nfs3_server

#[test]
fn test_nfs3_types_reexport_from_server() {
// Test creating types using the re-exported path from nfs3_server
let _handle = nfs3_server::nfs3_types::nfs3::nfs_fh3::default();
let _auth = nfs3_server::nfs3_types::rpc::opaque_auth::default();

// Also test accessing modules - just verify the path compiles
let _ = std::mem::size_of::<nfs3_server::nfs3_types::xdr_codec::Void>();
}
6 changes: 3 additions & 3 deletions crates/nfs3_tests/examples/perf_test.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use nfs3_client::io::{AsyncRead, AsyncWrite};
use nfs3_tests::TestContext;
use nfs3_types::nfs3::{
use nfs3_client::nfs3_types::nfs3::{
LOOKUP3args, READDIR3args, READDIRPLUS3args, cookieverf3, dirlist3, dirlistplus3, diropargs3,
filename3, nfs_fh3,
};
use nfs3_types::xdr_codec::Opaque;
use nfs3_client::nfs3_types::xdr_codec::Opaque;
use nfs3_tests::TestContext;
use tracing::info;

#[tokio::main(flavor = "current_thread")]
Expand Down
2 changes: 1 addition & 1 deletion crates/nfs3_tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ pub fn print_hex(data: &[u8]) {
for (i, chunk) in data.chunks(16).enumerate() {
print!("{:06x} | ", i * 16);
for byte in chunk {
print!("{:02x} ", byte);
print!("{byte:02x} ");
}
println!();
}
Expand Down
Loading