[−][src]Trait fuse_mt::FilesystemMT
This trait must be implemented to implement a filesystem with FuseMT.
Provided methods
fn init(&self, _req: RequestInfo) -> ResultEmpty
Called on mount, before any other function.
fn destroy(&self, _req: RequestInfo)
Called on filesystem unmount.
fn getattr(
&self,
_req: RequestInfo,
_path: &Path,
_fh: Option<u64>
) -> ResultEntry
&self,
_req: RequestInfo,
_path: &Path,
_fh: Option<u64>
) -> ResultEntry
Get the attributes of a filesystem entry.
fh
: a file handle if this is called on an open file.
fn chmod(
&self,
_req: RequestInfo,
_path: &Path,
_fh: Option<u64>,
_mode: u32
) -> ResultEmpty
&self,
_req: RequestInfo,
_path: &Path,
_fh: Option<u64>,
_mode: u32
) -> ResultEmpty
Change the mode of a filesystem entry.
fh
: a file handle if this is called on an open file.mode
: the mode to change the file to.
fn chown(
&self,
_req: RequestInfo,
_path: &Path,
_fh: Option<u64>,
_uid: Option<u32>,
_gid: Option<u32>
) -> ResultEmpty
&self,
_req: RequestInfo,
_path: &Path,
_fh: Option<u64>,
_uid: Option<u32>,
_gid: Option<u32>
) -> ResultEmpty
Change the owner UID and/or group GID of a filesystem entry.
fh
: a file handle if this is called on an open file.uid
: user ID to change the file's owner to. IfNone
, leave the UID unchanged.gid
: group ID to change the file's group to. IfNone
, leave the GID unchanged.
fn truncate(
&self,
_req: RequestInfo,
_path: &Path,
_fh: Option<u64>,
_size: u64
) -> ResultEmpty
&self,
_req: RequestInfo,
_path: &Path,
_fh: Option<u64>,
_size: u64
) -> ResultEmpty
Set the length of a file.
fh
: a file handle if this is called on an open file.size
: size in bytes to set as the file's length.
fn utimens(
&self,
_req: RequestInfo,
_path: &Path,
_fh: Option<u64>,
_atime: Option<Timespec>,
_mtime: Option<Timespec>
) -> ResultEmpty
&self,
_req: RequestInfo,
_path: &Path,
_fh: Option<u64>,
_atime: Option<Timespec>,
_mtime: Option<Timespec>
) -> ResultEmpty
Set timestamps of a filesystem entry.
fh
: a file handle if this is called on an open file.atime
: the time of last access.mtime
: the time of last modification.
fn utimens_macos(
&self,
_req: RequestInfo,
_path: &Path,
_fh: Option<u64>,
_crtime: Option<Timespec>,
_chgtime: Option<Timespec>,
_bkuptime: Option<Timespec>,
_flags: Option<u32>
) -> ResultEmpty
&self,
_req: RequestInfo,
_path: &Path,
_fh: Option<u64>,
_crtime: Option<Timespec>,
_chgtime: Option<Timespec>,
_bkuptime: Option<Timespec>,
_flags: Option<u32>
) -> ResultEmpty
Set timestamps of a filesystem entry (with extra options only used on MacOS).
fn readlink(&self, _req: RequestInfo, _path: &Path) -> ResultData
Read a symbolic link.
fn mknod(
&self,
_req: RequestInfo,
_parent: &Path,
_name: &OsStr,
_mode: u32,
_rdev: u32
) -> ResultEntry
&self,
_req: RequestInfo,
_parent: &Path,
_name: &OsStr,
_mode: u32,
_rdev: u32
) -> ResultEntry
Create a special file.
parent
: path to the directory to make the entry under.name
: name of the entry.mode
: mode for the new entry.rdev
: if mode has the bitsS_IFCHR
orS_IFBLK
set, this is the major and minor numbers for the device file. Otherwise it should be ignored.
fn mkdir(
&self,
_req: RequestInfo,
_parent: &Path,
_name: &OsStr,
_mode: u32
) -> ResultEntry
&self,
_req: RequestInfo,
_parent: &Path,
_name: &OsStr,
_mode: u32
) -> ResultEntry
Create a directory.
parent
: path to the directory to make the directory under.name
: name of the directory.mode
: permissions for the new directory.
fn unlink(
&self,
_req: RequestInfo,
_parent: &Path,
_name: &OsStr
) -> ResultEmpty
&self,
_req: RequestInfo,
_parent: &Path,
_name: &OsStr
) -> ResultEmpty
Remove a file.
parent
: path to the directory containing the file to delete.name
: name of the file to delete.
fn rmdir(&self, _req: RequestInfo, _parent: &Path, _name: &OsStr) -> ResultEmpty
Remove a directory.
parent
: path to the directory containing the directory to delete.name
: name of the directory to delete.
fn symlink(
&self,
_req: RequestInfo,
_parent: &Path,
_name: &OsStr,
_target: &Path
) -> ResultEntry
&self,
_req: RequestInfo,
_parent: &Path,
_name: &OsStr,
_target: &Path
) -> ResultEntry
Create a symbolic link.
parent
: path to the directory to make the link in.name
: name of the symbolic link.target
: path (may be relative or absolute) to the target of the link.
fn rename(
&self,
_req: RequestInfo,
_parent: &Path,
_name: &OsStr,
_newparent: &Path,
_newname: &OsStr
) -> ResultEmpty
&self,
_req: RequestInfo,
_parent: &Path,
_name: &OsStr,
_newparent: &Path,
_newname: &OsStr
) -> ResultEmpty
Rename a filesystem entry.
parent
: path to the directory containing the existing entry.name
: name of the existing entry.newparent
: path to the directory it should be renamed into (may be the same asparent
).newname
: name of the new entry.
fn link(
&self,
_req: RequestInfo,
_path: &Path,
_newparent: &Path,
_newname: &OsStr
) -> ResultEntry
&self,
_req: RequestInfo,
_path: &Path,
_newparent: &Path,
_newname: &OsStr
) -> ResultEntry
Create a hard link.
path
: path to an existing file.newparent
: path to the directory for the new link.newname
: name for the new link.
fn open(&self, _req: RequestInfo, _path: &Path, _flags: u32) -> ResultOpen
Open a file.
path
: path to the file.flags
: one ofO_RDONLY
,O_WRONLY
, orO_RDWR
, plus maybe 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 file opened even without any path info.
fn read(
&self,
_req: RequestInfo,
_path: &Path,
_fh: u64,
_offset: u64,
_size: u32,
result: impl FnOnce(Result<&[u8], c_int>)
)
&self,
_req: RequestInfo,
_path: &Path,
_fh: u64,
_offset: u64,
_size: u32,
result: impl FnOnce(Result<&[u8], c_int>)
)
Read from a file.
Note that it is not an error for this call to request to read past the end of the file, and you should only return data up to the end of the file (i.e. the number of bytes returned will be fewer than requested; possibly even zero). Do not extend the file in this case.
path
: path to the file.fh
: file handle returned from theopen
call.offset
: offset into the file to start reading.size
: number of bytes to read.result
: a callback that must be invoked to return the result of the operation: either the result data as a slice, or an error code.
This function has no return value; call the result
function instead.
fn write(
&self,
_req: RequestInfo,
_path: &Path,
_fh: u64,
_offset: u64,
_data: Vec<u8>,
_flags: u32
) -> ResultWrite
&self,
_req: RequestInfo,
_path: &Path,
_fh: u64,
_offset: u64,
_data: Vec<u8>,
_flags: u32
) -> ResultWrite
Write to a file.
path
: path to the file.fh
: file handle returned from theopen
call.offset
: offset into the file to start writing.data
: the data to writeflags
:
Return the number of bytes written.
fn flush(
&self,
_req: RequestInfo,
_path: &Path,
_fh: u64,
_lock_owner: u64
) -> ResultEmpty
&self,
_req: RequestInfo,
_path: &Path,
_fh: u64,
_lock_owner: u64
) -> ResultEmpty
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.
path
: path to the file.fh
: file handle returned from theopen
call.lock_owner
: if the filesystem supports locking (setlk
,getlk
), remove all locks belonging to this lock owner.
fn release(
&self,
_req: RequestInfo,
_path: &Path,
_fh: u64,
_flags: u32,
_lock_owner: u64,
_flush: bool
) -> ResultEmpty
&self,
_req: RequestInfo,
_path: &Path,
_fh: u64,
_flags: u32,
_lock_owner: u64,
_flush: bool
) -> ResultEmpty
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.
path
: path to the file.fh
: file handle returned from theopen
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.
fn fsync(
&self,
_req: RequestInfo,
_path: &Path,
_fh: u64,
_datasync: bool
) -> ResultEmpty
&self,
_req: RequestInfo,
_path: &Path,
_fh: u64,
_datasync: bool
) -> ResultEmpty
Write out any pending changes of a file.
When this returns, data should be written to persistent storage.
path
: path to the file.fh
: file handle returned from theopen
call.datasync
: iffalse
, also write metadata, otherwise just write file data.
fn opendir(&self, _req: RequestInfo, _path: &Path, _flags: u32) -> ResultOpen
Open a directory.
Analogous to the opend
call.
path
: path to the directory.flags
: file access flags. Will containO_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 directory opened even without any path info.
fn readdir(&self, _req: RequestInfo, _path: &Path, _fh: u64) -> ResultReaddir
Get the entries of a directory.
path
: path to the directory.fh
: file handle returned from theopendir
call.
Return all the entries of the directory.
fn releasedir(
&self,
_req: RequestInfo,
_path: &Path,
_fh: u64,
_flags: u32
) -> ResultEmpty
&self,
_req: RequestInfo,
_path: &Path,
_fh: u64,
_flags: u32
) -> ResultEmpty
Close an open directory.
This will be called exactly once for each opendir
call.
path
: path to the directory.fh
: file handle returned from theopendir
call.flags
: the file access flags passed to theopendir
call.
fn fsyncdir(
&self,
_req: RequestInfo,
_path: &Path,
_fh: u64,
_datasync: bool
) -> ResultEmpty
&self,
_req: RequestInfo,
_path: &Path,
_fh: u64,
_datasync: bool
) -> ResultEmpty
Write out any pending changes to a directory.
Analogous to the fsync
call.
fn statfs(&self, _req: RequestInfo, _path: &Path) -> ResultStatfs
Get filesystem statistics.
path
: path to some folder in the filesystem.
See the Statfs
struct for more details.
fn setxattr(
&self,
_req: RequestInfo,
_path: &Path,
_name: &OsStr,
_value: &[u8],
_flags: u32,
_position: u32
) -> ResultEmpty
&self,
_req: RequestInfo,
_path: &Path,
_name: &OsStr,
_value: &[u8],
_flags: u32,
_position: u32
) -> ResultEmpty
Set a file extended attribute.
path
: path to the file.name
: attribute name.value
: the data to set the value to.flags
: can be eitherXATTR_CREATE
orXATTR_REPLACE
.position
: offset into the attribute value to write data.
fn getxattr(
&self,
_req: RequestInfo,
_path: &Path,
_name: &OsStr,
_size: u32
) -> ResultXattr
&self,
_req: RequestInfo,
_path: &Path,
_name: &OsStr,
_size: u32
) -> ResultXattr
Get a file extended attribute.
path
: path to the filename
: 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.
fn listxattr(&self, _req: RequestInfo, _path: &Path, _size: u32) -> ResultXattr
List extended attributes for a file.
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.
fn removexattr(
&self,
_req: RequestInfo,
_path: &Path,
_name: &OsStr
) -> ResultEmpty
&self,
_req: RequestInfo,
_path: &Path,
_name: &OsStr
) -> ResultEmpty
Remove an extended attribute for a file.
path
: path to the file.name
: name of the attribute to remove.
fn access(&self, _req: RequestInfo, _path: &Path, _mask: u32) -> ResultEmpty
Check for access to a file.
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 other error code as appropriate (e.g. ENOENT
if the file doesn't exist).
fn create(
&self,
_req: RequestInfo,
_parent: &Path,
_name: &OsStr,
_mode: u32,
_flags: u32
) -> ResultCreate
&self,
_req: RequestInfo,
_parent: &Path,
_name: &OsStr,
_mode: u32,
_flags: u32
) -> ResultCreate
Create and open a new file.
parent
: path to the directory to create the file in.name
: name of the file to be created.mode
: the mode to set on the new file.flags
: flags like would be passed toopen
.
Return a CreatedEntry
(which contains the new file's attributes as well as a file handle
-- see documentation on open
for more info on that).