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§
- Ioctl
ReqConst Arg - Implementation of
IoctlReqwith a fixedcmdand passing a constant int as the argument, then returning the kernel’s result value. - Ioctl
ReqNo Args - Implementation of
IoctlReqwith a fixedcmdand passing no arguments at all, just returning the kernel’s result value. - Ioctl
ReqRead - Implementation of
IoctlReqwith a fixedcmdvalue and passing a pointer to a zeroed memory block of typeResultdirectly through to the underlying system call and then returnin a copy of that memory. - Ioctl
ReqWrite - Implementation of
IoctlReqwith a fixedcmdvalue and passing a pointer to an argument value in memory. - Ioctl
ReqWrite Read - Ioctl
ReqWrite Val - Implementation of
IoctlReqwith a fixedcmdvalue and passing a direct value from memory, without pointer indirection.
Traits§
- From
Ioctl Result - Trait for types that can be constructed automatically from
ioctlresults from requests with a given argument type and temporary value type. - IoDevice
- Represents a device type that can have
ioctlrequests implemented for it. - Ioctl
Req - Represents a particular request that can be issue with the
ioctlsystem call. - SubDevice
- Implemented by
IoDeviceimplementations that are “sub-devices” of another device, specified as type parameterParent.
Functions§
- _IO
- Equivalent to the kernel macro
_IOfor defining ioctl request numbers that neither read nor write within the standard numbering scheme. - _IOR
- Equivalent to the kernel macro
_IORfor defining ioctl request numbers where userspace reads data from the kernel. - _IOW
- Equivalent to the kernel macro
_IOWfor defining ioctl request numbers where userspace writes data to the kernel. - _IOWR
- Equivalent to the kernel macro
_IOWRfor defining ioctl request numbers where userspace writes data to the kernel and the kernel returns data back to userspace. - ioctl_
const_ ⚠arg - Constructs a new read-only
IoctlReqwith a fixed request code that passes a constant integer toioctland returns its result in the system call return value. - ioctl_
no_ ⚠arg - Constructs a new read-only
IoctlReqwith a fixed request code that passes no payload toioctland returns its result in the system call return value. - ioctl_
read ⚠ - Constructs a new read-only
IoctlReqwith a fixed request code and a result type that maps directly to the data the kernel will provide. - ioctl_
write ⚠ - Constructs a new write-only
IoctlReqwith a fixed request code and an argument type that maps directly to the data the kernel expects to receive a pointer to. - ioctl_
write_ ⚠val - Constructs a new write-only
IoctlReqwith a fixed request code and an argument type that the data the kernel expects to recieve directly as its argument, without any pointer indirection. - ioctl_
writeread ⚠ - Constructs a new write/read
IoctlReqwith a fixed request code and an argument type that maps directly to the data the kernel expects to recieve a pointer to.