[CRIU] [PATCH] restore: use /proc/self/mountinfo for collecting mounts fo the root task
Christopher Covington
cov at codeaurora.org
Tue Aug 12 11:13:47 PDT 2014
On 08/08/2014 06:33 AM, 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.
Why not make this part of fopen_proc?
Thanks,
Christopher
> 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..efd7119 100644
> --- a/proc_parse.c
> +++ b/proc_parse.c
> @@ -944,8 +944,12 @@ 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);
> - f = fopen(str, "r");
> + if (pid == PROC_SELF)
> + f = fopen("/proc/self/mountinfo", "r");
> + else {
> + snprintf(str, sizeof(str), "/proc/%d/mountinfo", pid);
> + f = fopen(str, "r");
> + }
> if (!f) {
> pr_perror("Can't open %d mountinfo", pid);
> return NULL;
>
--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by the Linux Foundation.
More information about the CRIU
mailing list