Trait NFSFileSystem

Source
pub trait NFSFileSystem: Sync {
Show 21 methods // Required methods fn capabilities(&self) -> VFSCapabilities; fn root_dir(&self) -> fileid3; fn lookup<'life0, 'life1, 'async_trait>( &'life0 self, dirid: fileid3, filename: &'life1 filename3, ) -> Pin<Box<dyn Future<Output = Result<fileid3, nfsstat3>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn getattr<'life0, 'async_trait>( &'life0 self, id: fileid3, ) -> Pin<Box<dyn Future<Output = Result<fattr3, nfsstat3>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn setattr<'life0, 'async_trait>( &'life0 self, id: fileid3, setattr: sattr3, ) -> Pin<Box<dyn Future<Output = Result<fattr3, nfsstat3>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn read<'life0, 'async_trait>( &'life0 self, id: fileid3, offset: u64, count: u32, ) -> Pin<Box<dyn Future<Output = Result<(Vec<u8>, bool), nfsstat3>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn write<'life0, 'life1, 'async_trait>( &'life0 self, id: fileid3, offset: u64, data: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<fattr3, nfsstat3>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn create<'life0, 'life1, 'async_trait>( &'life0 self, dirid: fileid3, filename: &'life1 filename3, attr: sattr3, ) -> Pin<Box<dyn Future<Output = Result<(fileid3, fattr3), nfsstat3>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn create_exclusive<'life0, 'life1, 'async_trait>( &'life0 self, dirid: fileid3, filename: &'life1 filename3, ) -> Pin<Box<dyn Future<Output = Result<fileid3, nfsstat3>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn mkdir<'life0, 'life1, 'async_trait>( &'life0 self, dirid: fileid3, dirname: &'life1 filename3, ) -> Pin<Box<dyn Future<Output = Result<(fileid3, fattr3), nfsstat3>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn remove<'life0, 'life1, 'async_trait>( &'life0 self, dirid: fileid3, filename: &'life1 filename3, ) -> Pin<Box<dyn Future<Output = Result<(), nfsstat3>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn rename<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, from_dirid: fileid3, from_filename: &'life1 filename3, to_dirid: fileid3, to_filename: &'life2 filename3, ) -> Pin<Box<dyn Future<Output = Result<(), nfsstat3>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn readdir<'life0, 'async_trait>( &'life0 self, dirid: fileid3, start_after: fileid3, max_entries: usize, ) -> Pin<Box<dyn Future<Output = Result<ReadDirResult, nfsstat3>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn symlink<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, dirid: fileid3, linkname: &'life1 filename3, symlink: &'life2 nfspath3, attr: &'life3 sattr3, ) -> Pin<Box<dyn Future<Output = Result<(fileid3, fattr3), nfsstat3>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait; fn readlink<'life0, 'async_trait>( &'life0 self, id: fileid3, ) -> Pin<Box<dyn Future<Output = Result<nfspath3, nfsstat3>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; // Provided methods fn readdir_simple<'life0, 'async_trait>( &'life0 self, dirid: fileid3, count: usize, ) -> Pin<Box<dyn Future<Output = Result<ReadDirSimpleResult, nfsstat3>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn fsinfo<'life0, 'async_trait>( &'life0 self, root_fileid: fileid3, ) -> Pin<Box<dyn Future<Output = Result<fsinfo3, nfsstat3>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn id_to_fh(&self, id: fileid3) -> nfs_fh3 { ... } fn fh_to_id(&self, id: &nfs_fh3) -> Result<fileid3, nfsstat3> { ... } fn path_to_id<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<fileid3, nfsstat3>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn serverid(&self) -> cookieverf3 { ... }
}
Expand description

The basic API to implement to provide an NFS file system

§Opaque FH

Files are only uniquely identified by a 64-bit file id. (basically an inode number) We automatically produce internally the opaque filehandle which is comprised of

  • A 64-bit generation number derived from the server startup time (i.e. so the opaque file handle expires when the NFS server restarts)
  • The 64-bit file id readdir pagination

§We do not use cookie verifier. We just use the start_after. The implementation should allow startat to start at any position. That is, the next query to readdir may be the last entry in the previous readdir response. There is a wierd annoying thing about readdir that limits the number of bytes in the response (instead of the number of entries). The caller will have to truncate the readdir response / issue more calls to readdir accordingly to fill up the expected number of bytes without exceeding it. Other requirements

getattr needs to be fast. NFS uses that a lot The 0 fileid is reserved and should not be used

Required Methods§

Source

fn capabilities(&self) -> VFSCapabilities

Returns the set of capabilities supported

Source

fn root_dir(&self) -> fileid3

Returns the ID the of the root directory “/”

Source

fn lookup<'life0, 'life1, 'async_trait>( &'life0 self, dirid: fileid3, filename: &'life1 filename3, ) -> Pin<Box<dyn Future<Output = Result<fileid3, nfsstat3>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Look up the id of a path in a directory

