diff options
| author | Eric Andersen <andersen@codepoet.org> | 1999-11-07 07:38:08 +0000 |
|---|---|---|
| committer | Eric Andersen <andersen@codepoet.org> | 1999-11-07 07:38:08 +0000 |
| commit | 07e5297ca7707d2fd56ab2fa8e1ea0c9805035e3 (patch) | |
| tree | 67473f996e985a255afbb8d20cb1583fe09f0b14 /init | |
| parent | dc6301e7ca26457e413f1dfc88fca4d19e775970 (diff) | |
| download | busybox-w32-07e5297ca7707d2fd56ab2fa8e1ea0c9805035e3.tar.gz busybox-w32-07e5297ca7707d2fd56ab2fa8e1ea0c9805035e3.tar.bz2 busybox-w32-07e5297ca7707d2fd56ab2fa8e1ea0c9805035e3.zip | |
init and ls -l fixes
Diffstat (limited to 'init')
| -rw-r--r-- | init/init.c | 64 |
1 files changed, 46 insertions, 18 deletions
diff --git a/init/init.c b/init/init.c index bf97fe5d6..707b1916f 100644 --- a/init/init.c +++ b/init/init.c | |||
| @@ -88,8 +88,14 @@ void message(int device, char *fmt, ...) | |||
| 88 | 88 | ||
| 89 | /* Take full control of the log tty, and never close it. | 89 | /* Take full control of the log tty, and never close it. |
| 90 | * It's mine, all mine! Muhahahaha! */ | 90 | * It's mine, all mine! Muhahahaha! */ |
| 91 | if (log_fd==-1) { | 91 | if (log_fd < 0) { |
| 92 | if ((log_fd = device_open(log, O_RDWR|O_NDELAY)) < 0) { | 92 | if (log == NULL) { |
| 93 | /* don't even try to log, because there is no such console */ | ||
| 94 | log_fd = -2; | ||
| 95 | /* log to main console instead */ | ||
| 96 | device = CONSOLE; | ||
| 97 | } | ||
| 98 | else if ((log_fd = device_open(log, O_RDWR|O_NDELAY)) < 0) { | ||
| 93 | log_fd=-1; | 99 | log_fd=-1; |
| 94 | fprintf(stderr, "Bummer, can't write to log on %s!\r\n", log); | 100 | fprintf(stderr, "Bummer, can't write to log on %s!\r\n", log); |
| 95 | fflush(stderr); | 101 | fflush(stderr); |
| @@ -97,7 +103,7 @@ void message(int device, char *fmt, ...) | |||
| 97 | } | 103 | } |
| 98 | } | 104 | } |
| 99 | 105 | ||
| 100 | if ( (device & LOG) && (log_fd != -1) ) { | 106 | if ( (device & LOG) && (log_fd >= 0) ) { |
| 101 | va_start(arguments, fmt); | 107 | va_start(arguments, fmt); |
| 102 | vdprintf(log_fd, fmt, arguments); | 108 | vdprintf(log_fd, fmt, arguments); |
| 103 | va_end(arguments); | 109 | va_end(arguments); |
| @@ -180,25 +186,40 @@ static void console_init() | |||
| 180 | int fd; | 186 | int fd; |
| 181 | int tried_devcons = 0; | 187 | int tried_devcons = 0; |
| 182 | int tried_vtprimary = 0; | 188 | int tried_vtprimary = 0; |
| 189 | struct serial_struct sr; | ||
| 183 | char *s; | 190 | char *s; |
| 184 | 191 | ||
| 185 | if ((s = getenv("CONSOLE")) != NULL) { | 192 | if ((s = getenv("CONSOLE")) != NULL) { |
| 186 | console = s; | 193 | console = s; |
| 187 | /* Apparently the sparc does wierd things... */ | 194 | } |
| 188 | #if defined (__sparc__) | 195 | #if defined (__sparc__) |
| 189 | if (strncmp( s, "/dev/tty", 8 )==0) { | 196 | /* sparc kernel supports console=tty[ab] parameter which is also |
| 190 | switch( s[8]) { | 197 | * passed to init, so catch it here */ |
| 191 | case 'a': | 198 | else if ((s = getenv("console")) != NULL) { |
| 192 | s=SERIAL_CON0; | 199 | /* remap tty[ab] to /dev/ttyS[01] */ |
| 193 | break; | 200 | if (strcmp( s, "ttya" )==0) |
| 194 | case 'b': | 201 | console = SERIAL_CON0; |
| 195 | s=SERIAL_CON1; | 202 | else if (strcmp( s, "ttyb" )==0) |
| 196 | } | 203 | console = SERIAL_CON1; |
| 197 | } | 204 | } |
| 198 | #endif | 205 | #endif |
| 199 | } else { | 206 | else { |
| 200 | console = VT_CONSOLE; | 207 | struct vt_stat vt; |
| 201 | tried_devcons++; | 208 | static char the_console[13]; |
| 209 | |||
| 210 | console = the_console; | ||
| 211 | /* 2.2 kernels: identify the real console backend and try to use it */ | ||
| 212 | if (ioctl(0,TIOCGSERIAL,&sr) == 0) { | ||
| 213 | /* this is a serial console */ | ||
| 214 | snprintf( the_console, sizeof the_console, "/dev/ttyS%d", sr.line ); | ||
| 215 | } | ||
| 216 | else if (ioctl(0, VT_GETSTATE, &vt) == 0) { | ||
| 217 | /* this is linux virtual tty */ | ||
| 218 | snprintf( the_console, sizeof the_console, "/dev/tty%d", vt.v_active ); | ||
| 219 | } else { | ||
| 220 | console = VT_CONSOLE; | ||
| 221 | tried_devcons++; | ||
| 222 | } | ||
| 202 | } | 223 | } |
| 203 | 224 | ||
| 204 | while ((fd = open(console, O_RDONLY | O_NONBLOCK)) < 0) { | 225 | while ((fd = open(console, O_RDONLY | O_NONBLOCK)) < 0) { |
| @@ -219,8 +240,15 @@ static void console_init() | |||
| 219 | if (fd < 0) | 240 | if (fd < 0) |
| 220 | /* Perhaps we should panic here? */ | 241 | /* Perhaps we should panic here? */ |
| 221 | console = "/dev/null"; | 242 | console = "/dev/null"; |
| 222 | else | 243 | else { |
| 244 | /* check for serial console and disable logging to tty3 & running a | ||
| 245 | * shell to tty2 */ | ||
| 246 | if (ioctl(0,TIOCGSERIAL,&sr) == 0) { | ||
| 247 | log = NULL; | ||
| 248 | second_console = NULL; | ||
| 249 | } | ||
| 223 | close(fd); | 250 | close(fd); |
| 251 | } | ||
| 224 | message(LOG, "console=%s\n", console ); | 252 | message(LOG, "console=%s\n", console ); |
| 225 | } | 253 | } |
| 226 | 254 | ||
| @@ -472,7 +500,7 @@ extern int init_main(int argc, char **argv) | |||
| 472 | if (pid1 == 0 && tty0_commands) { | 500 | if (pid1 == 0 && tty0_commands) { |
| 473 | pid1 = run(tty0_commands, console, wait_for_enter); | 501 | pid1 = run(tty0_commands, console, wait_for_enter); |
| 474 | } | 502 | } |
| 475 | if (pid2 == 0 && tty1_commands) { | 503 | if (pid2 == 0 && tty1_commands && second_console) { |
| 476 | pid2 = run(tty1_commands, second_console, TRUE); | 504 | pid2 = run(tty1_commands, second_console, TRUE); |
| 477 | } | 505 | } |
| 478 | wpid = wait(&status); | 506 | wpid = wait(&status); |
