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
20 changes: 10 additions & 10 deletions crates/nfs3_server/src/memfs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ impl Dir {
rdev: specdata3::default(),
fsid: 0,
fileid: id.into(),
atime: current_time.clone(),
mtime: current_time.clone(),
atime: current_time,
mtime: current_time,
ctime: current_time,
};
Self {
Expand Down Expand Up @@ -120,8 +120,8 @@ impl File {
rdev: specdata3::default(),
fsid: 0,
fileid: id.into(),
atime: current_time.clone(),
mtime: current_time.clone(),
atime: current_time,
mtime: current_time,
ctime: current_time,
};
Self {
Expand Down Expand Up @@ -267,7 +267,7 @@ impl Entry {
}
}

fn set_attr(&mut self, setattr: sattr3) {
fn set_attr(&mut self, setattr: &sattr3) {
Comment thread
Vaiz marked this conversation as resolved.
{
let attr = self.attr_mut();
match setattr.atime {
Expand Down Expand Up @@ -579,7 +579,7 @@ impl MemFs {
if entry.is_dir {
fs.add_dir(id, name)?;
} else {
fs.add_file(id, name, sattr3::default(), entry.content, None)?;
fs.add_file(id, name, &sattr3::default(), entry.content, None)?;
}
}

Expand Down Expand Up @@ -611,7 +611,7 @@ impl MemFs {
&self,
dirid: FileHandleU64,
filename: filename3<'static>,
attr: sattr3,
attr: &sattr3,
content: Vec<u8>,
verf: Option<createverf3>,
) -> Result<(FileHandleU64, fattr3), nfsstat3> {
Expand Down Expand Up @@ -749,7 +749,7 @@ impl NfsFileSystem for MemFs {
async fn setattr(&self, id: &FileHandleU64, setattr: sattr3) -> Result<fattr3, nfsstat3> {
let mut fs = self.fs.write().expect("lock is poisoned");
let entry = fs.get_mut(*id).ok_or(nfsstat3::NFS3ERR_NOENT)?;
entry.set_attr(setattr);
entry.set_attr(&setattr);
Ok(entry.attr().clone())
}

Expand All @@ -772,7 +772,7 @@ impl NfsFileSystem for MemFs {
filename: &filename3<'_>,
attr: sattr3,
) -> Result<(FileHandleU64, fattr3), nfsstat3> {
self.add_file(*dirid, filename.clone_to_owned(), attr, Vec::new(), None)
self.add_file(*dirid, filename.clone_to_owned(), &attr, Vec::new(), None)
}

async fn create_exclusive(
Expand All @@ -784,7 +784,7 @@ impl NfsFileSystem for MemFs {
self.add_file(
*dirid,
filename.clone_to_owned(),
sattr3::default(),
&sattr3::default(),
Vec::new(),
Some(createverf),
)
Expand Down
2 changes: 1 addition & 1 deletion crates/nfs3_server/src/nfs_handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ where
let ctime;
let before = match get_wcc_attr(context, &id).await {
Ok(wccattr) => {
ctime = wccattr.ctime.clone();
ctime = wccattr.ctime;
pre_op_attr::Some(wccattr)
}
Err(stat) => {
Expand Down
32 changes: 19 additions & 13 deletions crates/nfs3_types/src/nfs3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ pub type SETATTR3res = Nfs3Result<SETATTR3resok, SETATTR3resfail>;
pub type SYMLINK3res = Nfs3Result<SYMLINK3resok, SYMLINK3resfail>;
pub type WRITE3res = Nfs3Result<WRITE3resok, WRITE3resfail>;

#[derive(Debug, Clone, Default, PartialEq, Eq, XdrCodec)]
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, XdrCodec)]
pub enum Nfs3Option<T: Pack + Unpack> {
#[xdr(1)]
Some(T),
Expand Down Expand Up @@ -565,8 +565,9 @@ pub enum createhow3 {
EXCLUSIVE(createverf3),
}

#[derive(Copy, Clone, Debug, Eq, PartialEq, XdrCodec)]
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, XdrCodec)]
pub enum createmode3 {
#[default]
UNCHECKED = 0,
GUARDED = 1,
EXCLUSIVE = 2,
Expand Down Expand Up @@ -632,7 +633,7 @@ pub struct fattr3 {
pub ctime: nfstime3,
}

#[derive(Debug, Eq, PartialEq, XdrCodec)]
#[derive(Debug, Clone, Eq, PartialEq, XdrCodec)]
pub struct filename3<'a>(pub Opaque<'a>);

impl From<Vec<u8>> for filename3<'static> {
Expand Down Expand Up @@ -676,8 +677,9 @@ impl PartialEq<[u8]> for filename3<'_> {
}
}

#[derive(Copy, Clone, Debug, Eq, PartialEq, XdrCodec)]
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, XdrCodec)]
pub enum ftype3 {
#[default]
NF3REG = 1,
NF3DIR = 2,
NF3BLK = 3,
Expand Down Expand Up @@ -746,8 +748,9 @@ impl PartialEq<[u8]> for nfspath3<'_> {
}
}

#[derive(Copy, Clone, Debug, Eq, PartialEq, XdrCodec)]
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, XdrCodec)]
pub enum nfsstat3 {
#[default]
NFS3_OK = 0,
NFS3ERR_PERM = 1,
NFS3ERR_NOENT = 2,
Expand Down Expand Up @@ -816,7 +819,7 @@ impl std::fmt::Display for nfsstat3 {
}
}

#[derive(Clone, Default, Debug, Eq, PartialEq, XdrCodec)]
#[derive(Clone, Copy, Default, Debug, Eq, PartialEq, XdrCodec)]
pub struct nfstime3 {
pub seconds: u32,
pub nseconds: u32,
Expand Down Expand Up @@ -844,7 +847,7 @@ pub struct sattr3 {
pub mtime: set_mtime,
}

#[derive(Default, Debug, Clone, XdrCodec)]
#[derive(Default, Debug, Clone, Copy, XdrCodec)]
pub enum set_atime {
#[default]
#[xdr(0)]
Expand All @@ -855,7 +858,7 @@ pub enum set_atime {
SET_TO_CLIENT_TIME(nfstime3), // = 2,
}

#[derive(Default, Debug, Clone, XdrCodec)]
#[derive(Default, Debug, Clone, Copy, XdrCodec)]
pub enum set_mtime {
#[default]
#[xdr(0)]
Expand All @@ -872,8 +875,9 @@ pub struct specdata3 {
pub specdata2: u32,
}

#[derive(Copy, Clone, Debug, Eq, PartialEq, XdrCodec)]
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, XdrCodec)]
pub enum stable_how {
#[default]
UNSTABLE = 0,
DATA_SYNC = 1,
FILE_SYNC = 2,
Expand All @@ -885,14 +889,15 @@ pub struct symlinkdata3<'a> {
pub symlink_data: nfspath3<'a>,
}

#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]
pub enum time_how {
#[default]
DONT_CHANGE = 0,
SET_TO_SERVER_TIME = 1,
SET_TO_CLIENT_TIME = 2,
}

#[derive(Debug, XdrCodec)]
#[derive(Debug, Clone, Copy, XdrCodec)]
pub struct wcc_attr {
pub size: size3,
pub mtime: nfstime3,
Expand All @@ -905,7 +910,7 @@ pub struct wcc_data {
pub after: post_op_attr,
}

#[derive(Copy, Clone, Debug, Eq, PartialEq, XdrCodec)]
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, XdrCodec)]
pub struct writeverf3(pub [u8; NFS3_WRITEVERFSIZE]);

Comment thread
Vaiz marked this conversation as resolved.
pub type cookie3 = u64;
Expand Down Expand Up @@ -978,8 +983,9 @@ impl Unpack for mknoddata3 {
}
}

#[derive(Debug, Copy, Clone, PartialEq, Eq, XdrCodec)]
#[derive(Debug, Copy, Clone, Default, PartialEq, Eq, XdrCodec)]
pub enum NFS_PROGRAM {
#[default]
NFSPROC3_NULL = 0,
NFSPROC3_GETATTR = 1,
NFSPROC3_SETATTR = 2,
Expand Down
Loading