i.e. given a directory dir/ containing a file a.txt this may call lookup(id_of(“dir/”), “a.txt”) and this should return the id of the file “dir/a.txt”

This method should be fast as it is used very frequently.

Source

fn getattr<'life0, 'async_trait>( &'life0 self, id: fileid3, ) -> Pin<Box<dyn Future<Output = Result<fattr3, nfsstat3>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the attributes of an id. This method should be fast as it is used very frequently.

Source

fn setattr<'life0, 'async_trait>( &'life0 self, id: fileid3, setattr: sattr3, ) -> Pin<Box<dyn Future<Output = Result<fattr3, nfsstat3>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sets the attributes of an id this should return Err(nfsstat3::NFS3ERR_ROFS) if readonly

Source

fn read<'life0, 'async_trait>( &'life0 self, id: fileid3, offset: u64, count: u32, ) -> Pin<Box<dyn Future<Output = Result<(Vec<u8>, bool), nfsstat3>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Reads the contents of a file returning (bytes, EOF) Note that offset/count may go past the end of the file and that in that case, all bytes till the end of file are returned. EOF must be flagged if the end of the file is reached by the read.

Source

fn write<'life0, 'life1, 'async_trait>( &'life0 self, id: fileid3, offset: u64, data: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<fattr3, nfsstat3>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Writes the contents of a file returning (bytes, EOF) Note that offset/count may go past the end of the file and that in that case, the file is extended. If not supported due to readonly file system this should return Err(nfsstat3::NFS3ERR_ROFS)

Source

fn create<'life0, 'life1, 'async_trait>( &'life0 self, dirid: fileid3, filename: &'life1 filename3, attr: sattr3, ) -> Pin<Box<dyn Future<Output = Result<(fileid3, fattr3), nfsstat3>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Creates a file with the following attributes. If not supported due to readonly file system this should return Err(nfsstat3::NFS3ERR_ROFS)

Source

fn create_exclusive<'life0, 'life1, 'async_trait>( &'life0 self, dirid: fileid3, filename: &'life1 filename3, ) -> Pin<Box<dyn Future<Output = Result<fileid3, nfsstat3>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Creates a file if it does not already exist this should return Err(nfsstat3::NFS3ERR_ROFS)

Source

fn mkdir<'life0, 'life1, 'async_trait>( &'life0 self, dirid: fileid3, dirname: &'life1 filename3, ) -> Pin<Box<dyn Future<Output = Result<(fileid3, fattr3), nfsstat3>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Makes a directory with the following attributes. If not supported dur to readonly file system this should return Err(nfsstat3::NFS3ERR_ROFS)

Source

fn remove<'life0, 'life1, 'async_trait>( &'life0 self, dirid: fileid3, filename: &'life1 filename3, ) -> Pin<Box<dyn Future<Output = Result<(), nfsstat3>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Removes a file. If not supported due to readonly file system this should return Err(nfsstat3::NFS3ERR_ROFS)

Source

fn rename<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, from_dirid: fileid3, from_filename: &'life1 filename3, to_dirid: fileid3, to_filename: &'life2 filename3, ) -> Pin<Box<dyn Future<Output = Result<(), nfsstat3>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Removes a file. If not supported due to readonly file system this should return Err(nfsstat3::NFS3ERR_ROFS)

Source

fn readdir<'life0, 'async_trait>( &'life0 self, dirid: fileid3, start_after: fileid3, max_entries: usize, ) -> Pin<Box<dyn Future<Output = Result<ReadDirResult, nfsstat3>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the contents of a directory with pagination. Directory listing should be deterministic. Up to max_entries may be returned, and start_after is used to determine where to start returning entries from.

For instance if the directory has entry with ids [1,6,2,11,8,9] and start_after=6, readdir should returning 2,11,8,…

Makes a symlink with the following attributes. If not supported due to readonly file system this should return Err(nfsstat3::NFS3ERR_ROFS)

Reads a symlink

Provided Methods§

Source

fn readdir_simple<'life0, 'async_trait>( &'life0 self, dirid: fileid3, count: usize, ) -> Pin<Box<dyn Future<Output = Result<ReadDirSimpleResult, nfsstat3>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Simple version of readdir. Only need to return filename and id

Source

fn fsinfo<'life0, 'async_trait>( &'life0 self, root_fileid: fileid3, ) -> Pin<Box<dyn Future<Output = Result<fsinfo3, nfsstat3>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get static file system Information

Source

fn id_to_fh(&self, id: fileid3) -> nfs_fh3

Converts the fileid to an opaque NFS file handle. Optional.

Source

fn fh_to_id(&self, id: &nfs_fh3) -> Result<fileid3, nfsstat3>

Converts an opaque NFS file handle to a fileid. Optional.

Source

fn path_to_id<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<fileid3, nfsstat3>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Converts a complete path to a fileid. Optional. The default implementation walks the directory structure with lookup()

Source

fn serverid(&self) -> cookieverf3

Implementors§