Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > f8954580ba158b6b6d09fc47ad70af4c > files > 20

kexec-tools-1.102pre-21.el5.src.rpm

diff -up kexec-tools-testing-20070330/makedumpfile/makedumpfile.c.orig kexec-tools-testing-20070330/makedumpfile/makedumpfile.c
--- kexec-tools-testing-20070330/makedumpfile/makedumpfile.c.orig	2007-09-07 04:37:08.000000000 -0400
+++ kexec-tools-testing-20070330/makedumpfile/makedumpfile.c	2007-09-19 11:24:07.000000000 -0400
@@ -5069,6 +5069,9 @@ write_kdump_bitmap()
 	off_t offset;
 
 	int ret = FALSE;
+	unsigned long long paddr;
+	off_t offset_page;
+	unsigned char *buf = NULL;
 
 	if (info->flag_elf_dumpfile)
 		return FALSE;
@@ -5627,6 +5630,11 @@ create_dump_bitmap_xen()
 		    strerror(errno));
 		goto out;
 	}
+	if ((buf = malloc(info->page_size)) == NULL) {
+		ERRMSG("Can't allocate memory for the page. %s\n",
+		    strerror(errno));
+		goto out;
+	}
 
 	pfn = 0;
 	for (i = 0; i < info->num_load_memory; i++) {
@@ -5697,11 +5705,35 @@ create_dump_bitmap_xen()
 			 *  - xen heap area, or
 			 *  - selected domain page
 			 */
-			if (_domain == 0
-			    || (info->xen_heap_start <= pfn && pfn < info->xen_heap_end)
-			    || ((count_info & 0xffff) && is_select_domain(_domain))) {
-				set_bitmap(bm2.buf, pfn%PFN_BUFBITMAP, 1);
+			if (!(_domain == 0 ||
+			    (info->xen_heap_start <= pfn && pfn < info->xen_heap_end) ||
+			    ((count_info & 0xffff) && is_select_domain(_domain)))) {
+				continue;
+			}
+			if (info->dump_level & DL_EXCLUDE_ZERO) {
+				paddr = (unsigned long long)pfn * info->page_size;
+				offset_page = paddr_to_offset(paddr);
+				if (!offset_page) {
+					ERRMSG("Can't convert physaddr(%llx) to a offset.\n",
+						paddr);
+					goto out;
+				}
+				if (lseek(info->fd_memory, offset_page,
+					  SEEK_SET) == (off_t)-1) {
+					ERRMSG("Can't seek the dump memory(%s). %s\n",
+					        info->name_memory, strerror(errno));
+					goto out;
+				}
+				if (read(info->fd_memory, buf, info->page_size)
+					 != info->page_size) {
+					ERRMSG("Can't read the dump memory(%s). %s\n",
+						info->name_memory, strerror(errno));
+					goto out;
+				}
+				if (is_zero_page(buf, info->page_size))
+					continue;
 			}
+			set_bitmap(bm2.buf, pfn%PFN_BUFBITMAP, 1);
 		}
 	}