Lines Matching full:pid
9 #include <linux/pid.h>
58 struct pid *pid_a = rb_entry(a, struct pid, pidfs_node); in pidfs_ino_cmp()
59 struct pid *pid_b = rb_entry(b, struct pid, pidfs_node); in pidfs_ino_cmp()
70 void pidfs_add_pid(struct pid *pid) in pidfs_add_pid() argument
76 * to struct pid is the inode number. in pidfs_add_pid()
78 * On 32 bit the 64 bit number assigned to struct pid is split in pidfs_add_pid()
102 pid->ino = pidfs_ino_nr; in pidfs_add_pid()
103 pid->stashed = NULL; in pidfs_add_pid()
107 rb_find_add_rcu(&pid->pidfs_node, &pidfs_ino_tree, pidfs_ino_cmp); in pidfs_add_pid()
111 void pidfs_remove_pid(struct pid *pid) in pidfs_remove_pid() argument
114 rb_erase(&pid->pidfs_node, &pidfs_ino_tree); in pidfs_remove_pid()
124 * Pid:
125 * This function will print the pid that a given pidfd refers to in the
126 * pid namespace of the procfs instance.
127 * If the pid namespace of the process is not a descendant of the pid
128 * namespace of the procfs instance 0 will be shown as its pid. This is
130 * its pid namespace.
133 * If pid namespaces are supported then this function will also print
134 * the pid of a given pidfd refers to for all descendant pid namespaces
135 * starting from the current pid namespace of the instance, i.e. the
136 * Pid field and the first entry in the NSpid field will be identical.
137 * If the pid namespace of the process is not a descendant of the pid
140 * Note that this differs from the Pid and NSpid fields in
141 * /proc/<pid>/status where Pid and NSpid are always shown relative to
142 * the pid namespace of the procfs instance. The difference becomes
143 * obvious when sending around a pidfd between pid namespaces from a
145 * present between the pid namespaces:
146 * - create two new pid namespaces ns1 and ns2 in the initial pid
148 * new pid namespace and mount procfs)
151 * - read /proc/self/fdinfo/<pidfd> and observe that both Pid and NSpid
156 struct pid *pid = pidfd_pid(f); in pidfd_show_fdinfo() local
160 if (likely(pid_has_task(pid, PIDTYPE_PID))) { in pidfd_show_fdinfo()
162 nr = pid_nr_ns(pid, ns); in pidfd_show_fdinfo()
165 seq_put_decimal_ll(m, "Pid:\t", nr); in pidfd_show_fdinfo()
172 /* If nr is non-zero it means that 'pid' is valid and that in pidfd_show_fdinfo()
173 * ns, i.e. the pid namespace associated with the procfs in pidfd_show_fdinfo()
174 * instance, is in the pid namespace hierarchy of pid. in pidfd_show_fdinfo()
177 for (i = ns->level + 1; i <= pid->level; i++) in pidfd_show_fdinfo()
178 seq_put_decimal_ll(m, "\t", pid->numbers[i].nr); in pidfd_show_fdinfo()
190 struct pid *pid = pidfd_pid(file); in pidfd_poll() local
195 poll_wait(file, &pid->wait_pidfd, pts); in pidfd_poll()
201 task = pid_task(pid, PIDTYPE_PID); in pidfd_poll()
257 * Copy pid/tgid last, to reduce the chances the information might be in pidfd_info()
267 kinfo.pid = task_pid_vnr(task); in pidfd_info()
270 if (kinfo.pid == 0 || kinfo.tgid == 0 || (kinfo.ppid == 0 && kinfo.pid != 1)) in pidfd_info()
320 struct pid *pid = pidfd_pid(file); in pidfd_ioctl() local
335 task = get_pid_task(pid, PIDTYPE_PID); in pidfd_ioctl()
446 struct pid *pidfd_pid(const struct file *file) in pidfd_pid()
502 struct pid *pid = inode->i_private; in pidfs_evict_inode() local
505 put_pid(pid); in pidfs_evict_inode()
531 const struct pid *pid = inode->i_private; in pidfs_encode_fh() local
539 *(u64 *)fh = pid->ino; in pidfs_encode_fh()
546 const struct pid *pid = rb_entry(node, struct pid, pidfs_node); in pidfs_ino_find() local
548 if (pid_ino < pid->ino) in pidfs_ino_find()
550 if (pid_ino > pid->ino) in pidfs_ino_find()
555 /* Find a struct pid based on the inode number. */
556 static struct pid *pidfs_ino_get_pid(u64 ino) in pidfs_ino_get_pid()
558 struct pid *pid; in pidfs_ino_get_pid() local
573 pid = rb_entry(node, struct pid, pidfs_node); in pidfs_ino_get_pid()
575 /* Within our pid namespace hierarchy? */ in pidfs_ino_get_pid()
576 if (pid_vnr(pid) == 0) in pidfs_ino_get_pid()
579 return get_pid(pid); in pidfs_ino_get_pid()
589 struct pid *pid; in pidfs_fh_to_dentry() local
602 pid = pidfs_ino_get_pid(pid_ino); in pidfs_fh_to_dentry()
603 if (!pid) in pidfs_fh_to_dentry()
606 ret = path_from_stashed(&pid->stashed, pidfs_mnt, pid, &path); in pidfs_fh_to_dentry()
629 * pidfd_ino_get_pid() will verify that the struct pid is part in pidfs_export_permission()
630 * of the caller's pid namespace hierarchy. No further in pidfs_export_permission()
655 const struct pid *pid = data; in pidfs_init_inode() local
662 inode->i_ino = pidfs_ino(pid->ino); in pidfs_init_inode()
663 inode->i_generation = pidfs_gen(pid->ino); in pidfs_init_inode()
669 struct pid *pid = data; in pidfs_put_data() local
670 put_pid(pid); in pidfs_put_data()
699 struct file *pidfs_alloc_file(struct pid *pid, unsigned int flags) in pidfs_alloc_file() argument
706 ret = path_from_stashed(&pid->stashed, pidfs_mnt, get_pid(pid), &path); in pidfs_alloc_file()