task.c 1.2 KB

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