[PATCH v3 2/7] log: adjust indent and line breaks for log -s

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

 



Signed-off-by: Shogo Matsumoto <shogo.matsumoto@xxxxxxxxxxx>
---
 kernel.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/kernel.c b/kernel.c
index 461a5f2..57fe355 100644
--- a/kernel.c
+++ b/kernel.c
@@ -11553,6 +11553,8 @@ dump_audit(void)
 		error(INFO, "kernel audit log is empty\n");
 }
 
+#define PRINTK_SAFE_SEQ_BUF_INDENT 2
+
 static void
 __dump_printk_safe_seq_buf(char *buf_name, int msg_flags)
 {
@@ -11591,27 +11593,44 @@ __dump_printk_safe_seq_buf(char *buf_name, int msg_flags)
 		if (len > 0) {
 			int i, n;
 			char *p;
+			bool start_of_line;
 
 			readmem(buffer_addr + per_cpu_offset, KVADDR,
 				buffer, buffer_size,
 				"printk_safe_seq_buf buffer", FAULT_ON_ERROR);
 
+			start_of_line = true;
 			n = (len <= buffer_size) ? len : buffer_size;
 			for (i = 0, p = buffer; i < n; i++, p++) {
+				bool sol = start_of_line;
+				start_of_line = false;
 				if (*p == 0x1) { //SOH
 					i++; p++;
+
+					if (!sol)
+						fprintf(fp, "\n");
+
+					fprintf(fp, space(PRINTK_SAFE_SEQ_BUF_INDENT));
+
 					continue;
 				} else {
+					if (sol)
+						fprintf(fp, "%s", space(PRINTK_SAFE_SEQ_BUF_INDENT));
+
 					if (isprint(*p) || isspace(*p)) {
 						fputc(*p, fp);
+						if (*p == '\n')
+							start_of_line = true;
 					} else {
 						fputc('.', fp);
 					}
 				}
 			}
+			if (!start_of_line)
+				fputc('\n', fp);
 			fputc('\n', fp);
 		} else {
-			fprintf(fp, "(empty)\n\n");
+			fprintf(fp, "%s(empty)\n\n", space(PRINTK_SAFE_SEQ_BUF_INDENT));
 		}
 	}
 	FREEBUF(buffer);
-- 
2.29.2


--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/crash-utility




[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux