Blame SOURCES/kexec-tools-2.0.4-makedumpfile-Understand-v3.11-rc4-dmesg.patch

765b01
From a01b663749c4b221ecd03285fa24a4b31e742004 Mon Sep 17 00:00:00 2001
765b01
From: Lubomir Rintel <lkundrak@v3.sk>
765b01
Date: Fri, 20 Sep 2013 15:56:49 +0900
765b01
Subject: [PATCH] [PATCH v2] dump-dmesg: Understand >= v3.11-rc4 dmesg.
765b01
765b01
Symbol name changed with the following commit:
765b01
62e32ac printk: rename struct log to struct printk_log
765b01
765b01
Changes for v2:
765b01
  * Only back values for symbol names we did actually read;
765b01
    either "log" or "printk_log"
765b01
765b01
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
765b01
---
765b01
 makedumpfile.c | 69 +++++++++++++++++++++++++++++++++++++++++++---------------
765b01
 makedumpfile.h |  7 +++---
765b01
 2 files changed, 55 insertions(+), 21 deletions(-)
765b01
765b01
diff --git a/makedumpfile-1.5.4/makedumpfile.c b/makedumpfile-1.5.4/makedumpfile.c
765b01
index e01ff50..7bbdcc2 100644
765b01
--- a/makedumpfile-1.5.4/makedumpfile.c
765b01
+++ b/makedumpfile-1.5.4/makedumpfile.c
765b01
@@ -1389,10 +1389,23 @@ get_structure_info(void)
765b01
 	OFFSET_INIT(elf64_phdr.p_paddr, "elf64_phdr", "p_paddr");
765b01
 	OFFSET_INIT(elf64_phdr.p_memsz, "elf64_phdr", "p_memsz");
765b01
 
765b01
-	SIZE_INIT(log, "log");
765b01
-	OFFSET_INIT(log.ts_nsec, "log", "ts_nsec");
765b01
-	OFFSET_INIT(log.len, "log", "len");
765b01
-	OFFSET_INIT(log.text_len, "log", "text_len");
765b01
+	SIZE_INIT(printk_log, "printk_log");
765b01
+	if (SIZE(printk_log) != NOT_FOUND_STRUCTURE) {
765b01
+		/*
765b01
+		 * In kernel 3.11-rc4 the log structure name was renamed
765b01
+		 * to "printk_log".
765b01
+		 */
765b01
+		info->flag_use_printk_log = TRUE;
765b01
+		OFFSET_INIT(printk_log.ts_nsec, "printk_log", "ts_nsec");
765b01
+		OFFSET_INIT(printk_log.len, "printk_log", "len");
765b01
+		OFFSET_INIT(printk_log.text_len, "printk_log", "text_len");
765b01
+	} else {
765b01
+		info->flag_use_printk_log = FALSE;
765b01
+		SIZE_INIT(printk_log, "log");
765b01
+		OFFSET_INIT(printk_log.ts_nsec, "log", "ts_nsec");
765b01
+		OFFSET_INIT(printk_log.len, "log", "len");
765b01
+		OFFSET_INIT(printk_log.text_len, "log", "text_len");
765b01
+	}
765b01
 
765b01
 	return TRUE;
765b01
 }
765b01
@@ -1593,7 +1606,10 @@ write_vmcoreinfo_data(void)
765b01
 	WRITE_STRUCTURE_SIZE("node_memblk_s", node_memblk_s);
765b01
 	WRITE_STRUCTURE_SIZE("nodemask_t", nodemask_t);
765b01
 	WRITE_STRUCTURE_SIZE("pageflags", pageflags);
765b01
-	WRITE_STRUCTURE_SIZE("log", log);
765b01
+	if (info->flag_use_printk_log)
765b01
+		WRITE_STRUCTURE_SIZE("printk_log", printk_log);
765b01
+	else
765b01
+		WRITE_STRUCTURE_SIZE("log", printk_log);
765b01
 
765b01
 	/*
765b01
 	 * write the member offset of 1st kernel
765b01
@@ -1628,9 +1644,16 @@ write_vmcoreinfo_data(void)
765b01
 	WRITE_MEMBER_OFFSET("vm_struct.addr", vm_struct.addr);
765b01
 	WRITE_MEMBER_OFFSET("vmap_area.va_start", vmap_area.va_start);
765b01
 	WRITE_MEMBER_OFFSET("vmap_area.list", vmap_area.list);
765b01
-	WRITE_MEMBER_OFFSET("log.ts_nsec", log.ts_nsec);
765b01
-	WRITE_MEMBER_OFFSET("log.len", log.len);
765b01
-	WRITE_MEMBER_OFFSET("log.text_len", log.text_len);
765b01
+	if (info->flag_use_printk_log) {
765b01
+		WRITE_MEMBER_OFFSET("printk_log.ts_nsec", printk_log.ts_nsec);
765b01
+		WRITE_MEMBER_OFFSET("printk_log.len", printk_log.len);
765b01
+		WRITE_MEMBER_OFFSET("printk_log.text_len", printk_log.text_len);
765b01
+	} else {
765b01
+		/* Compatibility with pre-3.11-rc4 */
765b01
+		WRITE_MEMBER_OFFSET("log.ts_nsec", printk_log.ts_nsec);
765b01
+		WRITE_MEMBER_OFFSET("log.len", printk_log.len);
765b01
+		WRITE_MEMBER_OFFSET("log.text_len", printk_log.text_len);
765b01
+	}
765b01
 
765b01
 	if (SYMBOL(node_data) != NOT_FOUND_SYMBOL)
765b01
 		WRITE_ARRAY_LENGTH("node_data", node_data);
765b01
@@ -1909,7 +1932,6 @@ read_vmcoreinfo(void)
765b01
 	READ_STRUCTURE_SIZE("node_memblk_s", node_memblk_s);
765b01
 	READ_STRUCTURE_SIZE("nodemask_t", nodemask_t);
765b01
 	READ_STRUCTURE_SIZE("pageflags", pageflags);
765b01
-	READ_STRUCTURE_SIZE("log", log);
765b01
 
765b01
 	READ_MEMBER_OFFSET("page.flags", page.flags);
765b01
 	READ_MEMBER_OFFSET("page._count", page._count);
765b01
@@ -1940,9 +1962,20 @@ read_vmcoreinfo(void)
765b01
 	READ_MEMBER_OFFSET("vm_struct.addr", vm_struct.addr);
765b01
 	READ_MEMBER_OFFSET("vmap_area.va_start", vmap_area.va_start);
765b01
 	READ_MEMBER_OFFSET("vmap_area.list", vmap_area.list);
765b01
-	READ_MEMBER_OFFSET("log.ts_nsec", log.ts_nsec);
765b01
-	READ_MEMBER_OFFSET("log.len", log.len);
765b01
-	READ_MEMBER_OFFSET("log.text_len", log.text_len);
765b01
+
765b01
+	READ_STRUCTURE_SIZE("printk_log", printk_log);
765b01
+	if (SIZE(printk_log) != NOT_FOUND_STRUCTURE) {
765b01
+		info->flag_use_printk_log = TRUE;
765b01
+		READ_MEMBER_OFFSET("printk_log.ts_nsec", printk_log.ts_nsec);
765b01
+		READ_MEMBER_OFFSET("printk_log.len", printk_log.len);
765b01
+		READ_MEMBER_OFFSET("printk_log.text_len", printk_log.text_len);
765b01
+	} else {
765b01
+		info->flag_use_printk_log = FALSE;
765b01
+		READ_STRUCTURE_SIZE("log", printk_log);
765b01
+		READ_MEMBER_OFFSET("log.ts_nsec", printk_log.ts_nsec);
765b01
+		READ_MEMBER_OFFSET("log.len", printk_log.len);
765b01
+		READ_MEMBER_OFFSET("log.text_len", printk_log.text_len);
765b01
+	}
765b01
 
765b01
 	READ_ARRAY_LENGTH("node_data", node_data);
765b01
 	READ_ARRAY_LENGTH("pgdat_list", pgdat_list);
