Function rustix::ioctl::ioctl

source ·
pub unsafe fn ioctl<F: AsFd, I: Ioctl>(fd: F, ioctl: I) -> Result<I::Output>
Expand description

Perform an ioctl call.

ioctl was originally intended to act as a way of modifying the behavior of files, but has since been adopted as a general purpose system call for making calls into the kernel. In addition to the default calls exposed by generic file descriptors, many drivers expose their own ioctl calls for controlling their behavior, some of which are proprietary.

This crate exposes many other ioctl interfaces with safe and idiomatic wrappers, like ioctl_fionbio and ioctl_fionread. It is recommended to use those instead of this function, as they are safer and more idiomatic. For other cases, implement the Ioctl API and pass it to this function.

See documentation for Ioctl for more information.

§Safety

While Ioctl takes much of the unsafety out of ioctl calls, it is still unsafe to call this code with arbitrary device drivers, as it is up to the device driver to implement the ioctl call correctly. It is on the onus of the protocol between the user and the driver to ensure that the ioctl call is safe to make.

§References