Crate ioctl_gen

Source
Expand description

This crate lets you encode and decode ioctl numbers. It’s pretty much just a port of ioctl.h.

Here are some examples:

#[macro_use]
extern crate ioctlify;

// Taken from <linux/videodev2.h>
const VIDIOC_RESERVED:   u32 = io!(b'V', 1);
const VIDIOC_STREAMON:   u32 = iow!(b'V', 18, 4);
const VIDIOC_LOG_STATUS: u32 = io!(b'V', 70);

assert_eq!(ioc_type!(VIDIOC_RESERVED), b'V' as u32);
assert_eq!(VIDIOC_STREAMON, 1074026002);
assert_eq!(ioc_nr!(VIDIOC_LOG_STATUS), 70);

Macros§

io
Creates the ioctl number for an operation that isn’t reading or writing.
ioc
Creates the ioctl number for the given data.
ioc_dir
Decodes the access mode / direction from an ioctl number.
ioc_nr
Decodes the function number from an ioctl number.
ioc_size
Decodes the parameter size from an ioctl number.
ioc_type
Decodes the type from an ioctl number.
ior
Creates the ioctl number for a read-only operation.
iow
Creates the ioctl number for a write-only operation.
iowr
Creates the ioctl number for a read/write operation.

Constants§

DIRBITS
The number of bits used for the direction field.
DIRMASK
Bitmask for the direction field.
DIRSHIFT
Offset of the direction field.
NONE
Neither direction.
NRBITS
The number of bits used for the number field.
NRMASK
Bitmask for the number field.
NRSHIFT
Offset of the number field.
READ
The read direction.
SIZEBITS
The number of bits used for the size field.
SIZEMASK
Bitmask for the size field.
SIZESHIFT
Offset of the size field.
TYPEBITS
The number of bits used for the type field.
TYPEMASK
Bitmask for the type field.
TYPESHIFT
Offset of the type field.
WRITE
The write direction.