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.

ns: add to_<type>_ns() to respective headers

Every namespace type has a container_of(ns, <ns_type>, ns) static inline
function that is currently not exposed in the header. So we have a bunch
of places that open-code it via container_of(). Move it to the headers
so we can use it directly.

Reviewed-by: Aleksa Sarai <cyphar@cyphar.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>

+34 -35
+5
include/linux/cgroup.h
··· 794 794 795 795 #ifdef CONFIG_CGROUPS 796 796 797 + static inline struct cgroup_namespace *to_cg_ns(struct ns_common *ns) 798 + { 799 + return container_of(ns, struct cgroup_namespace, ns); 800 + } 801 + 797 802 void free_cgroup_ns(struct cgroup_namespace *ns); 798 803 799 804 struct cgroup_namespace *copy_cgroup_ns(unsigned long flags,
+5
include/linux/ipc_namespace.h
··· 129 129 #endif 130 130 131 131 #if defined(CONFIG_IPC_NS) 132 + static inline struct ipc_namespace *to_ipc_ns(struct ns_common *ns) 133 + { 134 + return container_of(ns, struct ipc_namespace, ns); 135 + } 136 + 132 137 extern struct ipc_namespace *copy_ipcs(unsigned long flags, 133 138 struct user_namespace *user_ns, struct ipc_namespace *ns); 134 139
+5
include/linux/pid_namespace.h
··· 54 54 #define PIDNS_ADDING (1U << 31) 55 55 56 56 #ifdef CONFIG_PID_NS 57 + static inline struct pid_namespace *to_pid_ns(struct ns_common *ns) 58 + { 59 + return container_of(ns, struct pid_namespace, ns); 60 + } 61 + 57 62 static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns) 58 63 { 59 64 if (ns != &init_pid_ns)
+4
include/linux/time_namespace.h
··· 33 33 extern struct time_namespace init_time_ns; 34 34 35 35 #ifdef CONFIG_TIME_NS 36 + static inline struct time_namespace *to_time_ns(struct ns_common *ns) 37 + { 38 + return container_of(ns, struct time_namespace, ns); 39 + } 36 40 void __init time_ns_init(void); 37 41 extern int vdso_join_timens(struct task_struct *task, 38 42 struct time_namespace *ns);
+5
include/linux/user_namespace.h
··· 168 168 169 169 #ifdef CONFIG_USER_NS 170 170 171 + static inline struct user_namespace *to_user_ns(struct ns_common *ns) 172 + { 173 + return container_of(ns, struct user_namespace, ns); 174 + } 175 + 171 176 static inline struct user_namespace *get_user_ns(struct user_namespace *ns) 172 177 { 173 178 if (ns)
+5
include/linux/utsname.h
··· 30 30 extern struct uts_namespace init_uts_ns; 31 31 32 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 + 33 38 static inline void get_uts_ns(struct uts_namespace *ns) 34 39 { 35 40 refcount_inc(&ns->ns.count);
+5
include/net/net_namespace.h
··· 262 262 #ifdef CONFIG_NET_NS 263 263 void __put_net(struct net *net); 264 264 265 + static inline struct net *to_net_ns(struct ns_common *ns) 266 + { 267 + return container_of(ns, struct net, ns); 268 + } 269 + 265 270 /* Try using get_net_track() instead */ 266 271 static inline struct net *get_net(struct net *net) 267 272 {
-5
ipc/namespace.c
··· 209 209 } 210 210 } 211 211 212 - static inline struct ipc_namespace *to_ipc_ns(struct ns_common *ns) 213 - { 214 - return container_of(ns, struct ipc_namespace, ns); 215 - } 216 - 217 212 static struct ns_common *ipcns_get(struct task_struct *task) 218 213 { 219 214 struct ipc_namespace *ns = NULL;
-5
kernel/cgroup/namespace.c
··· 89 89 return new_ns; 90 90 } 91 91 92 - static inline struct cgroup_namespace *to_cg_ns(struct ns_common *ns) 93 - { 94 - return container_of(ns, struct cgroup_namespace, ns); 95 - } 96 - 97 92 static int cgroupns_install(struct nsset *nsset, struct ns_common *ns) 98 93 { 99 94 struct nsproxy *nsproxy = nsset->nsproxy;
-5
kernel/pid_namespace.c
··· 345 345 return 0; 346 346 } 347 347 348 - static inline struct pid_namespace *to_pid_ns(struct ns_common *ns) 349 - { 350 - return container_of(ns, struct pid_namespace, ns); 351 - } 352 - 353 348 static struct ns_common *pidns_get(struct task_struct *task) 354 349 { 355 350 struct pid_namespace *ns;
-5
kernel/time/namespace.c
··· 261 261 kfree_rcu(ns, ns.ns_rcu); 262 262 } 263 263 264 - static struct time_namespace *to_time_ns(struct ns_common *ns) 265 - { 266 - return container_of(ns, struct time_namespace, ns); 267 - } 268 - 269 264 static struct ns_common *timens_get(struct task_struct *task) 270 265 { 271 266 struct time_namespace *ns = NULL;
-5
kernel/user_namespace.c
··· 1325 1325 } 1326 1326 EXPORT_SYMBOL(current_in_userns); 1327 1327 1328 - static inline struct user_namespace *to_user_ns(struct ns_common *ns) 1329 - { 1330 - return container_of(ns, struct user_namespace, ns); 1331 - } 1332 - 1333 1328 static struct ns_common *userns_get(struct task_struct *task) 1334 1329 { 1335 1330 struct user_namespace *user_ns;
-5
kernel/utsname.c
··· 103 103 kfree_rcu(ns, ns.ns_rcu); 104 104 } 105 105 106 - static inline struct uts_namespace *to_uts_ns(struct ns_common *ns) 107 - { 108 - return container_of(ns, struct uts_namespace, ns); 109 - } 110 - 111 106 static struct ns_common *utsns_get(struct task_struct *task) 112 107 { 113 108 struct uts_namespace *ns = NULL;
-5
net/core/net_namespace.c
··· 1541 1541 return net ? &net->ns : NULL; 1542 1542 } 1543 1543 1544 - static inline struct net *to_net_ns(struct ns_common *ns) 1545 - { 1546 - return container_of(ns, struct net, ns); 1547 - } 1548 - 1549 1544 static void netns_put(struct ns_common *ns) 1550 1545 { 1551 1546 put_net(to_net_ns(ns));