Skip to main content

relibc/header/sys_ioctl/
mod.rs

1//! `sys/ioctl.h` implementation.
2//!
3//! Non-POSIX, see <https://www.man7.org/linux/man-pages/man2/ioctl.2.html>.
4
5use crate::{
6    error::ResultExt,
7    platform::types::{c_char, c_int, c_ulong, c_ushort, c_void},
8};
9
10pub mod constants;
11
12pub use constants::*;
13
14// This is used from sgtty
15#[repr(C)]
16pub struct sgttyb {
17    sg_ispeed: c_char,
18    sg_ospeed: c_char,
19    sg_erase: c_char,
20    sg_kill: c_char,
21    sg_flags: c_ushort,
22}
23
24#[unsafe(no_mangle)]
25pub unsafe extern "C" fn ioctl(fd: c_int, request: c_ulong, out: *mut c_void) -> c_int {
26    // TODO: Somehow support varargs to syscall??
27    #[cfg(target_os = "linux")]
28    unsafe {
29        crate::platform::Sys::ioctl(fd, request, out).or_minus_one_errno()
30    }
31    #[cfg(target_os = "redox")]
32    unsafe { self::redox::ioctl_inner(fd, request, out) }.or_minus_one_errno()
33}
34
35#[cfg(target_os = "linux")]
36pub use self::linux::*;
37
38#[cfg(target_os = "linux")]
39pub mod linux;
40
41#[cfg(target_os = "redox")]
42pub use self::redox::*;
43
44#[cfg(target_os = "redox")]
45pub mod redox;