[CRIU] [PATCH 19/20] rst: Less arguments to restore_task_mnt_ns
Pavel Emelyanov
xemul at parallels.com
Tue Apr 22 09:40:06 PDT 2014
Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
cr-restore.c | 13 ++-----------
include/mount.h | 3 ++-
mount.c | 20 +++++++++++++++++++-
3 files changed, 23 insertions(+), 13 deletions(-)
diff --git a/cr-restore.c b/cr-restore.c
index 30c664c..3d14f27 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -1283,17 +1283,8 @@ static int restore_task_with_children(void *_arg)
if (create_children_and_session())
goto err;
- if (current->ids && current->ids->has_mnt_ns_id) {
- struct ns_id *nsid;
-
- nsid = lookup_ns_by_id(current->ids->mnt_ns_id, &mnt_ns_desc);
- if (nsid == NULL) {
- pr_err("Can't find mount namespace %d\n", current->ids->mnt_ns_id);
- goto err;
- }
- if (restore_task_mnt_ns(nsid, current->pid.real))
- goto err;
- }
+ if (restore_task_mnt_ns(current))
+ goto err;
if (unmap_guard_pages())
goto err;
diff --git a/include/mount.h b/include/mount.h
index 99e256e..bd7a6b6 100644
--- a/include/mount.h
+++ b/include/mount.h
@@ -29,7 +29,8 @@ extern dev_t phys_stat_resolve_dev(struct mount_info *tree,
extern bool phys_stat_dev_match(struct mount_info *tree, dev_t st_dev,
dev_t phys_dev, const char *path);
-extern int restore_task_mnt_ns(struct ns_id *nsid, pid_t pid);
+struct pstree_item;
+extern int restore_task_mnt_ns(struct pstree_item *);
extern int fini_mnt_ns(void);
char *rst_get_mnt_root(int mnt_id);
diff --git a/mount.c b/mount.c
index bb5ff0c..9ae1762 100644
--- a/mount.c
+++ b/mount.c
@@ -1575,7 +1575,7 @@ char *rst_get_mnt_root(int mnt_id)
return path;
}
-int restore_task_mnt_ns(struct ns_id *nsid, pid_t pid)
+static int do_restore_task_mnt_ns(struct ns_id *nsid, pid_t pid)
{
char path[PATH_MAX];
@@ -1613,6 +1613,24 @@ int restore_task_mnt_ns(struct ns_id *nsid, pid_t pid)
return 0;
}
+int restore_task_mnt_ns(struct pstree_item *current)
+{
+ if (current->ids && current->ids->has_mnt_ns_id) {
+ struct ns_id *nsid;
+
+ nsid = lookup_ns_by_id(current->ids->mnt_ns_id, &mnt_ns_desc);
+ if (nsid == NULL) {
+ pr_err("Can't find mount namespace %d\n", current->ids->mnt_ns_id);
+ return -1;
+ }
+
+ if (do_restore_task_mnt_ns(nsid, current->pid.real))
+ return -1;
+ }
+
+ return 0;
+}
+
/*
* All nested mount namespaces are restore as sub-trees of the root namespace.
*/
--
1.7.6.5
More information about the CRIU
mailing list