[BusyBox] Reboot not working?
Scott Murray
scottm at somanetworks.com
Thu Nov 8 12:15:27 UTC 2001
On Thu, 8 Nov 2001, Boris wrote:
> I should mention that im running init=/linuxrc rw. All off a ramdisk.
> ----- Original Message -----
> From: Boris
> To: busybox at busybox.net
> Sent: Thursday, November 08, 2001 12:47 PM
> Subject: [BusyBox] Reboot not working?
>
>
> I just downloaded the latest CVS of busybox and I can't seem to get
> the reboot applet to actually "reboot" my pc.Each time I run reboot it
> just comes back to the command line. Any ideas?
The reboot/halt applets in busybox normally rely on the init applet being
turned on, as they just send a signal to it to trigger the reboot/halt.
I'm attaching the patch I use against 0.60.1 to make reboot/halt call the
syscall directly if the init applet is turned off.
Erik, is there any chance you could apply this, or tell me what you'd
like cleaned up so that you'd consider applying it?
Scott
--
Scott Murray
SOMA Networks, Inc.
Toronto, Ontario
e-mail: scottm at somanetworks.com
-------------- next part --------------
diff -Nur --exclude=SCCS --exclude=BitKeeper --exclude=ChangeSet /ws/scottm/pure/busybox/busybox.h busybox/busybox.h
--- /ws/scottm/pure/busybox/busybox.h Mon Oct 22 23:32:27 2001
+++ busybox/busybox.h Wed Nov 7 17:55:19 2001
@@ -39,6 +39,22 @@
#include <features.h>
+/* Define bb_reboot for reboot related commands if init is not being used */
+#ifndef BB_INIT
+#include <linux/reboot.h>
+#if defined(__GLIBC__) || defined (__UCLIBC__)
+#include <sys/reboot.h>
+#define bb_reboot(flag) reboot(flag)
+#else
+#define bb_reboot(flag) reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, flag)
+#define RB_AUTOBOOT LINUX_REBOOT_CMD_RESTART
+#define RB_HALT_SYSTEM LINUX_REBOOT_CMD_HALT
+#endif
+#ifndef RB_POWER_OFF
+#define RB_POWER_OFF LINUX_REBOOT_CMD_POWER_OFF
+#endif
+#endif /* BB_INIT */
+
enum Location {
_BB_DIR_ROOT = 0,
diff -Nur --exclude=SCCS --exclude=BitKeeper --exclude=ChangeSet /ws/scottm/pure/busybox/halt.c busybox/halt.c
--- /ws/scottm/pure/busybox/halt.c Mon Oct 22 23:32:27 2001
+++ busybox/halt.c Wed Nov 7 17:55:19 2001
@@ -26,6 +26,7 @@
extern int halt_main(int argc, char **argv)
{
+#ifdef BB_INIT
#ifdef BB_FEATURE_LINUXRC
/* don't assume init's pid == 1 */
pid_t *pid = find_pid_by_name("init");
@@ -34,5 +35,8 @@
return(kill(*pid, SIGUSR1));
#else
return(kill(1, SIGUSR1));
+#endif
+#else
+ return(bb_reboot(RB_HALT_SYSTEM));
#endif
}
diff -Nur --exclude=SCCS --exclude=BitKeeper --exclude=ChangeSet /ws/scottm/pure/busybox/poweroff.c busybox/poweroff.c
--- /ws/scottm/pure/busybox/poweroff.c Mon Oct 22 23:32:28 2001
+++ busybox/poweroff.c Wed Nov 7 17:55:20 2001
@@ -26,6 +26,7 @@
extern int poweroff_main(int argc, char **argv)
{
+#ifdef BB_INIT
#ifdef BB_FEATURE_LINUXRC
/* don't assume init's pid == 1 */
pid_t *pid = find_pid_by_name("init");
@@ -35,4 +36,8 @@
#else
return(kill(1, SIGUSR2));
#endif
+#else
+ return(bb_reboot(RB_POWER_OFF));
+#endif
}
+
diff -Nur --exclude=SCCS --exclude=BitKeeper --exclude=ChangeSet /ws/scottm/pure/busybox/reboot.c busybox/reboot.c
--- /ws/scottm/pure/busybox/reboot.c Mon Oct 22 23:32:28 2001
+++ busybox/reboot.c Wed Nov 7 17:55:20 2001
@@ -26,6 +26,7 @@
extern int reboot_main(int argc, char **argv)
{
+#ifdef BB_INIT
#ifdef BB_FEATURE_LINUXRC
/* don't assume init's pid == 1 */
pid_t *pid = find_pid_by_name("init");
@@ -34,6 +35,9 @@
return(kill(*pid, SIGTERM));
#else
return(kill(1, SIGTERM));
+#endif
+#else
+ return(bb_reboot(RB_AUTOBOOT));
#endif
}
More information about the busybox
mailing list