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>
impl<D, T> Ioctl<D, T>
Sourcepub const unsafe fn classic(request: c_ulong) -> Self
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
type
s none are required. For others, particularly type
s that pass
pointers to the kernel as u64
, you need to ensure that things like
lifetimes are correct.
Sourcepub const unsafe fn lie<E, U>(self) -> Ioctl<E, U>
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.