To keep the output of makedumpfile --dump-dmesg being consistent with dmesg utility, this patch introduces two changes: 1. If a character is non-printable, print its hex value ("\\x%02x") 2. No special handling for "\n" ("\n" -> ".") Signed-off-by: WANG Chao <chaowang at redhat.com> --- makedumpfile.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/makedumpfile.c b/makedumpfile.c index ef08d91..73467ab 100644 --- a/makedumpfile.c +++ b/makedumpfile.c @@ -3848,12 +3848,10 @@ dump_log_entry(char *logptr, int fp) sprintf(buf, "[%5lld.%06ld] ", nanos, rem/1000); for (i = 0, p = msg; i < text_len; i++, p++) { - if (*p == '\n') - sprintf(buf, "%s.", buf); - else if (isprint(*p) || isspace(*p)) + if (isprint(*p) || isspace(*p)) sprintf(buf, "%s%c", buf, *p); else - sprintf(buf, "%s.", buf); + sprintf(buf, "%s\\x%02x", buf, *p); } sprintf(buf, "%s\n", buf); -- 1.8.4.2