xref: /linux/rust/helpers/task.c (revision c34e9ab9a612ee8b18273398ef75c207b01f516d)
1 // SPDX-License-Identifier: GPL-2.0
2 
3 #include <linux/sched/task.h>
4 
5 struct task_struct *rust_helper_get_current(void)
6 {
7 	return current;
8 }
9 
10 void rust_helper_get_task_struct(struct task_struct *t)
11 {
12 	get_task_struct(t);
13 }
14 
15 void rust_helper_put_task_struct(struct task_struct *t)
16 {
17 	put_task_struct(t);
18 }
19 
20 kuid_t rust_helper_task_uid(struct task_struct *task)
21 {
22 	return task_uid(task);
23 }
24 
25 kuid_t rust_helper_task_euid(struct task_struct *task)
26 {
27 	return task_euid(task);
28 }
29 
30 #ifndef CONFIG_USER_NS
31 uid_t rust_helper_from_kuid(struct user_namespace *to, kuid_t uid)
32 {
33 	return from_kuid(to, uid);
34 }
35 #endif /* CONFIG_USER_NS */
36 
37 bool rust_helper_uid_eq(kuid_t left, kuid_t right)
38 {
39 	return uid_eq(left, right);
40 }
41 
42 kuid_t rust_helper_current_euid(void)
43 {
44 	return current_euid();
45 }
46 
47 struct user_namespace *rust_helper_current_user_ns(void)
48 {
49 	return current_user_ns();
50 }
51 
52 pid_t rust_helper_task_tgid_nr_ns(struct task_struct *tsk,
53 				  struct pid_namespace *ns)
54 {
55 	return task_tgid_nr_ns(tsk, ns);
56 }
57