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