Skip to main content

AsyncFilesystem

Trait AsyncFilesystem 

Source
pub trait AsyncFilesystem:
    Send
    + Sync
    + 'static {
Show 34 methods // Provided methods fn init(&self, req: RequestInfo, config: &mut KernelConfig) -> ResultEmpty { ... } fn destroy(&self) { ... } fn getattr( &self, req: RequestInfo, path: EntryRef, fh: Option<u64>, ) -> impl Future<Output = ResultEntry> + Send { ... } fn chmod( &self, req: RequestInfo, path: ResolvedPath, fh: Option<u64>, mode: u32, ) -> impl Future<Output = ResultEmpty> + Send { ... } fn chown( &self, req: RequestInfo, path: ResolvedPath, fh: Option<u64>, uid: Option<u32>, gid: Option<u32>, ) -> impl Future<Output = ResultEmpty> + Send { ... } fn truncate( &self, req: RequestInfo, path: ResolvedPath, fh: Option<u64>, size: u64, ) -> impl Future<Output = ResultEmpty> + Send { ... } fn utimens( &self, req: RequestInfo, path: ResolvedPath, fh: Option<u64>, atime: Option<SystemTime>, mtime: Option<SystemTime>, ) -> impl Future<Output = ResultEmpty> + Send { ... } fn utimens_macos( &self, req: RequestInfo, path: ResolvedPath, fh: Option<u64>, crtime: Option<SystemTime>, chgtime: Option<SystemTime>, bkuptime: Option<SystemTime>, flags: Option<u32>, ) -> impl Future<Output = ResultEmpty> + Send { ... } fn readlink( &self, req: RequestInfo, path: ResolvedPath, ) -> impl Future<Output = ResultData> + Send { ... } fn mknod( &self, req: RequestInfo, entry: EntryName, mode: u32, rdev: u32, ) -> impl Future<Output = ResultEntry> + Send { ... } fn mkdir( &self, req: RequestInfo, entry: EntryName, mode: u32, ) -> impl Future<Output = ResultEntry> + Send { ... } fn unlink( &self, req: RequestInfo, entry: EntryName, ) -> impl Future<Output = ResultEmpty> + Send { ... } fn rmdir( &self, req: RequestInfo, entry: EntryName, ) -> impl Future<Output = ResultEmpty> + Send { ... } fn symlink( &self, req: RequestInfo, entry: EntryName, target: PathBuf, ) -> impl Future<Output = ResultEntry> + Send { ... } fn rename( &self, req: RequestInfo, entry: EntryName, new_entry: EntryName, ) -> impl Future<Output = ResultEmpty> + Send { ... } fn link( &self, req: RequestInfo, path: ResolvedPath, new_entry: EntryName, ) -> impl Future<Output = ResultEntry> + Send { ... } fn open( &self, req: RequestInfo, path: ResolvedPath, flags: u32, ) -> impl Future<Output = ResultOpen> + Send { ... } fn read( &self, req: RequestInfo, path: ResolvedPath, fh: u64, offset: u64, size: u32, ) -> impl Future<Output = ResultData> + Send { ... } fn write( &self, req: RequestInfo, path: ResolvedPath, fh: u64, offset: u64, data: Vec<u8>, flags: u32, ) -> impl Future<Output = ResultWrite> + Send { ... } fn flush( &self, req: RequestInfo, path: ResolvedPath, fh: u64, lock_owner: u64, ) -> impl Future<Output = ResultEmpty> + Send { ... } fn release( &self, req: RequestInfo, path: ResolvedPath, fh: u64, flags: u32, lock_owner: u64, flush: bool, ) -> impl Future<Output = ResultEmpty> + Send { ... } fn fsync( &self, req: RequestInfo, path: ResolvedPath, fh: u64, datasync: bool, ) -> impl Future<Output = ResultEmpty> + Send { ... } fn opendir( &self, req: RequestInfo, path: ResolvedPath, flags: u32, ) -> impl Future<Output = ResultOpen> + Send { ... } fn readdir( &self, req: RequestInfo, path: ResolvedPath, fh: u64, ) -> impl Stream<Item = ResultReaddirBatch> + Send + 'static { ... } fn legacy_readdir( &self, req: RequestInfo, path: ResolvedPath, fh: u64, ) -> impl Stream<Item = ResultLegacyReaddirBatch> + Send + 'static { ... } fn releasedir( &self, req: RequestInfo, path: ResolvedPath, fh: u64, flags: u32, ) -> impl Future<Output = ResultEmpty> + Send { ... } fn fsyncdir( &self, req: RequestInfo, path: ResolvedPath, fh: u64, datasync: bool, ) -> impl Future<Output = ResultEmpty> + Send { ... } fn statfs( &self, req: RequestInfo, path: ResolvedPath, ) -> impl Future<Output = ResultStatfs> + Send { ... } fn setxattr( &self, req: RequestInfo, path: ResolvedPath, name: OsString, value: Vec<u8>, flags: u32, position: u32, ) -> impl Future<Output = ResultEmpty> + Send { ... } fn getxattr( &self, req: RequestInfo, path: ResolvedPath, name: OsString, size: u32, ) -> impl Future<Output = ResultXattr> + Send { ... } fn listxattr( &self, req: RequestInfo, path: ResolvedPath, size: u32, ) -> impl Future<Output = ResultXattr> + Send { ... } fn removexattr( &self, req: RequestInfo, path: ResolvedPath, name: OsString, ) -> impl Future<Output = ResultEmpty> + Send { ... } fn access( &self, req: RequestInfo, path: ResolvedPath, mask: u32, ) -> impl Future<Output = ResultEmpty> + Send { ... } fn create( &self, req: RequestInfo, path: ResolvedPath, mode: u32, flags: u32, ) -> impl Future<Output = ResultCreate> + Send { ... }
}
Available on crate feature async only.
Expand description

