[BusyBox] Init utility options are too general
Scott Murray
scottm at somanetworks.com
Wed Jul 16 21:10:52 UTC 2003
On Wed, 16 Jul 2003, Scott Murray wrote:
> On Wed, 16 Jul 2003, Jonas Holmberg wrote:
>
> > > I don't believe we are the only embedded software company that writes
> > > our own init (which we do as an msh shell script), so this is
> > > likely to
> > > upset more than just us...
> >
> > Yep, that's true. We also need reboot without bb-init.
>
> I've got a patch against the 0.60.5 stable version that makes the
> reboot/halt/poweroff commands still work in the absence of the BB init
> that I'll try to get ported to 1.0.0-pre1 later today.
I'm attaching an updated version of my reboot/halt/poweroff without init
patch against 1.00-pre1. I've just tested it in my initial ramdisk
environment that requires this feature, and it seems to work fine. Erik,
any chance you could apply this?
Scott
--
Scott Murray
SOMA Networks, Inc.
Toronto, Ontario
e-mail: scottm at somanetworks.com
-------------- next part --------------
diff -Nur --exclude=RCS --exclude=CVS --exclude=SCCS --exclude=BitKeeper --exclude=ChangeSet --exclude=SOMA /ws/scottm/pure-dev/busybox/init/Config.in busybox/init/Config.in
--- /ws/scottm/pure-dev/busybox/init/Config.in 2003-07-16 13:28:46.000000000 -0400
+++ busybox/init/Config.in 2003-07-16 15:02:49.000000000 -0400
@@ -43,25 +43,21 @@
Prevent init from logging some messages to the console
during boot.
-# Some apps that are meaningless without BusyBox running as init
config CONFIG_HALT
bool "halt"
default y
- depends on CONFIG_INIT
help
'halt' tells the kernel to stop all processes and halt the system.
config CONFIG_POWEROFF
bool "poweroff"
default y
- depends on CONFIG_INIT
help
Stop all processes and (try to) power off the system.
config CONFIG_REBOOT
bool "reboot"
default y
- depends on CONFIG_INIT
help
Stop all processes and reboot the system.
diff -Nur --exclude=RCS --exclude=CVS --exclude=SCCS --exclude=BitKeeper --exclude=ChangeSet --exclude=SOMA /ws/scottm/pure-dev/busybox/init/halt.c busybox/init/halt.c
--- /ws/scottm/pure-dev/busybox/init/halt.c 2003-07-16 13:28:46.000000000 -0400
+++ busybox/init/halt.c 2003-07-16 15:07:49.000000000 -0400
@@ -28,5 +28,9 @@
extern int halt_main(int argc, char **argv)
{
+#ifdef CONFIG_INIT
return kill_init(SIGUSR1);
+#else
+ return bb_reboot(RB_HALT_SYSTEM);
+#endif
}
diff -Nur --exclude=RCS --exclude=CVS --exclude=SCCS --exclude=BitKeeper --exclude=ChangeSet --exclude=SOMA /ws/scottm/pure-dev/busybox/init/init_shared.h busybox/init/init_shared.h
--- /ws/scottm/pure-dev/busybox/init/init_shared.h 2003-07-16 13:28:46.000000000 -0400
+++ busybox/init/init_shared.h 2003-07-16 15:04:40.000000000 -0400
@@ -1 +1,17 @@
+/* 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 */
+
extern int kill_init(int sig);
diff -Nur --exclude=RCS --exclude=CVS --exclude=SCCS --exclude=BitKeeper --exclude=ChangeSet --exclude=SOMA /ws/scottm/pure-dev/busybox/init/poweroff.c busybox/init/poweroff.c
--- /ws/scottm/pure-dev/busybox/init/poweroff.c 2003-07-16 13:28:46.000000000 -0400
+++ busybox/init/poweroff.c 2003-07-16 15:08:00.000000000 -0400
@@ -23,8 +23,14 @@
#include "busybox.h"
#include <signal.h>
+#include "init_shared.h"
extern int poweroff_main(int argc, char **argv)
{
+#ifdef CONFIG_INIT
return kill_init(SIGUSR2);
+#else
+ return bb_reboot(RB_POWER_OFF);
+#endif
}
+
diff -Nur --exclude=RCS --exclude=CVS --exclude=SCCS --exclude=BitKeeper --exclude=ChangeSet --exclude=SOMA /ws/scottm/pure-dev/busybox/init/reboot.c busybox/init/reboot.c
--- /ws/scottm/pure-dev/busybox/init/reboot.c 2003-07-16 13:28:46.000000000 -0400
+++ busybox/init/reboot.c 2003-07-16 15:08:47.000000000 -0400
@@ -77,7 +77,11 @@
init_reboot(RB_AUTOBOOT);
return 0; /* Shrug */
#else
+#ifdef CONFIG_INIT
return kill_init(SIGTERM);
+#else
+ return bb_reboot(RB_AUTOBOOT);
+#endif
#endif
}
More information about the busybox
mailing list