aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Andersen <andersen@codepoet.org>2000-01-06 01:16:13 +0000
committerErik Andersen <andersen@codepoet.org>2000-01-06 01:16:13 +0000
commit9e7372584f5cbe50e15ba5d345b83a463322d21d (patch)
tree226cb6160b0812a13b455f425b7db10f9e53481e
parent0b874ed41f4bd7bec609541e2883d8ad4933c680 (diff)
downloadbusybox-w32-9e7372584f5cbe50e15ba5d345b83a463322d21d.tar.gz
busybox-w32-9e7372584f5cbe50e15ba5d345b83a463322d21d.tar.bz2
busybox-w32-9e7372584f5cbe50e15ba5d345b83a463322d21d.zip
inittab is now perfect. The universe will now submit to my
will. muhahahaha!!! Phear! -Erik
-rw-r--r--busybox.def.h43
-rw-r--r--init.c57
-rw-r--r--init/init.c57
3 files changed, 116 insertions, 41 deletions
diff --git a/busybox.def.h b/busybox.def.h
index 0e62ca781..032146519 100644
--- a/busybox.def.h
+++ b/busybox.def.h
@@ -1,8 +1,11 @@
1/* 1// This file defines the feature set to be compiled into busybox.
2 * This file is parsed by sed. You MUST use single line comments. 2// When you turn things off here, they won't be compiled in at all.
3 * IE //#define BB_BLAH 3//
4 */ 4//// This file is parsed by sed. You MUST use single line comments.
5 5// i.e. //#define BB_BLAH
6//
7//
8// BusyBox Applications
6#define BB_BUSYBOX 9#define BB_BUSYBOX
7#define BB_CAT 10#define BB_CAT
8#define BB_CHMOD_CHOWN_CHGRP 11#define BB_CHMOD_CHOWN_CHGRP
@@ -28,6 +31,7 @@
28#define BB_HEAD 31#define BB_HEAD
29#define BB_HOSTNAME 32#define BB_HOSTNAME
30#define BB_INIT 33#define BB_INIT
34// Don't turn BB_INSMOD on. It doesn't work.
31//#define BB_INSMOD 35//#define BB_INSMOD
32#define BB_KILL 36#define BB_KILL
33#define BB_KLOGD 37#define BB_KLOGD
@@ -80,9 +84,7 @@
80#define BB_UNAME 84#define BB_UNAME
81#define BB_GZIP 85#define BB_GZIP
82#define BB_GUNZIP 86#define BB_GUNZIP
83// Don't turn BB_UTILITY off. It contains support code 87// End of Applications List
84// that compiles to 0 if everything else if turned off.
85#define BB_UTILITY
86// 88//
87// 89//
88// 90//
@@ -91,19 +93,30 @@
91// pretty/useful). 93// pretty/useful).
92// 94//
93// 95//
94// enable features that use the /proc filesystem 96// enable features that use the /proc filesystem (apps that
97// break without this will tell you on compile)...
95#define BB_FEATURE_USE_PROCFS 98#define BB_FEATURE_USE_PROCFS
96//Enable init being called as /linuxrc
97#define BB_FEATURE_LINUXRC
98// Use termios to manipulate the screen ('more' is prettier with this on) 99// Use termios to manipulate the screen ('more' is prettier with this on)
99#define BB_FEATURE_USE_TERMIOS 100#define BB_FEATURE_USE_TERMIOS
100// calculate terminal & column widths 101// calculate terminal & column widths (for more and ls)
101#define BB_FEATURE_AUTOWIDTH 102#define BB_FEATURE_AUTOWIDTH
102// show username/groupnames (bypasses libc6 NSS) 103// show username/groupnames (bypasses libc6 NSS) for ls
103#define BB_FEATURE_LS_USERNAME 104#define BB_FEATURE_LS_USERNAME
104// show file timestamps 105// show file timestamps in ls
105#define BB_FEATURE_LS_TIMESTAMPS 106#define BB_FEATURE_LS_TIMESTAMPS
106// enable ls -p and -F 107// enable ls -p and -F
107#define BB_FEATURE_LS_FILETYPES 108#define BB_FEATURE_LS_FILETYPES
108// simplified ping 109// Change ping implementation -- simplified, featureless, but really small.
109//#define BB_SIMPLE_PING 110//#define BB_SIMPLE_PING
111// Make init use a simplified /etc/inittab file (recommended).
112#define BB_FEATURE_USE_INITTAB
113//Enable init being called as /linuxrc
114#define BB_FEATURE_LINUXRC
115//
116//
117//
118// Don't turn BB_UTILITY off. It contains support code
119// that compiles to 0 if everything else if turned off.
120#define BB_UTILITY
121//
122//
diff --git a/init.c b/init.c
index 116d07954..95c2322f7 100644
--- a/init.c
+++ b/init.c
@@ -97,7 +97,7 @@ typedef struct initActionTag initAction;
97struct initActionTag { 97struct initActionTag {
98 pid_t pid; 98 pid_t pid;
99 char process[256]; 99 char process[256];
100 char *console; 100 char console[256];
101 initAction *nextPtr; 101 initAction *nextPtr;
102 initActionEnum action; 102 initActionEnum action;
103}; 103};
@@ -496,9 +496,16 @@ static void reboot_signal(int sig)
496#endif 496#endif
497 497
498void new_initAction (const struct initActionType *a, 498void new_initAction (const struct initActionType *a,
499 char* process, char* console) 499 char* process, char* cons)
500{ 500{
501 initAction* newAction; 501 initAction* newAction;
502
503 /* If BusyBox detects that a serial console is in use,
504 * then entries containing non-empty id fields will _not_ be run.
505 */
506 if (second_console != NULL && *cons != '\0')
507 return;
508
502 newAction = calloc ((size_t)(1), sizeof(initAction)); 509 newAction = calloc ((size_t)(1), sizeof(initAction));
503 if (!newAction) { 510 if (!newAction) {
504 fprintf(stderr, "Memory allocation failure\n"); 511 fprintf(stderr, "Memory allocation failure\n");
@@ -508,7 +515,10 @@ void new_initAction (const struct initActionType *a,
508 initActionList = newAction; 515 initActionList = newAction;
509 strncpy( newAction->process, process, 255); 516 strncpy( newAction->process, process, 255);
510 newAction->action = a->action; 517 newAction->action = a->action;
511 newAction->console = console; 518 if (*cons != '\0')
519 strncpy(newAction->console, cons, 255);
520 else
521 strncpy(newAction->console, console, 255);
512 newAction->pid = 0; 522 newAction->pid = 0;
513} 523}
514 524
@@ -524,11 +534,19 @@ void delete_initAction (initAction *action)
524 } 534 }
525} 535}
526 536
537/* NOTE that if BB_FEATURE_USE_INITTAB is NOT defined,
538 * then parse_inittab() simply adds in some default
539 * actions(i.e runs INIT_SCRIPT and then starts a pair
540 * of "askfirst" shells. If BB_FEATURE_USE_INITTAB
541 * _is_ defined, but /etc/inittab is missing == same
542 * default behavior.
543 * */
527void parse_inittab(void) 544void parse_inittab(void)
528{ 545{
546#ifdef BB_FEATURE_USE_INITTAB
529 FILE* file; 547 FILE* file;
530 char buf[256]; 548 char buf[256], buf1[256];
531 char *p, *q, *r; 549 char *p, *q, *r, *s;
532 const struct initActionType *a = actions; 550 const struct initActionType *a = actions;
533 int foundIt; 551 int foundIt;
534 552
@@ -536,7 +554,7 @@ void parse_inittab(void)
536 file = fopen(INITTAB, "r"); 554 file = fopen(INITTAB, "r");
537 if (file == NULL) { 555 if (file == NULL) {
538 /* No inittab file -- set up some default behavior */ 556 /* No inittab file -- set up some default behavior */
539 557#endif
540 /* Askfirst shell on tty1 */ 558 /* Askfirst shell on tty1 */
541 new_initAction( &(actions[3]), SHELL, console ); 559 new_initAction( &(actions[3]), SHELL, console );
542 /* Askfirst shell on tty2 */ 560 /* Askfirst shell on tty2 */
@@ -546,6 +564,7 @@ void parse_inittab(void)
546 new_initAction( &(actions[0]), INIT_SCRIPT, console ); 564 new_initAction( &(actions[0]), INIT_SCRIPT, console );
547 565
548 return; 566 return;
567#ifdef BB_FEATURE_USE_INITTAB
549 } 568 }
550 569
551 while ( fgets(buf, 255, file) != NULL) { 570 while ( fgets(buf, 255, file) != NULL) {
@@ -558,15 +577,22 @@ void parse_inittab(void)
558 if (q != NULL) 577 if (q != NULL)
559 *q='\0'; 578 *q='\0';
560 579
561 /* Skip past the ID field and the runlevel 580 /* Keep a copy around for posterity's sake (and error msgs) */
562 * field (both are ignored) */ 581 strcpy(buf1, buf);
582
583 /* Grab the ID field */
584 s=p;
563 p = strchr( p, ':'); 585 p = strchr( p, ':');
586 if ( p != NULL || *(p+1) != '\0' ) {
587 *p='\0';
588 ++p;
589 }
564 590
565 /* Now peal off the process field from the end 591 /* Now peal off the process field from the end
566 * of the string */ 592 * of the string */
567 q = strrchr( p, ':'); 593 q = strrchr( p, ':');
568 if ( q == NULL || *(q+1) == '\0' ) { 594 if ( q == NULL || *(q+1) == '\0' ) {
569 fprintf(stderr, "Bad inittab entry: %s\n", buf); 595 fprintf(stderr, "Bad inittab entry: %s\n", buf1);
570 continue; 596 continue;
571 } else { 597 } else {
572 *q='\0'; 598 *q='\0';
@@ -576,7 +602,7 @@ void parse_inittab(void)
576 /* Now peal off the action field */ 602 /* Now peal off the action field */
577 r = strrchr( p, ':'); 603 r = strrchr( p, ':');
578 if ( r == NULL || *(r+1) == '\0') { 604 if ( r == NULL || *(r+1) == '\0') {
579 fprintf(stderr, "Bad inittab entry: %s\n", buf); 605 fprintf(stderr, "Bad inittab entry: %s\n", buf1);
580 continue; 606 continue;
581 } else { 607 } else {
582 ++r; 608 ++r;
@@ -586,7 +612,7 @@ void parse_inittab(void)
586 a = actions; 612 a = actions;
587 while (a->name != 0) { 613 while (a->name != 0) {
588 if (strcmp(a->name, r) == 0) { 614 if (strcmp(a->name, r) == 0) {
589 new_initAction( a, q, NULL); 615 new_initAction( a, q, s);
590 foundIt=TRUE; 616 foundIt=TRUE;
591 } 617 }
592 a++; 618 a++;
@@ -595,13 +621,13 @@ void parse_inittab(void)
595 continue; 621 continue;
596 else { 622 else {
597 /* Choke on an unknown action */ 623 /* Choke on an unknown action */
598 fprintf(stderr, "Bad inittab entry: %s\n", buf); 624 fprintf(stderr, "Bad inittab entry: %s\n", buf1);
599 } 625 }
600 } 626 }
601 return; 627 return;
628#endif
602} 629}
603 630
604
605extern int init_main(int argc, char **argv) 631extern int init_main(int argc, char **argv)
606{ 632{
607 initAction *a; 633 initAction *a;
@@ -675,6 +701,11 @@ extern int init_main(int argc, char **argv)
675 new_initAction( &(actions[3]), SHELL, console); 701 new_initAction( &(actions[3]), SHELL, console);
676 } else { 702 } else {
677 /* Not in single user mode -- see what inittab says */ 703 /* Not in single user mode -- see what inittab says */
704
705 /* NOTE that if BB_FEATURE_USE_INITTAB is NOT defined,
706 * then parse_inittab() simply adds in some default
707 * actions(i.e runs INIT_SCRIPT and then starts a pair
708 * of "askfirst" shells */
678 parse_inittab(); 709 parse_inittab();
679 } 710 }
680 711
diff --git a/init/init.c b/init/init.c
index 116d07954..95c2322f7 100644
--- a/init/init.c
+++ b/init/init.c
@@ -97,7 +97,7 @@ typedef struct initActionTag initAction;
97struct initActionTag { 97struct initActionTag {
98 pid_t pid; 98 pid_t pid;
99 char process[256]; 99 char process[256];
100 char *console; 100 char console[256];
101 initAction *nextPtr; 101 initAction *nextPtr;
102 initActionEnum action; 102 initActionEnum action;
103}; 103};
@@ -496,9 +496,16 @@ static void reboot_signal(int sig)
496#endif 496#endif
497 497
498void new_initAction (const struct initActionType *a, 498void new_initAction (const struct initActionType *a,
499 char* process, char* console) 499 char* process, char* cons)
500{ 500{
501 initAction* newAction; 501 initAction* newAction;
502
503 /* If BusyBox detects that a serial console is in use,
504 * then entries containing non-empty id fields will _not_ be run.
505 */
506 if (second_console != NULL && *cons != '\0')
507 return;
508
502 newAction = calloc ((size_t)(1), sizeof(initAction)); 509 newAction = calloc ((size_t)(1), sizeof(initAction));
503 if (!newAction) { 510 if (!newAction) {
504 fprintf(stderr, "Memory allocation failure\n"); 511 fprintf(stderr, "Memory allocation failure\n");
@@ -508,7 +515,10 @@ void new_initAction (const struct initActionType *a,
508 initActionList = newAction; 515 initActionList = newAction;
509 strncpy( newAction->process, process, 255); 516 strncpy( newAction->process, process, 255);
510 newAction->action = a->action; 517 newAction->action = a->action;
511 newAction->console = console; 518 if (*cons != '\0')
519 strncpy(newAction->console, cons, 255);
520 else
521 strncpy(newAction->console, console, 255);
512 newAction->pid = 0; 522 newAction->pid = 0;
513} 523}
514 524
@@ -524,11 +534,19 @@ void delete_initAction (initAction *action)
524 } 534 }
525} 535}
526 536
537/* NOTE that if BB_FEATURE_USE_INITTAB is NOT defined,
538 * then parse_inittab() simply adds in some default
539 * actions(i.e runs INIT_SCRIPT and then starts a pair
540 * of "askfirst" shells. If BB_FEATURE_USE_INITTAB
541 * _is_ defined, but /etc/inittab is missing == same
542 * default behavior.
543 * */
527void parse_inittab(void) 544void parse_inittab(void)
528{ 545{
546#ifdef BB_FEATURE_USE_INITTAB
529 FILE* file; 547 FILE* file;
530 char buf[256]; 548 char buf[256], buf1[256];
531 char *p, *q, *r; 549 char *p, *q, *r, *s;
532 const struct initActionType *a = actions; 550 const struct initActionType *a = actions;
533 int foundIt; 551 int foundIt;
534 552
@@ -536,7 +554,7 @@ void parse_inittab(void)
536 file = fopen(INITTAB, "r"); 554 file = fopen(INITTAB, "r");
537 if (file == NULL) { 555 if (file == NULL) {
538 /* No inittab file -- set up some default behavior */ 556 /* No inittab file -- set up some default behavior */
539 557#endif
540 /* Askfirst shell on tty1 */ 558 /* Askfirst shell on tty1 */
541 new_initAction( &(actions[3]), SHELL, console ); 559 new_initAction( &(actions[3]), SHELL, console );
542 /* Askfirst shell on tty2 */ 560 /* Askfirst shell on tty2 */
@@ -546,6 +564,7 @@ void parse_inittab(void)
546 new_initAction( &(actions[0]), INIT_SCRIPT, console ); 564 new_initAction( &(actions[0]), INIT_SCRIPT, console );
547 565
548 return; 566 return;
567#ifdef BB_FEATURE_USE_INITTAB
549 } 568 }
550 569
551 while ( fgets(buf, 255, file) != NULL) { 570 while ( fgets(buf, 255, file) != NULL) {
@@ -558,15 +577,22 @@ void parse_inittab(void)
558 if (q != NULL) 577 if (q != NULL)
559 *q='\0'; 578 *q='\0';
560 579
561 /* Skip past the ID field and the runlevel 580 /* Keep a copy around for posterity's sake (and error msgs) */
562 * field (both are ignored) */ 581 strcpy(buf1, buf);
582
583 /* Grab the ID field */
584 s=p;
563 p = strchr( p, ':'); 585 p = strchr( p, ':');
586 if ( p != NULL || *(p+1) != '\0' ) {
587 *p='\0';
588 ++p;
589 }
564 590
565 /* Now peal off the process field from the end 591 /* Now peal off the process field from the end
566 * of the string */ 592 * of the string */
567 q = strrchr( p, ':'); 593 q = strrchr( p, ':');
568 if ( q == NULL || *(q+1) == '\0' ) { 594 if ( q == NULL || *(q+1) == '\0' ) {
569 fprintf(stderr, "Bad inittab entry: %s\n", buf); 595 fprintf(stderr, "Bad inittab entry: %s\n", buf1);
570 continue; 596 continue;
571 } else { 597 } else {
572 *q='\0'; 598 *q='\0';
@@ -576,7 +602,7 @@ void parse_inittab(void)
576 /* Now peal off the action field */ 602 /* Now peal off the action field */
577 r = strrchr( p, ':'); 603 r = strrchr( p, ':');
578 if ( r == NULL || *(r+1) == '\0') { 604 if ( r == NULL || *(r+1) == '\0') {
579 fprintf(stderr, "Bad inittab entry: %s\n", buf); 605 fprintf(stderr, "Bad inittab entry: %s\n", buf1);
580 continue; 606 continue;
581 } else { 607 } else {
582 ++r; 608 ++r;
@@ -586,7 +612,7 @@ void parse_inittab(void)
586 a = actions; 612 a = actions;
587 while (a->name != 0) { 613 while (a->name != 0) {
588 if (strcmp(a->name, r) == 0) { 614 if (strcmp(a->name, r) == 0) {
589 new_initAction( a, q, NULL); 615 new_initAction( a, q, s);
590 foundIt=TRUE; 616 foundIt=TRUE;
591 } 617 }
592 a++; 618 a++;
@@ -595,13 +621,13 @@ void parse_inittab(void)
595 continue; 621 continue;
596 else { 622 else {
597 /* Choke on an unknown action */ 623 /* Choke on an unknown action */
598 fprintf(stderr, "Bad inittab entry: %s\n", buf); 624 fprintf(stderr, "Bad inittab entry: %s\n", buf1);
599 } 625 }
600 } 626 }
601 return; 627 return;
628#endif
602} 629}
603 630
604
605extern int init_main(int argc, char **argv) 631extern int init_main(int argc, char **argv)
606{ 632{
607 initAction *a; 633 initAction *a;
@@ -675,6 +701,11 @@ extern int init_main(int argc, char **argv)
675 new_initAction( &(actions[3]), SHELL, console); 701 new_initAction( &(actions[3]), SHELL, console);
676 } else { 702 } else {
677 /* Not in single user mode -- see what inittab says */ 703 /* Not in single user mode -- see what inittab says */
704
705 /* NOTE that if BB_FEATURE_USE_INITTAB is NOT defined,
706 * then parse_inittab() simply adds in some default
707 * actions(i.e runs INIT_SCRIPT and then starts a pair
708 * of "askfirst" shells */
678 parse_inittab(); 709 parse_inittab();
679 } 710 }
680 711