From 6abe05cd0c5f45b301f424527d2224b1e41e5ace Mon Sep 17 00:00:00 2001
From: Nadav Har'El <nyh@cloudius-systems.com>
Date: Mon, 22 Apr 2013 13:08:16 +0300
Subject: [PATCH] Fix implementation of TCGETS ioctl on console

While I implemented TCSETS ioctl, TCGETS used to be a no-op. This patch
implements it (which is trivial). TGETS is need because the standard
idiom for programs which switch to raw mode is to use TCGETS to save the
original mode, then use TCSETS, and when exiting restore the original mode.

Also used <sys/ioctl.h> definitions (from the host...) instead of the ugly
ioctl numbers.
---
 drivers/console.cc | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/console.cc b/drivers/console.cc
index a649cd8c9..cd051d226 100755
--- a/drivers/console.cc
+++ b/drivers/console.cc
@@ -5,6 +5,7 @@
 #include <queue>
 #include <deque>
 #include <vector>
+#include <sys/ioctl.h>
 
 #include "isa-serial.hh"
 #include "debug-console.hh"
@@ -200,9 +201,10 @@ static int
 console_ioctl(struct device *dev, u_long request, void *arg)
 {
     switch (request) {
-    case 0x5401: // TCGETS
-        return 0;   // XXX: stubbing out to get libc into line buffering mode
-    case 0x5402: // TCSETS
+    case TCGETS:
+        *static_cast<termios*>(arg) = tio;
+        return 0;
+    case TCSETS:
         tio = *static_cast<termios*>(arg);
         return 0;
     default:
-- 
GitLab