From 49e3e44bf1818f680847fabc472c1d27b3138af5 Mon Sep 17 00:00:00 2001
From: Noah <33094578+coolreader18@users.noreply.github.com>
Date: Sat, 5 Dec 2020 21:21:45 -0600
Subject: [PATCH] Handle TCSETSW and TCSETSF in ioctl

---
 src/header/sys_ioctl/redox.rs | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/header/sys_ioctl/redox.rs b/src/header/sys_ioctl/redox.rs
index a9d3fca7b..c234d0d80 100644
--- a/src/header/sys_ioctl/redox.rs
+++ b/src/header/sys_ioctl/redox.rs
@@ -12,6 +12,8 @@ pub const FIONBIO: c_ulong = 0x5421;
 
 pub const TCGETS: c_ulong = 0x5401;
 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 TCXONC: c_ulong = 0x540A;
@@ -24,6 +26,8 @@ pub const TIOCSPGRP: c_ulong = 0x5410;
 pub const TIOCGWINSZ: c_ulong = 0x5413;
 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> {
     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) ->
                 0
             }
         }
-        TCSETS => {
+        // TODO: give these different behaviors
+        TCSETS | TCSETSW | TCSETSF => {
             let termios = &*(out as *const termios::termios);
             if e(dup_write(fd, "termios", termios)) == !0 {
                 -1
-- 
GitLab