]> pilppa.org Git - linux-2.6-omap-h63xx.git/blob - include/linux/nsproxy.h
[PATCH] namespaces: utsname: implement utsname namespaces
[linux-2.6-omap-h63xx.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 struct uts_namespace;
9
10 /*
11  * A structure to contain pointers to all per-process
12  * namespaces - fs (mount), uts, network, sysvipc, etc.
13  *
14  * 'count' is the number of tasks holding a reference.
15  * The count for each namespace, then, will be the number
16  * of nsproxies pointing to it, not the number of tasks.
17  *
18  * The nsproxy is shared by tasks which share all namespaces.
19  * As soon as a single namespace is cloned or unshared, the
20  * nsproxy is copied.
21  */
22 struct nsproxy {
23         atomic_t count;
24         spinlock_t nslock;
25         struct uts_namespace *uts_ns;
26         struct namespace *namespace;
27 };
28 extern struct nsproxy init_nsproxy;
29
30 struct nsproxy *dup_namespaces(struct nsproxy *orig);
31 int copy_namespaces(int flags, struct task_struct *tsk);
32 void get_task_namespaces(struct task_struct *tsk);
33 void free_nsproxy(struct nsproxy *ns);
34
35 static inline void put_nsproxy(struct nsproxy *ns)
36 {
37         if (atomic_dec_and_test(&ns->count)) {
38                 free_nsproxy(ns);
39         }
40 }
41
42 static inline void exit_task_namespaces(struct task_struct *p)
43 {
44         struct nsproxy *ns = p->nsproxy;
45         if (ns) {
46                 put_nsproxy(ns);
47                 p->nsproxy = NULL;
48         }
49 }
50 #endif