xref: /linux/rust/helpers/task.c (revision 8ad1a41f7e23287f07a3516c700bc32501d4f104)
187634653SAndreas Hindborg // SPDX-License-Identifier: GPL-2.0
287634653SAndreas Hindborg 
387634653SAndreas Hindborg #include <linux/export.h>
487634653SAndreas Hindborg #include <linux/sched/task.h>
587634653SAndreas Hindborg 
687634653SAndreas Hindborg struct task_struct *rust_helper_get_current(void)
787634653SAndreas Hindborg {
887634653SAndreas Hindborg 	return current;
987634653SAndreas Hindborg }
1087634653SAndreas Hindborg 
1187634653SAndreas Hindborg void rust_helper_get_task_struct(struct task_struct *t)
1287634653SAndreas Hindborg {
1387634653SAndreas Hindborg 	get_task_struct(t);
1487634653SAndreas Hindborg }
1587634653SAndreas Hindborg 
1687634653SAndreas Hindborg void rust_helper_put_task_struct(struct task_struct *t)
1787634653SAndreas Hindborg {
1887634653SAndreas Hindborg 	put_task_struct(t);
1987634653SAndreas Hindborg }
20*8ad1a41fSAlice Ryhl 
21*8ad1a41fSAlice Ryhl kuid_t rust_helper_task_uid(struct task_struct *task)
22*8ad1a41fSAlice Ryhl {
23*8ad1a41fSAlice Ryhl 	return task_uid(task);
24*8ad1a41fSAlice Ryhl }
25*8ad1a41fSAlice Ryhl 
26*8ad1a41fSAlice Ryhl kuid_t rust_helper_task_euid(struct task_struct *task)
27*8ad1a41fSAlice Ryhl {
28*8ad1a41fSAlice Ryhl 	return task_euid(task);
29*8ad1a41fSAlice Ryhl }
30*8ad1a41fSAlice Ryhl 
31*8ad1a41fSAlice Ryhl #ifndef CONFIG_USER_NS
32*8ad1a41fSAlice Ryhl uid_t rust_helper_from_kuid(struct user_namespace *to, kuid_t uid)
33*8ad1a41fSAlice Ryhl {
34*8ad1a41fSAlice Ryhl 	return from_kuid(to, uid);
35*8ad1a41fSAlice Ryhl }
36*8ad1a41fSAlice Ryhl #endif /* CONFIG_USER_NS */
37*8ad1a41fSAlice Ryhl 
38*8ad1a41fSAlice Ryhl bool rust_helper_uid_eq(kuid_t left, kuid_t right)
39*8ad1a41fSAlice Ryhl {
40*8ad1a41fSAlice Ryhl 	return uid_eq(left, right);
41*8ad1a41fSAlice Ryhl }
42*8ad1a41fSAlice Ryhl 
43*8ad1a41fSAlice Ryhl kuid_t rust_helper_current_euid(void)
44*8ad1a41fSAlice Ryhl {
45*8ad1a41fSAlice Ryhl 	return current_euid();
46*8ad1a41fSAlice Ryhl }
47*8ad1a41fSAlice Ryhl 
48*8ad1a41fSAlice Ryhl struct user_namespace *rust_helper_current_user_ns(void)
49*8ad1a41fSAlice Ryhl {
50*8ad1a41fSAlice Ryhl 	return current_user_ns();
51*8ad1a41fSAlice Ryhl }
52*8ad1a41fSAlice Ryhl 
53*8ad1a41fSAlice Ryhl pid_t rust_helper_task_tgid_nr_ns(struct task_struct *tsk,
54*8ad1a41fSAlice Ryhl 				  struct pid_namespace *ns)
55*8ad1a41fSAlice Ryhl {
56*8ad1a41fSAlice Ryhl 	return task_tgid_nr_ns(tsk, ns);
57*8ad1a41fSAlice Ryhl }
58