summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-07-29 06:39:58 +0000
committerEric Andersen <andersen@codepoet.org>2002-07-29 06:39:58 +0000
commit3bc2b206b0197334e8f738db43e7089750958cc3 (patch)
tree8fa0ab8d63516a82499a9178c03dc30d5eeca2ac
parentaead70b4d15322d2eeee9384bacb2cc137f46f78 (diff)
downloadbusybox-w32-3bc2b206b0197334e8f738db43e7089750958cc3.tar.gz
busybox-w32-3bc2b206b0197334e8f738db43e7089750958cc3.tar.bz2
busybox-w32-3bc2b206b0197334e8f738db43e7089750958cc3.zip
Patch from Tim Riker to allow tty* in inittab if the tty
actually exists -- serial console is not the issue...
-rw-r--r--Changelog3
-rw-r--r--init/init.c59
2 files changed, 16 insertions, 46 deletions
diff --git a/Changelog b/Changelog
index 7ff9f9e32..023f90d9e 100644
--- a/Changelog
+++ b/Changelog
@@ -33,7 +33,8 @@
33 uClibc, fix route crashe 'route add', fix warnings compile 33 uClibc, fix route crashe 'route add', fix warnings compile
34 networking and pwd_grp applets 34 networking and pwd_grp applets
35 * Tim Riker <Tim@Rikers.org> 35 * Tim Riker <Tim@Rikers.org>
36 -- fix and shrink uuencode 36 -- fix and shrink uuencode
37 -- allow tty* in inittab if exist, serial console is not the issue
37 38
38 -Erik Andersen, --not yet released-- 39 -Erik Andersen, --not yet released--
39 40
diff --git a/init/init.c b/init/init.c
index 229e3c4d6..f6c2b6615 100644
--- a/init/init.c
+++ b/init/init.c
@@ -159,13 +159,10 @@ struct init_action {
159 159
160/* Static variables */ 160/* Static variables */
161static struct init_action *init_action_list = NULL; 161static struct init_action *init_action_list = NULL;
162static char *secondConsole = VC_2;
163static char *thirdConsole = VC_3;
164static char *fourthConsole = VC_4;
165static char *log = VC_5;
166static int kernelVersion = 0; 162static int kernelVersion = 0;
167static char termType[32] = "TERM=linux"; 163static char termType[32] = "TERM=linux";
168static char console[32] = _PATH_CONSOLE; 164static char console[32] = _PATH_CONSOLE;
165static char *log = VC_5;
169static sig_atomic_t got_cont = 0; 166static sig_atomic_t got_cont = 0;
170static const int LOG = 0x1; 167static const int LOG = 0x1;
171static const int CONSOLE = 0x2; 168static const int CONSOLE = 0x2;
@@ -223,15 +220,9 @@ static void message(int device, char *fmt, ...)
223 /* Take full control of the log tty, and never close it. 220 /* Take full control of the log tty, and never close it.
224 * It's mine, all mine! Muhahahaha! */ 221 * It's mine, all mine! Muhahahaha! */
225 if (log_fd < 0) { 222 if (log_fd < 0) {
226 if (log == NULL) { 223 if ((log_fd = device_open(log, O_RDWR|O_NDELAY)) < 0) {
227 /* don't even try to log, because there is no such console */
228 log_fd = -2;
229 /* log to main console instead */
230 device = CONSOLE;
231 } else if ((log_fd = device_open(log, O_RDWR|O_NDELAY)) < 0) {
232 log_fd = -2; 224 log_fd = -2;
233 fprintf(stderr, "Bummer, can't write to log on %s!\n", log); 225 fprintf(stderr, "Bummer, can't write to log on %s!\n", log);
234 log = NULL;
235 device = CONSOLE; 226 device = CONSOLE;
236 } 227 }
237 } 228 }
@@ -381,19 +372,12 @@ static void console_init(void)
381 /* Perhaps we should panic here? */ 372 /* Perhaps we should panic here? */
382 safe_strncpy(console, "/dev/null", sizeof(console)); 373 safe_strncpy(console, "/dev/null", sizeof(console));
383 } else { 374 } else {
384 /* check for serial console and disable logging to tty5 & 375 /* check for serial console */
385 * running a shell to tty2-4 */
386 if (ioctl(0, TIOCGSERIAL, &sr) == 0) { 376 if (ioctl(0, TIOCGSERIAL, &sr) == 0) {
387 log = NULL;
388 secondConsole = NULL;
389 thirdConsole = NULL;
390 fourthConsole = NULL;
391 /* Force the TERM setting to vt102 for serial console -- 377 /* Force the TERM setting to vt102 for serial console --
392 * iff TERM is set to linux (the default) */ 378 * if TERM is set to linux (the default) */
393 if (strcmp( termType, "TERM=linux" ) == 0) 379 if (strcmp( termType, "TERM=linux" ) == 0)
394 safe_strncpy(termType, "TERM=vt102", sizeof(termType)); 380 safe_strncpy(termType, "TERM=vt102", sizeof(termType));
395 message(LOG | CONSOLE,
396 "\rserial console detected. Disabling virtual terminals.\n");
397 } 381 }
398 close(fd); 382 close(fd);
399 } 383 }
@@ -802,9 +786,7 @@ static void halt_signal(int sig)
802 /* Seems the s390 console is Wierd(tm). */ 786 /* Seems the s390 console is Wierd(tm). */
803 "\rThe system is halted. You may reboot now.\n" 787 "\rThe system is halted. You may reboot now.\n"
804#else 788#else
805 /* secondConsole is NULL for a serial console */ 789 "\rThe system is halted. Press Reset or turn off power\n"
806 "\rThe system is halted. Press %s or turn off power\n",
807 (secondConsole == NULL)? "Reset" : "CTRL-ALT-DEL"
808#endif 790#endif
809 ); 791 );
810 sync(); 792 sync();
@@ -865,12 +847,8 @@ static void new_init_action(int action, char *command, char *cons)
865 if (*cons == '\0') 847 if (*cons == '\0')
866 cons = console; 848 cons = console;
867 849
868 /* If BusyBox detects that a serial console is in use, then entries 850 /* do not run entries if console device is not available */
869 * not refering to the console or null devices will _not_ be run. 851 if (access(cons, R_OK|W_OK))
870 * The exception to this rule is the null device.
871 */
872 if (secondConsole == NULL && strcmp(cons, console)
873 && strcmp(cons, "/dev/null"))
874 return; 852 return;
875 if (strcmp(cons, "/dev/null") == 0 && (action & ASKFIRST)) 853 if (strcmp(cons, "/dev/null") == 0 && (action & ASKFIRST))
876 return; 854 return;
@@ -944,17 +922,11 @@ static void parse_inittab(void)
944#endif 922#endif
945 /* Prepare to restart init when a HUP is received */ 923 /* Prepare to restart init when a HUP is received */
946 new_init_action(RESTART, "/sbin/init", console); 924 new_init_action(RESTART, "/sbin/init", console);
947 /* Askfirst shell on tty1 */ 925 /* Askfirst shell on tty1-4 */
948 new_init_action(ASKFIRST, LOGIN_SHELL, console); 926 new_init_action(ASKFIRST, LOGIN_SHELL, console);
949 /* Askfirst shell on tty2 */ 927 new_init_action(ASKFIRST, LOGIN_SHELL, VC_2);
950 if (secondConsole != NULL) 928 new_init_action(ASKFIRST, LOGIN_SHELL, VC_3);
951 new_init_action(ASKFIRST, LOGIN_SHELL, secondConsole); 929 new_init_action(ASKFIRST, LOGIN_SHELL, VC_4);
952 /* Askfirst shell on tty3 */
953 if (thirdConsole != NULL)
954 new_init_action(ASKFIRST, LOGIN_SHELL, thirdConsole);
955 /* Askfirst shell on tty4 */
956 if (fourthConsole != NULL)
957 new_init_action(ASKFIRST, LOGIN_SHELL, fourthConsole);
958 /* sysinit */ 930 /* sysinit */
959 new_init_action(SYSINIT, INIT_SCRIPT, console); 931 new_init_action(SYSINIT, INIT_SCRIPT, console);
960 932
@@ -1113,12 +1085,9 @@ extern int init_main(int argc, char **argv)
1113 if (argc > 1 && (!strcmp(argv[1], "single") || 1085 if (argc > 1 && (!strcmp(argv[1], "single") ||
1114 !strcmp(argv[1], "-s") || !strcmp(argv[1], "1"))) { 1086 !strcmp(argv[1], "-s") || !strcmp(argv[1], "1"))) {
1115 /* Ask first then start a shell on tty2-4 */ 1087 /* Ask first then start a shell on tty2-4 */
1116 if (secondConsole != NULL) 1088 new_init_action(ASKFIRST, LOGIN_SHELL, VC_2);
1117 new_init_action(ASKFIRST, LOGIN_SHELL, secondConsole); 1089 new_init_action(ASKFIRST, LOGIN_SHELL, VC_3);
1118 if (thirdConsole != NULL) 1090 new_init_action(ASKFIRST, LOGIN_SHELL, VC_4);
1119 new_init_action(ASKFIRST, LOGIN_SHELL, thirdConsole);
1120 if (fourthConsole != NULL)
1121 new_init_action(ASKFIRST, LOGIN_SHELL, fourthConsole);
1122 /* Start a shell on tty1 */ 1091 /* Start a shell on tty1 */
1123 new_init_action(RESPAWN, LOGIN_SHELL, console); 1092 new_init_action(RESPAWN, LOGIN_SHELL, console);
1124 } else { 1093 } else {