[CRIU] [PATCH 13/28] ns: Rename root_user_ns to top_user_ns
Kirill Tkhai
ktkhai at virtuozzo.com
Mon Jun 5 20:25:21 MSK 2017
I'm going to use this in !(root_ns_mask & CLONE_NEWUSER) case,
so choose a better name to fit everything.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
criu/cr-restore.c | 2 +-
criu/include/namespaces.h | 2 +-
criu/namespaces.c | 30 +++++++++++++++---------------
criu/net.c | 2 +-
4 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index a609a1ed9..88a9c50a5 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -479,7 +479,7 @@ static int setup_child_task_namespaces(struct pstree_item *item, struct ns_id **
else
item->user_ns = current->user_ns;
} else
- item->user_ns = root_user_ns;
+ item->user_ns = top_user_ns;
wait_pid_ns_helper_prepared(pid_ns, item->pid);
diff --git a/criu/include/namespaces.h b/criu/include/namespaces.h
index 4e06ebc0f..3cfa9a9bf 100644
--- a/criu/include/namespaces.h
+++ b/criu/include/namespaces.h
@@ -162,7 +162,7 @@ struct ns_id {
};
extern struct ns_id *ns_ids;
extern struct ns_id *top_pid_ns;
-extern struct ns_id *root_user_ns;
+extern struct ns_id *top_user_ns;
extern struct ns_id *top_net_ns;
#define NS_DESC_ENTRY(_cflag, _str, _alt_str) \
diff --git a/criu/namespaces.c b/criu/namespaces.c
index ea8e3e391..5c01491d8 100644
--- a/criu/namespaces.c
+++ b/criu/namespaces.c
@@ -894,7 +894,7 @@ static int set_ns_hookups(struct ns_id *ns)
}
struct ns_id *top_pid_ns = NULL;
-struct ns_id *root_user_ns = NULL;
+struct ns_id *top_user_ns = NULL;
struct ns_id *top_net_ns = NULL;
/* Mapping NS_ROOT to NS_CRIU */
UsernsEntry *userns_entry;
@@ -981,7 +981,7 @@ unsigned int target_userns_uid(struct ns_id *ns, unsigned int uid)
{
if (!(root_ns_mask & CLONE_NEWUSER))
return uid;
- if (ns == root_user_ns)
+ if (ns == top_user_ns)
return uid;
/* User ns max nesting level is only 32 */
uid = target_userns_uid(ns->parent, uid);
@@ -993,7 +993,7 @@ unsigned int target_userns_gid(struct ns_id *ns, unsigned int gid)
{
if (!(root_ns_mask & CLONE_NEWUSER))
return gid;
- if (ns == root_user_ns)
+ if (ns == top_user_ns)
return gid;
/* User ns max nesting level is only 32 */
gid = target_userns_gid(ns->parent, gid);
@@ -1005,7 +1005,7 @@ unsigned int root_userns_uid(struct ns_id *ns, unsigned int uid)
{
if (!(root_ns_mask & CLONE_NEWUSER))
return uid;
- while (ns != root_user_ns) {
+ while (ns != top_user_ns) {
uid = parent_userns_uid(ns->user.e, uid);
ns = ns->parent;
}
@@ -1017,7 +1017,7 @@ unsigned int root_userns_gid(struct ns_id *ns, unsigned int gid)
{
if (!(root_ns_mask & CLONE_NEWUSER))
return gid;
- while (ns != root_user_ns) {
+ while (ns != top_user_ns) {
gid = parent_userns_gid(ns->user.e, gid);
ns = ns->parent;
}
@@ -1116,7 +1116,7 @@ int collect_user_ns(struct ns_id *ns, void *oarg)
ns->user.e = e;
if (ns->type == NS_ROOT) {
userns_entry = e;
- root_user_ns = ns;
+ top_user_ns = ns;
}
/*
* User namespace is dumped before files to get uid and gid
@@ -1927,7 +1927,7 @@ static int do_read_old_user_ns_img(struct ns_id *ns, void *arg)
ns->user.e = e;
userns_entry = e;
ns->type = NS_ROOT;
- root_user_ns = ns;
+ top_user_ns = ns;
return 0;
}
@@ -1939,16 +1939,16 @@ static int read_old_user_ns_img(void)
if (!(root_ns_mask & CLONE_NEWUSER))
return 0;
/* If new format img has already been read */
- if (root_user_ns)
+ if (top_user_ns)
return 0;
- /* Old format img is only for root_user_ns. More or less is error */
+ /* Old format img is only for top_user_ns. More or less is error */
ret = walk_namespaces(&user_ns_desc, do_read_old_user_ns_img, &count);
if (ret < 0)
return -1;
for (ns = ns_ids; ns != NULL; ns = ns->next)
if (ns->nd != &user_ns_desc)
- ns->user_ns = root_user_ns;
+ ns->user_ns = top_user_ns;
return 0;
}
@@ -2087,12 +2087,12 @@ int read_ns_with_hookups(void)
list_add(&ns->siblings, &p_ns->children);
}
} else if (e->ns_cflag == CLONE_NEWUSER) {
- if (root_user_ns) {
- pr_err("root_user_ns already set\n");
+ if (top_user_ns) {
+ pr_err("top_user_ns already set\n");
goto close;
}
ns->type = NS_ROOT;
- root_user_ns = ns;
+ top_user_ns = ns;
userns_entry = ns->user.e;
} else if (e->ns_cflag == CLONE_NEWPID) {
if (top_pid_ns) {
@@ -2381,7 +2381,7 @@ static int create_user_ns_hierarhy_fn(void *in_arg)
struct ns_id *me, *child;
pid_t pid = -1;
- if (p_arg->me != root_user_ns)
+ if (p_arg->me != top_user_ns)
p_futex = &p_arg->futex;
me = p_arg->me;
@@ -2449,7 +2449,7 @@ static int create_user_ns_hierarhy_fn(void *in_arg)
static int create_user_ns_hierarhy(void)
{
- struct ns_arg arg = { .me = root_user_ns };
+ struct ns_arg arg = { .me = top_user_ns };
return create_user_ns_hierarhy_fn(&arg);
}
diff --git a/criu/net.c b/criu/net.c
index 17976afb8..bc42c02a2 100644
--- a/criu/net.c
+++ b/criu/net.c
@@ -2108,7 +2108,7 @@ static int __prepare_net_namespaces(void *unused)
if (nsid->nd != &net_ns_desc)
continue;
- if (root_user_ns && nsid->user_ns != root_user_ns) {
+ if (top_user_ns && nsid->user_ns != top_user_ns) {
if (call_in_child_process(create_net_ns, nsid) < 0)
goto err;
} else if (nsid->type == NS_ROOT) {
More information about the CRIU
mailing list