Lines Matching +full:reference +full:- +full:sync
1 // SPDX-License-Identifier: GPL-2.0
12 sync::aref::ARef,
75 /// Getting the current task and storing it in some struct. The reference count is automatically
79 /// use kernel::{task::Task, sync::aref::ARef};
87 /// fn new() -> Self {
107 unsafe impl Sync for Task {}
112 /// For example, to retrieve the pid-namespace of a task, you must use rcu protection unless it is
126 /// Other operations temporarily create a new sub-context:
142 fn deref(&self) -> &Task { in deref()
161 pub fn current_raw() -> *mut bindings::task_struct { in current_raw()
166 /// Returns a task reference for the currently executing task/thread.
177 pub unsafe fn current() -> impl Deref<Target = CurrentTask> { in current()
185 fn deref(&self) -> &Self::Target { in current()
186 // SAFETY: The returned reference borrows from this `TaskRef`, so it cannot outlive in current()
189 // is okay to return a `CurrentTask` reference here. in current()
202 pub fn as_ptr(&self) -> *mut bindings::task_struct { in as_ptr()
207 pub fn pid(&self) -> Pid { in pid()
215 pub fn uid(&self) -> Kuid { in uid()
222 pub fn euid(&self) -> Kuid { in euid()
229 pub fn signal_pending(&self) -> bool { in signal_pending()
234 /// Returns task's pid namespace with elevated reference count
236 pub fn get_pid_ns(&self) -> Option<ARef<PidNamespace>> { in get_pid_ns()
243 // reference count via `task_get_pid_ns()`. in get_pid_ns()
252 pub fn tgid_nr_ns(&self, pidns: Option<&PidNamespace>) -> Pid { in tgid_nr_ns()
278 pub fn mm(&self) -> Option<&MmWithUser> { in mm()
287 // SAFETY: If `current->mm` is non-null, then it references a valid mm with a non-zero in mm()
299 // In either case, it's not possible to read `current->mm` and keep using it after the in mm()
311 pub fn active_pid_ns(&self) -> Option<&PidNamespace> { in active_pid_ns()
325 // safe and requires neither RCU locking nor a reference count to be held. Retrieving the in active_pid_ns()
329 // SAFETY: If `current`'s pid ns is non-null, then it references a valid pid ns. in active_pid_ns()
337 pub fn group_leader(&self) -> &Task { in group_leader()
342 // SAFETY: `current->group_leader` stays valid for at least the duration in which `current` in group_leader()
350 unsafe impl crate::sync::aref::AlwaysRefCounted for Task {
353 // SAFETY: The existence of a shared reference means that the refcount is nonzero. in inc_ref()
366 fn eq(&self, other: &Self) -> bool { in eq()
376 pub fn current_euid() -> Kuid { in current_euid()
383 pub fn from_raw(kuid: bindings::kuid_t) -> Self { in from_raw()
389 pub fn into_raw(self) -> bindings::kuid_t { in into_raw()
397 pub fn into_uid_in_current_ns(self) -> bindings::uid_t { in into_uid_in_current_ns()
405 fn eq(&self, other: &Kuid) -> bool { in eq()
420 /// [`might_sleep()`]: https://docs.kernel.org/driver-api/basics.html#c.might_sleep
429 // SAFETY: `file.as_ptr()` is valid for reading and guaranteed to be nul-terminated. in might_sleep()