Filesystem operations that may complete asynchronously.

Operation arguments are owned so their futures can outlive the FUSE request callback.

Provided Methods§

Source

fn init(&self, req: RequestInfo, config: &mut KernelConfig) -> ResultEmpty

Called when the filesystem is mounted, before any other operation.

  • req: information about the FUSE request.
  • config: kernel configuration that may be adjusted before mounting.
Source

fn destroy(&self)

Called when the filesystem is unmounted.

Source

fn getattr( &self, req: RequestInfo, path: EntryRef, fh: Option<u64>, ) -> impl Future<Output = ResultEntry> + Send

Get the attributes of a filesystem entry.

  • req: information about the FUSE request.
  • path: path to the entry.
  • fh: a file handle if this is called on an open file.
Source

fn chmod( &self, req: RequestInfo, path: ResolvedPath, fh: Option<u64>, mode: u32, ) -> impl Future<Output = ResultEmpty> + Send

Change the mode of a filesystem entry.

  • req: information about the FUSE request.
  • path: path to the entry.
  • fh: a file handle if this is called on an open file.
  • mode: the mode to change the file to.
Source

fn chown( &self, req: RequestInfo, path: ResolvedPath, fh: Option<u64>, uid: Option<u32>, gid: Option<u32>, ) -> impl Future<Output = ResultEmpty> + Send

Change the owner UID and/or group GID of a filesystem entry.

  • req: information about the FUSE request.
  • path: path to the entry.
  • fh: a file handle if this is called on an open file.
  • uid: new user ID for the file owner. If None, leave the UID unchanged.
  • gid: new group ID for the file. If None, leave the GID unchanged.
Source

fn truncate( &self, req: RequestInfo, path: ResolvedPath, fh: Option<u64>, size: u64, ) -> impl Future<Output = ResultEmpty> + Send

