#ioctl #numbers #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

#19 in #ioctl

Download history 92/week @ 2024-10-11 132/week @ 2024-10-18 130/week @ 2024-10-25 129/week @ 2024-11-01 174/week @ 2024-11-08 149/week @ 2024-11-15 123/week @ 2024-11-22 161/week @ 2024-11-29 343/week @ 2024-12-06 205/week @ 2024-12-13 71/week @ 2024-12-20 48/week @ 2024-12-27 226/week @ 2025-01-03 344/week @ 2025-01-10 301/week @ 2025-01-17 122/week @ 2025-01-24

1,019 downloads per month
Used in 4 crates (3 directly)

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;

// 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