* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
+#include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/reboot.h>
-#include "busybox.h"
#include "init_shared.h"
/* Static variables */
static struct init_action *init_action_list = NULL;
-static char console[CONSOLE_BUFF_SIZE] = _PATH_CONSOLE;
+static char console[CONSOLE_BUFF_SIZE] = CONSOLE_DEV;
#ifndef CONFIG_SYSLOGD
static char *log_console = VC_5;
#endif
+#if !ENABLE_DEBUG_INIT
static sig_atomic_t got_cont = 0;
+#endif
enum {
LOG = 0x1,
#endif
#ifndef RB_HALT_SYSTEM
- RB_HALT_SYSTEM = 0xcdef0123,
+ RB_HALT_SYSTEM = 0xcdef0123, /* FIXME: this overflows enum */
RB_ENABLE_CAD = 0x89abcdef,
RB_DISABLE_CAD = 0,
RB_POWER_OFF = 0x4321fedc,
/* Function prototypes */
static void delete_init_action(struct init_action *a);
static int waitfor(const struct init_action *a, pid_t pid);
+#if !ENABLE_DEBUG_INIT
static void shutdown_signal(int sig);
-
+#endif
static void loop_forever(void)
{
#endif
if (device & CONSOLE) {
- int fd = device_open(_PATH_CONSOLE,
+ int fd = device_open(CONSOLE_DEV,
O_WRONLY | O_NOCTTY | O_NONBLOCK);
/* Always send console messages to /dev/console so people will see them. */
if (fd >= 0) {
/* this is linux virtual tty */
snprintf(console, sizeof(console) - 1, VC_FORMAT, vt.v_active);
} else {
- safe_strncpy(console, _PATH_CONSOLE, sizeof(console));
+ safe_strncpy(console, CONSOLE_DEV, sizeof(console));
tried++;
}
}
while ((fd = open(console, O_RDONLY | O_NONBLOCK)) < 0 && tried < 2) {
/* Can't open selected console -- try
logical system console and VT_MASTER */
- safe_strncpy(console, (tried == 0 ? _PATH_CONSOLE : CURRENT_VC),
+ safe_strncpy(console, (tried == 0 ? CONSOLE_DEV : CURRENT_VC),
sizeof(console));
tried++;
}
}
/* Open the new terminal device */
-static void open_new_terminal(const char *device, char fail) {
+static void open_new_terminal(const char * const device, const int fail) {
struct stat sb;
if ((device_open(device, O_RDWR)) < 0) {
if (fail)
_exit(1);
/* else */
+#if !ENABLE_DEBUG_INIT
shutdown_signal(SIGUSR1);
+#else
+ _exit(2);
+#endif
}
}