Expand description
A safer abstraction for ioctl
.
The ioctl
system call is very open-ended, supporting a variety of
different operations with different argument and result types, with the
valid operations varying drastically based on which underlying driver or
type of device the file represents. Passing the wrong kind of value to the
wrong request can cause memory corruption.
To make ioctl
a little safer to use, this module provides the building
blocks for request constants that also include information about the
argument and result types, so that the super::File::ioctl
method can
then provide a type-safe interface as long as these constants are defined
correctly. IoctlReq
implementations can be defined in other crates that
provide support for particular device types or device drivers.
Structs
IoctlReq
with a fixed cmd
and passing no arguments
at all, just returning the kernel’s result value.IoctlReq
with a fixed cmd
value and passing a
pointer to a zeroed memory block of type Result
directly through to the
underlying system call and then returnin a copy of that memory.IoctlReq
with a fixed cmd
value and passing a
pointer to an argument value in memory.IoctlReq
with a fixed cmd
value and passing a
direct value from memory, without pointer indirection.Traits
ioctl
results
from requests with a given argument type and temporary value type.ioctl
requests implemented for it.ioctl
system call.Functions
_IO
for defining ioctl request numbers that
neither read nor write within the standard numbering scheme._IOR
for defining ioctl request numbers
where userspace reads data from the kernel._IOW
for defining ioctl request numbers
where userspace writes data to the kernel._IOWR
for defining ioctl request numbers
where userspace writes data to the kernel and the kernel returns data
back to userspace.IoctlReq
with a fixed request code that
passes no payload to ioctl
and returns its result in the system call
return value.IoctlReq
with a fixed request code and
a result type that maps directly to the data the kernel will
provide.IoctlReq
with a fixed request code and
an argument type that maps directly to the data the kernel expects
to receive a pointer to.IoctlReq
with a fixed request code and
an argument type that the data the kernel expects to recieve directly as
its argument, without any pointer indirection.