[CRIU] [PATCH] restore: use /proc/self/mountinfo for collecting mounts fo the root task

Cyrill Gorcunov gorcunov at gmail.com
Fri Aug 8 03:18:49 PDT 2014


On Fri, Aug 08, 2014 at 02:04:46PM +0400, Andrey Vagin wrote:
> If the root task is forked in a new pidns, it can't use its pid for
> accessing /proc, because this proc belongs to the source pidns.
> 
> +++ b/proc_parse.c
> @@ -944,7 +944,10 @@ struct mount_info *parse_mountinfo(pid_t pid, struct ns_id *nsid)
>  	FILE *f;
>  	char str[1024];
>  
> -	snprintf(str, sizeof(str), "/proc/%d/mountinfo", pid);
> +	if (pid == PROC_SELF)
> +		snprintf(str, sizeof(str), "/proc/self/mountinfo");

Really? Why simply not use "/proc/self/mountinfo" here, why add
additional snprintf (without even format string)?

> +	else
> +		snprintf(str, sizeof(str), "/proc/%d/mountinfo", pid);
>  	f = fopen(str, "r");
>  	if (!f) {
>  		pr_perror("Can't open %d mountinfo", pid);


More information about the CRIU mailing list