Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

uts: split namespace into separate header

We have dedicated headers for all namespace types. Add one for the uts
namespace as well. Now it's consistent for all namespace types.

Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>

+66 -57
+65
include/linux/uts_namespace.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef _LINUX_UTS_NAMESPACE_H 3 + #define _LINUX_UTS_NAMESPACE_H 4 + 5 + #include <linux/ns_common.h> 6 + #include <uapi/linux/utsname.h> 7 + 8 + struct user_namespace; 9 + extern struct user_namespace init_user_ns; 10 + 11 + struct uts_namespace { 12 + struct new_utsname name; 13 + struct user_namespace *user_ns; 14 + struct ucounts *ucounts; 15 + struct ns_common ns; 16 + } __randomize_layout; 17 + 18 + extern struct uts_namespace init_uts_ns; 19 + 20 + #ifdef CONFIG_UTS_NS 21 + static inline struct uts_namespace *to_uts_ns(struct ns_common *ns) 22 + { 23 + return container_of(ns, struct uts_namespace, ns); 24 + } 25 + 26 + static inline void get_uts_ns(struct uts_namespace *ns) 27 + { 28 + refcount_inc(&ns->ns.count); 29 + } 30 + 31 + extern struct uts_namespace *copy_utsname(unsigned long flags, 32 + struct user_namespace *user_ns, struct uts_namespace *old_ns); 33 + extern void free_uts_ns(struct uts_namespace *ns); 34 + 35 + static inline void put_uts_ns(struct uts_namespace *ns) 36 + { 37 + if (refcount_dec_and_test(&ns->ns.count)) 38 + free_uts_ns(ns); 39 + } 40 + 41 + void uts_ns_init(void); 42 + #else 43 + static inline void get_uts_ns(struct uts_namespace *ns) 44 + { 45 + } 46 + 47 + static inline void put_uts_ns(struct uts_namespace *ns) 48 + { 49 + } 50 + 51 + static inline struct uts_namespace *copy_utsname(unsigned long flags, 52 + struct user_namespace *user_ns, struct uts_namespace *old_ns) 53 + { 54 + if (flags & CLONE_NEWUTS) 55 + return ERR_PTR(-EINVAL); 56 + 57 + return old_ns; 58 + } 59 + 60 + static inline void uts_ns_init(void) 61 + { 62 + } 63 + #endif 64 + 65 + #endif /* _LINUX_UTS_NAMESPACE_H */
+1 -57
include/linux/utsname.h
··· 7 7 #include <linux/nsproxy.h> 8 8 #include <linux/ns_common.h> 9 9 #include <linux/err.h> 10 - #include <uapi/linux/utsname.h> 10 + #include <linux/uts_namespace.h> 11 11 12 12 enum uts_proc { 13 13 UTS_PROC_ARCH, ··· 17 17 UTS_PROC_HOSTNAME, 18 18 UTS_PROC_DOMAINNAME, 19 19 }; 20 - 21 - struct user_namespace; 22 - extern struct user_namespace init_user_ns; 23 - 24 - struct uts_namespace { 25 - struct new_utsname name; 26 - struct user_namespace *user_ns; 27 - struct ucounts *ucounts; 28 - struct ns_common ns; 29 - } __randomize_layout; 30 - extern struct uts_namespace init_uts_ns; 31 - 32 - #ifdef CONFIG_UTS_NS 33 - static inline struct uts_namespace *to_uts_ns(struct ns_common *ns) 34 - { 35 - return container_of(ns, struct uts_namespace, ns); 36 - } 37 - 38 - static inline void get_uts_ns(struct uts_namespace *ns) 39 - { 40 - refcount_inc(&ns->ns.count); 41 - } 42 - 43 - extern struct uts_namespace *copy_utsname(unsigned long flags, 44 - struct user_namespace *user_ns, struct uts_namespace *old_ns); 45 - extern void free_uts_ns(struct uts_namespace *ns); 46 - 47 - static inline void put_uts_ns(struct uts_namespace *ns) 48 - { 49 - if (refcount_dec_and_test(&ns->ns.count)) 50 - free_uts_ns(ns); 51 - } 52 - 53 - void uts_ns_init(void); 54 - #else 55 - static inline void get_uts_ns(struct uts_namespace *ns) 56 - { 57 - } 58 - 59 - static inline void put_uts_ns(struct uts_namespace *ns) 60 - { 61 - } 62 - 63 - static inline struct uts_namespace *copy_utsname(unsigned long flags, 64 - struct user_namespace *user_ns, struct uts_namespace *old_ns) 65 - { 66 - if (flags & CLONE_NEWUTS) 67 - return ERR_PTR(-EINVAL); 68 - 69 - return old_ns; 70 - } 71 - 72 - static inline void uts_ns_init(void) 73 - { 74 - } 75 - #endif 76 20 77 21 #ifdef CONFIG_PROC_SYSCTL 78 22 extern void uts_proc_notify(enum uts_proc proc);