[CRIU] [PATCH 2/2] restore: remount /proc after clone(CLONE_NEWPID)

Tycho Andersen tycho.andersen at canonical.com
Fri Aug 8 05:55:43 PDT 2014


Hi Andrew,

On Fri, Aug 08, 2014 at 01:57:49PM +0400, Andrew Vagin wrote:
>
> diff --git a/mount.c b/mount.c
> index e0e88ea..3287282 100644
> --- a/mount.c
> +++ b/mount.c
> @@ -1911,7 +1911,7 @@ int prepare_mnt_ns(void)
>  {
>  	int ret = -1;
>  	struct mount_info *mis, *old;
> -	struct ns_id ns = { .pid = getpid(), .nd = &mnt_ns_desc };
> +	struct ns_id ns = { .pid = PROC_SELF, .nd = &mnt_ns_desc };
>  
>  	if (!(root_ns_mask & CLONE_NEWNS))
>  		return rst_collect_local_mntns();
> diff --git a/proc_parse.c b/proc_parse.c
> index 66a1e12..e50063f 100644
> --- a/proc_parse.c
> +++ 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");
> +	else
> +		snprintf(str, sizeof(str), "/proc/%d/mountinfo", pid);
>  	f = fopen(str, "r");
>  	if (!f) {
>  		pr_perror("Can't open %d mountinfo", pid);

Another way you could do this without the #define is just compare pid
vs. getpid(), but yes, this will fix it.

Thanks,

Tycho


More information about the CRIU mailing list