Merge tag 'pci-v6.16-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci
[linux-block.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>
b119f13f 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 12enum uts_proc {
52826d3b 13 UTS_PROC_ARCH,
f1ecf068
LDM
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 24struct uts_namespace {
4865ecf1 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{
9a56493f 35 refcount_inc(&ns->ns.count);
4865ecf1
SH
36}
37
213dd266 38extern struct uts_namespace *copy_utsname(unsigned long flags,
bcf58e72 39 struct user_namespace *user_ns, struct uts_namespace *old_ns);
9a56493f 40extern void free_uts_ns(struct uts_namespace *ns);
4865ecf1
SH
41
42static inline void put_uts_ns(struct uts_namespace *ns)
43{
9a56493f
KT
44 if (refcount_dec_and_test(&ns->ns.count))
45 free_uts_ns(ns);
4865ecf1 46}
3ea056c5
AD
47
48void uts_ns_init(void);
58bfdd6d
PE
49#else
50static inline void get_uts_ns(struct uts_namespace *ns)
51{
52}
53
54static inline void put_uts_ns(struct uts_namespace *ns)
55{
56}
57
58static inline struct uts_namespace *copy_utsname(unsigned long flags,
bcf58e72 59 struct user_namespace *user_ns, struct uts_namespace *old_ns)
58bfdd6d
PE
60{
61 if (flags & CLONE_NEWUTS)
62 return ERR_PTR(-EINVAL);
63
bcf58e72 64 return old_ns;
58bfdd6d 65}
3ea056c5
AD
66
67static inline void uts_ns_init(void)
68{
69}
58bfdd6d
PE
70#endif
71
f1ecf068
LDM
72#ifdef CONFIG_PROC_SYSCTL
73extern void uts_proc_notify(enum uts_proc proc);
74#else
75static inline void uts_proc_notify(enum uts_proc proc)
76{
77}
78#endif
79
0bdd7aab
SH
80static inline struct new_utsname *utsname(void)
81{
4865ecf1 82 return &current->nsproxy->uts_ns->name;
0bdd7aab
SH
83}
84
85static inline struct new_utsname *init_utsname(void)
86{
4865ecf1 87 return &init_uts_ns.name;
0bdd7aab
SH
88}
89
1da177e4 90extern struct rw_semaphore uts_sem;
b119f13f 91
b119f13f 92#endif /* _LINUX_UTSNAME_H */