Expand description
Provides constant functions to compute for ioctl(2)
identifiers.
Currently, this supports Linux and macOS. The long term goal is to support ioctl
identifiers for other BSD
variants.
§Usage Notes
IoctlId
is an alias for the type to pass into the ioctl(2)
request. This is either a u32
or u64
, depending
on the target OS and architecture.
The io()
, ior()
, iow()
, and iowr()
functions take a type parameter, similar to the _IO()
,
_IOR()
, _IOW()
, and _IOWR()
macros.
For example, the following C code:
struct my_ioctl_data {
unsigned int a;
};
#define MY_IOCTL _IOR(0x12, 0x34, struct my_ioctl_data)
Would be written in Rust as:
use ioctl_id::*;
#[repr(C)]
struct MyIoctlData {
a: u32,
}
const MY_IOCTL: IoctlId = ior::<MyIoctlData>(0x12, 0x34);
Constants§
- IOC_
DIRBITS - The number of bits used to represent the direction of the
ioctl(2)
call. - IOC_
DIRMASK - Bitmask for valid
ioctl(2)
direction values. - IOC_
DIRSHIFT - The number of bits to shift
ioctl(2)
direction values by. - IOC_
NONE - Direction bit specifying no data is read or written.
- IOC_
NRBITS - This is the same for all architectures.
- IOC_
NRMASK - Bitmask for valid
ioctl(2)
call identifiers. - IOC_
NRSHIFT - The number of bits to shift
ioctl(2)
call identifiers by. - IOC_
READ - Direction bit specifying data is read.
- IOC_
SIZEBITS - The number of bits used to represent the size of the argument to the
ioctl(2)
call. - IOC_
SIZEMASK - Bitmask for valid
ioctl(2)
size values. - IOC_
SIZESHIFT - The number of bits to shift
ioctl(2)
size values by. - IOC_
TYPEBITS - The number of bits available for
ioctl(2)
type identifiers. - IOC_
TYPEMASK - Bitmask for valid
ioctl(2)
type identifiers. - IOC_
TYPESHIFT - The number of bits to shift
ioctl(2)
type identifiers by. - IOC_
WRITE - Direction bit specifying data is written.
Functions§
- io
- Create an
ioctl(2)
identifier for a call that passes no data. - ioc
- Create an
ioctl(2)
identifier from a direction value, type identifier, call identifier, and size value. - ioc_dir
- Decode the direction value from an
ioctl(2)
identifier. - ioc_nr
- Decode the call identifier from an
ioctl(2)
identifier. - ioc_
size - Decode the size identifier from an
ioctl(2)
identifier. - ioc_
type - Decode the type identifier from an
ioctl(2)
identifier. - ior
- Create an
ioctl(2)
identifier for a call that reads data. - iow
- Create an
ioctl(2)
identifier for a call that writes data. - iowr
- Create an
ioctl(2)
identifier for a call that reads and writes data.
Type Aliases§
- IoctlId
- The identifier type for ioctl calls.