Commit 30936058 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

ns: Extend ns_desc to carry the length of the ns name

This will be needed for fast parsing of procfs ns references.

[ xemul: Add user_ns_desc here ]
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 4531f0ac
...@@ -9,9 +9,18 @@ struct cr_options; ...@@ -9,9 +9,18 @@ struct cr_options;
struct ns_desc { struct ns_desc {
unsigned int cflag; unsigned int cflag;
char *str; char *str;
size_t len;
}; };
#define NS_DESC_ENTRY(_cflag, _str) \
{ \
.cflag = _cflag, \
.str = _str, \
.len = sizeof(_str) - 1, \
}
extern struct ns_desc pid_ns_desc; extern struct ns_desc pid_ns_desc;
extern struct ns_desc user_ns_desc;
extern unsigned long current_ns_mask; extern unsigned long current_ns_mask;
int dump_namespaces(struct pid *pid, unsigned int ns_flags); int dump_namespaces(struct pid *pid, unsigned int ns_flags);
......
...@@ -938,7 +938,4 @@ int prepare_ipc_ns(int pid) ...@@ -938,7 +938,4 @@ int prepare_ipc_ns(int pid)
return 0; return 0;
} }
struct ns_desc ipc_ns_desc = { struct ns_desc ipc_ns_desc = NS_DESC_ENTRY(CLONE_NEWIPC, "ipc");
.cflag = CLONE_NEWIPC,
.str = "ipc",
};
...@@ -812,7 +812,4 @@ int mntns_collect_root(pid_t pid) ...@@ -812,7 +812,4 @@ int mntns_collect_root(pid_t pid)
return 0; return 0;
} }
struct ns_desc mnt_ns_desc = { struct ns_desc mnt_ns_desc = NS_DESC_ENTRY(CLONE_NEWNS, "mnt");
.cflag = CLONE_NEWNS,
.str = "mnt",
};
...@@ -313,7 +313,5 @@ int try_show_namespaces(int ns_pid, struct cr_options *o) ...@@ -313,7 +313,5 @@ int try_show_namespaces(int ns_pid, struct cr_options *o)
return 0; return 0;
} }
struct ns_desc pid_ns_desc = { struct ns_desc pid_ns_desc = NS_DESC_ENTRY(CLONE_NEWPID, "pid");
.cflag = CLONE_NEWPID, struct ns_desc user_ns_desc = NS_DESC_ENTRY(CLONE_NEWUSER, "user");
.str = "pid",
};
...@@ -404,7 +404,4 @@ void network_unlock(void) ...@@ -404,7 +404,4 @@ void network_unlock(void)
run_scripts("network-unlock"); run_scripts("network-unlock");
} }
struct ns_desc net_ns_desc = { struct ns_desc net_ns_desc = NS_DESC_ENTRY(CLONE_NEWNET, "net");
.cflag = CLONE_NEWNET,
.str = "net",
};
...@@ -70,7 +70,4 @@ void show_utsns(int fd) ...@@ -70,7 +70,4 @@ void show_utsns(int fd)
pb_show_vertical(fd, PB_UTSNS); pb_show_vertical(fd, PB_UTSNS);
} }
struct ns_desc uts_ns_desc = { struct ns_desc uts_ns_desc = NS_DESC_ENTRY(CLONE_NEWUTS, "uts");
.cflag = CLONE_NEWUTS,
.str = "uts",
};
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