From e36f6eff1556ecbe720d0ad0e9fd1c4f898fbc42 Mon Sep 17 00:00:00 2001 From: Richard Lawrence Date: Mon, 8 Sep 2025 10:09:10 -0500 Subject: [PATCH] Backticks. Clippy says it's better to use backticks in doc strings: [https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown] It formats prettier. --- examples/notify_inval_inode.rs | 2 +- examples/passthrough.rs | 26 ++-- src/lib.rs | 78 +++++------ src/ll/reply.rs | 2 +- src/ll/request.rs | 246 ++++++++++++++++----------------- src/mnt/mod.rs | 2 +- src/mnt/mount_options.rs | 4 +- src/notify.rs | 2 +- src/passthrough.rs | 14 +- src/reply.rs | 12 +- src/session.rs | 4 +- 11 files changed, 196 insertions(+), 196 deletions(-) diff --git a/examples/notify_inval_inode.rs b/examples/notify_inval_inode.rs index 4b9f1162..369562f3 100644 --- a/examples/notify_inval_inode.rs +++ b/examples/notify_inval_inode.rs @@ -185,7 +185,7 @@ struct Options { #[clap(short, long)] no_notify: bool, - /// Use notify_store() instead of notify_inval_inode() + /// Use `notify_store()` instead of `notify_inval_inode()` #[clap(short = 's', long)] notify_store: bool, } diff --git a/examples/passthrough.rs b/examples/passthrough.rs index eec90502..beeb1056 100644 --- a/examples/passthrough.rs +++ b/examples/passthrough.rs @@ -16,20 +16,20 @@ use std::time::{Duration, UNIX_EPOCH}; const TTL: Duration = Duration::from_secs(1); // 1 second -/// BackingCache is an example of how a filesystem might manage BackingId objects for fd -/// passthrough. The idea is to avoid creating more than one BackingId object per file at a time. +/// `BackingCache` is an example of how a filesystem might manage `BackingId` objects for fd +/// passthrough. The idea is to avoid creating more than one `BackingId` object per file at a time. /// -/// We do this by keeping a weak "by inode" hash table mapping inode numbers to BackingId. If a -/// BackingId already exists, we use it. Otherwise, we create it. This is not enough to keep the -/// BackingId alive, though. For each Filesystem::open() request we allocate a fresh 'fh' -/// (monotonically increasing u64, next_fh, never recycled) and use that to keep a *strong* -/// reference on the BackingId for that open. We drop it from the table on Filesystem::release(), -/// which means the BackingId will be dropped in the kernel when the last user of it closes. +/// We do this by keeping a weak "by inode" hash table mapping inode numbers to `BackingId`. If a +/// `BackingId` already exists, we use it. Otherwise, we create it. This is not enough to keep the +/// `BackingId` alive, though. For each `Filesystem::open()` request we allocate a fresh 'fh' +/// (monotonically increasing u64, `next_fh`, never recycled) and use that to keep a *strong* +/// reference on the `BackingId` for that open. We drop it from the table on `Filesystem::release()`, +/// which means the `BackingId` will be dropped in the kernel when the last user of it closes. /// /// In this way, if a request to open a file comes in and the file is already open, we'll reuse the -/// BackingId, but as soon as all references are closed, the BackingId will be dropped. +/// `BackingId`, but as soon as all references are closed, the `BackingId` will be dropped. /// -/// It's left as an exercise to the reader to implement an active cleanup of the by_inode table, if +/// It's left as an exercise to the reader to implement an active cleanup of the `by_inode` table, if /// desired, but our little example filesystem only contains one file. :) #[derive(Debug, Default)] struct BackingCache { @@ -44,9 +44,9 @@ impl BackingCache { self.next_fh } - /// Gets the existing BackingId for `ino` if it exists, or calls `callback` to create it. + /// Gets the existing `BackingId` for `ino` if it exists, or calls `callback` to create it. /// - /// Returns a unique file handle and the BackingID (possibly shared, possibly new). The + /// Returns a unique file handle and the `BackingID` (possibly shared, possibly new). The /// returned file handle should be `put()` when you're done with it. fn get_or( &mut self, @@ -70,7 +70,7 @@ impl BackingCache { } /// Releases a file handle previously obtained from `get_or()`. If this was a last user of a - /// particular BackingId then it will be dropped. + /// particular `BackingId` then it will be dropped. fn put(&mut self, fh: u64) { eprintln!("Put fh {fh}"); match self.by_handle.remove(&fh) { diff --git a/src/lib.rs b/src/lib.rs index 816ec9f2..0dd89842 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -85,19 +85,19 @@ const fn default_init_flags(#[allow(unused_variables)] capabilities: u64) -> u64 #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] #[cfg_attr(feature = "serializable", derive(Serialize, Deserialize))] pub enum FileType { - /// Named pipe (S_IFIFO) + /// Named pipe (`S_IFIFO`) NamedPipe, - /// Character device (S_IFCHR) + /// Character device (`S_IFCHR`) CharDevice, - /// Block device (S_IFBLK) + /// Block device (`S_IFBLK`) BlockDevice, - /// Directory (S_IFDIR) + /// Directory (`S_IFDIR`) Directory, - /// Regular file (S_IFREG) + /// Regular file (`S_IFREG`) RegularFile, - /// Symbolic link (S_IFLNK) + /// Symbolic link (`S_IFLNK`) Symlink, - /// Unix domain socket (S_IFSOCK) + /// Unix domain socket (`S_IFSOCK`) Socket, } @@ -177,8 +177,8 @@ impl KernelConfig { /// This has to be at least 1 to support passthrough to backing files. Setting this to 0 (the /// default) effectively disables support for passthrough. /// - /// With max_stack_depth > 1, the backing files can be on a stacked fs (e.g. overlayfs) - /// themselves and with max_stack_depth == 1, this FUSE filesystem can be stacked as the + /// With `max_stack_depth` > 1, the backing files can be on a stacked fs (e.g. overlayfs) + /// themselves and with `max_stack_depth` == 1, this FUSE filesystem can be stacked as the /// underlying fs of a stacked fs (e.g. overlayfs). /// /// The kernel currently has a hard maximum value of 2. Anything higher won't work. @@ -307,14 +307,14 @@ impl KernelConfig { /// Filesystem trait. /// /// This trait must be implemented to provide a userspace filesystem via FUSE. -/// These methods correspond to fuse_lowlevel_ops in libfuse. Reasonable default +/// These methods correspond to `fuse_lowlevel_ops` in libfuse. Reasonable default /// implementations are provided here to get a mountable filesystem that does /// nothing. #[allow(clippy::too_many_arguments)] pub trait Filesystem { /// Initialize filesystem. /// Called before any other filesystem method. - /// The kernel module connection can be configured using the KernelConfig object + /// The kernel module connection can be configured using the `KernelConfig` object fn init(&mut self, _req: &Request<'_>, _config: &mut KernelConfig) -> Result<(), c_int> { Ok(()) } @@ -480,13 +480,13 @@ pub trait Filesystem { } /// Open a file. - /// Open flags (with the exception of O_CREAT, O_EXCL, O_NOCTTY and O_TRUNC) are + /// Open flags (with the exception of `O_CREAT`, `O_EXCL`, `O_NOCTTY` and `O_TRUNC`) 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. See fuse_file_info - /// structure in for more details. + /// 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. See `fuse_file_info` + /// structure in <`fuse_common.h`> for more details. fn open(&mut self, _req: &Request<'_>, _ino: u64, _flags: i32, reply: ReplyOpen) { reply.opened(0, 0); } @@ -494,13 +494,13 @@ pub trait Filesystem { /// 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 + /// 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. /// - /// flags: these are the file flags, such as O_SYNC. Only supported with ABI >= 7.9 - /// lock_owner: only supported with ABI >= 7.9 + /// flags: these are the file flags, such as `O_SYNC`. Only supported with ABI >= 7.9 + /// `lock_owner`: only supported with ABI >= 7.9 fn read( &mut self, _req: &Request<'_>, @@ -521,16 +521,16 @@ pub trait Filesystem { /// 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 + /// 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. /// - /// write_flags: will contain FUSE_WRITE_CACHE, if this write is from the page cache. If set, + /// `write_flags`: will contain `FUSE_WRITE_CACHE`, if this write is from the page cache. If set, /// the pid, uid, gid, and fh may not match the value that would have been sent if write cachin /// is disabled - /// flags: these are the file flags, such as O_SYNC. Only supported with ABI >= 7.9 - /// lock_owner: only supported with ABI >= 7.9 + /// flags: these are the file flags, such as `O_SYNC`. Only supported with ABI >= 7.9 + /// `lock_owner`: only supported with ABI >= 7.9 fn write( &mut self, _req: &Request<'_>, @@ -553,7 +553,7 @@ pub trait Filesystem { } /// Flush method. - /// This is called on each close() of the opened file. Since file descriptors can + /// 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 @@ -561,7 +561,7 @@ pub trait Filesystem { /// NOTE: 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'. + /// operations (`setlk`, `getlk`) it should remove all locks belonging to `lock_owner`. fn flush(&mut self, _req: &Request<'_>, ino: u64, fh: u64, lock_owner: u64, reply: ReplyEmpty) { warn!("[Not Implemented] flush(ino: {ino:#x?}, fh: {fh}, lock_owner: {lock_owner:?})"); reply.error(ENOSYS); @@ -571,7 +571,7 @@ pub trait Filesystem { /// 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 + /// 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. @@ -608,7 +608,7 @@ pub trait Filesystem { } /// Read directory. - /// Send a buffer filled using buffer.fill(), with size not exceeding the + /// Send a buffer filled using `buffer.fill()`, with size not exceeding the /// requested size. Send an empty buffer on end of stream. fh will contain the /// value set by the opendir method, or will be undefined if the opendir method /// didn't set any value. @@ -625,7 +625,7 @@ pub trait Filesystem { } /// Read directory. - /// Send a buffer filled using buffer.fill(), with size not exceeding the + /// Send a buffer filled using `buffer.fill()`, with size not exceeding the /// requested size. Send an empty buffer on end of stream. fh will contain the /// value set by the opendir method, or will be undefined if the opendir method /// didn't set any value. @@ -727,7 +727,7 @@ pub trait Filesystem { } /// Check file access permissions. - /// This will be called for the access() system call. If the 'default_permissions' + /// This will be called for the `access()` system call. If the `default_permissions` /// mount option is given, this method is not called. This method is not called /// under Linux kernel versions 2.4.x fn access(&mut self, _req: &Request<'_>, ino: u64, mask: i32, reply: ReplyEmpty) { @@ -737,14 +737,14 @@ pub trait Filesystem { /// Create and open a file. /// If the file does not exist, first create it with the specified mode, and then - /// open it. You can use any open flags in the flags parameter except O_NOCTTY. + /// open it. You can use any open flags in the flags parameter except `O_NOCTTY`. /// The filesystem can store any type of file handle (such as a pointer or index) /// in fh, which can then be used across all subsequent file operations including /// read, write, flush, release, and fsync. Additionally, the filesystem may set - /// certain flags like direct_io and keep_cache to change the way the file is - /// opened. See fuse_file_info structure in for more details. If + /// certain flags like `direct_io` and `keep_cache` to change the way the file is + /// opened. See `fuse_file_info` structure in <`fuse_common.h`> for more details. 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. + /// 2.6.15, the `mknod()` and `open()` methods will be called instead. fn create( &mut self, _req: &Request<'_>, @@ -785,8 +785,8 @@ pub trait Filesystem { /// Acquire, modify or release a POSIX file lock. /// For POSIX threads (NPTL) there's a 1-1 relation between pid and owner, but /// otherwise this is not always the case. For checking lock ownership, - /// 'fi->owner' must be used. The l_pid field in 'struct flock' should only be - /// used to fill in this field in getlk(). Note: if the locking methods are not + /// 'fi->owner' must be used. The `l_pid` field in 'struct flock' should only be + /// used to fill in this field in `getlk()`. Note: if the locking methods are not /// implemented, the kernel will still allow file locking to work locally. /// Hence these are only interesting for network filesystems and similar. fn setlk( @@ -912,8 +912,8 @@ pub trait Filesystem { reply.error(ENOSYS); } - /// macOS only: Rename the volume. Set fuse_init_out.flags during init to - /// FUSE_VOL_RENAME to enable + /// macOS only: Rename the volume. Set `fuse_init_out.flags` during init to + /// `FUSE_VOL_RENAME` to enable #[cfg(target_os = "macos")] fn setvolname(&mut self, _req: &Request<'_>, name: &OsStr, reply: ReplyEmpty) { warn!("[Not Implemented] setvolname(name: {name:?})"); @@ -939,8 +939,8 @@ pub trait Filesystem { reply.error(ENOSYS); } - /// macOS only: Query extended times (bkuptime and crtime). Set fuse_init_out.flags - /// during init to FUSE_XTIMES to enable + /// macOS only: Query extended times (`bkuptime` and `crtime`). Set `fuse_init_out.flags` + /// during init to `FUSE_XTIMES` to enable #[cfg(target_os = "macos")] fn getxtimes(&mut self, _req: &Request<'_>, ino: u64, reply: ReplyXTimes) { warn!("[Not Implemented] getxtimes(ino: {ino:#x?})"); @@ -965,7 +965,7 @@ pub fn mount>( /// Mount the given filesystem to the given mountpoint. This function will /// not return until the filesystem is unmounted. /// -/// NOTE: This will eventually replace mount(), once the API is stable +/// NOTE: This will eventually replace `mount()`, once the API is stable pub fn mount2>( filesystem: FS, mountpoint: P, diff --git a/src/ll/reply.rs b/src/ll/reply.rs index ed525bd4..2aa02dc4 100644 --- a/src/ll/reply.rs +++ b/src/ll/reply.rs @@ -293,7 +293,7 @@ pub(crate) fn mode_from_kind_and_perm(kind: FileType, perm: u16) -> u32 { }) as u32 | perm as u32 } -/// Returns a fuse_attr from FileAttr +/// Returns a `fuse_attr` from `FileAttr` pub(crate) fn fuse_attr_from_attr(attr: &crate::FileAttr) -> abi::fuse_attr { let (atime_secs, atime_nanos) = time_from_system_time(&attr.atime); let (mtime_secs, mtime_nanos) = time_from_system_time(&attr.mtime); diff --git a/src/ll/request.rs b/src/ll/request.rs index 066ab78b..681a517e 100644 --- a/src/ll/request.rs +++ b/src/ll/request.rs @@ -32,10 +32,10 @@ pub enum RequestError { /// distinguish between multiple concurrent requests. The unique id of a request may be /// reused in later requests after it has completed. /// -/// This can be retrieve for any request using [Request::unique]. The kernel -/// will send an [Interrupt] request to cancel requests in progress. It's +/// This can be retrieve for any request using [`Request::unique`]. The kernel +/// will send an [`Interrupt`] request to cancel requests in progress. It's /// important to handle this for any requests that may block indefinitely, like -/// [SetLkW]. +/// [`SetLkW`]. #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "serializable", derive(Serialize, Deserialize))] pub struct RequestId(pub u64); @@ -48,26 +48,26 @@ impl From for u64 { /// A newtype for inode numbers /// /// These are generated by the filesystem implementation and returned to the -/// kernel in response to a call to [Lookup], [Create], [MkNod], [MkDir] or -/// [SymLink]. The kernel will then pass these numbers back to the filesystem +/// kernel in response to a call to [`Lookup`], [`Create`], [`MkNod`], [`MkDir`] or +/// [`SymLink`]. The kernel will then pass these numbers back to the filesystem /// implementation when it needs to refer to a given file. Every request has -/// an associated [INodeNo], accessible as [Request::nodeid]. +/// an associated [`INodeNo`], accessible as [`Request::nodeid`]. /// /// Reference Counting /// ------------------ /// /// Every time the kernel receives a given inode number in a response to a -/// [Lookup], [Create], [MkNod], [MkDir] or [SymLink] request it increments an +/// [`Lookup`], [`Create`], [`MkNod`], [`MkDir`] or [`SymLink`] request it increments an /// internal counter for that inode. The filesystem implementation should do /// the same. When the kernel is no longer interested in this inode it will -/// send a [Forget] message with that counter. The filesystem implementation +/// send a [`Forget`] message with that counter. The filesystem implementation /// should decrement its own counter and if it reaches 0 then the inode number /// may be recycled and your filesystem implementation may clean up its /// internal data-structures relating to that inode. /// -/// We implement conversion from [INodeNo] to [u64] but not vice-versa because -/// not all [u64]s are valid [INodeNo]s, but the reverse is true. So to produce -/// a [INodeNo] from a [u64] we must be explicit. +/// We implement conversion from [`INodeNo`] to [`u64`] but not vice-versa because +/// not all [`u64`]s are valid [`INodeNo`]s, but the reverse is true. So to produce +/// a [`INodeNo`] from a [`u64`] we must be explicit. #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "serializable", derive(Serialize, Deserialize))] pub struct INodeNo(pub u64); @@ -80,38 +80,38 @@ impl From for u64 { /// A newtype for file handles /// /// This corresponds to a single file description in a client program. These -/// are generated by the filesystem implementation in replies to [Open], -/// [OpenDir] and [Create] requests. It's used as a correlation id across -/// [Read], [Write], [FSync], [IoCtl], [Poll], [FAllocate], [ReadDir], -/// [FSyncDir], [GetLk], [SetLk], [SetLkW], [ReadDirPlus], [Lseek] and -/// [CopyFileRange] requests. +/// are generated by the filesystem implementation in replies to [`Open`], +/// [`OpenDir`] and [`Create`] requests. It's used as a correlation id across +/// [`Read`], [`Write`], [`FSync`], [`IoCtl`], [`Poll`], [`FAllocate`], [`ReadDir`], +/// [`FSyncDir`], [`GetLk`], [`SetLk`], [`SetLkW`], [`ReadDirPlus`], [`Lseek`] and +/// [`CopyFileRange`] requests. /// -/// A filesystem implementation may store arbitrary data as the [FileHandle], as +/// A filesystem implementation may store arbitrary data as the [`FileHandle`], as /// long as it fits into 64-bits and doesn't need to change for over the lifetime -/// of the [FileHandle]. Typically this might consist of an index into an array -/// of [FileHandle]s that the filesystem implementation maintains. +/// of the [`FileHandle`]. Typically this might consist of an index into an array +/// of [`FileHandle`]s that the filesystem implementation maintains. /// /// Filesystems may instead implement stateless file I/O and use `0` as the -/// [FileHandle] - although this makes it impossible to correctly implement -/// resumable [ReadDir] in the presence of mutable directories (see [OpenDir]). +/// [`FileHandle`] - although this makes it impossible to correctly implement +/// resumable [`ReadDir`] in the presence of mutable directories (see [`OpenDir`]). /// /// Lifecycle /// --------- /// -/// A [FileHandle] is owned by one or more file-descriptors (or memory +/// A [`FileHandle`] is owned by one or more file-descriptors (or memory /// mappings) in the client program. Multiple file descriptors can point to -/// the same [FileHandle], just as a single INode can have multiple -/// [FileHandle]s open at one time. Every time a single file-descriptor is -/// closed a [Flush] request is made. This gives filesystem implementations +/// the same [`FileHandle`], just as a single `INode` can have multiple +/// [`FileHandle`]s open at one time. Every time a single file-descriptor is +/// closed a [`Flush`] request is made. This gives filesystem implementations /// an opportunity to return an error message from that `close()` call. After -/// all the file-descriptors are closed that own a given [FileHandle] the -/// [Release]/[ReleaseDir] request will be made. This is an opportunity for +/// all the file-descriptors are closed that own a given [`FileHandle`] the +/// [`Release`]/[`ReleaseDir`] request will be made. This is an opportunity for /// the filesystem implementation to free any internal per-FileHandle data /// structures it has allocated. /// -/// We implement conversion from FileHandle to u64 but not vice-versa because -/// not all u64s are valid FileHandles, but the reverse is true. So to produce -/// a FileHandle from a u64 we must be explicit. +/// We implement conversion from `FileHandle` to[ `u64`] but not vice-versa because +/// not all [`u64`]s are valid `FileHandles`, but the reverse is true. So to produce +/// a `FileHandle` from a [`u64`] we must be explicit. #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "serializable", derive(Serialize, Deserialize))] pub struct FileHandle(pub u64); @@ -126,11 +126,11 @@ impl From for u64 { /// /// TODO: Document lock lifecycle and how and when to implement file locking. /// -/// See [Read], [Write], [Release], [Flush], [GetLk], [SetLk], [SetLkW]. +/// See [`Read`], [`Write`], [`Release`], [`Flush`], [`GetLk`], [`SetLk`], [`SetLkW`]. /// -/// We implement conversion from [LockOwner] to [u64] but not vice-versa -/// because all LockOwners are valid [u64]s, but not vice-versa. So to produce -/// a [LockOwner] from a [u64] we must be explicit. +/// We implement conversion from [`LockOwner`] to [`u64`] but not vice-versa +/// because all `LockOwners` are valid [`u64`]s, but not vice-versa. So to produce +/// a [`LockOwner`] from a [`u64`] we must be explicit. #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "serializable", derive(Serialize, Deserialize))] pub struct LockOwner(pub u64); @@ -286,9 +286,9 @@ mod op { /// Look up a directory entry by name and get its attributes. /// - /// Implementations allocate and assign [INodeNo]s in this request. Learn more - /// about INode lifecycle and the relationship between [Lookup] and [Forget] in the - /// documentation for [INodeNo]. + /// Implementations allocate and assign [`INodeNo`]s in this request. Learn more + /// about `INode` lifecycle and the relationship between [`Lookup`] and [`Forget`] in the + /// documentation for [`INodeNo`]. #[derive(Debug)] pub struct Lookup<'a> { header: &'a fuse_in_header, @@ -302,13 +302,13 @@ mod op { } /// Forget about an inode. /// - /// The nlookup parameter indicates the number of lookups previously performed on + /// The `nlookup` parameter indicates the number of lookups previously performed on /// this inode. If the filesystem implements inode lifetimes, it is recommended that /// inodes acquire a single reference on each lookup, and lose nlookup references on /// each forget. The filesystem may ignore forget calls, if the inodes don't need to /// have a limited lifetime. /// - /// Learn more about INode lifecycle in the documentation for [INodeNo]. + /// Learn more about `INode` lifecycle in the documentation for [`INodeNo`]. /// /// On unmount it is not guaranteed, that all referenced inodes will receive a forget /// message. @@ -411,10 +411,10 @@ mod op { #[cfg(not(feature = "abi-7-23"))] None } - /// The value set by the [Open] method. See [FileHandle]. + /// The value set by the [`Open`] method. See [`FileHandle`]. /// /// This will only be set if the user passed a file-descriptor to set the - /// attributes - i.e. they used [libc::fchmod] rather than [libc::chmod]. + /// attributes - i.e. they used [`libc::fchmod`] rather than [`libc::chmod`]. pub fn file_handle(&self) -> Option { match self.arg.valid & FATTR_FH { 0 => None, @@ -640,9 +640,9 @@ mod op { /// 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. See fuse_file_info - /// structure in for more details. + /// 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. See `fuse_file_info` + /// structure in <`fuse_common.h`> for more details. #[derive(Debug)] pub struct Open<'a> { header: &'a fuse_in_header, @@ -659,7 +659,7 @@ mod op { /// /// 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 + /// 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. #[derive(Debug)] @@ -696,7 +696,7 @@ mod op { /// 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 + /// 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. #[derive(Debug)] @@ -717,15 +717,15 @@ mod op { pub fn data(&self) -> &'a [u8] { self.data } - /// Will contain FUSE_WRITE_CACHE, if this write is from the page cache. If set, + /// Will contain `FUSE_WRITE_CACHE`, if this write is from the page cache. If set, /// the pid, uid, gid, and fh may not match the value that would have been sent if write caching /// is disabled /// - /// TODO: WriteFlags type or remove this + /// TODO: `WriteFlags` type or remove this pub fn write_flags(&self) -> u32 { self.arg.write_flags } - /// lock_owner: only supported with ABI >= 7.9 + /// `lock_owner`: only supported with ABI >= 7.9 pub fn lock_owner(&self) -> Option { if self.arg.write_flags & FUSE_WRITE_LOCKOWNER != 0 { Some(LockOwner(self.arg.lock_owner)) @@ -733,7 +733,7 @@ mod op { None } } - /// flags: these are the file flags, such as O_SYNC. Only supported with ABI >= 7.9 + /// flags: these are the file flags, such as `O_SYNC`. Only supported with ABI >= 7.9 /// TODO: Make a Flags type specifying valid values pub fn flags(&self) -> i32 { self.arg.flags @@ -750,7 +750,7 @@ mod op { /// 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] + /// 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. @@ -764,7 +764,7 @@ mod op { pub fn flush(&self) -> bool { self.arg.release_flags & FUSE_RELEASE_FLUSH != 0 } - /// The value set by the [Open] method. + /// The value set by the [`Open`] method. pub fn file_handle(&self) -> FileHandle { FileHandle(self.arg.fh) } @@ -790,7 +790,7 @@ mod op { } impl_request!(FSync<'a>); impl FSync<'_> { - /// The value set by the [Open] method. + /// The value set by the [`Open`] method. pub fn file_handle(&self) -> FileHandle { FileHandle(self.arg.fh) } @@ -820,7 +820,7 @@ mod op { pub fn flags(&self) -> i32 { self.arg.flags } - /// This will always be 0 except on MacOS. It's recommended that + /// This will always be 0 except on `MacOS`. It's recommended that /// implementations return EINVAL if this is not 0. pub fn position(&self) -> u32 { #[cfg(target_os = "macos")] @@ -832,7 +832,7 @@ mod op { /// Get an extended attribute. /// - /// If the requested XAttr doesn't exist return [Err(Errno::NO_XATTR)] which will + /// If the requested `XAttr` doesn't exist, return [`Err(Errno::NO_XATTR)`] which will /// map to the right platform-specific error code. #[derive(Debug)] pub struct GetXAttr<'a> { @@ -842,32 +842,32 @@ mod op { } impl_request!(GetXAttr<'a>); - /// Type for [GetXAttrSizeEnum::GetSize]. + /// Type for [`GetXAttrSizeEnum::GetSize`]. /// - /// Represents a request from the user to get the size of the data stored in the XAttr. + /// Represents a request from the user to get the size of the data stored in the `XAttr`. #[derive(Debug)] pub struct GetXAttrSize(); #[derive(Debug)] - /// Return type for [GetXAttr::size]. + /// Return type for [`GetXAttr::size`]. pub enum GetXAttrSizeEnum { - /// User is requesting the size of the data stored in the XAttr + /// User is requesting the size of the data stored in the `XAttr` GetSize(GetXAttrSize), - /// User is requesting the data stored in the XAttr. If the data will fit - /// in this number of bytes it should be returned, otherwise return [Err(Errno::ERANGE)]. + /// User is requesting the data stored in the `XAttr`. If the data will fit + /// in this number of bytes it should be returned, otherwise return [`Err(Errno::ERANGE)`]. #[allow(dead_code)] Size(NonZeroU32), } impl<'a> GetXAttr<'a> { - /// Name of the XAttr + /// Name of the `XAttr` pub fn name(&self) -> &'a OsStr { self.name } - /// See [GetXAttrSizeEnum]. + /// See [`GetXAttrSizeEnum`]. /// /// You only need to check this value as an optimisation where there's a - /// cost difference between checking the size of the data stored in an XAttr - /// and actually providing the data. Otherwise just call [reply()] with the + /// cost difference between checking the size of the data stored in an `XAttr` + /// and actually providing the data. Otherwise just call [`reply()`] with the /// data and it will do the right thing. pub fn size(&self) -> GetXAttrSizeEnum { let s: Result = self.arg.size.try_into(); @@ -876,7 +876,7 @@ mod op { Err(_) => GetXAttrSizeEnum::GetSize(GetXAttrSize()), } } - /// The size of the buffer the user has allocated to store the XAttr value. + /// The size of the buffer the user has allocated to store the `XAttr` value. pub(crate) fn size_u32(&self) -> u32 { self.arg.size } @@ -891,7 +891,7 @@ mod op { impl_request!(ListXAttr<'a>); impl ListXAttr<'_> { /// The size of the buffer the caller has allocated to receive the list of - /// XAttrs. If this is 0 the user is just probing to find how much space is + /// `XAttrs`. If this is 0 the user is just probing to find how much space is /// required to fit the whole list. /// /// You don't need to worry about this except as an optimisation. @@ -902,8 +902,8 @@ mod op { /// Remove an extended attribute. /// - /// Return [Err(Errno::NO_XATTR)] if the xattr doesn't exist - /// Return [Err(Errno::ENOTSUP)] if this filesystem doesn't support XAttrs + /// Return [`Err(Errno::NO_XATTR)`] if the xattr doesn't exist + /// Return [`Err(Errno::ENOTSUP)`] if this filesystem doesn't support `XAttrs` #[derive(Debug)] pub struct RemoveXAttr<'a> { header: &'a fuse_in_header, @@ -911,7 +911,7 @@ mod op { } impl_request!(RemoveXAttr<'a>); impl<'a> RemoveXAttr<'a> { - /// Name of the XAttr to remove + /// Name of the `XAttr` to remove pub fn name(&self) -> &'a OsStr { self.name } @@ -919,15 +919,15 @@ mod op { /// Flush method. /// - /// This is called on each close() of the opened file. Since file descriptors can + /// 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. /// - /// NOTE: the name of the method is misleading, since (unlike fsync) the filesystem + /// NOTE: 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'. + /// operations (`setlk`, `getlk`) it should remove all locks belonging to `lock_owner`. #[derive(Debug)] pub struct Flush<'a> { header: &'a fuse_in_header, @@ -1005,11 +1005,11 @@ mod op { /// 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, though that makes it impossible to implement standard conforming + /// 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`, though that makes it impossible to implement standard conforming /// directory stream operations in case the contents of the directory can change - /// between [OpenDir] and [ReleaseDir]. + /// between [`OpenDir`] and [`ReleaseDir`]. /// /// TODO: Document how to implement "standard conforming directory stream operations" #[derive(Debug)] @@ -1033,7 +1033,7 @@ mod op { } impl_request!(ReadDir<'a>); impl ReadDir<'_> { - /// The value set by the [OpenDir] method. + /// The value set by the [`OpenDir`] method. pub fn file_handle(&self) -> FileHandle { FileHandle(self.arg.fh) } @@ -1047,7 +1047,7 @@ mod op { /// Release an open directory. /// - /// For every [OpenDir] call there will be exactly one [ReleaseDir] call. + /// For every [`OpenDir`] call there will be exactly one [`ReleaseDir`] call. #[derive(Debug)] pub struct ReleaseDir<'a> { header: &'a fuse_in_header, @@ -1055,7 +1055,7 @@ mod op { } impl_request!(ReleaseDir<'a>); impl ReleaseDir<'_> { - /// The value set by the [OpenDir] method. + /// The value set by the [`OpenDir`] method. pub fn file_handle(&self) -> FileHandle { FileHandle(self.arg.fh) } @@ -1083,7 +1083,7 @@ mod op { } impl_request!(FSyncDir<'a>); impl FSyncDir<'_> { - /// The value set by the [OpenDir] method. See [FileHandle]. + /// The value set by the [`OpenDir`] method. See [`FileHandle`]. pub fn file_handle(&self) -> FileHandle { FileHandle(self.arg.fh) } @@ -1101,7 +1101,7 @@ mod op { } impl_request!(GetLk<'a>); impl GetLk<'_> { - /// The value set by the [Open] method. See [FileHandle]. + /// The value set by the [`Open`] method. See [`FileHandle`]. pub fn file_handle(&self) -> FileHandle { FileHandle(self.arg.fh) } @@ -1117,8 +1117,8 @@ mod op { /// /// For POSIX threads (NPTL) there's a 1-1 relation between pid and owner, but /// otherwise this is not always the case. For checking lock ownership, - /// 'fi->owner' must be used. The l_pid field in 'struct flock' should only be - /// used to fill in this field in getlk(). Note: if the locking methods are not + /// 'fi->owner' must be used. The `l_pid` field in 'struct `flock`' should only be + /// used to fill in this field in `getlk()`. Note: if the locking methods are not /// implemented, the kernel will still allow file locking to work locally. /// Hence these are only interesting for network filesystems and similar. #[derive(Debug)] @@ -1128,7 +1128,7 @@ mod op { } impl_request!(SetLk<'a>); impl SetLk<'_> { - /// The value set by the [Open] method. See [FileHandle]. + /// The value set by the [`Open`] method. See [`FileHandle`]. pub fn file_handle(&self) -> FileHandle { FileHandle(self.arg.fh) } @@ -1146,7 +1146,7 @@ mod op { } impl_request!(SetLkW<'a>); impl SetLkW<'_> { - /// The value set by the [Open] method. See [FileHandle]. + /// The value set by the [`Open`] method. See [`FileHandle`]. pub fn file_handle(&self) -> FileHandle { FileHandle(self.arg.fh) } @@ -1160,7 +1160,7 @@ mod op { /// Check file access permissions. /// - /// This will be called for the `access()` system call. If the 'default_permissions' + /// This will be called for the `access()` system call. If the `default_permissions` /// mount option is given, this method is not called. #[derive(Debug)] pub struct Access<'a> { @@ -1179,12 +1179,12 @@ mod op { /// 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. See fuse_file_info - /// structure in for more details. 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. + /// 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. See `fuse_file_info` + /// structure in <`fuse_common.h`> for more details. 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. #[derive(Debug)] pub struct Create<'a> { header: &'a fuse_in_header, @@ -1199,7 +1199,7 @@ mod op { pub fn mode(&self) -> u32 { self.arg.mode } - /// Flags as passed to the creat() call + /// Flags as passed to the `create()` call pub fn flags(&self) -> i32 { self.arg.flags } @@ -1223,28 +1223,28 @@ mod op { /// 3) If the request is already sent to userspace, then an INTERRUPT /// request is queued. /// - /// [Interrupt] requests take precedence over other requests, so the - /// userspace filesystem will receive queued [Interrupt]s before any others. + /// [`Interrupt`] requests take precedence over other requests, so the + /// userspace filesystem will receive queued [`Interrupt`]s before any others. /// - /// The userspace filesystem may ignore the [Interrupt] requests entirely, + /// The userspace filesystem may ignore the [`Interrupt`] requests entirely, /// or may honor them by sending a reply to the **original** request, with - /// the error set to [Errno::EINTR]. + /// the error set to [`Errno::EINTR`]. /// /// It is also possible that there's a race between processing the - /// original request and its [Interrupt] request. There are two + /// original request and its [`Interrupt`] request. There are two /// possibilities: /// - /// 1. The [Interrupt] request is processed before the original request is + /// 1. The [`Interrupt`] request is processed before the original request is /// processed /// - /// 2. The [Interrupt] request is processed after the original request has + /// 2. The [`Interrupt`] request is processed after the original request has /// been answered /// /// If the filesystem cannot find the original request, it should wait for /// some timeout and/or a number of new requests to arrive, after which it - /// should reply to the [Interrupt] request with an [Errno::EAGAIN] error. - /// In case (1) the [Interrupt] request will be requeued. In case (2) the - /// [Interrupt] reply will be ignored. + /// should reply to the [`Interrupt`] request with an [`Errno::EAGAIN`] error. + /// In case (1) the [`Interrupt`] request will be requeued. In case (2) the + /// [`Interrupt`] reply will be ignored. #[derive(Debug)] pub struct Interrupt<'a> { header: &'a fuse_in_header, @@ -1259,7 +1259,7 @@ mod op { /// Map block index within file to block index within device. /// Note: This makes sense only for block device backed filesystems mounted - /// with the 'blkdev' option + /// with the `blkdev` option #[derive(Debug)] pub struct BMap<'a> { header: &'a fuse_in_header, @@ -1301,7 +1301,7 @@ mod op { pub fn unrestricted(&self) -> bool { self.arg.flags & consts::FUSE_IOCTL_UNRESTRICTED != 0 } - /// The value set by the [Open] method. See [FileHandle]. + /// The value set by the [`Open`] method. See [`FileHandle`]. pub fn file_handle(&self) -> FileHandle { FileHandle(self.arg.fh) } @@ -1326,7 +1326,7 @@ mod op { } impl_request!(Poll<'a>); impl Poll<'_> { - /// The value set by the [Open] method. See [FileHandle]. + /// The value set by the [`Open`] method. See [`FileHandle`]. pub fn file_handle(&self) -> FileHandle { FileHandle(self.arg.fh) } @@ -1350,7 +1350,7 @@ mod op { } } - /// NotifyReply. TODO: currently unsupported by fuser + /// `NotifyReply`. TODO: currently unsupported by fuser #[derive(Debug)] pub struct NotifyReply<'a> { header: &'a fuse_in_header, @@ -1359,7 +1359,7 @@ mod op { } impl_request!(NotifyReply<'a>); - /// BatchForget: TODO: merge with Forget + /// `BatchForget`: TODO: merge with Forget #[derive(Debug)] pub struct BatchForget<'a> { header: &'a fuse_in_header, @@ -1369,7 +1369,7 @@ mod op { } impl_request!(BatchForget<'a>); impl<'a> BatchForget<'a> { - /// TODO: Don't return fuse_forget_one, this should be private + /// TODO: Don't return `fuse_forget_one`, this should be private pub fn nodes(&self) -> &'a [fuse_forget_one] { self.nodes } @@ -1388,7 +1388,7 @@ mod op { impl_request!(FAllocate<'a>); #[cfg(feature = "abi-7-19")] impl FAllocate<'_> { - /// The value set by the [Open] method. See [FileHandle]. + /// The value set by the [`Open`] method. See [`FileHandle`]. pub fn file_handle(&self) -> FileHandle { FileHandle(self.arg.fh) } @@ -1406,7 +1406,7 @@ mod op { /// Read directory. /// - /// TODO: Document when this is called rather than ReadDirectory + /// TODO: Document when this is called rather than `ReadDir` #[cfg(feature = "abi-7-21")] #[derive(Debug)] pub struct ReadDirPlus<'a> { @@ -1417,7 +1417,7 @@ mod op { impl_request!(ReadDirPlus<'a>); #[cfg(feature = "abi-7-21")] impl ReadDirPlus<'_> { - /// The value set by the [Open] method. See [FileHandle]. + /// The value set by the [`Open`] method. See [`FileHandle`]. pub fn file_handle(&self) -> FileHandle { FileHandle(self.arg.fh) } @@ -1431,7 +1431,7 @@ mod op { /// Rename a file. /// - /// TODO: Document the differences to [Rename] and [Exchange] + /// TODO: Document the differences to [`Rename`] and [`Exchange`] #[cfg(feature = "abi-7-23")] #[derive(Debug)] pub struct Rename2<'a> { @@ -1458,8 +1458,8 @@ mod op { } } /// Flags as passed to renameat2. As of Linux 3.18 this is - /// [libc::RENAME_EXCHANGE], [libc::RENAME_NOREPLACE] and - /// [libc::RENAME_WHITEOUT]. If you don't handle a particular flag + /// [`libc::RENAME_EXCHANGE`], [`libc::RENAME_NOREPLACE`] and + /// [`libc::RENAME_WHITEOUT`]. If you don't handle a particular flag /// reply with an EINVAL error. /// /// TODO: Replace with enum/flags type @@ -1481,7 +1481,7 @@ mod op { impl_request!(Lseek<'a>); #[cfg(feature = "abi-7-24")] impl Lseek<'_> { - /// The value set by the [Open] method. See [FileHandle]. + /// The value set by the [`Open`] method. See [`FileHandle`]. pub fn file_handle(&self) -> FileHandle { FileHandle(self.arg.fh) } @@ -1499,7 +1499,7 @@ mod op { #[derive(Debug, Clone, Copy)] pub struct CopyFileRangeFile { pub inode: INodeNo, - /// The value set by the [Open] method. See [FileHandle]. + /// The value set by the [`Open`] method. See [`FileHandle`]. pub file_handle: FileHandle, pub offset: i64, } @@ -1539,7 +1539,7 @@ mod op { } } - /// MacOS only: Rename the volume. Set `fuse_init_out.flags` during init to + /// `MacOS` only: Rename the volume. Set `fuse_init_out.flags` during init to /// `FUSE_VOL_RENAME` to enable #[cfg(target_os = "macos")] #[derive(Debug)] @@ -1556,8 +1556,8 @@ mod op { } } - /// macOS only: Query extended times (bkuptime and crtime). Set fuse_init_out.flags - /// during init to FUSE_XTIMES to enable + /// `MacOS` only: Query extended times (`bkuptime` and `crtime`). Set `fuse_init_out.flags` + /// during init to `FUSE_XTIMES` to enable #[cfg(target_os = "macos")] #[derive(Debug)] pub struct GetXTimes<'a> { @@ -1565,8 +1565,8 @@ mod op { } #[cfg(target_os = "macos")] impl_request!(GetXTimes<'a>); - // API TODO: Consider rename2(RENAME_EXCHANGE) - /// macOS only (undocumented) + // API TODO: Consider `rename2(RENAME_EXCHANGE)` + /// `MacOS` only (undocumented) #[cfg(target_os = "macos")] #[derive(Debug)] pub struct Exchange<'a> { diff --git a/src/mnt/mod.rs b/src/mnt/mod.rs index 74c2e4f7..870dc36e 100644 --- a/src/mnt/mod.rs +++ b/src/mnt/mod.rs @@ -24,7 +24,7 @@ use std::io; #[cfg(any(feature = "libfuse", test))] use mount_options::MountOption; -/// Helper function to provide options as a fuse_args struct +/// Helper function to provide options as a `fuse_args` struct /// (which contains an argc count and an argv pointer) #[cfg(any(feature = "libfuse", test))] fn with_fuse_args T>(options: &[MountOption], f: F) -> T { diff --git a/src/mnt/mount_options.rs b/src/mnt/mount_options.rs index 1778d28e..0ce71969 100644 --- a/src/mnt/mount_options.rs +++ b/src/mnt/mount_options.rs @@ -156,8 +156,8 @@ pub fn option_to_string(option: &MountOption) -> String { /// Parses mount command args. /// -/// Input: ["-o", "suid", "-o", "ro,nodev,noexec", "-osync"] -/// Output Ok([Suid, RO, NoDev, NoExec, Sync]) +/// Input: `"-o", "suid", "-o", "ro,nodev,noexec", "-osync"` +/// Output Ok([`Suid`, `RO`, `NoDev`, `NoExec`, `Sync`]) pub(crate) fn parse_options_from_args(args: &[&OsStr]) -> io::Result> { let err = |x| io::Error::new(ErrorKind::InvalidInput, x); let args: Option> = args.iter().map(|x| x.to_str()).collect(); diff --git a/src/notify.rs b/src/notify.rs index ed2e0e20..95dc8033 100644 --- a/src/notify.rs +++ b/src/notify.rs @@ -13,7 +13,7 @@ use crate::{ reply::ReplySender, }; -/// A handle to a pending poll() request. Can be saved and used to notify the +/// A handle to a pending `poll()` request. Can be saved and used to notify the /// kernel when a poll is ready. #[derive(Clone)] pub struct PollHandle { diff --git a/src/passthrough.rs b/src/passthrough.rs index 0c36c724..6376d5ff 100644 --- a/src/passthrough.rs +++ b/src/passthrough.rs @@ -33,20 +33,20 @@ nix::ioctl_write_ptr!( /// `ReplyOpen::opened_passthrough()`. /// /// When working with backing IDs you need to ensure that they live "long enough". A good practice -/// is to create them in the Filesystem::open() impl, store them in the struct of your Filesystem -/// impl, then drop them in the Filesystem::release() impl. Dropping them immediately after -/// sending them in the Filesystem::open() impl can lead to the kernel returning EIO when userspace +/// is to create them in the `Filesystem::open()` impl, store them in the struct of your Filesystem +/// impl, then drop them in the `Filesystem::release()` impl. Dropping them immediately after +/// sending them in the `Filesystem::open()` impl can lead to the kernel returning EIO when userspace /// attempts to access the file. /// -/// This is implemented as a safe wrapper around the backing_id field of the fuse_backing_map +/// This is implemented as a safe wrapper around the `backing_id` field of the `fuse_backing_map` /// struct used by the ioctls involved in fd passthrough. It is created by performing a -/// FUSE_DEV_IOC_BACKING_OPEN ioctl on an fd and has a Drop trait impl which makes a matching -/// FUSE_DEV_IOC_BACKING_CLOSE call. It holds a weak reference on the fuse channel to allow it to +/// `FUSE_DEV_IOC_BACKING_OPEN` ioctl on an fd and has a Drop trait impl which makes a matching +/// `FUSE_DEV_IOC_BACKING_CLOSE` call. It holds a weak reference on the fuse channel to allow it to /// make that call (if the channel hasn't already been closed). #[derive(Debug)] pub struct BackingId { channel: Weak, - /// The backing_id field passed to and from the kernel + /// The `backing_id` field passed to and from the kernel pub(crate) backing_id: u32, } diff --git a/src/reply.rs b/src/reply.rs index 16f045b4..0938edb7 100644 --- a/src/reply.rs +++ b/src/reply.rs @@ -3,8 +3,8 @@ //! A reply is passed to filesystem operation implementations and must be used to send back the //! result of an operation. The reply can optionally be sent to another thread to asynchronously //! work on an operation and provide the result later. Also it allows replying with a block of -//! data without cloning the data. A reply *must always* be used (by calling either ok() or -//! error() exactly once). +//! data without cloning the data. A reply *must always* be used (by calling either `ok()` or +//! `error()` exactly once). use crate::ll::{ self, Generation, @@ -292,7 +292,7 @@ impl ReplyOpen { self.reply.sender.as_ref().unwrap().open_backing(fd.as_fd()) } - /// Reply to a request with an opened backing id. Call ReplyOpen::open_backing() to get one of + /// Reply to a request with an opened backing id. Call `ReplyOpen::open_backing()` to get one of /// these. #[cfg(feature = "abi-7-40")] pub fn opened_passthrough(self, fh: u64, flags: u32, backing_id: &BackingId) { @@ -542,7 +542,7 @@ pub struct ReplyDirectory { } impl ReplyDirectory { - /// Creates a new ReplyDirectory with a specified buffer size. + /// Creates a new `ReplyDirectory` with a specified buffer size. pub fn new(unique: u64, sender: S, size: usize) -> ReplyDirectory { ReplyDirectory { reply: Reply::new(unique, sender), @@ -576,7 +576,7 @@ impl ReplyDirectory { } /// -/// DirectoryPlus reply +/// `DirectoryPlus` reply /// #[derive(Debug)] pub struct ReplyDirectoryPlus { @@ -585,7 +585,7 @@ pub struct ReplyDirectoryPlus { } impl ReplyDirectoryPlus { - /// Creates a new ReplyDirectory with a specified buffer size. + /// Creates a new `ReplyDirectory` with a specified buffer size. pub fn new(unique: u64, sender: S, size: usize) -> ReplyDirectoryPlus { ReplyDirectoryPlus { reply: Reply::new(unique, sender), diff --git a/src/session.rs b/src/session.rs index 1b989b5a..76e26255 100644 --- a/src/session.rs +++ b/src/session.rs @@ -28,7 +28,7 @@ use crate::{channel::ChannelSender, notify::Notifier}; pub const MAX_WRITE_SIZE: usize = 16 * 1024 * 1024; /// Size of the buffer for reading a request from the kernel. Since the kernel may send -/// up to MAX_WRITE_SIZE bytes in a write request, we use that value plus some extra space. +/// up to `MAX_WRITE_SIZE` bytes in a write request, we use that value plus some extra space. const BUFFER_SIZE: usize = MAX_WRITE_SIZE + 4096; #[derive(Default, Debug, Eq, PartialEq)] @@ -53,7 +53,7 @@ pub struct Session { /// Handle to the mount. Dropping this unmounts. mount: Arc>>, /// Whether to restrict access to owner, root + owner, or unrestricted - /// Used to implement allow_root and auto_unmount + /// Used to implement `allow_root` and `auto_unmount` pub(crate) allowed: SessionACL, /// User that launched the fuser process pub(crate) session_owner: u32,