initrd: Spawn an emergency shell when something goes wrong

set -e allows to exit if a command fails. We install a trap and execute
emergency_shell() when either the init script exits or when ctrl-c is
typed (say if we are stuck somewhere and we want to debug it).

(From OE-Core rev: ae5e2bd994e3f60d3803ab56e6ed34d08fbc56f0)

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Damien Lespiau 2012-09-27 15:20:50 +01:00 committed by Richard Purdie
parent 6d3d4baeeb
commit ffb6928f57
1 changed files with 11 additions and 0 deletions

View File

@ -2,6 +2,17 @@
PATH=/sbin:/bin:/usr/sbin:/usr/bin
emergency_shell()
{
echo "Bug in initramfs /init detected. Dropping to a shell. Good luck!"
echo
sh
}
trap "emergency_shell" 0 2
# exit immediately if a command fails
set -e
ROOT_MOUNT="/rootfs/"
ROOT_IMAGE="rootfs.img"
MOUNT="/bin/mount"