userns: Make create_new_namespaces take a user_ns parameter
[linux-2.6-block.git] / include / linux / utsname.h
CommitLineData
1da177e4
LT
1#ifndef _LINUX_UTSNAME_H
2#define _LINUX_UTSNAME_H
3
b119f13f
CLG
4
5#include <linux/sched.h>
6#include <linux/kref.h>
7#include <linux/nsproxy.h>
58bfdd6d 8#include <linux/err.h>
607ca46e 9#include <uapi/linux/utsname.h>
b119f13f 10
f1ecf068
LDM
11enum uts_proc {
12 UTS_PROC_OSTYPE,
13 UTS_PROC_OSRELEASE,
14 UTS_PROC_VERSION,
15 UTS_PROC_HOSTNAME,
16 UTS_PROC_DOMAINNAME,
17};
18
59607db3
SH
19struct user_namespace;
20extern struct user_namespace init_user_ns;
21
4865ecf1
SH
22struct uts_namespace {
23 struct kref kref;
24 struct new_utsname name;
59607db3 25 struct user_namespace *user_ns;
4865ecf1
SH
26};
27extern struct uts_namespace init_uts_ns;
28
58bfdd6d 29#ifdef CONFIG_UTS_NS
4865ecf1
SH
30static inline void get_uts_ns(struct uts_namespace *ns)
31{
32 kref_get(&ns->kref);
33}
34
213dd266 35extern struct uts_namespace *copy_utsname(unsigned long flags,
bcf58e72 36 struct user_namespace *user_ns, struct uts_namespace *old_ns);
4865ecf1
SH
37extern void free_uts_ns(struct kref *kref);
38
39static inline void put_uts_ns(struct uts_namespace *ns)
40{
41 kref_put(&ns->kref, free_uts_ns);
42}
58bfdd6d
PE
43#else
44static inline void get_uts_ns(struct uts_namespace *ns)
45{
46}
47
48static inline void put_uts_ns(struct uts_namespace *ns)
49{
50}
51
52static inline struct uts_namespace *copy_utsname(unsigned long flags,
bcf58e72 53 struct user_namespace *user_ns, struct uts_namespace *old_ns)
58bfdd6d
PE
54{
55 if (flags & CLONE_NEWUTS)
56 return ERR_PTR(-EINVAL);
57
bcf58e72 58 return old_ns;
58bfdd6d
PE
59}
60#endif
61
f1ecf068
LDM
62#ifdef CONFIG_PROC_SYSCTL
63extern void uts_proc_notify(enum uts_proc proc);
64#else
65static inline void uts_proc_notify(enum uts_proc proc)
66{
67}
68#endif
69
0bdd7aab
SH
70static inline struct new_utsname *utsname(void)
71{
4865ecf1 72 return &current->nsproxy->uts_ns->name;
0bdd7aab
SH
73}
74
75static inline struct new_utsname *init_utsname(void)
76{
4865ecf1 77 return &init_uts_ns.name;
0bdd7aab
SH
78}
79
1da177e4 80extern struct rw_semaphore uts_sem;
b119f13f 81
b119f13f 82#endif /* _LINUX_UTSNAME_H */