diff options
| -rw-r--r-- | init/init.c | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/init/init.c b/init/init.c index bca4dd7b6..118ab327a 100644 --- a/init/init.c +++ b/init/init.c | |||
| @@ -127,6 +127,12 @@ static const int RB_AUTOBOOT = 0x01234567; | |||
| 127 | //static const int MAXENV = 16; /* Number of env. vars */ | 127 | //static const int MAXENV = 16; /* Number of env. vars */ |
| 128 | static const int LOG = 0x1; | 128 | static const int LOG = 0x1; |
| 129 | static const int CONSOLE = 0x2; | 129 | static const int CONSOLE = 0x2; |
| 130 | #if defined BB_FEATURE_EXTRA_QUIET | ||
| 131 | static const int MAYBE_CONSOLE = 0x0; | ||
| 132 | #else | ||
| 133 | #define MAYBE_CONSOLE CONSOLE | ||
| 134 | #endif | ||
| 135 | |||
| 130 | 136 | ||
| 131 | /* Allowed init action types */ | 137 | /* Allowed init action types */ |
| 132 | typedef enum { | 138 | typedef enum { |
| @@ -186,6 +192,11 @@ static void loop_forever(void) | |||
| 186 | 192 | ||
| 187 | /* Print a message to the specified device. | 193 | /* Print a message to the specified device. |
| 188 | * Device may be bitwise-or'd from LOG | CONSOLE */ | 194 | * Device may be bitwise-or'd from LOG | CONSOLE */ |
| 195 | #ifdef DEBUG_INIT | ||
| 196 | static inline messageND(int device, char *fmt, ...) { } | ||
| 197 | #else | ||
| 198 | #define messageND message | ||
| 199 | #endif | ||
| 189 | static void message(int device, char *fmt, ...) | 200 | static void message(int device, char *fmt, ...) |
| 190 | __attribute__ ((format (printf, 2, 3))); | 201 | __attribute__ ((format (printf, 2, 3))); |
| 191 | static void message(int device, char *fmt, ...) | 202 | static void message(int device, char *fmt, ...) |
| @@ -539,19 +550,15 @@ static pid_t run(char *command, char *terminal, int get_enter) | |||
| 539 | * be allowed to start a shell or whatever an init script | 550 | * be allowed to start a shell or whatever an init script |
| 540 | * specifies. | 551 | * specifies. |
| 541 | */ | 552 | */ |
| 542 | #ifdef DEBUG_INIT | 553 | messageND(LOG, "Waiting for enter to start '%s' (pid %d, console %s)\n", |
| 543 | message(LOG, "Waiting for enter to start '%s' (pid %d, console %s)\n", | ||
| 544 | cmd[0], getpid(), terminal); | 554 | cmd[0], getpid(), terminal); |
| 545 | #endif | ||
| 546 | write(fileno(stdout), press_enter, sizeof(press_enter) - 1); | 555 | write(fileno(stdout), press_enter, sizeof(press_enter) - 1); |
| 547 | getc(stdin); | 556 | getc(stdin); |
| 548 | } | 557 | } |
| 549 | 558 | ||
| 550 | #ifdef DEBUG_INIT | ||
| 551 | /* Log the process name and args */ | 559 | /* Log the process name and args */ |
| 552 | message(LOG, "Starting pid %d, console %s: '%s'\n", | 560 | messageND(LOG, "Starting pid %d, console %s: '%s'\n", |
| 553 | getpid(), terminal, command); | 561 | getpid(), terminal, command); |
| 554 | #endif | ||
| 555 | 562 | ||
| 556 | #if defined CONFIG_FEATURE_INIT_COREDUMPS | 563 | #if defined CONFIG_FEATURE_INIT_COREDUMPS |
| 557 | if (stat (CORE_ENABLE_FLAG_FILE, &sb) == 0) { | 564 | if (stat (CORE_ENABLE_FLAG_FILE, &sb) == 0) { |
| @@ -937,22 +944,7 @@ extern int init_main(int argc, char **argv) | |||
| 937 | putenv("PATH="_PATH_STDPATH); | 944 | putenv("PATH="_PATH_STDPATH); |
| 938 | 945 | ||
| 939 | /* Hello world */ | 946 | /* Hello world */ |
| 940 | #ifndef DEBUG_INIT | 947 | message(MAYBE_CONSOLE|LOG, "init started: %s\n", full_version); |
| 941 | message( | ||
| 942 | #if ! defined CONFIG_FEATURE_EXTRA_QUIET | ||
| 943 | CONSOLE| | ||
| 944 | #endif | ||
| 945 | LOG, | ||
| 946 | "init started: %s\n", full_version); | ||
| 947 | #else | ||
| 948 | message( | ||
| 949 | #if ! defined CONFIG_FEATURE_EXTRA_QUIET | ||
| 950 | CONSOLE| | ||
| 951 | #endif | ||
| 952 | LOG, | ||
| 953 | "init(%d) started: %s\n", getpid(), full_version); | ||
| 954 | #endif | ||
| 955 | |||
| 956 | 948 | ||
| 957 | /* Make sure there is enough memory to do something useful. */ | 949 | /* Make sure there is enough memory to do something useful. */ |
| 958 | check_memory(); | 950 | check_memory(); |
| @@ -1032,8 +1024,7 @@ extern int init_main(int argc, char **argv) | |||
| 1032 | for (a = initActionList; a; a = a->nextPtr) { | 1024 | for (a = initActionList; a; a = a->nextPtr) { |
| 1033 | if (a->pid == wpid) { | 1025 | if (a->pid == wpid) { |
| 1034 | a->pid = 0; | 1026 | a->pid = 0; |
| 1035 | message(LOG, | 1027 | message(LOG, "Process '%s' (pid %d) exited. Scheduling it for restart.\n", |
| 1036 | "Process '%s' (pid %d) exited. Scheduling it for restart.\n", | ||
| 1037 | a->process, wpid); | 1028 | a->process, wpid); |
| 1038 | } | 1029 | } |
| 1039 | } | 1030 | } |
