Log error messages to /dev/kmsg
authorPhilippe Seewer <philippe.seewer@bfh.ch>
Tue, 16 Jun 2009 16:03:59 +0000 (18:03 +0200)
committerPhilippe Seewer <philippe.seewer@bfh.ch>
Wed, 17 Jun 2009 06:37:40 +0000 (08:37 +0200)
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.

modules.d/99base/dracut-lib
modules.d/99base/init

index 336b235..9cd515b 100644 (file)
@@ -22,8 +22,8 @@ source_all() {
 }
 
 die() {
-    printf "FATAL: $1\n"
-    printf "Refusing to continue\n"
+    printf "<1>FATAL: $1\n" > /dev/kmsg
+    printf "<1>Refusing to continue\n" > /dev/kmsg
     exit 1
 }
 
index 8a5eac0..7ecf03a 100755 (executable)
@@ -7,11 +7,11 @@
 
 emergency_shell()
 {
+    source_all emergency
     echo ; echo
     echo "Bug in initramfs /init detected. Dropping to a shell. Good luck!"
     echo
     sh -i
-    source_all emergency
 }
 
 export PATH=/sbin:/bin:/usr/sbin:/usr/bin
@@ -34,6 +34,7 @@ getarg rdinitdebug && set -x
 mknod /dev/null c 1 3
 mknod /dev/ptmx c 5 2
 mknod /dev/console c 5 1
+mknod /dev/kmsg c 1 11
 mkdir /dev/pts
 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
 source_all cmdline
 
-if [ -z "$rootok" -a -n "${root%%error:*}" ]; then
-    root="error: No handler for 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
+[ -z "$root" ] && die "No or empty root= argument"
+[ -z "$rootok" ] && die "Don't know how to handle 'root=$root'"
 
 # Network root scripts may need updated root= options,
 # so deposit them where they can see them (udev purges the env)