Function vmm_sys_util::ioctl::ioctl [−][src]
pub unsafe fn ioctl<F: AsRawFd>(fd: &F, req: c_ulong) -> c_int
Run an ioctl
with no arguments.
Arguments
fd
: an open file descriptor corresponding to the device on which to call the ioctl.req
: a device-dependent request code.
Safety
The caller should ensure to pass a valid file descriptor and have the return value checked.
Examples
#[macro_use] extern crate vmm_sys_util; use vmm_sys_util::ioctl::ioctl; const KVMIO: c_uint = 0xAE; const KVM_API_VERSION: u32 = 12; ioctl_io_nr!(KVM_GET_API_VERSION, KVMIO, 0x00); let open_flags = O_RDWR | O_CLOEXEC; let kvm_fd = unsafe { open("/dev/kvm\0".as_ptr() as *const c_char, open_flags) }; let ret = unsafe { ioctl(&File::from_raw_fd(kvm_fd), KVM_GET_API_VERSION()) }; assert_eq!(ret as u32, KVM_API_VERSION);