Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement the TIOCGWINSZ ioctl. #70

Merged
merged 1 commit into from
Dec 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions c-scape/src/data/linux_gnu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub(crate) const DT_LNK: u8 = 10;
pub(crate) const DT_SOCK: u8 = 12;

pub(crate) const TCGETS: c_long = 0x5401;
pub(crate) const TIOCGWINSZ: c_long = 0x5413;
pub(crate) const FIONBIO: c_long = 0x5421;

pub(crate) const ALIGNOF_MAXALIGN_T: usize = 16;
Expand Down
1 change: 1 addition & 0 deletions c-scape/src/data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ constant!(DT_REG);
constant!(DT_LNK);
constant!(DT_SOCK);
constant!(TCGETS);
constant!(TIOCGWINSZ);
constant!(FIONBIO);
#[cfg(not(target_arch = "riscv64"))] // libc for riscv64 doesn't have max_align_t yet
constant_same_as!(
Expand Down
13 changes: 12 additions & 1 deletion c-scape/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1493,7 +1493,7 @@ unsafe extern "C" fn ioctl(fd: c_int, request: c_long, mut args: ...) -> c_int {
let fd = BorrowedFd::borrow_raw_fd(fd);
match set_errno(rustix::io::ioctl_tcgets(&fd)) {
Some(x) => {
*args.arg::<*mut rustix::io::Termios>() = x;
args.arg::<*mut rustix::io::Termios>().write(x);
0
}
None => -1,
Expand All @@ -1509,6 +1509,17 @@ unsafe extern "C" fn ioctl(fd: c_int, request: c_long, mut args: ...) -> c_int {
None => -1,
}
}
data::TIOCGWINSZ => {
libc!(ioctl(fd, TIOCGWINSZ));
let fd = BorrowedFd::borrow_raw_fd(fd);
match set_errno(rustix::io::ioctl_tiocgwinsz(&fd)) {
Some(x) => {
args.arg::<*mut rustix::io::Winsize>().write(x);
0
}
None => -1,
}
}
_ => panic!("unrecognized ioctl({})", request),
}
}
Expand Down