Skip to main content

BackingId

Struct BackingId 

Source
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

Source

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.

Source

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().

Trait Implementations§

Source§

impl Debug for BackingId

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for BackingId

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.