summaryrefslogtreecommitdiff
path: root/init/init.c
diff options
context:
space:
mode:
authorJeremie Koenig2010-05-27 15:38:44 +0200
committerDenys Vlasenko2010-07-19 00:45:51 +0200
commit714674e4da3d92c5dd14e00ab30794a895b91eb4 (patch)
tree0d27bc73f1f2fe0175c5fc948451b86c52f9bb90 /init/init.c
parentf812eace1863feeac64dc8af27f4ab0f98119618 (diff)
downloadbusybox-714674e4da3d92c5dd14e00ab30794a895b91eb4.zip
busybox-714674e4da3d92c5dd14e00ab30794a895b91eb4.tar.gz
init,halt: portability improvements
* make init and halt use the same RB_* constants for reboot() * conditionalize the Linux-specific code Inspired by init.init.diff from the Debian kFreeBSD patches at: http://svn.debian.org/viewsvn/d-i/people/slackydeb/kfreebsd/busybox/1.14/debian Signed-off-by: Jeremie Koenig <jk@jk.fr.eu.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'init/init.c')
-rw-r--r--init/init.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/init/init.c b/init/init.c
index 1388c75..d8bf158 100644
--- a/init/init.c
+++ b/init/init.c
@@ -12,7 +12,6 @@
#include "libbb.h"
#include <syslog.h>
#include <paths.h>
-#include <sys/reboot.h>
#include <sys/resource.h>
#ifdef __linux__
#include <linux/vt.h>
@@ -20,6 +19,7 @@
#if ENABLE_FEATURE_UTMP
# include <utmp.h> /* DEAD_PROCESS */
#endif
+#include "reboot.h" /* reboot() constants */
/* Used only for sanitizing purposes in set_sane_term() below. On systems where
* the baud rate is stored in a separate field, we can safely disable them. */
@@ -97,13 +97,6 @@ static const char *log_console = VC_5;
enum {
L_LOG = 0x1,
L_CONSOLE = 0x2,
-#ifndef RB_HALT_SYSTEM
- RB_HALT_SYSTEM = 0xcdef0123, /* FIXME: this overflows enum */
- RB_ENABLE_CAD = 0x89abcdef,
- RB_DISABLE_CAD = 0,
- RB_POWER_OFF = 0x4321fedc,
- RB_AUTOBOOT = 0x01234567,
-#endif
};
/* Print a message to the specified device.
@@ -724,10 +717,12 @@ static void restart_handler(int sig UNUSED_PARAM)
run_shutdown_and_kill_processes();
+#ifdef RB_ENABLE_CAD
/* Allow Ctrl-Alt-Del to reboot the system.
* This is how kernel sets it up for init, we follow suit.
*/
reboot(RB_ENABLE_CAD); /* misnomer */
+#endif
if (open_stdio_to_tty(a->terminal)) {
dbg_message(L_CONSOLE, "Trying to re-exec %s", a->command);
@@ -870,9 +865,11 @@ int init_main(int argc UNUSED_PARAM, char **argv)
) {
bb_show_usage();
}
+#ifdef RB_DISABLE_CAD
/* Turn off rebooting via CTL-ALT-DEL - we get a
* SIGINT on CAD so we can shut things down gracefully... */
reboot(RB_DISABLE_CAD); /* misnomer */
+#endif
}
/* Figure out where the default console should be */
@@ -895,6 +892,8 @@ int init_main(int argc UNUSED_PARAM, char **argv)
message(L_CONSOLE | L_LOG, "init started: %s", bb_banner);
#endif
+/* struct sysinfo is linux-specific */
+#ifdef __linux__
/* Make sure there is enough memory to do something useful. */
if (ENABLE_SWAPONOFF) {
struct sysinfo info;
@@ -910,6 +909,7 @@ int init_main(int argc UNUSED_PARAM, char **argv)
run_actions(SYSINIT); /* wait and removing */
}
}
+#endif
/* Check if we are supposed to be in single user mode */
if (argv[1]