Trait PathFilesystem

Source
pub trait PathFilesystem: Send {
    type DirEntryStream<'a>: Stream<Item = Result<DirectoryEntry>> + Send + 'a
       where Self: 'a;
    type DirEntryPlusStream<'a>: Stream<Item = Result<DirectoryEntryPlus>> + Send + 'a
       where Self: 'a;

Show 43 methods // Required methods fn init( &self, req: Request, ) -> impl Future<Output = Result<ReplyInit>> + Send; fn destroy(&self, req: Request) -> impl Future<Output = ()> + Send; fn getlk( &self, req: Request, path: Option<&OsStr>, fh: u64, lock_owner: u64, start: u64, end: u64, type: u32, pid: u32, ) -> impl Future<Output = Result<ReplyLock>> + Send; fn setlk( &self, req: Request, path: Option<&OsStr>, fh: u64, lock_owner: u64, start: u64, end: u64, type: u32, pid: u32, block: bool, ) -> impl Future<Output = Result<()>> + Send; // Provided methods fn lookup( &self, req: Request, parent: &OsStr, name: &OsStr, ) -> impl Future<Output = Result<ReplyEntry>> + Send { ... } fn forget( &self, req: Request, parent: &OsStr, nlookup: u64, ) -> impl Future<Output = ()> + Send { ... } fn getattr( &self, req: Request, path: Option<&OsStr>, fh: Option<u64>, flags: u32, ) -> impl Future<Output = Result<ReplyAttr>> + Send { ... } fn setattr( &self, req: Request, path: Option<&OsStr>, fh: Option<u64>, set_attr: SetAttr, ) -> impl Future<Output = Result<ReplyAttr>> + Send { ... } fn readlink( &self, req: Request, path: &OsStr, ) -> impl Future<Output = Result<ReplyData>> + Send { ... } fn symlink( &self, req: Request, parent: &OsStr, name: &OsStr, link_path: &OsStr, ) -> impl Future<Output = Result<ReplyEntry>> + Send { ... } fn mknod( &self, req: Request, parent: &OsStr, name: &OsStr, mode: u32, rdev: u32, ) -> impl Future<Output = Result<ReplyEntry>> + Send { ... } fn mkdir( &self, req: Request, parent: &OsStr, name: &OsStr, mode: u32, umask: u32, ) -> impl Future<Output = Result<ReplyEntry>> + Send { ... } fn unlink( &self, req: Request, parent: &OsStr, name: &OsStr, ) -> impl Future<Output = Result<()>> + Send { ... } fn rmdir( &self, req: Request, parent: &OsStr, name: &OsStr, ) -> impl Future<Output = Result<()>> + Send { ... } fn rename( &self, req: Request, origin_parent: &OsStr, origin_name: &OsStr, parent: &OsStr, name: &OsStr, ) -> impl Future<Output = Result<()>> + Send { ... } fn link( &self, req: Request, path: &OsStr, new_parent: &OsStr, new_name: &OsStr, ) -> impl Future<Output = Result<ReplyEntry>> + Send { ... } fn open( &self, req: Request, path: &OsStr, flags: u32, ) -> impl Future<Output = Result<ReplyOpen>> + Send { ... } fn read( &self, req: Request, path: Option<&OsStr>, fh: u64, offset: u64, size: u32, ) -> impl Future<Output = Result<ReplyData>> + Send { ... } fn write( &self, req: Request, path: Option<&OsStr>, fh: u64, offset: u64, data: &[u8], write_flags: u32, flags: u32, ) -> impl Future<Output = Result<ReplyWrite>> + Send { ... } fn statfs( &self, req: Request, path: &OsStr, ) -> impl Future<Output = Result<ReplyStatFs>> + Send { ... } fn release( &self, req: Request, path: Option<&OsStr>, fh: u64, flags: u32, lock_owner: u64, flush: bool, ) -> impl Future<Output = Result<()>> + Send { ... } fn fsync( &self, req: Request, path: Option<&OsStr>, fh: u64, datasync: bool, ) -> impl Future<Output = Result<()>> + Send { ... } fn setxattr( &self, req: Request, path: &OsStr, name: &OsStr, value: &[u8], flags: u32, position: u32, ) -> impl Future<Output = Result<()>> + Send { ... } fn getxattr( &self, req: Request, path: &OsStr, name: &OsStr, size: u32, ) -> impl Future<Output = Result<ReplyXAttr>> + Send { ... } fn listxattr( &self, req: Request, path: &OsStr, size: u32, ) -> impl Future<Output = Result<ReplyXAttr>> + Send { ... } fn removexattr( &self, req: Request, path: &OsStr, name: &OsStr, ) -> impl Future<Output = Result<()>> + Send { ... } fn flush( &self, req: Request, path: Option<&OsStr>, fh: u64, lock_owner: u64, ) -> impl Future<Output = Result<()>> + Send { ... } fn opendir( &self, req: Request, path: &OsStr, flags: u32, ) -> impl Future<Output = Result<ReplyOpen>> + Send { ... } fn readdir<'a>( &'a self, req: Request, path: &'a OsStr, fh: u64, offset: i64, ) -> impl Future<Output = Result<ReplyDirectory<Self::DirEntryStream<'a>>>> + Send { ... } fn releasedir( &self, req: Request, path: &OsStr, fh: u64, flags: u32, ) -> impl Future<Output = Result<()>> + Send { ... } fn fsyncdir( &self, req: Request, path: &OsStr, fh: u64, datasync: bool, ) -> impl Future<Output = Result<()>> + Send { ... } fn access( &self, req: Request, path: &OsStr, mask: u32, ) -> impl Future<Output = Result<()>> + Send { ... } fn create( &self, req: Request, parent: &OsStr, name: &OsStr, mode: u32, flags: u32, ) -> impl Future<Output = Result<ReplyCreated>> + Send { ... } fn interrupt( &self, req: Request, unique: u64, ) -> impl Future<Output = Result<()>> + Send { ... } fn bmap( &self, req: Request, path: &OsStr, block_size: u32, idx: u64, ) -> impl Future<Output = Result<ReplyBmap>> + Send { ... } fn poll( &self, req: Request, path: Option<&OsStr>, fh: u64, kn: Option<u64>, flags: u32, envents: u32, notify: &Notify, ) -> impl Future<Output = Result<ReplyPoll>> + Send { ... } fn notify_reply( &self, req: Request, path: &OsStr, offset: u64, data: Bytes, ) -> impl Future<Output = Result<()>> + Send { ... } fn batch_forget( &self, req: Request, paths: &[&OsStr], ) -> impl Future<Output = ()> + Send { ... } fn fallocate( &self, req: Request, path: Option<&OsStr>, fh: u64, offset: u64, length: u64, mode: u32, ) -> impl Future<Output = Result<()>> + Send { ... } fn readdirplus<'a>( &'a self, req: Request, parent: &'a OsStr, fh: u64, offset: u64, lock_owner: u64, ) -> impl Future<Output = Result<ReplyDirectoryPlus<Self::DirEntryPlusStream<'a>>>> + Send { ... } fn rename2( &self, req: Request, origin_parent: &OsStr, origin_name: &OsStr, parent: &OsStr, name: &OsStr, flags: u32, ) -> impl Future<Output = Result<()>> + Send { ... } fn lseek( &self, req: Request, path: Option<&OsStr>, fh: u64, offset: u64, whence: u32, ) -> impl Future<Output = Result<ReplyLSeek>> + Send { ... } fn copy_file_range( &self, req: Request, from_path: Option<&OsStr>, fh_in: u64, offset_in: u64, to_path: Option<&OsStr>, fh_out: u64, offset_out: u64, length: u64, flags: u64, ) -> impl Future<Output = Result<ReplyCopyFileRange>> + Send { ... }
}
Expand description

