[CRIU] [PATCH 01/14]v3 page-read: check that don't read page from hole
Kir Kolyshkin
kir at parallels.com
Thu Dec 19 13:34:41 PST 2013
On 12/17/2013 07:27 AM, Tikhomirov Pavel wrote:
> Signed-off-by: Tikhomirov Pavel <snorcht at gmail.com>
> ---
> page-read.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/page-read.c b/page-read.c
> index 83820fa..60f8e65 100644
> --- a/page-read.c
> +++ b/page-read.c
> @@ -125,8 +125,13 @@ static int read_pagemap_page(struct page_read *pr, unsigned long vaddr, void *bu
> if (ret == -1)
> return ret;
> } else {
> + off_t current_vaddr = lseek(pr->fd_pg, 0, SEEK_CUR);
> pr_debug("\tpr%u Read page %lx from self %lx/%"PRIx64"\n", pr->id,
> - vaddr, pr->cvaddr, lseek(pr->fd_pg, 0, SEEK_CUR));
> + vaddr, pr->cvaddr, current_vaddr);
> + if (current_vaddr != lseek(pr->fd_pg, current_vaddr, SEEK_DATA)) {
> + pr_perror("Can't read page because of hole /%"PRIx64, current_vaddr);
You should use pr_error() here. pr_perror() is for printing strerror(errno),
and errno can only be set if lseek() returns negative value.
> + return -1;
> + }
> ret = read(pr->fd_pg, buf, PAGE_SIZE);
> if (ret != PAGE_SIZE) {
> pr_perror("Can't read mapping page %d", ret);
More information about the CRIU
mailing list