From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mx1.redhat.com ([209.132.183.28]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZrLS3-00017w-IZ for kexec@lists.infradead.org; Wed, 28 Oct 2015 07:47:20 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 954918E240 for ; Wed, 28 Oct 2015 07:46:58 +0000 (UTC) From: Dangyi Liu Subject: [PATCH] vmcore-dmesg: Collect full dmesg regardless of logged_chars Date: Wed, 28 Oct 2015 15:46:49 +0800 Message-Id: <1446018409-11183-1-git-send-email-dliu@redhat.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "kexec" Errors-To: kexec-bounces+dwmw2=infradead.org@lists.infradead.org To: kexec@lists.infradead.org Cc: Dangyi Liu logged_chars would be set to 0 by `dmesg -c`, but full dmesg is useful for debugging. 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, as the same logic as crash utility is using. Signed-off-by: Dangyi Liu --- vmcore-dmesg/vmcore-dmesg.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c index f47ee11..134a4ef 100644 --- a/vmcore-dmesg/vmcore-dmesg.c +++ b/vmcore-dmesg/vmcore-dmesg.c @@ -540,6 +540,12 @@ static void dump_dmesg_legacy(int fd) exit(53); } + /* + * To collect full dmesg including the part before `dmesg -c` is useful for + * later debugging. Use same logic as what crash utility is using. + */ + 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 _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec