[PATCH] vmcore-dmesg: do not use logged_chars as dmesg length

Dangyi Liu dliu at redhat.com
Tue Oct 27 22:38:27 PDT 2015


logged_chars would be set to 0 by `dmesg -c`, but we want to get the
full dmesg after crash. So instead of using logged_chars directly, we
calculate it by ourselves.

Now logged_chars is set to the minimum of log_end and log_buf_len, which
is coherent to how crash utility deals with dmesg length.

Signed-off-by: Dangyi Liu <dliu at redhat.com>
---
 vmcore-dmesg/vmcore-dmesg.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c
index f47ee11..ec2570f 100644
--- a/vmcore-dmesg/vmcore-dmesg.c
+++ b/vmcore-dmesg/vmcore-dmesg.c
@@ -540,6 +540,9 @@ static void dump_dmesg_legacy(int fd)
 		exit(53);
 	}
 
+	// `dmesg -c` would set logged_chars to 0, then we cannot get a full dmesg.
+	logged_chars = log_end < log_buf_len ? log_end : log_buf_len;
+
 	write_to_stdout(buf + (log_buf_len -  logged_chars), logged_chars);
 }
 
-- 
2.4.3




More information about the kexec mailing list