7ebe66670c592d64cba6b829ce42307b141e44cb
[deliverable/linux.git] / include / linux / nsproxy.h
1 #ifndef _LINUX_NSPROXY_H
2 #define _LINUX_NSPROXY_H
3
4 #include <linux/spinlock.h>
5 #include <linux/sched.h>
6
7 struct namespace;
8
9 /*
10 * A structure to contain pointers to all per-process
11 * namespaces - fs (mount), uts, network, sysvipc, etc.
12 *
13 * 'count' is the number of tasks holding a reference.
14 * The count for each namespace, then, will be the number
15 * of nsproxies pointing to it, not the number of tasks.
16 *
17 * The nsproxy is shared by tasks which share all namespaces.
18 * As soon as a single namespace is cloned or unshared, the
19 * nsproxy is copied.
20 */
21 struct nsproxy {
22 atomic_t count;
23 spinlock_t nslock;
24 struct namespace *namespace;
25 };
26 extern struct nsproxy init_nsproxy;
27
28 struct nsproxy *dup_namespaces(struct nsproxy *orig);
29 int copy_namespaces(int flags, struct task_struct *tsk);
30 void get_task_namespaces(struct task_struct *tsk);
31 void free_nsproxy(struct nsproxy *ns);
32
33 static inline void put_nsproxy(struct nsproxy *ns)
34 {
35 if (atomic_dec_and_test(&ns->count)) {
36 free_nsproxy(ns);
37 }
38 }
39
40 static inline void exit_task_namespaces(struct task_struct *p)
41 {
42 struct nsproxy *ns = p->nsproxy;
43 if (ns) {
44 put_nsproxy(ns);
45 p->nsproxy = NULL;
46 }
47 }
48 #endif
This page took 0.034052 seconds and 4 git commands to generate.