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

mount: prepare to work without mnt_id

Kernels before 3.15 doesn't show mnt_id and mnt_id isn't saved in
images, if mntns isn't dumped.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent b6d3314c
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
extern struct mount_info *mntinfo; extern struct mount_info *mntinfo;
extern int mntns_collect_root(pid_t pid); extern int mntns_collect_root(pid_t pid);
extern struct ns_id *lookup_nsid_by_mnt_id(int mnt_id);
struct proc_mountinfo; struct proc_mountinfo;
......
...@@ -1578,6 +1578,9 @@ char *rst_get_mnt_root(int mnt_id) ...@@ -1578,6 +1578,9 @@ char *rst_get_mnt_root(int mnt_id)
if (!(root_ns_mask & CLONE_NEWNS)) if (!(root_ns_mask & CLONE_NEWNS))
return path; return path;
if (mnt_id == -1)
return path;
m = lookup_mnt_id(mnt_id); m = lookup_mnt_id(mnt_id);
if (m == NULL) if (m == NULL)
return NULL; return NULL;
...@@ -1843,6 +1846,27 @@ set_root: ...@@ -1843,6 +1846,27 @@ set_root:
return ret; return ret;
} }
struct ns_id *lookup_nsid_by_mnt_id(int mnt_id)
{
struct mount_info *mi;
/*
* Kernel before 3.15 doesn't show mnt_id for file descriptors.
* mnt_id isn't saved for files, if mntns isn't dumped.
* In both these cases we have only one root, so here
* is not matter which mount will be restured.
*/
if (mnt_id == -1)
mi = mntinfo;
else
mi = lookup_mnt_id(mnt_id);
if (mi == NULL)
return NULL;
return mi->nsid;
}
int collect_mnt_namespaces(void) int collect_mnt_namespaces(void)
{ {
struct mount_info *pm; struct mount_info *pm;
......
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