busybox-1.1.3-watchdog_reboot.patch: This patch will enable systems to reboot which can't reboot in the "normal" way. It uses the system watchdog timer with a minimal timeout of 1 sec to cause a reboot. The normal shutdown process is not influenced by it. Author: Tobias Simon diff --exclude CVS -uNr busybox-1.1.3/init/Config.in busybox-1.1.3.modified/init/Config.in --- busybox-1.1.3/init/Config.in 2006-03-22 22:16:25.000000000 +0100 +++ busybox-1.1.3.modified/init/Config.in 2007-01-08 11:43:00.000000000 +0100 @@ -65,6 +65,14 @@ help Stop all processes and either halt, reboot, or power off the system. +config CONFIG_WATCHDOG_REBOOT + bool "watchdog timer reboot" + depends on CONFIG_HALT + default n + help + Thix fix enables rebooting systems for which the normal reboot does not work + using the watchdog timer in /dev/misc/watchdog. + config CONFIG_MESG bool "mesg" default y diff --exclude CVS -uNr busybox-1.1.3/init/init.c busybox-1.1.3.modified/init/init.c --- busybox-1.1.3/init/init.c 2006-03-22 22:16:25.000000000 +0100 +++ busybox-1.1.3.modified/init/init.c 2007-01-08 11:45:02.000000000 +0100 @@ -29,8 +29,15 @@ #include #include #include + #include "busybox.h" +#ifdef CONFIG_WATCHDOG_REBOOT +#include +#include +#endif /* CONFIG_WATCHDOG_REBOOT */ + + #include "init_shared.h" @@ -647,6 +654,20 @@ * linux/kernel/sys.c, which can cause the machine to panic when * the init process is killed.... */ if ((pid = fork()) == 0) { +#ifdef CONFIG_WATCHDOG_REBOOT + if (magic == RB_AUTOBOOT) { + int fd = open("/dev/misc/watchdog", O_WRONLY); + if (fd < 0) { + message(CONSOLE | LOG, "could not reboot: please enable watchdog support in the kernel."); + } + else { + /* reboot in a second: */ + unsigned long timeout = 1; + ioctl(fd, WDIOC_SETTIMEOUT, &timeout); + close(fd); + } + } +#endif /* CONFIG_WATCHDOG_REBOOT */ reboot(magic); _exit(0); }