get_pfn_offset is used for generating incomplete kdump core. When enospac occurs in writing the buf cd_page, it can be used to get how many pages have been written. Signed-off-by: Zhou Wenjian <zhouwj-fnst at cn.fujitsu.com> --- makedumpfile.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/makedumpfile.c b/makedumpfile.c index 5a53246..e8b52f4 100644 --- a/makedumpfile.c +++ b/makedumpfile.c @@ -6300,6 +6300,30 @@ write_cd_buf(struct cache_data *cd) } int +get_pfn_offset(void *buf, struct cache_data *cd_page){ + int size, file_end, offset; + page_desc_t *pd; + + size = 0; + offset = 0; + file_end = lseek(cd_page->fd, 0, SEEK_END); + if (file_end < 0) + ERRMSG("Can't seek end of the dump file(%s).\n", cd_page->file_name); + + while (TRUE) { + pd = (page_desc_t *)buf; + size += pd->size; + if (size > file_end - cd_page->offset) + break; + + offset++; + buf += sizeof(page_desc_t); + } + + return offset; +} + +int write_kdump_pages_cyclic(struct cache_data *cd_header, struct cache_data *cd_page, struct page_desc *pd_zero, off_t *offset_data, struct cycle *cycle) { -- 1.8.3.1