public inbox for kexec@lists.infradead.org
 help / color / mirror / Atom feed
From: Vivek Goyal <vgoyal@redhat.com>
To: Simon Horman <horms@verge.net.au>,
	Kexec Mailing List <kexec@lists.infradead.org>
Cc: Taras Kondratiuk <taras.kondratiuk@linaro.org>,
	WANG Chao <chaowang@redhat.com>, Lubomir Rintel <lkundrak@v3.sk>
Subject: [PATCH] vmcore-dmesg: Handle struct log to struct printk_log renaming
Date: Thu, 22 May 2014 10:43:14 -0400	[thread overview]
Message-ID: <20140522144314.GE13647@redhat.com> (raw)

vmcore-dmesg has been failing for me for quite some time as struct log
was renamed to struct printk_log.

62e32ac printk: rename struct log to struct printk_log

This patch has been sitting in mailing list for quite some time. It
is time to repost the patch.

I took original patch of Lubomir and modified a bit to take care of
concern of hardcoded string length.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
---

Changes for v2:
  * Clarified printk_log vs. log in some comments.

 vmcore-dmesg/vmcore-dmesg.c |   53 +++++++++++++++++++++++++++++++-------------
 1 file changed, 38 insertions(+), 15 deletions(-)

Index: kexec-tools/vmcore-dmesg/vmcore-dmesg.c
===================================================================
--- kexec-tools.orig/vmcore-dmesg/vmcore-dmesg.c	2014-05-22 10:38:50.792356739 -0400
+++ kexec-tools/vmcore-dmesg/vmcore-dmesg.c	2014-05-22 10:39:12.463355316 -0400
@@ -35,10 +35,10 @@ static loff_t logged_chars_vaddr;
 static loff_t log_first_idx_vaddr;
 static loff_t log_next_idx_vaddr;
 
-/* struct log size */
+/* struct printk_log (or older log) size */
 static uint64_t log_sz;
 
-/* struct log field offsets */
+/* struct printk_log (or older log) field offsets */
 static uint64_t log_offset_ts_nsec = UINT64_MAX;
 static uint16_t log_offset_len = UINT16_MAX;
 static uint16_t log_offset_text_len = UINT16_MAX;
@@ -255,6 +255,7 @@ static void scan_vmcoreinfo(char *start,
 	char *pos, *eol;
 	char temp_buf[1024];
 	bool last_line = false;
+	char *str;
 
 #define SYMBOL(sym) {					\
 	.str = "SYMBOL(" #sym  ")=",			\
@@ -325,19 +326,41 @@ static void scan_vmcoreinfo(char *start,
 			*symbol[i].vaddr = vaddr;
 		}
 
-		/* Check for "SIZE(log)=" */
-		if (memcmp("SIZE(log)=", pos, 10) == 0)
-			log_sz = strtoull(pos + 10, NULL, 10);
-
-		/* Check for struct log field offsets */
-		if (memcmp("OFFSET(log.ts_nsec)=", pos, 20) == 0)
-			log_offset_ts_nsec = strtoull(pos + 20, NULL, 10);
-
-		if (memcmp("OFFSET(log.len)=", pos, 16) == 0)
-			log_offset_len = strtoul(pos + 16, NULL, 10);
-
-		if (memcmp("OFFSET(log.text_len)=", pos, 21) == 0)
-			log_offset_text_len = strtoul(pos + 21, NULL, 10);
+		/* Check for "SIZE(printk_log)" or older "SIZE(log)=" */
+		str = "SIZE(log)=";
+		if (memcmp(str, pos, strlen(str)) == 0)
+			log_sz = strtoull(pos + strlen(str), NULL, 10);
+
+		str = "SIZE(printk_log)=";
+		if (memcmp(str, pos, strlen(str)) == 0)
+			log_sz = strtoull(pos + strlen(str), NULL, 10);
+
+		/* Check for struct printk_log (or older log) field offsets */
+		str = "OFFSET(log.ts_nsec)=";
+		if (memcmp(str, pos, strlen(str)) == 0)
+			log_offset_ts_nsec = strtoull(pos + strlen(str), NULL,
+							10);
+		str = "OFFSET(printk_log.ts_nsec)=";
+		if (memcmp(str, pos, strlen(str)) == 0)
+			log_offset_ts_nsec = strtoull(pos + strlen(str), NULL,
+							10);
+
+		str = "OFFSET(log.len)=";
+		if (memcmp(str, pos, strlen(str)) == 0)
+			log_offset_len = strtoul(pos + strlen(str), NULL, 10);
+
+		str = "OFFSET(printk_log.len)=";
+		if (memcmp(str, pos, strlen(str)) == 0)
+			log_offset_len = strtoul(pos + strlen(str), NULL, 10);
+
+		str = "OFFSET(log.text_len)=";
+		if (memcmp(str, pos, strlen(str)) == 0)
+			log_offset_text_len = strtoul(pos + strlen(str), NULL,
+							10);
+		str = "OFFSET(printk_log.text_len)=";
+		if (memcmp(str, pos, strlen(str)) == 0)
+			log_offset_text_len = strtoul(pos + strlen(str), NULL,
+							10);
 
 		if (last_line)
 			break;

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

             reply	other threads:[~2014-05-22 14:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-22 14:43 Vivek Goyal [this message]
2014-05-26  6:54 ` [PATCH] vmcore-dmesg: Handle struct log to struct printk_log renaming Simon Horman
2014-05-27 13:13   ` Vivek Goyal
2014-05-27 23:45     ` Simon Horman
2014-05-28 12:27       ` Vivek Goyal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140522144314.GE13647@redhat.com \
    --to=vgoyal@redhat.com \
    --cc=chaowang@redhat.com \
    --cc=horms@verge.net.au \
    --cc=kexec@lists.infradead.org \
    --cc=lkundrak@v3.sk \
    --cc=taras.kondratiuk@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox