[CRIU] [PATCH v2 09/36] ns: Change arguments of dump_user_ns()
Kirill Tkhai
ktkhai at virtuozzo.com
Fri Feb 3 08:12:58 PST 2017
Make ns as only argument of dump_user_ns(). As the only ns,
which it may be called for is root_item's ns, the logic
after this patch remains the same as it was before.
Also make dump_user_ns() static.
In addition, pass ns to check_user_ns().
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
criu/include/namespaces.h | 1 -
criu/namespaces.c | 14 +++++++++-----
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/criu/include/namespaces.h b/criu/include/namespaces.h
index e1f0fa79f..8831234e2 100644
--- a/criu/include/namespaces.h
+++ b/criu/include/namespaces.h
@@ -155,7 +155,6 @@ extern int stop_usernsd(void);
extern uid_t userns_uid(uid_t uid);
extern gid_t userns_gid(gid_t gid);
-extern int dump_user_ns(pid_t pid, int ns_id);
extern void free_userns_maps(void);
extern int join_ns_add(const char *type, char *ns_file, char *extra_opts);
extern int check_namespace_opts(void);
diff --git a/criu/namespaces.c b/criu/namespaces.c
index de5ced1f2..b5573d539 100644
--- a/criu/namespaces.c
+++ b/criu/namespaces.c
@@ -865,6 +865,8 @@ static int parse_id_map(pid_t pid, char *name, UidGidExtent ***pb_exts)
return -1;
}
+static int dump_user_ns(struct ns_id *ns);
+
int collect_user_ns(struct ns_id *ns, void *oarg)
{
/*
@@ -872,7 +874,7 @@ int collect_user_ns(struct ns_id *ns, void *oarg)
* mappings, which are used for convirting local id-s to
* userns id-s (userns_uid(), userns_gid())
*/
- if (dump_user_ns(root_item->pid->real, root_item->ids->user_ns_id))
+ if (dump_user_ns(ns))
return -1;
return 0;
@@ -905,8 +907,9 @@ static int collect_ns_hierarhy(bool for_dump)
return 0;
}
-static int check_user_ns(int pid)
+static int check_user_ns(struct ns_id *ns)
{
+ pid_t pid = ns->ns_pid;
int status;
pid_t chld;
@@ -1005,9 +1008,10 @@ static int check_user_ns(int pid)
return 0;
}
-int dump_user_ns(pid_t pid, int ns_id)
+static int dump_user_ns(struct ns_id *ns)
{
int ret, exit_code = -1;
+ pid_t pid = ns->ns_pid;
UsernsEntry *e = &userns_entry;
struct cr_img *img;
@@ -1021,10 +1025,10 @@ int dump_user_ns(pid_t pid, int ns_id)
goto err;
e->n_gid_map = ret;
- if (check_user_ns(pid))
+ if (check_user_ns(ns))
return -1;
- img = open_image(CR_FD_USERNS, O_DUMP, ns_id);
+ img = open_image(CR_FD_USERNS, O_DUMP, ns->id);
if (!img)
goto err;
ret = pb_write_one(img, e, PB_USERNS);
More information about the CRIU
mailing list