Path based filesystem trait.

Required Associated Types§

Source

type DirEntryStream<'a>: Stream<Item = Result<DirectoryEntry>> + Send + 'a where Self: 'a

dir entry stream given by readdir.

Source

type DirEntryPlusStream<'a>: Stream<Item = Result<DirectoryEntryPlus>> + Send + 'a where Self: 'a

dir entry plus stream given by readdirplus.

Required Methods§

Source

fn init(&self, req: Request) -> impl Future<Output = Result<ReplyInit>> + Send

initialize filesystem. Called before any other filesystem method.

Source

fn destroy(&self, req: Request) -> impl Future<Output = ()> + Send

clean up filesystem. Called on filesystem exit which is fuseblk, in normal fuse filesystem, kernel may call forget for root. There is some discuss for this https://github.com/bazil/fuse/issues/82#issuecomment-88126886, https://sourceforge.net/p/fuse/mailman/message/31995737/

Source

fn getlk( &self, req: Request, path: Option<&OsStr>, fh: u64, lock_owner: u64, start: u64, end: u64, type: u32, pid: u32, ) -> impl Future<Output = Result<ReplyLock>> + Send

Available on crate feature file-lock only.

test for a POSIX file lock.

§Notes:

this is supported on enable file-lock feature.

Source

fn setlk( &self, req: Request, path: Option<&OsStr>, fh: u64, lock_owner: u64, start: u64, end: u64, type: u32, pid: u32, block: bool, ) -> impl Future<Output = Result<()>> + Send

