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