inittab is now perfect. The universe will now submit to my

will. muhahahaha!!!  Phear!
 -Erik
This commit is contained in:
Erik Andersen 2000-01-06 01:16:13 +00:00
parent 0b874ed41f
commit 9e7372584f
3 changed files with 116 additions and 41 deletions

View File

@ -1,8 +1,11 @@
/* // This file defines the feature set to be compiled into busybox.
* This file is parsed by sed. You MUST use single line comments. // When you turn things off here, they won't be compiled in at all.
* IE //#define BB_BLAH //
*/ //// This file is parsed by sed. You MUST use single line comments.
// i.e. //#define BB_BLAH
//
//
// BusyBox Applications
#define BB_BUSYBOX #define BB_BUSYBOX
#define BB_CAT #define BB_CAT
#define BB_CHMOD_CHOWN_CHGRP #define BB_CHMOD_CHOWN_CHGRP
@ -28,6 +31,7 @@
#define BB_HEAD #define BB_HEAD
#define BB_HOSTNAME #define BB_HOSTNAME
#define BB_INIT #define BB_INIT
// Don't turn BB_INSMOD on. It doesn't work.
//#define BB_INSMOD //#define BB_INSMOD
#define BB_KILL #define BB_KILL
#define BB_KLOGD #define BB_KLOGD
@ -80,9 +84,7 @@
#define BB_UNAME #define BB_UNAME
#define BB_GZIP #define BB_GZIP
#define BB_GUNZIP #define BB_GUNZIP
// Don't turn BB_UTILITY off. It contains support code // End of Applications List
// that compiles to 0 if everything else if turned off.
#define BB_UTILITY
// //
// //
// //
@ -91,19 +93,30 @@
// pretty/useful). // pretty/useful).
// //
// //
// enable features that use the /proc filesystem // enable features that use the /proc filesystem (apps that
// break without this will tell you on compile)...
#define BB_FEATURE_USE_PROCFS #define BB_FEATURE_USE_PROCFS
//Enable init being called as /linuxrc
#define BB_FEATURE_LINUXRC
// Use termios to manipulate the screen ('more' is prettier with this on) // Use termios to manipulate the screen ('more' is prettier with this on)
#define BB_FEATURE_USE_TERMIOS #define BB_FEATURE_USE_TERMIOS
// calculate terminal & column widths // calculate terminal & column widths (for more and ls)
#define BB_FEATURE_AUTOWIDTH #define BB_FEATURE_AUTOWIDTH
// show username/groupnames (bypasses libc6 NSS) // show username/groupnames (bypasses libc6 NSS) for ls
#define BB_FEATURE_LS_USERNAME #define BB_FEATURE_LS_USERNAME
// show file timestamps // show file timestamps in ls
#define BB_FEATURE_LS_TIMESTAMPS #define BB_FEATURE_LS_TIMESTAMPS
// enable ls -p and -F // enable ls -p and -F
#define BB_FEATURE_LS_FILETYPES #define BB_FEATURE_LS_FILETYPES
// simplified ping // Change ping implementation -- simplified, featureless, but really small.
//#define BB_SIMPLE_PING //#define BB_SIMPLE_PING
// Make init use a simplified /etc/inittab file (recommended).
#define BB_FEATURE_USE_INITTAB
//Enable init being called as /linuxrc
#define BB_FEATURE_LINUXRC
//
//
//
// Don't turn BB_UTILITY off. It contains support code
// that compiles to 0 if everything else if turned off.
#define BB_UTILITY
//
//

57
init.c
View File

@ -97,7 +97,7 @@ typedef struct initActionTag initAction;
struct initActionTag { struct initActionTag {
pid_t pid; pid_t pid;
char process[256]; char process[256];
char *console; char console[256];
initAction *nextPtr; initAction *nextPtr;
initActionEnum action; initActionEnum action;
}; };
@ -496,9 +496,16 @@ static void reboot_signal(int sig)
#endif #endif
void new_initAction (const struct initActionType *a, void new_initAction (const struct initActionType *a,
char* process, char* console) char* process, char* cons)
{ {
initAction* newAction; initAction* newAction;
/* If BusyBox detects that a serial console is in use,
* then entries containing non-empty id fields will _not_ be run.
*/
if (second_console != NULL && *cons != '\0')
return;
newAction = calloc ((size_t)(1), sizeof(initAction)); newAction = calloc ((size_t)(1), sizeof(initAction));
if (!newAction) { if (!newAction) {
fprintf(stderr, "Memory allocation failure\n"); fprintf(stderr, "Memory allocation failure\n");
@ -508,7 +515,10 @@ void new_initAction (const struct initActionType *a,
initActionList = newAction; initActionList = newAction;
strncpy( newAction->process, process, 255); strncpy( newAction->process, process, 255);
newAction->action = a->action; newAction->action = a->action;
newAction->console = console; if (*cons != '\0')
strncpy(newAction->console, cons, 255);
else
strncpy(newAction->console, console, 255);
newAction->pid = 0; newAction->pid = 0;
} }
@ -524,11 +534,19 @@ void delete_initAction (initAction *action)
} }
} }
/* NOTE that if BB_FEATURE_USE_INITTAB is NOT defined,
* then parse_inittab() simply adds in some default
* actions(i.e runs INIT_SCRIPT and then starts a pair
* of "askfirst" shells. If BB_FEATURE_USE_INITTAB
* _is_ defined, but /etc/inittab is missing == same
* default behavior.
* */
void parse_inittab(void) void parse_inittab(void)
{ {
#ifdef BB_FEATURE_USE_INITTAB
FILE* file; FILE* file;
char buf[256]; char buf[256], buf1[256];
char *p, *q, *r; char *p, *q, *r, *s;
const struct initActionType *a = actions; const struct initActionType *a = actions;
int foundIt; int foundIt;
@ -536,7 +554,7 @@ void parse_inittab(void)
file = fopen(INITTAB, "r"); file = fopen(INITTAB, "r");
if (file == NULL) { if (file == NULL) {
/* No inittab file -- set up some default behavior */ /* No inittab file -- set up some default behavior */
#endif
/* Askfirst shell on tty1 */ /* Askfirst shell on tty1 */
new_initAction( &(actions[3]), SHELL, console ); new_initAction( &(actions[3]), SHELL, console );
/* Askfirst shell on tty2 */ /* Askfirst shell on tty2 */
@ -546,6 +564,7 @@ void parse_inittab(void)
new_initAction( &(actions[0]), INIT_SCRIPT, console ); new_initAction( &(actions[0]), INIT_SCRIPT, console );
return; return;
#ifdef BB_FEATURE_USE_INITTAB
} }
while ( fgets(buf, 255, file) != NULL) { while ( fgets(buf, 255, file) != NULL) {
@ -558,15 +577,22 @@ void parse_inittab(void)
if (q != NULL) if (q != NULL)
*q='\0'; *q='\0';
/* Skip past the ID field and the runlevel /* Keep a copy around for posterity's sake (and error msgs) */
* field (both are ignored) */ strcpy(buf1, buf);
/* Grab the ID field */
s=p;
p = strchr( p, ':'); p = strchr( p, ':');
if ( p != NULL || *(p+1) != '\0' ) {
*p='\0';
++p;
}
/* Now peal off the process field from the end /* Now peal off the process field from the end
* of the string */ * of the string */
q = strrchr( p, ':'); q = strrchr( p, ':');
if ( q == NULL || *(q+1) == '\0' ) { if ( q == NULL || *(q+1) == '\0' ) {
fprintf(stderr, "Bad inittab entry: %s\n", buf); fprintf(stderr, "Bad inittab entry: %s\n", buf1);
continue; continue;
} else { } else {
*q='\0'; *q='\0';
@ -576,7 +602,7 @@ void parse_inittab(void)
/* Now peal off the action field */ /* Now peal off the action field */
r = strrchr( p, ':'); r = strrchr( p, ':');
if ( r == NULL || *(r+1) == '\0') { if ( r == NULL || *(r+1) == '\0') {
fprintf(stderr, "Bad inittab entry: %s\n", buf); fprintf(stderr, "Bad inittab entry: %s\n", buf1);
continue; continue;
} else { } else {
++r; ++r;
@ -586,7 +612,7 @@ void parse_inittab(void)
a = actions; a = actions;
while (a->name != 0) { while (a->name != 0) {
if (strcmp(a->name, r) == 0) { if (strcmp(a->name, r) == 0) {
new_initAction( a, q, NULL); new_initAction( a, q, s);
foundIt=TRUE; foundIt=TRUE;
} }
a++; a++;
@ -595,13 +621,13 @@ void parse_inittab(void)
continue; continue;
else { else {
/* Choke on an unknown action */ /* Choke on an unknown action */
fprintf(stderr, "Bad inittab entry: %s\n", buf); fprintf(stderr, "Bad inittab entry: %s\n", buf1);
} }
} }
return; return;
#endif
} }
extern int init_main(int argc, char **argv) extern int init_main(int argc, char **argv)
{ {
initAction *a; initAction *a;
@ -675,6 +701,11 @@ extern int init_main(int argc, char **argv)
new_initAction( &(actions[3]), SHELL, console); new_initAction( &(actions[3]), SHELL, console);
} else { } else {
/* Not in single user mode -- see what inittab says */ /* Not in single user mode -- see what inittab says */
/* NOTE that if BB_FEATURE_USE_INITTAB is NOT defined,
* then parse_inittab() simply adds in some default
* actions(i.e runs INIT_SCRIPT and then starts a pair
* of "askfirst" shells */
parse_inittab(); parse_inittab();
} }

View File

@ -97,7 +97,7 @@ typedef struct initActionTag initAction;
struct initActionTag { struct initActionTag {
pid_t pid; pid_t pid;
char process[256]; char process[256];
char *console; char console[256];
initAction *nextPtr; initAction *nextPtr;
initActionEnum action; initActionEnum action;
}; };
@ -496,9 +496,16 @@ static void reboot_signal(int sig)
#endif #endif
void new_initAction (const struct initActionType *a, void new_initAction (const struct initActionType *a,
char* process, char* console) char* process, char* cons)
{ {
initAction* newAction; initAction* newAction;
/* If BusyBox detects that a serial console is in use,
* then entries containing non-empty id fields will _not_ be run.
*/
if (second_console != NULL && *cons != '\0')
return;
newAction = calloc ((size_t)(1), sizeof(initAction)); newAction = calloc ((size_t)(1), sizeof(initAction));
if (!newAction) { if (!newAction) {
fprintf(stderr, "Memory allocation failure\n"); fprintf(stderr, "Memory allocation failure\n");
@ -508,7 +515,10 @@ void new_initAction (const struct initActionType *a,
initActionList = newAction; initActionList = newAction;
strncpy( newAction->process, process, 255); strncpy( newAction->process, process, 255);
newAction->action = a->action; newAction->action = a->action;
newAction->console = console; if (*cons != '\0')
strncpy(newAction->console, cons, 255);
else
strncpy(newAction->console, console, 255);
newAction->pid = 0; newAction->pid = 0;
} }
@ -524,11 +534,19 @@ void delete_initAction (initAction *action)
} }
} }
/* NOTE that if BB_FEATURE_USE_INITTAB is NOT defined,
* then parse_inittab() simply adds in some default
* actions(i.e runs INIT_SCRIPT and then starts a pair
* of "askfirst" shells. If BB_FEATURE_USE_INITTAB
* _is_ defined, but /etc/inittab is missing == same
* default behavior.
* */
void parse_inittab(void) void parse_inittab(void)
{ {
#ifdef BB_FEATURE_USE_INITTAB
FILE* file; FILE* file;
char buf[256]; char buf[256], buf1[256];
char *p, *q, *r; char *p, *q, *r, *s;
const struct initActionType *a = actions; const struct initActionType *a = actions;
int foundIt; int foundIt;
@ -536,7 +554,7 @@ void parse_inittab(void)
file = fopen(INITTAB, "r"); file = fopen(INITTAB, "r");
if (file == NULL) { if (file == NULL) {
/* No inittab file -- set up some default behavior */ /* No inittab file -- set up some default behavior */
#endif
/* Askfirst shell on tty1 */ /* Askfirst shell on tty1 */
new_initAction( &(actions[3]), SHELL, console ); new_initAction( &(actions[3]), SHELL, console );
/* Askfirst shell on tty2 */ /* Askfirst shell on tty2 */
@ -546,6 +564,7 @@ void parse_inittab(void)
new_initAction( &(actions[0]), INIT_SCRIPT, console ); new_initAction( &(actions[0]), INIT_SCRIPT, console );
return; return;
#ifdef BB_FEATURE_USE_INITTAB
} }
while ( fgets(buf, 255, file) != NULL) { while ( fgets(buf, 255, file) != NULL) {
@ -558,15 +577,22 @@ void parse_inittab(void)
if (q != NULL) if (q != NULL)
*q='\0'; *q='\0';
/* Skip past the ID field and the runlevel /* Keep a copy around for posterity's sake (and error msgs) */
* field (both are ignored) */ strcpy(buf1, buf);
/* Grab the ID field */
s=p;
p = strchr( p, ':'); p = strchr( p, ':');
if ( p != NULL || *(p+1) != '\0' ) {
*p='\0';
++p;
}
/* Now peal off the process field from the end /* Now peal off the process field from the end
* of the string */ * of the string */
q = strrchr( p, ':'); q = strrchr( p, ':');
if ( q == NULL || *(q+1) == '\0' ) { if ( q == NULL || *(q+1) == '\0' ) {
fprintf(stderr, "Bad inittab entry: %s\n", buf); fprintf(stderr, "Bad inittab entry: %s\n", buf1);
continue; continue;
} else { } else {
*q='\0'; *q='\0';
@ -576,7 +602,7 @@ void parse_inittab(void)
/* Now peal off the action field */ /* Now peal off the action field */
r = strrchr( p, ':'); r = strrchr( p, ':');
if ( r == NULL || *(r+1) == '\0') { if ( r == NULL || *(r+1) == '\0') {
fprintf(stderr, "Bad inittab entry: %s\n", buf); fprintf(stderr, "Bad inittab entry: %s\n", buf1);
continue; continue;
} else { } else {
++r; ++r;
@ -586,7 +612,7 @@ void parse_inittab(void)
a = actions; a = actions;
while (a->name != 0) { while (a->name != 0) {
if (strcmp(a->name, r) == 0) { if (strcmp(a->name, r) == 0) {
new_initAction( a, q, NULL); new_initAction( a, q, s);
foundIt=TRUE; foundIt=TRUE;
} }
a++; a++;
@ -595,13 +621,13 @@ void parse_inittab(void)
continue; continue;
else { else {
/* Choke on an unknown action */ /* Choke on an unknown action */
fprintf(stderr, "Bad inittab entry: %s\n", buf); fprintf(stderr, "Bad inittab entry: %s\n", buf1);
} }
} }
return; return;
#endif
} }
extern int init_main(int argc, char **argv) extern int init_main(int argc, char **argv)
{ {
initAction *a; initAction *a;
@ -675,6 +701,11 @@ extern int init_main(int argc, char **argv)
new_initAction( &(actions[3]), SHELL, console); new_initAction( &(actions[3]), SHELL, console);
} else { } else {
/* Not in single user mode -- see what inittab says */ /* Not in single user mode -- see what inittab says */
/* NOTE that if BB_FEATURE_USE_INITTAB is NOT defined,
* then parse_inittab() simply adds in some default
* actions(i.e runs INIT_SCRIPT and then starts a pair
* of "askfirst" shells */
parse_inittab(); parse_inittab();
} }