aboutsummaryrefslogtreecommitdiff
path: root/init/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'init/init.c')
-rw-r--r--init/init.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/init/init.c b/init/init.c
index 928f84b91..10cb015dd 100644
--- a/init/init.c
+++ b/init/init.c
@@ -9,11 +9,6 @@
9 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 9 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
10 */ 10 */
11 11
12/* Turn this on to disable all the dangerous
13 rebooting stuff when debugging.
14#define DEBUG_INIT
15*/
16
17#include <stdio.h> 12#include <stdio.h>
18#include <stdlib.h> 13#include <stdlib.h>
19#include <errno.h> 14#include <errno.h>
@@ -191,13 +186,13 @@ static void loop_forever(void)
191 186
192/* Print a message to the specified device. 187/* Print a message to the specified device.
193 * Device may be bitwise-or'd from LOG | CONSOLE */ 188 * Device may be bitwise-or'd from LOG | CONSOLE */
194#ifndef DEBUG_INIT 189#if ENABLE_DEBUG_INIT
195static inline void messageD(int ATTRIBUTE_UNUSED device, 190#define messageD message
191#else
192static inline void messageD(int ATTRIBUTE_UNUSED device,
196 const char ATTRIBUTE_UNUSED *fmt, ...) 193 const char ATTRIBUTE_UNUSED *fmt, ...)
197{ 194{
198} 195}
199#else
200#define messageD message
201#endif 196#endif
202static void message(int device, const char *fmt, ...) 197static void message(int device, const char *fmt, ...)
203 __attribute__ ((format(printf, 2, 3))); 198 __attribute__ ((format(printf, 2, 3)));
@@ -253,7 +248,7 @@ static void message(int device, const char *fmt, ...)
253 if (fd >= 0) { 248 if (fd >= 0) {
254 bb_full_write(fd, msg, l); 249 bb_full_write(fd, msg, l);
255 close(fd); 250 close(fd);
256#ifdef DEBUG_INIT 251#if ENABLE_DEBUG_INIT
257 /* all descriptors may be closed */ 252 /* all descriptors may be closed */
258 } else { 253 } else {
259 bb_error_msg("Bummer, can't print: "); 254 bb_error_msg("Bummer, can't print: ");
@@ -655,7 +650,7 @@ static void run_actions(int action)
655 } 650 }
656} 651}
657 652
658#ifndef DEBUG_INIT 653#if !ENABLE_DEBUG_INIT
659static void init_reboot(unsigned long magic) 654static void init_reboot(unsigned long magic)
660{ 655{
661 pid_t pid; 656 pid_t pid;
@@ -816,7 +811,7 @@ static void cont_handler(int sig ATTRIBUTE_UNUSED)
816 got_cont = 1; 811 got_cont = 1;
817} 812}
818 813
819#endif /* ! DEBUG_INIT */ 814#endif /* ! ENABLE_DEBUG_INIT */
820 815
821static void new_init_action(int action, const char *command, const char *cons) 816static void new_init_action(int action, const char *command, const char *cons)
822{ 817{
@@ -1026,7 +1021,7 @@ int init_main(int argc, char **argv)
1026 if (argc > 1 && !strcmp(argv[1], "-q")) { 1021 if (argc > 1 && !strcmp(argv[1], "-q")) {
1027 return kill(1,SIGHUP); 1022 return kill(1,SIGHUP);
1028 } 1023 }
1029#ifndef DEBUG_INIT 1024#if !ENABLE_DEBUG_INIT
1030 /* Expect to be invoked as init with PID=1 or be invoked as linuxrc */ 1025 /* Expect to be invoked as init with PID=1 or be invoked as linuxrc */
1031 if (getpid() != 1 && 1026 if (getpid() != 1 &&
1032 (!ENABLE_FEATURE_INITRD || !strstr(bb_applet_name, "linuxrc"))) 1027 (!ENABLE_FEATURE_INITRD || !strstr(bb_applet_name, "linuxrc")))