Skip to content
Snippets Groups Projects
Commit 307cd568 authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Merge branch 'fix-tcsetattr' into 'master'

Handle TCSETSW and TCSETSF in ioctl

Closes #168

See merge request !324
parents 7ed74c8c 49e3e44b
No related branches found
No related tags found
1 merge request!324Handle TCSETSW and TCSETSF in ioctl
Pipeline #9178 passed with warnings
...@@ -12,6 +12,8 @@ pub const FIONBIO: c_ulong = 0x5421; ...@@ -12,6 +12,8 @@ pub const FIONBIO: c_ulong = 0x5421;
pub const TCGETS: c_ulong = 0x5401; pub const TCGETS: c_ulong = 0x5401;
pub const TCSETS: c_ulong = 0x5402; pub const TCSETS: c_ulong = 0x5402;
pub const TCSETSW: c_ulong = 0x5403;
pub const TCSETSF: c_ulong = 0x5404;
pub const TCSBRK: c_ulong = 0x5409; pub const TCSBRK: c_ulong = 0x5409;
pub const TCXONC: c_ulong = 0x540A; pub const TCXONC: c_ulong = 0x540A;
...@@ -24,6 +26,8 @@ pub const TIOCSPGRP: c_ulong = 0x5410; ...@@ -24,6 +26,8 @@ pub const TIOCSPGRP: c_ulong = 0x5410;
pub const TIOCGWINSZ: c_ulong = 0x5413; pub const TIOCGWINSZ: c_ulong = 0x5413;
pub const TIOCSWINSZ: c_ulong = 0x5414; pub const TIOCSWINSZ: c_ulong = 0x5414;
// TODO: some of the structs passed as T have padding bytes, so casting to a byte slice is UB
fn dup_read<T>(fd: c_int, name: &str, t: &mut T) -> syscall::Result<usize> { fn dup_read<T>(fd: c_int, name: &str, t: &mut T) -> syscall::Result<usize> {
let dup = syscall::dup(fd as usize, name.as_bytes())?; let dup = syscall::dup(fd as usize, name.as_bytes())?;
...@@ -79,7 +83,8 @@ pub unsafe extern "C" fn ioctl(fd: c_int, request: c_ulong, out: *mut c_void) -> ...@@ -79,7 +83,8 @@ pub unsafe extern "C" fn ioctl(fd: c_int, request: c_ulong, out: *mut c_void) ->
0 0
} }
} }
TCSETS => { // TODO: give these different behaviors
TCSETS | TCSETSW | TCSETSF => {
let termios = &*(out as *const termios::termios); let termios = &*(out as *const termios::termios);
if e(dup_write(fd, "termios", termios)) == !0 { if e(dup_write(fd, "termios", termios)) == !0 {
-1 -1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment