]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - include/linux/utsname.h
Merge tag 'for-linus-20170825' of git://git.infradead.org/linux-mtd
[mirror_ubuntu-artful-kernel.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>
435d5f4b 8#include <linux/ns_common.h>
58bfdd6d 9#include <linux/err.h>
607ca46e 10#include <uapi/linux/utsname.h>
b119f13f 11
f1ecf068
LDM
12enum 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
20struct user_namespace;
21extern struct user_namespace init_user_ns;
22
4865ecf1
SH
23struct uts_namespace {
24 struct kref kref;
25 struct new_utsname name;
59607db3 26 struct user_namespace *user_ns;
f7af3d1c 27 struct ucounts *ucounts;
435d5f4b 28 struct ns_common ns;
3859a271 29} __randomize_layout;
4865ecf1
SH
30extern struct uts_namespace init_uts_ns;
31
58bfdd6d 32#ifdef CONFIG_UTS_NS
4865ecf1
SH
33static inline void get_uts_ns(struct uts_namespace *ns)
34{
35 kref_get(&ns->kref);
36}
37
213dd266 38extern struct uts_namespace *copy_utsname(unsigned long flags,
bcf58e72 39 struct user_namespace *user_ns, struct uts_namespace *old_ns);
4865ecf1
SH
40extern void free_uts_ns(struct kref *kref);
41
42static inline void put_uts_ns(struct uts_namespace *ns)
43{
44 kref_put(&ns->kref, free_uts_ns);
45}
58bfdd6d
PE
46#else
47static inline void get_uts_ns(struct uts_namespace *ns)
48{
49}
50
51static inline void put_uts_ns(struct uts_namespace *ns)
52{
53}
54
55static inline struct uts_namespace *copy_utsname(unsigned long flags,
bcf58e72 56 struct user_namespace *user_ns, struct uts_namespace *old_ns)
58bfdd6d
PE
57{
58 if (flags & CLONE_NEWUTS)
59 return ERR_PTR(-EINVAL);
60
bcf58e72 61 return old_ns;
58bfdd6d
PE
62}
63#endif
64
f1ecf068
LDM
65#ifdef CONFIG_PROC_SYSCTL
66extern void uts_proc_notify(enum uts_proc proc);
67#else
68static inline void uts_proc_notify(enum uts_proc proc)
69{
70}
71#endif
72
0bdd7aab
SH
73static inline struct new_utsname *utsname(void)
74{
4865ecf1 75 return &current->nsproxy->uts_ns->name;
0bdd7aab
SH
76}
77
78static inline struct new_utsname *init_utsname(void)
79{
4865ecf1 80 return &init_uts_ns.name;
0bdd7aab
SH
81}
82
1da177e4 83extern struct rw_semaphore uts_sem;
b119f13f 84
b119f13f 85#endif /* _LINUX_UTSNAME_H */