[PATCH] vmcore-dmesg: Read renamed printk_log parameters

Taras Kondratiuk taras.kondratiuk at linaro.org
Fri Oct 4 09:20:59 EDT 2013


printk log structure name was changed in v3.11-rc4 by commit
62e32ac printk: rename struct log to struct printk_log

Add macros to remove hardcoded lengths and read both log name variants.

Signed-off-by: Taras Kondratiuk <taras.kondratiuk at linaro.org>
---
 vmcore-dmesg/vmcore-dmesg.c |   25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c
index 0f477c0..022708d 100644
--- a/vmcore-dmesg/vmcore-dmesg.c
+++ b/vmcore-dmesg/vmcore-dmesg.c
@@ -255,6 +255,16 @@ static void scan_vmcoreinfo(char *start, size_t size)
 	char temp_buf[1024];
 	bool last_line = false;
 
+#define READ_INT_PARAM(name, var, converter) {				\
+	if (!memcmp(name, pos, sizeof(name) - 1))			\
+		var = converter(pos + sizeof(name) - 1, NULL, 10); }
+
+#define READ_LOG_PARAMETERS(log_name) {							  \
+	READ_INT_PARAM("SIZE("   #log_name          ")=", log_sz,              strtoull); \
+	READ_INT_PARAM("OFFSET(" #log_name  ".ts_nsec)=", log_offset_ts_nsec,  strtoull); \
+	READ_INT_PARAM("OFFSET(" #log_name      ".len)=", log_offset_len,      strtoul);  \
+	READ_INT_PARAM("OFFSET(" #log_name ".text_len)=", log_offset_text_len, strtoul); }
+
 #define SYMBOL(sym) {					\
 	.str = "SYMBOL(" #sym  ")=",			\
 	.name = #sym,					\
@@ -324,19 +334,8 @@ static void scan_vmcoreinfo(char *start, size_t size)
 			*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);
+		READ_LOG_PARAMETERS(log);
+		READ_LOG_PARAMETERS(printk_log);
 
 		if (last_line)
 			break;
-- 
1.7.9.5




More information about the kexec mailing list