Set the length of a file.

  • req: information about the FUSE request.
  • path: path to the file.
  • fh: a file handle if this is called on an open file.
  • size: new file length in bytes.
Source

fn utimens( &self, req: RequestInfo, path: ResolvedPath, fh: Option<u64>, atime: Option<SystemTime>, mtime: Option<SystemTime>, ) -> impl Future<Output = ResultEmpty> + Send

Set the timestamps of a filesystem entry.

  • req: information about the FUSE request.
  • path: path to the entry.
  • fh: a file handle if this is called on an open file.
  • atime: new access time, or None to leave it unchanged.
  • mtime: new modification time, or None to leave it unchanged.
Source

fn utimens_macos( &self, req: RequestInfo, path: ResolvedPath, fh: Option<u64>, crtime: Option<SystemTime>, chgtime: Option<SystemTime>, bkuptime: Option<SystemTime>, flags: Option<u32>, ) -> impl Future<Output = ResultEmpty> + Send

Set the timestamps of a filesystem entry using the additional macOS options.

  • req: information about the FUSE request.
  • path: path to the entry.
  • fh: a file handle if this is called on an open file.
  • crtime: new creation time, or None to leave it unchanged.
  • chgtime: new metadata change time, or None to leave it unchanged.
  • bkuptime: new backup time, or None to leave it unchanged.
  • flags: new macOS file flags, or None to leave them unchanged.

Read a symbolic link.

  • req: information about the FUSE request.
  • path: path to the symbolic link.
Source

fn mknod( &self, req: RequestInfo, entry: EntryName, mode: u32, rdev: u32, ) -> impl Future<Output = ResultEntry> + Send

Create a special file.

  • req: information about the FUSE request.
  • entry: entry name resolved relative to its parent directory.
  • mode: mode for the new entry.
  • rdev: device number when mode contains S_IFCHR or S_IFBLK; ignored otherwise.
Source

fn mkdir( &self, req: RequestInfo, entry: EntryName, mode: u32, ) -> impl Future<Output = ResultEntry> + Send

Create a directory.

  • req: information about the FUSE request.
  • entry: directory name resolved relative to its parent directory.
  • mode: permissions for the new directory.

Remove a file.

  • req: information about the FUSE request.
  • entry: file name resolved relative to its parent directory.
Source

fn rmdir( &self, req: RequestInfo, entry: EntryName, ) -> impl Future<Output = ResultEmpty> + Send

Remove a directory.

  • req: information about the FUSE request.
  • entry: directory name resolved relative to its parent directory.

Create a symbolic link.

  • req: information about the FUSE request.
  • entry: symbolic link name resolved relative to its parent directory.
  • target: path (may be relative or absolute) to the target of the link.
Source

fn rename( &self, req: RequestInfo, entry: EntryName, new_entry: EntryName, ) -> impl Future<Output = ResultEmpty> + Send

Rename a filesystem entry.

  • req: information about the FUSE request.
  • entry: current entry name resolved relative to its parent directory.
  • new_entry: new entry name resolved relative to its parent directory.

Create a hard link.

  • req: information about the FUSE request.
  • path: path to an existing file.
  • new_entry: new link name resolved relative to its parent directory.
Source

fn open( &self, req: RequestInfo, path: ResolvedPath, flags: u32, ) -> impl Future<Output = ResultOpen> + Send

Open a file.

  • req: information about the FUSE request.
  • path: path to the file.
  • flags: one of O_RDONLY, O_WRONLY, or O_RDWR, plus any additional flags.

Return a tuple of (file handle, flags). The file handle will be passed to any subsequent calls that operate on the file, and can be any value you choose, though it should allow your filesystem to identify the open file even without path information.

Source

fn read( &self, req: RequestInfo, path: ResolvedPath, fh: u64, offset: u64, size: u32, ) -> impl Future<Output = ResultData> + Send

Read from a file.

