diff --git a/diskdump.c b/diskdump.c index 1d6f7a5..850b174 100644 --- a/diskdump.c +++ b/diskdump.c @@ -999,6 +999,17 @@ cache_page(physaddr_t paddr) if (FLAT_FORMAT()) { if (!read_flattened_format(dd->dfd, pd.offset, dd->compressed_page, pd.size)) return READ_ERROR; + } else if (is_incomplete_dump() && (0 == pd.offset)) { + /* + * if --zero_excluded is specified and incomplete flag is set in dump file, + * zero will be used to fill the lost part. + */ + if (!(*diskdump_flags & ZERO_EXCLUDED)) + return READ_ERROR; + error(WARNING, "%s: data may be lost\n" + " pfn:%lld\n\n" + ,pc->dumpfile,pfn); + memset(dd->compressed_page, 0, dd->block_size); } else { if (lseek(dd->dfd, pd.offset, SEEK_SET) == failed) return SEEK_ERROR; diff --git a/netdump.c b/netdump.c index abc85e0..c8f057e 100644 --- a/netdump.c +++ b/netdump.c @@ -608,7 +608,21 @@ read_netdump(int fd, void *bufptr, int cnt, ulong addr, physaddr_t paddr) "offset: %llx\n", (ulonglong)offset); return SEEK_ERROR; } - if (read(nd->ndfd, bufptr, cnt) != cnt) { + /* + * if --zero_excluded is specified and incomplete flag is set in ELF file, + * zero will be used to fill the lost part. + */ + ssize_t read_ret = read(nd->ndfd, bufptr, cnt); + if (read_ret != cnt) { + if (is_incomplete_dump() && (read_ret >= 0 && + *diskdump_flags & ZERO_EXCLUDED)) { + error(WARNING, "%s: data may be lost\n" + " offset:%llx\n\n", + pc->dumpfile, offset); + bufptr += read_ret; + bzero(bufptr, cnt - read_ret); + return cnt; + } if (CRASHDEBUG(8)) fprintf(fp, "read_netdump: READ_ERROR: " "offset: %llx\n", (ulonglong)offset);