Available on crate feature file-lock only.

acquire, modify or release a POSIX file lock.

§Notes:

this is supported on enable file-lock feature.

Provided Methods§

Source

fn lookup( &self, req: Request, parent: &OsStr, name: &OsStr, ) -> impl Future<Output = Result<ReplyEntry>> + Send

look up a directory entry by name and get its attributes.

Source

fn forget( &self, req: Request, parent: &OsStr, nlookup: u64, ) -> impl Future<Output = ()> + Send

forget an path. The nlookup parameter indicates the number of lookups previously performed on this path. If the filesystem implements path lifetimes, it is recommended that paths acquire a single reference on each lookup, and lose nlookup references on each forget. The filesystem may ignore forget calls, if the paths don’t need to have a limited lifetime. On unmount it is not guaranteed, that all referenced paths will receive a forget message. When filesystem is normal(not fuseblk) and unmounting, kernel may send forget request for root and this library will stop session after call forget. There is some discussion for this https://github.com/bazil/fuse/issues/82#issuecomment-88126886, https://sourceforge.net/p/fuse/mailman/message/31995737/ https://sourceforge.net/p/fuse/mailman/message/31995737/

Source

fn getattr( &self, req: Request, path: Option<&OsStr>, fh: Option<u64>, flags: u32, ) -> impl Future<Output = Result<ReplyAttr>> + Send

get file attributes. If fh is None, means fh is not set. If path is None, means the path may be deleted.

Source

fn setattr( &self, req: Request, path: Option<&OsStr>, fh: Option<u64>, set_attr: SetAttr, ) -> impl Future<Output = Result<ReplyAttr>> + Send

set file attributes. If fh is None, means fh is not set. If path is None, means the path may be deleted.

read symbolic link.

create a symbolic link.

Source

fn mknod( &self, req: Request, parent: &OsStr, name: &OsStr, mode: u32, rdev: u32, ) -> impl Future<Output = Result<ReplyEntry>> + Send

create file node. Create a regular file, character device, block device, fifo or socket node. When creating file, most cases user only need to implement create.

Source

fn mkdir( &self, req: Request, parent: &OsStr, name: &OsStr, mode: u32, umask: u32, ) -> impl Future<Output = Result<ReplyEntry>> + Send

create a directory.

remove a file.

Source

fn rmdir( &self, req: Request, parent: &OsStr, name: &OsStr, ) -> impl Future<Output = Result<()>> + Send

remove a directory.

Source

fn rename( &self, req: Request, origin_parent: &OsStr, origin_name: &OsStr, parent: &OsStr, name: &OsStr, ) -> impl Future<Output = Result<()>> + Send

rename a file or directory.

create a hard link.

Source

fn open( &self, req: Request, path: &OsStr, flags: u32, ) -> impl Future<Output = Result<ReplyOpen>> + Send

open a file. Open flags (with the exception of O_CREAT, O_EXCL and O_NOCTTY) are available in flags. Filesystem may store an arbitrary file handle (pointer, index, etc) in fh, and use this in other all other file operations (read, write, flush, release, fsync). Filesystem may also implement stateless file I/O and not store anything in fh. There are also some flags (direct_io, keep_cache) which the filesystem may set, to change the way the file is opened. A file system need not implement this method if it sets MountOptions::no_open_support and if the kernel supports FUSE_NO_OPEN_SUPPORT.

§Notes:

See fuse_file_info structure in fuse_common.h for more details.

Source

fn read( &self, req: Request, path: Option<&OsStr>, fh: u64, offset: u64, size: u32, ) -> impl Future<Output = Result<ReplyData>> + Send

read data. Read should send exactly the number of bytes requested except on EOF or error, otherwise the rest of the data will be substituted with zeroes. An exception to this is when the file has been opened in direct_io mode, in which case the return value of the read system call will reflect the return value of this operation. fh will contain the value set by the open method, or will be undefined if the open method didn’t set any value. when path is None, it means the path may be deleted.