Reading past the end of the file is not an error. Return only the available data up to the end of the file, which may be fewer bytes than requested or even zero bytes. Do not extend the file in this case.

  • req: information about the FUSE request.
  • path: path to the file.
  • fh: file handle returned from the open call.
  • offset: offset into the file to start reading.
  • size: number of bytes to read.
Source

fn write( &self, req: RequestInfo, path: ResolvedPath, fh: u64, offset: u64, data: Vec<u8>, flags: u32, ) -> impl Future<Output = ResultWrite> + Send

Write to a file.

  • req: information about the FUSE request.
  • path: path to the file.
  • fh: file handle returned from the open call.
  • offset: offset into the file to start writing.
  • data: data to write.
  • flags: file open flags.

Return the number of bytes written.

Source

fn flush( &self, req: RequestInfo, path: ResolvedPath, fh: u64, lock_owner: u64, ) -> impl Future<Output = ResultEmpty> + Send

Called each time a program calls close on an open file.

Note that because file descriptors can be duplicated (by dup, dup2, fork) this may be called multiple times for a given file handle. The main use of this function is if the filesystem would like to return an error to the close call. Note that most programs ignore the return value of close, though.

  • req: information about the FUSE request.
  • path: path to the file.
  • fh: file handle returned from the open call.
  • lock_owner: if the filesystem supports locking (setlk, getlk), remove all locks belonging to this lock owner.
Source

fn release( &self, req: RequestInfo, path: ResolvedPath, fh: u64, flags: u32, lock_owner: u64, flush: bool, ) -> impl Future<Output = ResultEmpty> + Send

Called when an open file is closed.

There will be one of these for each open call. After release, no more calls will be made with the given file handle.

  • req: information about the FUSE request.
  • path: path to the file.
  • fh: file handle returned from the open call.
  • flags: the flags passed when the file was opened.
  • lock_owner: if the filesystem supports locking (setlk, getlk), remove all locks belonging to this lock owner.
  • flush: whether pending data must be flushed or not.
Source

fn fsync( &self, req: RequestInfo, path: ResolvedPath, fh: u64, datasync: bool, ) -> impl Future<Output = ResultEmpty> + Send

Write out any pending changes to a file.

When this returns, data should be written to persistent storage.

  • req: information about the FUSE request.
  • path: path to the file.
  • fh: file handle returned from the open call.
  • datasync: if false, also write metadata; otherwise, write only file data.
Source

fn opendir( &self, req: RequestInfo, path: ResolvedPath, flags: u32, ) -> impl Future<Output = ResultOpen> + Send

Open a directory.

Analogous to the opendir call.

  • req: information about the FUSE request.
  • path: path to the directory.
  • flags: file access flags. Will contain O_DIRECTORY at least.

Return a tuple of (file handle, flags). The file handle will be passed to any subsequent calls that operate on the directory, and can be any value you choose, though it should allow your filesystem to identify the open directory even without path information.

Source

fn readdir( &self, req: RequestInfo, path: ResolvedPath, fh: u64, ) -> impl Stream<Item = ResultReaddirBatch> + Send + 'static

Gets directory entries together with their attributes.

  • req: information about the FUSE request.
  • path: path to the directory.
  • fh: file handle returned from the opendir call.

Batching allows initial results to be returned before directory enumeration completes. FuserNG deliberately retains consumed entries until releasedir so earlier offsets can be replayed without restarting enumeration or repeating backend requests. This history trades memory for fast replay; batching is intended to reduce result delivery latency.

Source

fn legacy_readdir( &self, req: RequestInfo, path: ResolvedPath, fh: u64, ) -> impl Stream<Item = ResultLegacyReaddirBatch> + Send + 'static

Available on crate feature legacy_readdir only.

Gets directory entries without attributes for the legacy FUSE readdir operation.

  • req: information about the FUSE request.
  • path: path to the directory.
  • fh: file handle returned from the opendir call.

Batching allows initial results to be returned before directory enumeration completes. FuserNG deliberately retains consumed entries until releasedir so earlier offsets can be replayed without restarting enumeration or repeating backend requests. This history trades memory for fast replay; batching is intended to reduce result delivery latency.

Source

fn releasedir( &self, req: RequestInfo, path: ResolvedPath, fh: u64, flags: u32, ) -> impl Future<Output = ResultEmpty> + Send

Close an open directory.

This will be called exactly once for each opendir call.

  • req: information about the FUSE request.
  • path: path to the directory.
  • fh: file handle returned from the opendir call.
  • flags: the file access flags passed to the opendir call.
Source

fn fsyncdir( &self, req: RequestInfo, path: ResolvedPath, fh: u64, datasync: bool, ) -> impl Future<Output = ResultEmpty> + Send

Write out any pending changes to a directory.

Analogous to the fsync call.

  • req: information about the FUSE request.
  • path: path to the directory.
  • fh: file handle returned from the opendir call.
  • datasync: if false, also write metadata; otherwise, write only directory data.
Source

fn statfs( &self, req: RequestInfo, path: ResolvedPath, ) -> impl Future<Output = ResultStatfs> + Send

Get filesystem statistics.

  • req: information about the FUSE request.
  • path: path to a directory in the filesystem.

See the Statfs struct for more details.

Source

fn setxattr( &self, req: RequestInfo, path: ResolvedPath, name: OsString, value: Vec<u8>, flags: u32, position: u32, ) -> impl Future<Output = ResultEmpty> + Send

Set an extended attribute on a file.

  • req: information about the FUSE request.
  • path: path to the file.
  • name: attribute name.
  • value: the data to set the value to.
  • flags: can be either XATTR_CREATE or XATTR_REPLACE.
  • position: offset into the attribute value to write data.
Source

fn getxattr( &self, req: RequestInfo, path: ResolvedPath, name: OsString, size: u32, ) -> impl Future<Output = ResultXattr> + Send

Get an extended attribute from a file.

  • req: information about the FUSE request.
  • path: path to the file.
  • name: attribute name.
  • size: the maximum number of bytes to read.

If size is 0, return Xattr::Size(n) where n is the size of the attribute data. Otherwise, return Xattr::Data(data) with the requested data.

Source

fn listxattr( &self, req: RequestInfo, path: ResolvedPath, size: u32, ) -> impl Future<Output = ResultXattr> + Send

List extended attributes for a file.

  • req: information about the FUSE request.
  • path: path to the file.
  • size: maximum number of bytes to return.

If size is 0, return Xattr::Size(n) where n is the size required for the list of attribute names. Otherwise, return Xattr::Data(data) where data is all the null-terminated attribute names.

Source

fn removexattr( &self, req: RequestInfo, path: ResolvedPath, name: OsString, ) -> impl Future<Output = ResultEmpty> + Send

Remove an extended attribute from a file.

  • req: information about the FUSE request.
  • path: path to the file.
  • name: name of the attribute to remove.
Source

fn access( &self, req: RequestInfo, path: ResolvedPath, mask: u32, ) -> impl Future<Output = ResultEmpty> + Send

Check for access to a file.

  • req: information about the FUSE request.
  • path: path to the file.
  • mask: mode bits to check for access to.

Return Ok(()) if all requested permissions are allowed, otherwise return Err(EACCES) or another appropriate error code (e.g. ENOENT if the file doesn’t exist).

Source

fn create( &self, req: RequestInfo, path: ResolvedPath, mode: u32, flags: u32, ) -> impl Future<Output = ResultCreate> + Send

Create and open a new file.

  • req: information about the FUSE request.
  • path: path to the new file.
  • mode: the mode to set on the new file.
  • flags: flags that would be passed to open.

Return a CreatedEntry containing the new file’s attributes and a file handle. See the documentation for open for more information about file handles.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§