mirror of https://github.com/torvalds/linux.git
ns: add ns_debug()
Add ns_debug() that asserts that the correct operations are used for the namespace type. Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
d7610cb745
commit
5890f504ef
|
|
@ -2,6 +2,55 @@
|
||||||
|
|
||||||
#include <linux/ns_common.h>
|
#include <linux/ns_common.h>
|
||||||
#include <linux/proc_ns.h>
|
#include <linux/proc_ns.h>
|
||||||
|
#include <linux/vfsdebug.h>
|
||||||
|
|
||||||
|
#ifdef CONFIG_DEBUG_VFS
|
||||||
|
static void ns_debug(struct ns_common *ns, const struct proc_ns_operations *ops)
|
||||||
|
{
|
||||||
|
switch (ns->ops->type) {
|
||||||
|
#ifdef CONFIG_CGROUPS
|
||||||
|
case CLONE_NEWCGROUP:
|
||||||
|
VFS_WARN_ON_ONCE(ops != &cgroupns_operations);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_IPC_NS
|
||||||
|
case CLONE_NEWIPC:
|
||||||
|
VFS_WARN_ON_ONCE(ops != &ipcns_operations);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
case CLONE_NEWNS:
|
||||||
|
VFS_WARN_ON_ONCE(ops != &mntns_operations);
|
||||||
|
break;
|
||||||
|
#ifdef CONFIG_NET_NS
|
||||||
|
case CLONE_NEWNET:
|
||||||
|
VFS_WARN_ON_ONCE(ops != &netns_operations);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_PID_NS
|
||||||
|
case CLONE_NEWPID:
|
||||||
|
VFS_WARN_ON_ONCE(ops != &pidns_operations);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_TIME_NS
|
||||||
|
case CLONE_NEWTIME:
|
||||||
|
VFS_WARN_ON_ONCE(ops != &timens_operations);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_USER_NS
|
||||||
|
case CLONE_NEWUSER:
|
||||||
|
VFS_WARN_ON_ONCE(ops != &userns_operations);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_UTS_NS
|
||||||
|
case CLONE_NEWUTS:
|
||||||
|
VFS_WARN_ON_ONCE(ops != &utsns_operations);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
VFS_WARN_ON_ONCE(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int __ns_common_init(struct ns_common *ns, const struct proc_ns_operations *ops, int inum)
|
int __ns_common_init(struct ns_common *ns, const struct proc_ns_operations *ops, int inum)
|
||||||
{
|
{
|
||||||
|
|
@ -12,6 +61,10 @@ int __ns_common_init(struct ns_common *ns, const struct proc_ns_operations *ops,
|
||||||
RB_CLEAR_NODE(&ns->ns_tree_node);
|
RB_CLEAR_NODE(&ns->ns_tree_node);
|
||||||
INIT_LIST_HEAD(&ns->ns_list_node);
|
INIT_LIST_HEAD(&ns->ns_list_node);
|
||||||
|
|
||||||
|
#ifdef CONFIG_DEBUG_VFS
|
||||||
|
ns_debug(ns, ops);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (inum) {
|
if (inum) {
|
||||||
ns->inum = inum;
|
ns->inum = inum;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue