I've attached a patch, repeated here, to ticket #5516 which fixes the issue there, which is that it is impossible to enter failsafe mode from the serial console because the stated 'Enter CTRL-C to enter failsafe mode' doesn't work.
The fact is that CTRL-C to enter failsafe can't work because SIGINT is not generated by Ctrl-C while on /dev/console in single user mode in Linux. Ever. That is because there is no job control on /dev/console in single user mode. It's just a fact of life. Needs testing to ensure that reset button entry of failsafe still works (SIGUSR1) and that other means of generating SIGINT still enter failsafe mode. Also adds a 3rd_party failsafe script option which is useful for service providers who want to use OpenWRT and have special non-generic customization needs. Like the project I'm working on. And finally; would it be possible to get svn commit access and what are the policies for using it (I will do my best not to step on anyone's toes or break anything, for instance). I think Florian and Jo will vouch for me, but I haven't asked them yet. I do have commit access to LuCI's svn thanks to Jo, already. -- And that's my crabbing done for the day. Got it out of the way early, now I have the rest of the afternoon to sniff fragrant tea-roses or strangle cute bunnies or something. -- Michael Devore GnuPG Key Fingerprint 86 F5 81 A5 D4 2E 1F 1C http://gnupg.org The C Shore (Daniel Dickinson's Website) http://www.bmts.com/~cshore
Index: package/base-files/files/etc/preinit =================================================================== --- package/base-files/files/etc/preinit (revision 17031) +++ package/base-files/files/etc/preinit (working copy) @@ -1,6 +1,6 @@ #!/bin/sh # Copyright (C) 2006 OpenWrt.org -export PATH=/bin:/sbin:/usr/bin:/usr/sbin +export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin . /etc/diag.sh failsafe_ip() { @@ -8,12 +8,14 @@ } failsafe() { + echo "- enter failsafe -" [ -n "$ifname" ] && grep "$ifname" /proc/net/dev >/dev/null && { failsafe_ip netmsg 192.168.1.255 "Entering Failsafe!" telnetd -l /bin/login.sh <> /dev/null 2>&1 } lock /tmp/.failsafe + [ -x /sbin/3rdparty_failsafe ] && /sbin/3rdparty_failsafe ash --login } @@ -62,9 +62,10 @@ exec <$M0 >$M1 2>&0 echo "- preinit -" -echo "Press CTRL-C for failsafe" -trap 'FAILSAFE=true' INT -trap 'FAILSAFE=true' USR1 +trap 'echo "1" >/tmp/.failsafe-true; lock -u /tmp/.wait-failsafe ; rm -f /tmp/.wait-failsafe' INT +trap 'echo "1" >/tmp/.failsafe-true; lock -u /tmp/.wait-failsafe ; rm -f /tmp/.wait-failsafe' USR1 + [ -e /etc/preinit.arch ] && . /etc/preinit.arch set_state preinit echo "$HOTPLUG" > /proc/sys/kernel/hotplug + @@ -68,7 +68,56 @@ +TIMEOUT="$(cat /etc/preinit.timeout)" + +[ -n "$TIMEOUT" ] || TIMEOUT=1 +TIMEOUT="${TIMEOUT%%\ *}" +[ $TIMEOUT -ge 1 ] || TIMEOUT=1 + +TIMER=$TIMEOUT +lock /tmp/.wait-failsafe +{ + while [ $TIMER -gt 0 ]; do + echo "$TIMER" >/tmp/.failsafe-wait-sec + TIMER=$(($TIMER - 1)) + sleep 1 + done + lock -u /tmp/.wait-failsafe + rm -f /tmp/.wait-failsafe +} & + +if [ "$M0" = "/dev/console" ]; then + echo "Press f<ENTER> for failsafe" + # if we're on the console we wait for input + { + while [ -r /tmp/.wait-failsafe ]; do + TIMER="$(cat /tmp/.failsafe-wait-sec)" + + [ -n "$TIMER" ] || TIMER=1 + TIMER="${TIMER%%\ *}" + [ $TIMER -ge 1 ] || TIMER=1 + { + read -t "$TIMER" DOFAILSAFE + if [ "$DOFAILSAFE" = "f" ]; then + echo "1" >/tmp/.failsafe-true + lock -u /tmp/.wait-failsafe + rm -f /tmp/.wait-failsafe + fi + } + done + } +else + echo "Waiting for external event (e.g. reset button) for failsafe" + # if we're not on the console we sleep in case reset is pressed +fi +lock -w /tmp/.wait-failsafe + +[ "$(cat /tmp/.failsafe-true)" = "1" ] && FAILSAFE=true export FAILSAFE + eval ${FAILSAFE:+failsafe} lock -w /tmp/.failsafe +echo "- regular boot -" +echo "- mount -" + Index: package/base-files/Makefile =================================================================== --- package/base-files/Makefile (revision 17031) +++ package/base-files/Makefile (working copy) @@ -56,6 +56,7 @@ /etc/profile /etc/shells /etc/sysctl.conf +/etc/config/rootfsflash $(call $(TARGET)/conffiles) endef @@ -140,6 +140,10 @@ $(call Build/Compile/Default) endef +define ImageConfigOptions + echo "$(if $(CONFIG_TARGET_PREINIT_TIMEOUT),$(CONFIG_TARGET_PREINIT_TIMEOUT),5)" >$(1)/etc/preinit.timeout +endef + define Package/base-files$(TARGET)/install $(CP) ./files/* $(1)/ if [ -d $(GENERIC_PLATFORM_DIR)/base-files/. ]; then \ @@ -192,7 +210,8 @@ rm -f $(1)/var ln -sf /tmp $(1)/var mkdir -p $(1)/etc - ln -sf /tmp/resolv.conf /tmp/fstab /tmp/TZ $(1)/etc/ + ln -sf /tmp/resolv.conf /tmp/fstab /tmp/TZ $(1)/etc/ + $(call ImageConfigOptions,$(1)) $(call Package/base-files/install-target,$(1)) for conffile in $(1)/etc/config/*; do \ if [ -f "$$$$conffile" ]; then \ Index: Config.in =================================================================== --- Config.in (revision 17031) +++ Config.in (working copy) @@ -165,6 +165,19 @@ endmenu +menuconfig IMAGEOPT + bool "Image Config Options" + default n + +config TARGET_PREINIT_TIMEOUT + int + prompt "Failsafe wait timeout" if IMAGEOPT + default 5 + help + How long to wait for failsafe mode to be entered before + continuing with a regular boot if failsafe not selected. + + menuconfig DEVEL bool "Advanced configuration options (for developers)" default n
signature.asc
Description: PGP signature
_______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel