mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-26 03:25:30 +00:00
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: Andrey Vagin <avagin@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
b6d3314c54
commit
fb3ce0fbeb
2 changed files with 25 additions and 0 deletions
|
|
@ -4,6 +4,7 @@
|
|||
extern struct mount_info *mntinfo;
|
||||
|
||||
extern int mntns_collect_root(pid_t pid);
|
||||
extern struct ns_id *lookup_nsid_by_mnt_id(int mnt_id);
|
||||
|
||||
struct proc_mountinfo;
|
||||
|
||||
|
|
|
|||
24
mount.c
24
mount.c
|
|
@ -1578,6 +1578,9 @@ char *rst_get_mnt_root(int mnt_id)
|
|||
if (!(root_ns_mask & CLONE_NEWNS))
|
||||
return path;
|
||||
|
||||
if (mnt_id == -1)
|
||||
return path;
|
||||
|
||||
m = lookup_mnt_id(mnt_id);
|
||||
if (m == NULL)
|
||||
return NULL;
|
||||
|
|
@ -1843,6 +1846,27 @@ set_root:
|
|||
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)
|
||||
{
|
||||
struct mount_info *pm;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue