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