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 2008-06-23 09:35:32.000000000 -0400 +++ kexec-tools-testing-20070330/makedumpfile/makedumpfile.c 2008-06-23 09:36:06.000000000 -0400 @@ -4821,10 +4821,11 @@ out: int write_kdump_pages() { - unsigned long long pfn, per, num_dumpable = 0, num_dumped = 0; + int size; + unsigned long long paddr, pfn, per, num_dumpable = 0, num_dumped = 0; unsigned long size_out; struct page_desc pd, pd_zero; - off_t offset_data = 0, offset_memory = 0; + off_t offset_data = 0, offset_memory1, offset_memory2; struct disk_dump_header *dh = info->dump_header; unsigned char *buf = NULL, *buf_out = NULL; unsigned long len_buf_out; @@ -4972,18 +4973,47 @@ write_kdump_pages() num_dumped++; - offset_memory = paddr_to_offset(info->page_size*pfn); - if (lseek(info->fd_memory, offset_memory, SEEK_SET) - == failed) { + paddr = info->page_size * pfn; + offset_memory1 = paddr_to_offset(paddr); + offset_memory2 = paddr_to_offset(paddr + info->page_size); + if (lseek(info->fd_memory, offset_memory1, SEEK_SET) == failed) { 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 (offset_memory1 + info->page_size == offset_memory2) { + 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; + } + } else { + /* + * Find the bound. + */ + for (size = 1; size < info->page_size; size++) { + offset_memory2 = paddr_to_offset(paddr + size); + if (offset_memory1 + size != offset_memory2) + break; + } + if (read(info->fd_memory, buf, size) != size) { + ERRMSG("Can't read the dump memory(%s). %s\n", + info->name_memory, strerror(errno)); + goto out; + } + if (lseek(info->fd_memory, offset_memory2, SEEK_SET) + == failed) { + ERRMSG("Can't seek the dump memory(%s). %s\n", + info->name_memory, strerror(errno)); + goto out; + } + if (read(info->fd_memory, buf + size, info->page_size - size) + != info->page_size - size) { + ERRMSG("Can't read the dump memory(%s). %s\n", + info->name_memory, strerror(errno)); + goto out; + } } /*