xref: /linux/rust/helpers/pid_namespace.c (revision 37a93dd5c49b5fda807fd204edf2547c3493319c)
1 // SPDX-License-Identifier: GPL-2.0
2 
3 #include <linux/pid_namespace.h>
4 #include <linux/cleanup.h>
5 
6 __rust_helper struct pid_namespace *
7 rust_helper_get_pid_ns(struct pid_namespace *ns)
8 {
9 	return get_pid_ns(ns);
10 }
11 
12 __rust_helper void rust_helper_put_pid_ns(struct pid_namespace *ns)
13 {
14 	put_pid_ns(ns);
15 }
16 
17 /* Get a reference on a task's pid namespace. */
18 __rust_helper struct pid_namespace *
19 rust_helper_task_get_pid_ns(struct task_struct *task)
20 {
21 	struct pid_namespace *pid_ns;
22 
23 	guard(rcu)();
24 	pid_ns = task_active_pid_ns(task);
25 	if (pid_ns)
26 		get_pid_ns(pid_ns);
27 	return pid_ns;
28 }
29