[PATCH] vmcore-dmesg: print white-space characters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Some sort of space like "\t" "\n" are used in kernel log. But we treat
them as non-printables and output "\x20%x" for each non-printable. So
let's fix it.

Signed-off-by: WANG Chao <chaowang at redhat.com>
---
 vmcore-dmesg/vmcore-dmesg.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c
index df14c89..0345660 100644
--- a/vmcore-dmesg/vmcore-dmesg.c
+++ b/vmcore-dmesg/vmcore-dmesg.c
@@ -16,6 +16,7 @@
 #include <elf.h>
 #include <stdbool.h>
 #include <inttypes.h>
+#include <ctype.h>
 
 /* The 32bit and 64bit note headers make it clear we don't care */
 typedef Elf32_Nhdr Elf_Nhdr;
@@ -668,7 +669,7 @@ static void dump_dmesg_structured(int fd)
 		for (i = 0; i < text_len; i++) {
 			unsigned char c = log_text(msg)[i];
 
-			if (c < ' ' || c >= 128)
+			if (!isprint(c) && !isspace(c))
 				len += sprintf(out_buf + len, "\\x%02x", c);
 			else
 				out_buf[len++] = c;
-- 
1.8.4.2




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux