2 * Copyright (C) 2006 IBM Corporation
4 * Author: Serge Hallyn <serue@us.ibm.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation, version 2 of the
12 #include <linux/module.h>
13 #include <linux/version.h>
14 #include <linux/nsproxy.h>
16 static inline void get_nsproxy(struct nsproxy *ns)
18 atomic_inc(&ns->count);
21 void get_task_namespaces(struct task_struct *tsk)
23 struct nsproxy *ns = tsk->nsproxy;
30 * creates a copy of "orig" with refcount 1.
31 * This does not grab references to the contained namespaces,
32 * so that needs to be done by dup_namespaces.
34 static inline struct nsproxy *clone_namespaces(struct nsproxy *orig)
38 ns = kmalloc(sizeof(struct nsproxy), GFP_KERNEL);
40 memcpy(ns, orig, sizeof(struct nsproxy));
41 atomic_set(&ns->count, 1);
47 * copies the nsproxy, setting refcount to 1, and grabbing a
48 * reference to all contained namespaces. Called from
51 struct nsproxy *dup_namespaces(struct nsproxy *orig)
53 struct nsproxy *ns = clone_namespaces(orig);
59 * called from clone. This now handles copy for nsproxy and all
62 int copy_namespaces(int flags, struct task_struct *tsk)
64 struct nsproxy *old_ns = tsk->nsproxy;
74 void free_nsproxy(struct nsproxy *ns)