Re: [PATCH v4 7/9] rust: file: add `Kuid` wrapper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux