-/*
- * This file is parsed by sed. You MUST use single line comments.
- * IE //#define BB_BLAH
- */
-
+// This file defines the feature set to be compiled into busybox.
+// When you turn things off here, they won't be compiled in at all.
+//
+//// This file is parsed by sed. You MUST use single line comments.
+// i.e. //#define BB_BLAH
+//
+//
+// BusyBox Applications
#define BB_BUSYBOX
#define BB_CAT
#define BB_CHMOD_CHOWN_CHGRP
#define BB_HEAD
#define BB_HOSTNAME
#define BB_INIT
+// Don't turn BB_INSMOD on. It doesn't work.
//#define BB_INSMOD
#define BB_KILL
#define BB_KLOGD
#define BB_UNAME
#define BB_GZIP
#define BB_GUNZIP
-// Don't turn BB_UTILITY off. It contains support code
-// that compiles to 0 if everything else if turned off.
-#define BB_UTILITY
+// End of Applications List
//
//
//
// 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
-//Enable init being called as /linuxrc
-#define BB_FEATURE_LINUXRC
// Use termios to manipulate the screen ('more' is prettier with this on)
#define BB_FEATURE_USE_TERMIOS
-// calculate terminal & column widths
+// calculate terminal & column widths (for more and ls)
#define BB_FEATURE_AUTOWIDTH
-// show username/groupnames (bypasses libc6 NSS)
+// show username/groupnames (bypasses libc6 NSS) for ls
#define BB_FEATURE_LS_USERNAME
-// show file timestamps
+// show file timestamps in ls
#define BB_FEATURE_LS_TIMESTAMPS
// enable ls -p and -F
#define BB_FEATURE_LS_FILETYPES
-// simplified ping
+// Change ping implementation -- simplified, featureless, but really small.
//#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
+//
+//
struct initActionTag {
pid_t pid;
char process[256];
- char *console;
+ char console[256];
initAction *nextPtr;
initActionEnum action;
};
#endif
void new_initAction (const struct initActionType *a,
- char* process, char* console)
+ char* process, char* cons)
{
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));
if (!newAction) {
fprintf(stderr, "Memory allocation failure\n");
initActionList = newAction;
strncpy( newAction->process, process, 255);
newAction->action = a->action;
- newAction->console = console;
+ if (*cons != '\0')
+ strncpy(newAction->console, cons, 255);
+ else
+ strncpy(newAction->console, console, 255);
newAction->pid = 0;
}
}
}
+/* 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)
{
+#ifdef BB_FEATURE_USE_INITTAB
FILE* file;
- char buf[256];
- char *p, *q, *r;
+ char buf[256], buf1[256];
+ char *p, *q, *r, *s;
const struct initActionType *a = actions;
int foundIt;
file = fopen(INITTAB, "r");
if (file == NULL) {
/* No inittab file -- set up some default behavior */
-
+#endif
/* Askfirst shell on tty1 */
new_initAction( &(actions[3]), SHELL, console );
/* Askfirst shell on tty2 */
new_initAction( &(actions[0]), INIT_SCRIPT, console );
return;
+#ifdef BB_FEATURE_USE_INITTAB
}
while ( fgets(buf, 255, file) != NULL) {
if (q != NULL)
*q='\0';
- /* Skip past the ID field and the runlevel
- * field (both are ignored) */
+ /* Keep a copy around for posterity's sake (and error msgs) */
+ strcpy(buf1, buf);
+
+ /* Grab the ID field */
+ s=p;
p = strchr( p, ':');
+ if ( p != NULL || *(p+1) != '\0' ) {
+ *p='\0';
+ ++p;
+ }
/* Now peal off the process field from the end
* of the string */
q = strrchr( p, ':');
if ( q == NULL || *(q+1) == '\0' ) {
- fprintf(stderr, "Bad inittab entry: %s\n", buf);
+ fprintf(stderr, "Bad inittab entry: %s\n", buf1);
continue;
} else {
*q='\0';
/* Now peal off the action field */
r = strrchr( p, ':');
if ( r == NULL || *(r+1) == '\0') {
- fprintf(stderr, "Bad inittab entry: %s\n", buf);
+ fprintf(stderr, "Bad inittab entry: %s\n", buf1);
continue;
} else {
++r;
a = actions;
while (a->name != 0) {
if (strcmp(a->name, r) == 0) {
- new_initAction( a, q, NULL);
+ new_initAction( a, q, s);
foundIt=TRUE;
}
a++;
continue;
else {
/* Choke on an unknown action */
- fprintf(stderr, "Bad inittab entry: %s\n", buf);
+ fprintf(stderr, "Bad inittab entry: %s\n", buf1);
}
}
return;
+#endif
}
-
extern int init_main(int argc, char **argv)
{
initAction *a;
new_initAction( &(actions[3]), SHELL, console);
} else {
/* 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();
}
struct initActionTag {
pid_t pid;
char process[256];
- char *console;
+ char console[256];
initAction *nextPtr;
initActionEnum action;
};
#endif
void new_initAction (const struct initActionType *a,
- char* process, char* console)
+ char* process, char* cons)
{
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));
if (!newAction) {
fprintf(stderr, "Memory allocation failure\n");
initActionList = newAction;
strncpy( newAction->process, process, 255);
newAction->action = a->action;
- newAction->console = console;
+ if (*cons != '\0')
+ strncpy(newAction->console, cons, 255);
+ else
+ strncpy(newAction->console, console, 255);
newAction->pid = 0;
}
}
}
+/* 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)
{
+#ifdef BB_FEATURE_USE_INITTAB
FILE* file;
- char buf[256];
- char *p, *q, *r;
+ char buf[256], buf1[256];
+ char *p, *q, *r, *s;
const struct initActionType *a = actions;
int foundIt;
file = fopen(INITTAB, "r");
if (file == NULL) {
/* No inittab file -- set up some default behavior */
-
+#endif
/* Askfirst shell on tty1 */
new_initAction( &(actions[3]), SHELL, console );
/* Askfirst shell on tty2 */
new_initAction( &(actions[0]), INIT_SCRIPT, console );
return;
+#ifdef BB_FEATURE_USE_INITTAB
}
while ( fgets(buf, 255, file) != NULL) {
if (q != NULL)
*q='\0';
- /* Skip past the ID field and the runlevel
- * field (both are ignored) */
+ /* Keep a copy around for posterity's sake (and error msgs) */
+ strcpy(buf1, buf);
+
+ /* Grab the ID field */
+ s=p;
p = strchr( p, ':');
+ if ( p != NULL || *(p+1) != '\0' ) {
+ *p='\0';
+ ++p;
+ }
/* Now peal off the process field from the end
* of the string */
q = strrchr( p, ':');
if ( q == NULL || *(q+1) == '\0' ) {
- fprintf(stderr, "Bad inittab entry: %s\n", buf);
+ fprintf(stderr, "Bad inittab entry: %s\n", buf1);
continue;
} else {
*q='\0';
/* Now peal off the action field */
r = strrchr( p, ':');
if ( r == NULL || *(r+1) == '\0') {
- fprintf(stderr, "Bad inittab entry: %s\n", buf);
+ fprintf(stderr, "Bad inittab entry: %s\n", buf1);
continue;
} else {
++r;
a = actions;
while (a->name != 0) {
if (strcmp(a->name, r) == 0) {
- new_initAction( a, q, NULL);
+ new_initAction( a, q, s);
foundIt=TRUE;
}
a++;
continue;
else {
/* Choke on an unknown action */
- fprintf(stderr, "Bad inittab entry: %s\n", buf);
+ fprintf(stderr, "Bad inittab entry: %s\n", buf1);
}
}
return;
+#endif
}
-
extern int init_main(int argc, char **argv)
{
initAction *a;
new_initAction( &(actions[3]), SHELL, console);
} else {
/* 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();
}