Commit c9228dd8 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

restore: use /proc/self/mountinfo for collecting mounts fo the root task (v3)

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.

v2: don't copy a static string.
v3: take a bright part of Tycho's patch
Reported-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Cc: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Acked-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 7833260b
......@@ -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();
......
......@@ -944,8 +944,7 @@ 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");
f = fopen_proc(pid, "mountinfo");
if (!f) {
pr_perror("Can't open %d mountinfo", pid);
return NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment