]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
fix: line-buffer log output to /dev/kmsg
authorDaniel Hast <hast.daniel@protonmail.com>
Fri, 31 Oct 2025 13:06:17 +0000 (09:06 -0400)
committerBenjamin Drung <bdrung@ubuntu.com>
Fri, 31 Oct 2025 16:56:38 +0000 (17:56 +0100)
/dev/kmsg is only designed to accept single lines at a time, and
therefore has a relatively small message size limit. This means we need
to line-buffer the output of awk (and prepend the message level prefix
to each line rather than just the first).

Signed-off-by: Daniel Hast <hast.daniel@protonmail.com>
dracut-logger.sh

index 1c6a7484df9f8c713925f99771937cf971920aef..81fe2726b710cb04ea987805a2e9858d47ec5e52 100644 (file)
@@ -436,8 +436,9 @@ _do_dlog_batch_kmsglog() {
     local kmsg_lvlc
     if ((lvl <= kmsgloglvl)); then
         kmsg_lvlc="$(_dlvl2syslvl "$lvl")" || return 1
-        awk -v lvlc="${kmsg_lvlc}" -v prefix="dracut[$$] " \
-            '{ if (NR==1) printf "<%s>", lvlc; print prefix $0 }' > /dev/kmsg
+        # /dev/kmsg is designed to only accept single lines at a time, so the
+        # output of awk has to be line-buffered.
+        awk -v prefix="<${kmsg_lvlc}>dracut[$$] " '{ print prefix $0; fflush() }' > /dev/kmsg
     else
         cat > /dev/null
     fi