765b01
@@ -3710,13 +3743,13 @@ dump_log_entry(char *logptr, int fp)
765b01
 	ulonglong nanos;
765b01
 	ulong rem;
765b01
 
765b01
-	text_len = USHORT(logptr + OFFSET(log.text_len));
765b01
-	ts_nsec = ULONGLONG(logptr + OFFSET(log.ts_nsec));
765b01
+	text_len = USHORT(logptr + OFFSET(printk_log.text_len));
765b01
+	ts_nsec = ULONGLONG(logptr + OFFSET(printk_log.ts_nsec));
765b01
 
765b01
 	nanos = (ulonglong)ts_nsec / (ulonglong)1000000000;
765b01
 	rem = (ulonglong)ts_nsec % (ulonglong)1000000000;
765b01
 
765b01
-	msg = logptr + SIZE(log);
765b01
+	msg = logptr + SIZE(printk_log);
765b01
 
765b01
 	sprintf(buf, "[%5lld.%06ld] ", nanos, rem/1000);
765b01
 
765b01
@@ -3754,7 +3787,7 @@ log_from_idx(unsigned int idx, char *logbuf)
765b01
 	 * the buffer.
765b01
 	 */
765b01
 
765b01
-	msglen = USHORT(logptr + OFFSET(log.len));
765b01
+	msglen = USHORT(logptr + OFFSET(printk_log.len));
765b01
 	if (!msglen)
765b01
 		logptr = logbuf;
765b01
 
765b01
@@ -3775,9 +3808,9 @@ log_next(unsigned int idx, char *logbuf)
765b01
 	 * return the one after that.
765b01
 	 */
765b01
 
765b01
-	msglen = USHORT(logptr + OFFSET(log.len));
765b01
+	msglen = USHORT(logptr + OFFSET(printk_log.len));
765b01
 	if (!msglen) {
765b01
-		msglen = USHORT(logbuf + OFFSET(log.len));
765b01
+		msglen = USHORT(logbuf + OFFSET(printk_log.len));
765b01
 		return msglen;
765b01
 	}
765b01
 
765b01
diff --git a/makedumpfile-1.5.4/makedumpfile.h b/makedumpfile-1.5.4/makedumpfile.h
765b01
index c504bfb..3a7e61a 100644
765b01
--- a/makedumpfile-1.5.4/makedumpfile.h
765b01
+++ b/makedumpfile-1.5.4/makedumpfile.h
765b01
@@ -893,6 +893,7 @@ struct DumpInfo {
765b01
 	int		flag_force;	     /* overwrite existing stuff */
765b01
 	int		flag_exclude_xen_dom;/* exclude Domain-U from xen-kdump */
765b01
 	int             flag_dmesg;          /* dump the dmesg log out of the vmcore file */
765b01
+	int		flag_use_printk_log; /* did we read printk_log symbol name? */
765b01
 	int		flag_nospace;	     /* the flag of "No space on device" error */
765b01
 	unsigned long	vaddr_for_vtop;      /* virtual address for debugging */
765b01
 	long		page_size;           /* size of page */
765b01
@@ -1176,6 +1177,7 @@ struct size_table {
765b01
 	long	list_head;
765b01
 	long	node_memblk_s;
765b01
 	long	nodemask_t;
765b01
+	long	printk_log;
765b01
 
765b01
 	/*
765b01
 	 * for Xen extraction
765b01
@@ -1198,7 +1200,6 @@ struct size_table {
765b01
 	long	cpumask_t;
765b01
 	long	kexec_segment;
765b01
 	long	elf64_hdr;
765b01
-	long	log;
765b01
 
765b01
 	long	pageflags;
765b01
 };
765b01
@@ -1337,11 +1338,11 @@ struct offset_table {
765b01
 		long	p_memsz;
765b01
 	} elf64_phdr;
765b01
 
765b01
-	struct log_s {
765b01
+	struct printk_log_s {
765b01
 		long ts_nsec;
765b01
 		long len;
765b01
 		long text_len;
765b01
-	} log;
765b01
+	} printk_log;
765b01
 
765b01
 };
765b01
 
765b01
-- 
765b01
1.8.3.1
765b01