diff options
author | Peter Korsgaard | 2013-01-06 00:07:17 +0100 |
---|---|---|
committer | Mike Frysinger | 2013-01-05 21:02:14 -0500 |
commit | 3917fa32dce8c887d0a87d0d2f4490f1b89b51d0 (patch) | |
tree | 37069276b1d94e05bf9c032985b7b214f4ae9eb5 /util-linux | |
parent | fb499c57525377ca579e310d2d29c867535dd2f6 (diff) | |
download | busybox-3917fa32dce8c887d0a87d0d2f4490f1b89b51d0.zip busybox-3917fa32dce8c887d0a87d0d2f4490f1b89b51d0.tar.gz |
dmesg: handle multi-char log levels
Since Linux 3.5 (7ff9554bb5: printk: convert byte-buffer to variable-length
record buffer), klog buffer can now contain log lines with multi-char
loglevel indicators (<[0-9]+>) - So we can no longer just skip 3 bytes.
Instead skip past the terminating '>' like util-linux does.
function old new delta
dmesg_main 266 280 +13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 13/0) Total: 13 bytes
Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'util-linux')
-rw-r--r-- | util-linux/dmesg.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/util-linux/dmesg.c b/util-linux/dmesg.c index 6505da5..81ba1c9 100644 --- a/util-linux/dmesg.c +++ b/util-linux/dmesg.c @@ -59,16 +59,15 @@ int dmesg_main(int argc UNUSED_PARAM, char **argv) int last = '\n'; int in = 0; - /* Skip <#> at the start of lines */ + /* Skip <[0-9]+> at the start of lines */ while (1) { if (last == '\n' && buf[in] == '<') { - in += 3; - if (in >= len) - break; + while (buf[in++] != '>' && in < len) + ; + } else { + last = buf[in++]; + putchar(last); } - last = buf[in]; - putchar(last); - in++; if (in >= len) break; } |