@@ -16,6 +16,15 @@ struct time_namespace;
1616struct user_namespace ;
1717struct uts_namespace ;
1818
19+ extern struct cgroup_namespace init_cgroup_ns ;
20+ extern struct ipc_namespace init_ipc_ns ;
21+ extern struct mnt_namespace init_mnt_ns ;
22+ extern struct net init_net ;
23+ extern struct pid_namespace init_pid_ns ;
24+ extern struct time_namespace init_time_ns ;
25+ extern struct user_namespace init_user_ns ;
26+ extern struct uts_namespace init_uts_ns ;
27+
1928struct ns_common {
2029 struct dentry * stashed ;
2130 const struct proc_ns_operations * ops ;
@@ -31,8 +40,7 @@ struct ns_common {
3140 };
3241};
3342
34- int ns_common_init (struct ns_common * ns , const struct proc_ns_operations * ops ,
35- bool alloc_inum );
43+ int __ns_common_init (struct ns_common * ns , const struct proc_ns_operations * ops , int inum );
3644
3745#define to_ns_common (__ns ) \
3846 _Generic((__ns), \
@@ -45,4 +53,31 @@ int ns_common_init(struct ns_common *ns, const struct proc_ns_operations *ops,
4553 struct user_namespace *: &(__ns)->ns, \
4654 struct uts_namespace *: &(__ns)->ns)
4755
56+ #define ns_init_inum (__ns ) \
57+ _Generic((__ns), \
58+ struct cgroup_namespace *: CGROUP_NS_INIT_INO, \
59+ struct ipc_namespace *: IPC_NS_INIT_INO, \
60+ struct mnt_namespace *: MNT_NS_INIT_INO, \
61+ struct net *: NET_NS_INIT_INO, \
62+ struct pid_namespace *: PID_NS_INIT_INO, \
63+ struct time_namespace *: TIME_NS_INIT_INO, \
64+ struct user_namespace *: USER_NS_INIT_INO, \
65+ struct uts_namespace *: UTS_NS_INIT_INO)
66+
67+ #define ns_init_ns (__ns ) \
68+ _Generic((__ns), \
69+ struct cgroup_namespace *: &init_cgroup_ns, \
70+ struct ipc_namespace *: &init_ipc_ns, \
71+ struct mnt_namespace *: &init_mnt_ns, \
72+ struct net *: &init_net, \
73+ struct pid_namespace *: &init_pid_ns, \
74+ struct time_namespace *: &init_time_ns, \
75+ struct user_namespace *: &init_user_ns, \
76+ struct uts_namespace *: &init_uts_ns)
77+
78+ #define ns_common_init (__ns , __ops ) \
79+ __ns_common_init(to_ns_common(__ns), __ops, (((__ns) == ns_init_ns(__ns)) ? ns_init_inum(__ns) : 0))
80+
81+ #define ns_common_init_inum (__ns , __ops , __inum ) __ns_common_init(to_ns_common(__ns), __ops, __inum)
82+
4883#endif
0 commit comments