Source

fn write( &self, req: Request, path: Option<&OsStr>, fh: u64, offset: u64, data: &[u8], write_flags: u32, flags: u32, ) -> impl Future<Output = Result<ReplyWrite>> + Send

write data. Write should return exactly the number of bytes requested except on error. An exception to this is when the file has been opened in direct_io mode, in which case the return value of the write system call will reflect the return value of this operation. fh will contain the value set by the open method, or will be undefined if the open method didn’t set any value. When path is None, it means the path may be deleted. When write_flags contains FUSE_WRITE_CACHE, means the write operation is a delay write.

Source

fn statfs( &self, req: Request, path: &OsStr, ) -> impl Future<Output = Result<ReplyStatFs>> + Send

get filesystem statistics.

Source

fn release( &self, req: Request, path: Option<&OsStr>, fh: u64, flags: u32, lock_owner: u64, flush: bool, ) -> impl Future<Output = Result<()>> + Send

release an open file. Release is called when there are no more references to an open file: all file descriptors are closed and all memory mappings are unmapped. For every open call there will be exactly one release call. The filesystem may reply with an error, but error values are not returned to close() or munmap() which triggered the release. fh will contain the value set by the open method, or will be undefined if the open method didn’t set any value. flags will contain the same flags as for open. flush means flush the data or not when closing file. when path is None, it means the path may be deleted.

Source

fn fsync( &self, req: Request, path: Option<&OsStr>, fh: u64, datasync: bool, ) -> impl Future<Output = Result<()>> + Send

synchronize file contents. If the datasync is true, then only the user data should be flushed, not the metadata. when path is None, it means the path may be deleted.

Source

fn setxattr( &self, req: Request, path: &OsStr, name: &OsStr, value: &[u8], flags: u32, position: u32, ) -> impl Future<Output = Result<()>> + Send

set an extended attribute.

Source

fn getxattr( &self, req: Request, path: &OsStr, name: &OsStr, size: u32, ) -> impl Future<Output = Result<ReplyXAttr>> + Send

get an extended attribute. If size is too small, use ReplyXAttr::Size to return correct size. If size is enough, use ReplyXAttr::Data to send it, or return error.

Source

fn listxattr( &self, req: Request, path: &OsStr, size: u32, ) -> impl Future<Output = Result<ReplyXAttr>> + Send

list extended attribute names. If size is too small, use ReplyXAttr::Size to return correct size. If size is enough, use ReplyXAttr::Data to send it, or return error.

Source

fn removexattr( &self, req: Request, path: &OsStr, name: &OsStr, ) -> impl Future<Output = Result<()>> + Send

remove an extended attribute.

Source

fn flush( &self, req: Request, path: Option<&OsStr>, fh: u64, lock_owner: u64, ) -> impl Future<Output = Result<()>> + Send

flush method. This is called on each close() of the opened file. Since file descriptors can be duplicated (dup, dup2, fork), for one open call there may be many flush calls. Filesystems shouldn’t assume that flush will always be called after some writes, or that if will be called at all. fh will contain the value set by the open method, or will be undefined if the open method didn’t set any value. when path is None, it means the path may be deleted.

§Notes:

the name of the method is misleading, since (unlike fsync) the filesystem is not forced to flush pending writes. One reason to flush data, is if the filesystem wants to return write errors. If the filesystem supports file locking operations ( setlk, getlk) it should remove all locks belonging to lock_owner.

Source

fn opendir( &self, req: Request, path: &OsStr, flags: u32, ) -> impl Future<Output = Result<ReplyOpen>> + Send

open a directory. Filesystem may store an arbitrary file handle (pointer, index, etc) in fh, and use this in other all other directory stream operations (readdir, releasedir, fsyncdir). Filesystem may also implement stateless directory I/O and not store anything in fh. A file system need not implement this method if it sets MountOptions::no_open_dir_support and if the kernel supports FUSE_NO_OPENDIR_SUPPORT.

Source

fn readdir<'a>( &'a self, req: Request, path: &'a OsStr, fh: u64, offset: i64, ) -> impl Future<Output = Result<ReplyDirectory<Self::DirEntryStream<'a>>>> + Send

read directory. offset is used to track the offset of the directory entries. fh will contain the value set by the opendir method, or will be undefined if the opendir method didn’t set any value.

Source

