lkml.org 
[lkml]   [2024]   [Feb]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v4 7/9] rust: file: add `Kuid` wrapper
On Fri, Feb 02, 2024 at 10:55:41AM +0000, Alice Ryhl wrote:
> + /// Returns the given task's pid in the current pid namespace.
> + pub fn pid_in_current_ns(&self) -> Pid {
> + let current = Task::current_raw();
> + // SAFETY: Calling `task_active_pid_ns` with the current task is always safe.
> + let namespace = unsafe { bindings::task_active_pid_ns(current) };
> + // SAFETY: We know that `self.0.get()` is valid by the type invariant, and the namespace
> + // pointer is not dangling since it points at this task's namespace.
> + unsafe { bindings::task_tgid_nr_ns(self.0.get(), namespace) }
> + }

pids are reference counted in the kernel, how does this deal with that?
Are they just ignored somehow? Where is the reference count given back?

thanks,

greg k-h

\
 
 \ /
  Last update: 2024-05-27 14:46    [W:0.180 / U:0.272 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site