OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: Questions about warm reboot

From: Joachim Schipper (j.schippermath.uu.nl)
Date: Sat Aug 04 2007 - 11:41:51 CDT


On Fri, Aug 03, 2007 at 11:23:09AM -0400, Tom Roeder wrote:
> Hi OpenBSD tech,
>
> I have a question about warm reboot on the i386 under OpenBSD, and I
> hope that this is the right forum to ask it in.
<snip: 'warmer' reboots>
> The second, related question: I have been looking for ways to perform a
> reboot that is distinguishable from a reboot from momentary power
> failure (guaranteed to be a cold reboot). Asserting the INIT pin,
> above, would suffice, since some state is preserved across the reboot
> that wouldn't be preserved across a power failure. Do any of you know
> any other reboot operation that can be reliably distinguished from
> (re)boot from power failure under OpenBSD?

Tobias' suggestion of using nvram is cool, but why does the following
not suffice:

/etc/rc.local.conf:
if [ -e /shutdown_ok ]; then
    rm /shutdown_ok;
else
    echo 'Host was not properly shut down - back up now' | \
      mail -s 'UNCLEAN SHUTDOWN' root;
fi
...

/etc/rc.shutdown:
...
touch /shutdown_ok

Granted, this scheme fails if the system fails in between the kernel
finishing device detection and the system starting /etc/rc.local.conf -
but would that be an actual problem? And if so, couldn't it be fixed by
hacking on /etc/rc instead of stuffing undocumented values in
undocumented places? I'd rather tangle with sh than the BIOS... and this
scheme has the advantage of catching panics as well as power cuts. (Or
disadvantage, depending on how you look at it.)

                Joachim

--
TFMotD: lock, simple_lock_init, simple_lock, simple_lock_try,
simple_unlock, lockinit, lockmgr, lockstatus, lockmgr_printinfo (9) -
kernel lock functions