diff options
| author | Jeremie Koenig <jk@jk.fr.eu.org> | 2010-05-27 15:37:32 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-07-19 00:45:42 +0200 |
| commit | f812eace1863feeac64dc8af27f4ab0f98119618 (patch) | |
| tree | c43fa6cadcde7037f33dd774d4bb2128e5583c2a /init | |
| parent | 1d7266d3b59be361763dab61f680103bbb70f3e9 (diff) | |
| download | busybox-w32-f812eace1863feeac64dc8af27f4ab0f98119618.tar.gz busybox-w32-f812eace1863feeac64dc8af27f4ab0f98119618.tar.bz2 busybox-w32-f812eace1863feeac64dc8af27f4ab0f98119618.zip | |
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')
| -rw-r--r-- | init/init.c | 17 |
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 @@ | |||
| 14 | #include <paths.h> | 14 | #include <paths.h> |
| 15 | #include <sys/reboot.h> | 15 | #include <sys/reboot.h> |
| 16 | #include <sys/resource.h> | 16 | #include <sys/resource.h> |
| 17 | #ifdef __linux__ | ||
| 17 | #include <linux/vt.h> | 18 | #include <linux/vt.h> |
| 19 | #endif | ||
| 18 | #if ENABLE_FEATURE_UTMP | 20 | #if ENABLE_FEATURE_UTMP |
| 19 | # include <utmp.h> /* DEAD_PROCESS */ | 21 | # include <utmp.h> /* DEAD_PROCESS */ |
| 20 | #endif | 22 | #endif |
| 21 | 23 | ||
| 24 | /* Used only for sanitizing purposes in set_sane_term() below. On systems where | ||
| 25 | * the baud rate is stored in a separate field, we can safely disable them. */ | ||
| 26 | #ifndef CBAUD | ||
| 27 | # define CBAUD 0 | ||
| 28 | # define CBAUDEX 0 | ||
| 29 | #endif | ||
| 22 | 30 | ||
| 23 | /* Was a CONFIG_xxx option. A lot of people were building | 31 | /* Was a CONFIG_xxx option. A lot of people were building |
| 24 | * not fully functional init by switching it on! */ | 32 | * not fully functional init by switching it on! */ |
| @@ -166,7 +174,9 @@ static void message(int where, const char *fmt, ...) | |||
| 166 | 174 | ||
| 167 | static void console_init(void) | 175 | static void console_init(void) |
| 168 | { | 176 | { |
| 177 | #ifdef VT_OPENQRY | ||
| 169 | int vtno; | 178 | int vtno; |
| 179 | #endif | ||
| 170 | char *s; | 180 | char *s; |
| 171 | 181 | ||
| 172 | s = getenv("CONSOLE"); | 182 | s = getenv("CONSOLE"); |
| @@ -190,6 +200,7 @@ static void console_init(void) | |||
| 190 | } | 200 | } |
| 191 | 201 | ||
| 192 | s = getenv("TERM"); | 202 | s = getenv("TERM"); |
| 203 | #ifdef VT_OPENQRY | ||
| 193 | if (ioctl(STDIN_FILENO, VT_OPENQRY, &vtno) != 0) { | 204 | if (ioctl(STDIN_FILENO, VT_OPENQRY, &vtno) != 0) { |
| 194 | /* Not a linux terminal, probably serial console. | 205 | /* Not a linux terminal, probably serial console. |
| 195 | * Force the TERM setting to vt102 | 206 | * Force the TERM setting to vt102 |
| @@ -198,7 +209,9 @@ static void console_init(void) | |||
| 198 | putenv((char*)"TERM=vt102"); | 209 | putenv((char*)"TERM=vt102"); |
| 199 | if (!ENABLE_FEATURE_INIT_SYSLOG) | 210 | if (!ENABLE_FEATURE_INIT_SYSLOG) |
| 200 | log_console = NULL; | 211 | log_console = NULL; |
| 201 | } else if (!s) | 212 | } else |
| 213 | #endif | ||
| 214 | if (!s) | ||
| 202 | putenv((char*)"TERM=linux"); | 215 | putenv((char*)"TERM=linux"); |
| 203 | } | 216 | } |
| 204 | 217 | ||
| @@ -220,8 +233,10 @@ static void set_sane_term(void) | |||
| 220 | tty.c_cc[VSTOP] = 19; /* C-s */ | 233 | tty.c_cc[VSTOP] = 19; /* C-s */ |
| 221 | tty.c_cc[VSUSP] = 26; /* C-z */ | 234 | tty.c_cc[VSUSP] = 26; /* C-z */ |
| 222 | 235 | ||
| 236 | #ifdef __linux__ | ||
| 223 | /* use line discipline 0 */ | 237 | /* use line discipline 0 */ |
| 224 | tty.c_line = 0; | 238 | tty.c_line = 0; |
| 239 | #endif | ||
| 225 | 240 | ||
| 226 | /* Make it be sane */ | 241 | /* Make it be sane */ |
| 227 | tty.c_cflag &= CBAUD | CBAUDEX | CSIZE | CSTOPB | PARENB | PARODD; | 242 | tty.c_cflag &= CBAUD | CBAUDEX | CSIZE | CSTOPB | PARENB | PARODD; |
