pub struct BackingId { /* private fields */ }Expand description
A reference to a previously opened fd intended to be used for passthrough
You can create these via ReplyOpen::open_backing()
and send them via 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
attempts to access the file.
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
make that call (if the channel hasn’t already been closed).
Implementations§
Source§impl BackingId
impl BackingId
Sourcepub fn create_raw(fuse_dev: impl AsFd, fd: impl AsFd) -> Result<u32>
pub fn create_raw(fuse_dev: impl AsFd, fd: impl AsFd) -> Result<u32>
Creates a new backing file reference for the given file descriptor.
Usually, you will want to use ReplyOpen::open_backing()
instead, since this method will return a raw backing_id value instead of a managed
BackingId wrapper. As such you must manage the lifetime of the backing file yourself.
This method is useful if you want to open a backing file reference without access to a reply object.
Sourcepub fn into_raw(self) -> u32
pub fn into_raw(self) -> u32
Converts this backing file reference into the raw backing_id value as returned by the kernel.
This method transfers ownership of the backing file to the caller, who must invoke the
FUSE_DEV_IOC_BACKING_CLOSE themselves once they wish to close the backing file.
The returned ID may subsequently be reopened using
ReplyOpen::wrap_backing().