1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_UTSNAME_H
3 #define _LINUX_UTSNAME_H
6 #include <linux/sched.h>
7 #include <linux/nsproxy.h>
8 #include <linux/ns_common.h>
10 #include <uapi/linux/utsname.h>
20 struct user_namespace;
21 extern struct user_namespace init_user_ns;
23 struct uts_namespace {
24 struct new_utsname name;
25 struct user_namespace *user_ns;
26 struct ucounts *ucounts;
29 extern struct uts_namespace init_uts_ns;
32 static inline void get_uts_ns(struct uts_namespace *ns)
34 refcount_inc(&ns->ns.count);
37 extern struct uts_namespace *copy_utsname(unsigned long flags,
38 struct user_namespace *user_ns, struct uts_namespace *old_ns);
39 extern void free_uts_ns(struct uts_namespace *ns);
41 static inline void put_uts_ns(struct uts_namespace *ns)
43 if (refcount_dec_and_test(&ns->ns.count))
47 void uts_ns_init(void);
49 static inline void get_uts_ns(struct uts_namespace *ns)
53 static inline void put_uts_ns(struct uts_namespace *ns)
57 static inline struct uts_namespace *copy_utsname(unsigned long flags,
58 struct user_namespace *user_ns, struct uts_namespace *old_ns)
60 if (flags & CLONE_NEWUTS)
61 return ERR_PTR(-EINVAL);
66 static inline void uts_ns_init(void)
71 #ifdef CONFIG_PROC_SYSCTL
72 extern void uts_proc_notify(enum uts_proc proc);
74 static inline void uts_proc_notify(enum uts_proc proc)
79 static inline struct new_utsname *utsname(void)
81 return ¤t->nsproxy->uts_ns->name;
84 static inline struct new_utsname *init_utsname(void)
86 return &init_uts_ns.name;
89 extern struct rw_semaphore uts_sem;
91 #endif /* _LINUX_UTSNAME_H */