Log error messages to /dev/kmsg

When die()'ing inside scripts that are udev run, a simple echo isn't
good, udev usually swallows that. Routing messages to /dev/kmsg
ensures they appear on screen and in addition are easily saved through
dmesg.
master
Philippe Seewer 2009-06-16 18:03:59 +02:00
parent 311a2769a0
commit 0fd1ab9d87
2 changed files with 6 additions and 13 deletions

View File

@ -22,8 +22,8 @@ source_all() {
} }


die() { die() {
printf "FATAL: $1\n" printf "<1>FATAL: $1\n" > /dev/kmsg
printf "Refusing to continue\n" printf "<1>Refusing to continue\n" > /dev/kmsg
exit 1 exit 1
} }



View File

@ -7,11 +7,11 @@


emergency_shell() emergency_shell()
{ {
source_all emergency
echo ; echo echo ; echo
echo "Bug in initramfs /init detected. Dropping to a shell. Good luck!" echo "Bug in initramfs /init detected. Dropping to a shell. Good luck!"
echo echo
sh -i sh -i
source_all emergency
} }


export PATH=/sbin:/bin:/usr/sbin:/usr/bin export PATH=/sbin:/bin:/usr/sbin:/usr/bin
@ -34,6 +34,7 @@ getarg rdinitdebug && set -x
mknod /dev/null c 1 3 mknod /dev/null c 1 3
mknod /dev/ptmx c 5 2 mknod /dev/ptmx c 5 2
mknod /dev/console c 5 1 mknod /dev/console c 5 1
mknod /dev/kmsg c 1 11
mkdir /dev/pts mkdir /dev/pts
mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts >/dev/null 2>&1 mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts >/dev/null 2>&1


@ -41,16 +42,8 @@ mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts >/dev/null 2>&1
getarg 'rdbreak=cmdline' && emergency_shell getarg 'rdbreak=cmdline' && emergency_shell
source_all cmdline source_all cmdline


if [ -z "$rootok" -a -n "${root%%error:*}" ]; then [ -z "$root" ] && die "No or empty root= argument"
root="error: No handler for root=${root}" [ -z "$rootok" ] && die "Don't know how to handle 'root=$root'"
fi

if [ -n "$root" -a -z "${root%%error:*}" ]; then
case "${root%%:*}" in
'') die "No root= option specified, and no network support" ;;
error) die "${root#error:}" ;;
esac
fi


# Network root scripts may need updated root= options, # Network root scripts may need updated root= options,
# so deposit them where they can see them (udev purges the env) # so deposit them where they can see them (udev purges the env)