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/kref.h>
8 #include <linux/nsproxy.h>
9 #include <linux/ns_common.h>
10 #include <linux/err.h>
11 #include <uapi/linux/utsname.h>
21 struct user_namespace;
22 extern struct user_namespace init_user_ns;
24 struct uts_namespace {
26 struct new_utsname name;
27 struct user_namespace *user_ns;
28 struct ucounts *ucounts;
31 extern struct uts_namespace init_uts_ns;
34 static inline void get_uts_ns(struct uts_namespace *ns)
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);
43 static inline void put_uts_ns(struct uts_namespace *ns)
45 kref_put(&ns->kref, free_uts_ns);
48 void uts_ns_init(void);
50 static inline void get_uts_ns(struct uts_namespace *ns)
54 static inline void put_uts_ns(struct uts_namespace *ns)
58 static inline struct uts_namespace *copy_utsname(unsigned long flags,
59 struct user_namespace *user_ns, struct uts_namespace *old_ns)
61 if (flags & CLONE_NEWUTS)
62 return ERR_PTR(-EINVAL);
67 static inline void uts_ns_init(void)
72 #ifdef CONFIG_PROC_SYSCTL
73 extern void uts_proc_notify(enum uts_proc proc);
75 static inline void uts_proc_notify(enum uts_proc proc)
80 static inline struct new_utsname *utsname(void)
82 return ¤t->nsproxy->uts_ns->name;
85 static inline struct new_utsname *init_utsname(void)
87 return &init_uts_ns.name;
90 extern struct rw_semaphore uts_sem;
92 #endif /* _LINUX_UTSNAME_H */