[Toybox] [PATCH] dmesg: fix multi-line messages

Rob Landley rob at landley.net
Mon Mar 2 12:05:40 PST 2020


On 3/1/20 7:49 AM, Ju Hyung Park wrote:
> A single printk() can contain multiple lines via multiple '\n's,
> and toybox just spits it out to a single line with '\x0a' as the delimiter.
> 
> Fix it.
> 
> Test:
> sh -c "printf 'line a\nline b'" > /dev/kmsg

I'm not sure what the sh -c wrapper accomplishes here? Other than adding the \n
on the end which you can just put in the printf arguments? (If you _don't_,
kmesg apparently waits for more input before flushing the line to dmesg? Weird.)

Anyway, I did sudo /bin/bash and then
# printf 'line a\nline b\n' > /dev/kmsg
# dmesg | tail -n 4
[2345516.970681] line a
[2345516.970685] line b
[2345537.210346] line a
[2345537.210349] line b

I'm not sure where you're getting the \x0a from but it's not happening on my
devuan 2.0 system? Hmmm...

# printf 'line a\\x0aline b\n' > /dev/kmsg
# dmesg | tail -n 1
[2345900.170108] line a\x0aline b

The util-linux dmesg isn't parsing "\x0a" as a magic sequence, that I can tell?

How do I reproduce the problem you're seeing?

Rob



More information about the Toybox mailing list