[PATCH] uts: copy nsproxy only when needed
[deliverable/linux.git] / include / linux / nsproxy.h
CommitLineData
ab516013
SH
1#ifndef _LINUX_NSPROXY_H
2#define _LINUX_NSPROXY_H
3
4#include <linux/spinlock.h>
5#include <linux/sched.h>
6
1651e14e 7struct namespace;
4865ecf1 8struct uts_namespace;
1651e14e 9
ab516013
SH
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 */
22struct nsproxy {
23 atomic_t count;
24 spinlock_t nslock;
4865ecf1 25 struct uts_namespace *uts_ns;
1651e14e 26 struct namespace *namespace;
ab516013
SH
27};
28extern struct nsproxy init_nsproxy;
29
30struct nsproxy *dup_namespaces(struct nsproxy *orig);
31int copy_namespaces(int flags, struct task_struct *tsk);
32void get_task_namespaces(struct task_struct *tsk);
33void free_nsproxy(struct nsproxy *ns);
34
35static inline void put_nsproxy(struct nsproxy *ns)
36{
37 if (atomic_dec_and_test(&ns->count)) {
38 free_nsproxy(ns);
39 }
40}
41
42static 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
This page took 0.465668 seconds and 5 git commands to generate.