#ioctl #number #encode #control #linux

ioctl-gen

Simple macros for generating ioctl numbers

2 releases

Uses old Rust 2015

0.1.1 Jan 7, 2017
0.1.0 Jan 7, 2017

#3 in #ioctl

Download history 38/week @ 2021-05-29 131/week @ 2021-06-05 50/week @ 2021-06-12 36/week @ 2021-06-19 44/week @ 2021-06-26 65/week @ 2021-07-03 47/week @ 2021-07-10 181/week @ 2021-07-17 78/week @ 2021-07-24 54/week @ 2021-07-31 51/week @ 2021-08-07 70/week @ 2021-08-14 75/week @ 2021-08-21 12/week @ 2021-08-28 16/week @ 2021-09-04 50/week @ 2021-09-11

340 downloads per month
Used in 2 crates

MIT license

5KB
64 lines

#6 ioctl-gen

Documentation

Making those magic ioctl numbers is really annoying without macros, so here are some macros. And if you were wondering, yes, they work in constants.

Example

#[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);

Installation

In Cargo.toml:

[dependencies]
ioctl-gen = "0.1.0"

License

The MIT license.


lib.rs:

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;

# fn main() {
// 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);
# }

No runtime deps