[CRIU] [PATCH] restorer: rework unmaping old VMA-s (v2)

Pavel Emelyanov xemul at parallels.com
Fri Sep 20 11:26:18 EDT 2013


>  /*
> + * This function unmaps all VMAs, which don't belong to
> + * the restored process or the restorer
> + */
> +static int unmap_old_vmas(void *premmapped_addr, unsigned long premmapped_len,
> +		      void *bootstrap_start, unsigned long bootstrap_len)
> +{
> +	unsigned long s1, s2;
> +	void *p1, *p2;
> +	int ret;
> +
> +	if ((void *) premmapped_addr < bootstrap_start) {
> +		p1 = premmapped_addr;
> +		s1 = premmapped_len;
> +		p2 = bootstrap_start;
> +		s2 = bootstrap_len;
> +	} else {
> +		p2 = premmapped_addr;
> +		s2 = premmapped_len;
> +		p1 = bootstrap_start;
> +		s1 = bootstrap_len;
> +	}
> +
> +	ret = sys_munmap(NULL, p1 - NULL);
> +	if (ret) {
> +		pr_err("Unable to unmap (%p-%p)\n", NULL, p1);

You told that you wanted to know the ret value in case of error.
Have you changed your mind?

> +		return -1;
> +	}
> +
> +	ret = sys_munmap(p1 + s1, p2 - (p1 + s1));
> +	if (ret) {
> +		pr_err("Unable to unmap (%p-%p)\n", p1 + s1, p2);
> +		return -1;
> +	}
> +
> +	ret = sys_munmap(p2 + s2, (void *) TASK_SIZE - (p2 + s2));
> +	if (ret) {
> +		pr_err("Unable to unmap (%p-%p)\n", p2 + s2, (void *)TASK_SIZE);
> +		return -1;
> +	}
> +
> +	return 0;
> +}


More information about the CRIU mailing list