Merge branch 'pm-qos'
[sfrench/cifs-2.6.git] / include / linux / utsname.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_UTSNAME_H
3 #define _LINUX_UTSNAME_H
4
5
6 #include <linux/sched.h>
7 #include <linux/kref.h>
8 #include <linux/nsproxy.h>
9 #include <linux/ns_common.h>
10 #include <linux/err.h>
11 #include <uapi/linux/utsname.h>
12
13 enum uts_proc {
14         UTS_PROC_OSTYPE,
15         UTS_PROC_OSRELEASE,
16         UTS_PROC_VERSION,
17         UTS_PROC_HOSTNAME,
18         UTS_PROC_DOMAINNAME,
19 };
20
21 struct user_namespace;
22 extern struct user_namespace init_user_ns;
23
24 struct uts_namespace {
25         struct kref kref;
26         struct new_utsname name;
27         struct user_namespace *user_ns;
28         struct ucounts *ucounts;
29         struct ns_common ns;
30 } __randomize_layout;
31 extern struct uts_namespace init_uts_ns;
32
33 #ifdef CONFIG_UTS_NS
34 static inline void get_uts_ns(struct uts_namespace *ns)
35 {
36         kref_get(&ns->kref);
37 }
38
39 extern struct uts_namespace *copy_utsname(unsigned long flags,
40         struct user_namespace *user_ns, struct uts_namespace *old_ns);
41 extern void free_uts_ns(struct kref *kref);
42
43 static inline void put_uts_ns(struct uts_namespace *ns)
44 {
45         kref_put(&ns->kref, free_uts_ns);
46 }
47 #else
48 static inline void get_uts_ns(struct uts_namespace *ns)
49 {
50 }
51
52 static inline void put_uts_ns(struct uts_namespace *ns)
53 {
54 }
55
56 static inline struct uts_namespace *copy_utsname(unsigned long flags,
57         struct user_namespace *user_ns, struct uts_namespace *old_ns)
58 {
59         if (flags & CLONE_NEWUTS)
60                 return ERR_PTR(-EINVAL);
61
62         return old_ns;
63 }
64 #endif
65
66 #ifdef CONFIG_PROC_SYSCTL
67 extern void uts_proc_notify(enum uts_proc proc);
68 #else
69 static inline void uts_proc_notify(enum uts_proc proc)
70 {
71 }
72 #endif
73
74 static inline struct new_utsname *utsname(void)
75 {
76         return &current->nsproxy->uts_ns->name;
77 }
78
79 static inline struct new_utsname *init_utsname(void)
80 {
81         return &init_uts_ns.name;
82 }
83
84 extern struct rw_semaphore uts_sem;
85
86 #endif /* _LINUX_UTSNAME_H */