Struct Ioctl

Source
pub struct Ioctl<D, T>(/* private fields */);
Expand description

A defined ioctl along with its associated direction and type

Implementations§

Source§

impl<D, T> Ioctl<D, T>

Source

pub const unsafe fn classic(request: c_ulong) -> Self

Define a new ioctl with an associated direction and type

The request argument is the allocated integer which uniquely identifies this ioctl.

§Safety

This function is unsafe because defining an ioctl with an incorrect request, direction or argument type can later result in memory corruption. You are responsible to ensure these values are correct.

Further, you are responsible to ensure that the argument type itself provides appropriate safe wrappers around its raw contents. For some types none are required. For others, particularly types that pass pointers to the kernel as u64, you need to ensure that things like lifetimes are correct.

Source

pub const unsafe fn lie<E, U>(self) -> Ioctl<E, U>

Lie about the ioctl direction or type

This function should be avoided unless necessary.

Sometimes kernel developers make mistakes and use the wrong macros or types during their ioctl definitions. However, once merged these form part of the userspace API and won’t be broken. Therefore, we need a way to use the request number with the incorrect type. This function allows this.

Whenever using this function, it would be wise to include a comment with a link to the kernel’s ioctl definition and explaining why the definition is incorrect.

§Safety

For safety details, see Ioctl::classic.

Additionally, one should note that this function discards your normal protections. So you need to make sure that you have it correct.

Source§

impl Ioctl<Read, c_void>

Source

pub fn ioctl(self, fd: &impl AsRawFd) -> Result<c_uint>

Issue an ioctl to read a file descriptor’s metadata as c_uint.

No argument is supplied to the internal ioctl() call. The raw (positive) return value from the internal ioctl() call is returned on success.

Source§

impl<T> Ioctl<Read, &T>

Source

pub fn ioctl(self, fd: &impl AsRawFd) -> Result<(c_uint, T)>

Issue an ioctl to read a file descriptor’s metadata as type T.

A zeroed instance of type T is passed as the first argument to the internal ioctl() call. Upon success, returns the raw (positive) return value and the instance of T.

Source§

impl Ioctl<Write, c_void>

Source

pub fn ioctl(self, fd: &mut impl AsRawFd) -> Result<c_uint>

Issue an ioctl to modify a file descriptor

No argument is provided.

On success, returns the (positive) return value.

Source§

impl Ioctl<Write, c_int>

Source

pub fn ioctl(self, fd: &mut impl AsRawFd, data: c_int) -> Result<c_uint>

Issue an ioctl to modify a file descriptor

A C-integer argument is provided.

On success, returns the (positive) return value.

Source§

impl<T> Ioctl<Write, &T>

Source

pub fn ioctl(self, fd: &mut impl AsRawFd, data: &T) -> Result<c_uint>

Issue an ioctl to modify a file descriptor

A reference to an immutable instance of T is provided as the argument.

On success, returns the (positive) return value.

Source§

impl<T> Ioctl<WriteRead, &T>

Source

pub fn ioctl(self, fd: &mut impl AsRawFd, data: &mut T) -> Result<c_uint>

Issue an ioctl to modify a file descriptor and read its metadata

A reference to a mutable instance of T is provided as the argument.

On success, returns the (positive) return value.

Trait Implementations§

Source§

impl<D: Clone, T: Clone> Clone for Ioctl<D, T>

Source§

fn clone(&self) -> Ioctl<D, T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<D: PartialEq, T: PartialEq> PartialEq for Ioctl<D, T>

Source§

fn eq(&self, other: &Ioctl<D, T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<D: Copy, T: Copy> Copy for Ioctl<D, T>

Source§

impl<D: Eq, T: Eq> Eq for Ioctl<D, T>

Source§

impl<D, T> StructuralPartialEq for Ioctl<D, T>

Auto Trait Implementations§

§

impl<D, T> Freeze for Ioctl<D, T>

§

impl<D, T> RefUnwindSafe for Ioctl<D, T>

§

impl<D, T> Send for Ioctl<D, T>
where D: Send, T: Send,

§

impl<D, T> Sync for Ioctl<D, T>
where D: Sync, T: Sync,

§

impl<D, T> Unpin for Ioctl<D, T>
where D: Unpin, T: Unpin,

§

impl<D, T> UnwindSafe for Ioctl<D, T>
where D: UnwindSafe, T: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.