[projects/geninitrd] add messages to dmesg about geninitrd startup and when it switches root

glen glen at pld-linux.org
Thu Jan 16 22:06:38 CET 2014


commit 2b945b6bc9e04ea15e0691fe228276297f993e8b
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Thu Jan 16 23:03:52 2014 +0200

    add messages to dmesg about geninitrd startup and when it switches root

 geninitrd | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
---
diff --git a/geninitrd b/geninitrd
index fe7e13e..44b254b 100755
--- a/geninitrd
+++ b/geninitrd
@@ -86,6 +86,25 @@ debug() {
 	[ x"$verbose" = x"-v -v" ] && msg "$*" >&3
 }
 
+# add initrd code to print to kmsg
+# @param string message
+# @param int loglevel. defaults to "6" (info)
+# Log levels can be:
+# Name		String	Meaning
+# KERN_EMERG	"0"	Emergency messages, system is about to crash or is unstable
+# KERN_ALERT	"1"	Something bad happened and action must be taken immediately
+# KERN_CRIT	"2"	A critical condition occurred like a serious hardware/software failure
+# KERN_ERR	"3"	An error condition, often used by drivers to indicate difficulties with the hardware
+# KERN_WARNING	"4"	A warning, meaning nothing serious by itself but might indicate problems
+# KERN_NOTICE	"5"	Nothing serious, but notably nevertheless. Often used to report security events.
+# KERN_INFO	"6"	Informational message e.g. startup information at driver initialization
+# KERN_DEBUG	"7"	Debug messages
+# KERN_CONT	"c"	"continued" line of log printout (only done after a line that had no enclosing \n)
+kmsg() {
+	local msg="$1" level=${2:-6}
+	echo "echo '<$level>$msg' > /dev/kmsg" | add_linuxrc
+}
+
 # aborts program abnormally
 die() {
 	local rc=${2:-1}
@@ -956,8 +975,11 @@ initrd_gen_initramfs_switchroot() {
 			echo "Last 20 lines of dmesg:"
 			dmesg | tail -n 20
 		fi
+
 	EOF
 
+	kmsg "geninitrd/$VERSION switching root"
+
 	umount_all
 	busybox_applet switch_root usleep
 	add_linuxrc <<-'EOF'
@@ -1423,6 +1445,7 @@ mknod -m 666 "$DESTDIR/dev/null" c 1 3
 mknod -m 666 "$DESTDIR/dev/zero" c 1 5
 mknod -m 666 "$DESTDIR/dev/random" c 1 8
 mknod -m 666 "$DESTDIR/dev/urandom" c 1 9
+mknod -m 644 "$DESTDIR/dev/kmsg" c 1 11
 
 inst_exec $busybox /bin/busybox
 ln -s busybox $DESTDIR/bin/sh
@@ -1436,6 +1459,9 @@ add_linuxrc <<EOF
 
 EOF
 mount_proc
+
+kmsg "geninitrd/$VERSION starting"
+
 add_linuxrc <<-EOF
 	# builtin defaults from geninitrd
 	ROOT=$rootdev
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/geninitrd.git/commitdiff/2b945b6bc9e04ea15e0691fe228276297f993e8b



More information about the pld-cvs-commit mailing list