aboutsummaryrefslogtreecommitdiff
path: root/init/init.c
diff options
context:
space:
mode:
authorJeremie Koenig <jk@jk.fr.eu.org>2010-05-27 15:37:32 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-07-19 00:45:42 +0200
commitf812eace1863feeac64dc8af27f4ab0f98119618 (patch)
treec43fa6cadcde7037f33dd774d4bb2128e5583c2a /init/init.c
parent1d7266d3b59be361763dab61f680103bbb70f3e9 (diff)
downloadbusybox-f812eace1863feeac64dc8af27f4ab0f98119618.tar.gz
init,loginutils: termios portability fixes
Signed-off-by: Jeremie Koenig <jk@jk.fr.eu.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'init/init.c')
-rw-r--r--init/init.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/init/init.c b/init/init.c
index 2eb8f1a54..1388c75cc 100644
--- a/init/init.c
+++ b/init/init.c
@@ -14,11 +14,19 @@
#include <paths.h>
#include <sys/reboot.h>
#include <sys/resource.h>
+#ifdef __linux__
#include <linux/vt.h>
+#endif
#if ENABLE_FEATURE_UTMP
# include <utmp.h> /* DEAD_PROCESS */
#endif
+/* Used only for sanitizing purposes in set_sane_term() below. On systems where
+ * the baud rate is stored in a separate field, we can safely disable them. */
+#ifndef CBAUD
+# define CBAUD 0
+# define CBAUDEX 0
+#endif
/* Was a CONFIG_xxx option. A lot of people were building
* not fully functional init by switching it on! */
@@ -166,7 +174,9 @@ static void message(int where, const char *fmt, ...)
static void console_init(void)
{
+#ifdef VT_OPENQRY
int vtno;
+#endif
char *s;
s = getenv("CONSOLE");
@@ -190,6 +200,7 @@ static void console_init(void)
}
s = getenv("TERM");
+#ifdef VT_OPENQRY
if (ioctl(STDIN_FILENO, VT_OPENQRY, &vtno) != 0) {
/* Not a linux terminal, probably serial console.
* Force the TERM setting to vt102
@@ -198,7 +209,9 @@ static void console_init(void)
putenv((char*)"TERM=vt102");
if (!ENABLE_FEATURE_INIT_SYSLOG)
log_console = NULL;
- } else if (!s)
+ } else
+#endif
+ if (!s)
putenv((char*)"TERM=linux");
}
@@ -220,8 +233,10 @@ static void set_sane_term(void)
tty.c_cc[VSTOP] = 19; /* C-s */
tty.c_cc[VSUSP] = 26; /* C-z */
+#ifdef __linux__
/* use line discipline 0 */
tty.c_line = 0;
+#endif
/* Make it be sane */
tty.c_cflag &= CBAUD | CBAUDEX | CSIZE | CSTOPB | PARENB | PARODD;