Skip to content

Commit d7e4f85

Browse files
Leo Yankuba-moo
authored andcommitted
pid: Introduce helper task_is_in_init_pid_ns()
Currently the kernel uses open code in multiple places to check if a task is in the root PID namespace with the kind of format: if (task_active_pid_ns(current) == &init_pid_ns) do_something(); This patch creates a new helper function, task_is_in_init_pid_ns(), it returns true if a passed task is in the root PID namespace, otherwise returns false. So it will be used to replace open codes. Suggested-by: Suzuki K Poulose <[email protected]> Signed-off-by: Leo Yan <[email protected]> Reviewed-by: Leon Romanovsky <[email protected]> Acked-by: Suzuki K Poulose <[email protected]> Acked-by: Balbir Singh <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent a92f7a6 commit d7e4f85

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

include/linux/pid_namespace.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,9 @@ extern struct pid_namespace *task_active_pid_ns(struct task_struct *tsk);
8686
void pidhash_init(void);
8787
void pid_idr_init(void);
8888

89+
static inline bool task_is_in_init_pid_ns(struct task_struct *tsk)
90+
{
91+
return task_active_pid_ns(tsk) == &init_pid_ns;
92+
}
93+
8994
#endif /* _LINUX_PID_NS_H */

0 commit comments

Comments
 (0)