[Toybox] [PATCH] init: don't use VT_OPENQRY ioctl

Isaac Dunham ibid.ag at gmail.com
Sat Jan 25 18:09:10 PST 2014


init: don't use VT_OPENQRY.

The original codepath checks if there is a VT available, 
and if there isn't sets TERM to vt102 (unless TERM is set to something 
other than "linux").
Otherwise, TERM is set to "linux" if it is not already set.

However, we can rely on getty/... to set TERM if "linux" is not suitable.
This has the benefit of dropping a slightly messy section.
--
Thanks,
Isaac Dunham

-------------- next part --------------
diff --git a/toys/pending/init.c b/toys/pending/init.c
index 91110fa..8199e74 100644
--- a/toys/pending/init.c
+++ b/toys/pending/init.c
@@ -17,7 +17,6 @@ config INIT
 */
 
 #include "toys.h"
-#include <linux/vt.h>
 #include <sys/reboot.h>
 
 struct action_list_seed {
@@ -60,14 +59,7 @@ static void initialize_console(void)
     }
   }
 
-  p = getenv("TERM");
-#ifdef VT_OPENQRY
-  int terminal_no;
-  if (ioctl(0, VT_OPENQRY, &terminal_no)) {
-    if (!p || !strcmp(p,"linux")) putenv("TERM=vt102");
-  } else
-#endif  
-  if (!p) putenv("TERM=linux");
+  if (!getenv("TERM")) putenv("TERM=linux");
 }
 
 static void set_sane_term(void)


More information about the Toybox mailing list