fn releasedir( &self, req: Request, path: &OsStr, fh: u64, flags: u32, ) -> impl Future<Output = Result<()>> + Send

release an open directory. For every opendir call there will be exactly one releasedir call. fh will contain the value set by the opendir method, or will be undefined if the opendir method didn’t set any value.

Source

fn fsyncdir( &self, req: Request, path: &OsStr, fh: u64, datasync: bool, ) -> impl Future<Output = Result<()>> + Send

synchronize directory contents. If the datasync is true, then only the directory contents should be flushed, not the metadata. fh will contain the value set by the opendir method, or will be undefined if the opendir method didn’t set any value.

Source

fn access( &self, req: Request, path: &OsStr, mask: u32, ) -> impl Future<Output = Result<()>> + Send

check file access permissions. This will be called for the access() system call. If the default_permissions mount option is given, this method is not be called. This method is not called under Linux kernel versions 2.4.x.

Source

fn create( &self, req: Request, parent: &OsStr, name: &OsStr, mode: u32, flags: u32, ) -> impl Future<Output = Result<ReplyCreated>> + Send

create and open a file. If the file does not exist, first create it with the specified mode, and then open it. Open flags (with the exception of O_NOCTTY) are available in flags. Filesystem may store an arbitrary file handle (pointer, index, etc) in fh, and use this in other all other file operations (read, write, flush, release, fsync). There are also some flags (direct_io, keep_cache) which the filesystem may set, to change the way the file is opened. If this method is not implemented or under Linux kernel versions earlier than 2.6.15, the mknod and open methods will be called instead.

§Notes:

See fuse_file_info structure in fuse_common.h for more details.

Source

fn interrupt( &self, req: Request, unique: u64, ) -> impl Future<Output = Result<()>> + Send

handle interrupt. When a operation is interrupted, an interrupt request will send to fuse server with the unique id of the operation.

Source

fn bmap( &self, req: Request, path: &OsStr, block_size: u32, idx: u64, ) -> impl Future<Output = Result<ReplyBmap>> + Send

map block index within file to block index within device.

§Notes:

This may not works because currently this crate doesn’t support fuseblk mode yet.

Source

fn poll( &self, req: Request, path: Option<&OsStr>, fh: u64, kn: Option<u64>, flags: u32, envents: u32, notify: &Notify, ) -> impl Future<Output = Result<ReplyPoll>> + Send

poll for IO readiness events.

Source

fn notify_reply( &self, req: Request, path: &OsStr, offset: u64, data: Bytes, ) -> impl Future<Output = Result<()>> + Send

receive notify reply from kernel.

Source

fn batch_forget( &self, req: Request, paths: &[&OsStr], ) -> impl Future<Output = ()> + Send

forget more than one path. This is a batch version forget

Source

fn fallocate( &self, req: Request, path: Option<&OsStr>, fh: u64, offset: u64, length: u64, mode: u32, ) -> impl Future<Output = Result<()>> + Send

allocate space for an open file. This function ensures that required space is allocated for specified file.

§Notes:

more information about fallocate, please see man 2 fallocate

Source

fn readdirplus<'a>( &'a self, req: Request, parent: &'a OsStr, fh: u64, offset: u64, lock_owner: u64, ) -> impl Future<Output = Result<ReplyDirectoryPlus<Self::DirEntryPlusStream<'a>>>> + Send

read directory entries, but with their attribute, like readdir

Source

fn rename2( &self, req: Request, origin_parent: &OsStr, origin_name: &OsStr, parent: &OsStr, name: &OsStr, flags: u32, ) -> impl Future<Output = Result<()>> + Send

rename a file or directory with flags.

Source

fn lseek( &self, req: Request, path: Option<&OsStr>, fh: u64, offset: u64, whence: u32, ) -> impl Future<Output = Result<ReplyLSeek>> + Send

find next data or hole after the specified offset.

Source

fn copy_file_range( &self, req: Request, from_path: Option<&OsStr>, fh_in: u64, offset_in: u64, to_path: Option<&OsStr>, fh_out: u64, offset_out: u64, length: u64, flags: u64, ) -> impl Future<Output = Result<ReplyCopyFileRange>> + Send

copy a range of data from one file to another. This can improve performance because it reduce data copy: in normal, data will copy from FUSE server to kernel, then to user-space, then to kernel, finally send back to FUSE server. By implement this method, data will only copy in FUSE server internal. when from_path or to_path is None, it means the path may be deleted.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§