#ioc #ff #magic #effect #ioctl #envelope #level

yanked ioctl

DEPRECATED in favor of nix

Uses old Rust 2015

0.3.4 May 28, 2017
0.3.3 Jul 21, 2015
0.3.2 May 31, 2015
0.2.1 May 29, 2015
0.1.2 May 26, 2015
Download history 109/week @ 2023-05-31 69/week @ 2023-06-07 96/week @ 2023-06-14 135/week @ 2023-06-21 92/week @ 2023-06-28 89/week @ 2023-07-05 87/week @ 2023-07-12 97/week @ 2023-07-19 106/week @ 2023-07-26 82/week @ 2023-08-02 98/week @ 2023-08-09 107/week @ 2023-08-16 89/week @ 2023-08-23 80/week @ 2023-08-30 116/week @ 2023-09-06 94/week @ 2023-09-13

388 downloads per month
Used in 4 crates (via kvm)



Rust 771 SLoC // 0.4% comments Python 234 SLoC // 0.0% comments


Travis Crates.io


Helpers for binding ioctls in Rust. Currently supports Linux on all architectures except SPARC and Alpha. Other platforms welcome!

This library is pretty low-level and messy. ioctl is not fun.

What is an ioctl?

The ioctl function is the grab-bag system call on POSIX systems. Don't want to add a new syscall? Make it an ioctl! ioctl refers to both the syscall, and the commands that can be send with it. ioctl stands for "IO control", and the commands are always sent to a file descriptor.

What does this library support?

This library provides the ioctl! macro, for binding ioctls. It also tries to bind every ioctl supported by the system with said macro, but many ioctls require some amount of manual work to support (usually by providing structs or other types) that this library does not support yet.

Additionally, in etc, there are scripts for scraping system headers for ioctl definitions, and generating calls to ioctl! corresponding to them.

How do I get the magic numbers?

Look at your system's headers. For example, /usr/include/linxu/input.h has a lot of lines defining macros which use _IOR, _IOW, _IOC, and _IORW. These macros correspond to the ior!, iow!, ioc!, and iorw! macros defined in this crate. Additionally, there is the ioctl! macro for creating a wrapper around ioctl that is somewhat more type-safe.

Most ioctls have no or little documentation. You'll need to scrounge through the source to figure out what they do and how they should be used.


extern crate ioctl;

ioctl!(bad kiocsound with 0x4B2F);
ioctl!(none drm_ioctl_set_master with b'd', 0x1e);
ioctl!(read ev_get_version with b'E', 0x01; u32);
ioctl!(write ev_set_repeat with b'E', 0x03; [u32; 2]);

fn main() {
    let mut x = 0;
    let ret = unsafe { ev_get_version(0, &mut x) };
    println!("returned {}, x = {}", ret, x);

No runtime deps