| .. | .. |
|---|
| 3 | 3 | #define _LINUX_PID_H |
|---|
| 4 | 4 | |
|---|
| 5 | 5 | #include <linux/rculist.h> |
|---|
| 6 | | -#include <linux/wait.h> |
|---|
| 7 | 6 | #include <linux/atomic.h> |
|---|
| 7 | +#include <linux/wait.h> |
|---|
| 8 | +#include <linux/refcount.h> |
|---|
| 8 | 9 | |
|---|
| 9 | 10 | enum pid_type |
|---|
| 10 | 11 | { |
|---|
| .. | .. |
|---|
| 58 | 59 | |
|---|
| 59 | 60 | struct pid |
|---|
| 60 | 61 | { |
|---|
| 61 | | - atomic_t count; |
|---|
| 62 | + refcount_t count; |
|---|
| 62 | 63 | unsigned int level; |
|---|
| 64 | + spinlock_t lock; |
|---|
| 63 | 65 | /* lists of tasks that use this pid */ |
|---|
| 64 | 66 | struct hlist_head tasks[PIDTYPE_MAX]; |
|---|
| 67 | + struct hlist_head inodes; |
|---|
| 65 | 68 | /* wait queue for pidfd notifications */ |
|---|
| 66 | 69 | wait_queue_head_t wait_pidfd; |
|---|
| 67 | 70 | struct rcu_head rcu; |
|---|
| .. | .. |
|---|
| 72 | 75 | |
|---|
| 73 | 76 | extern const struct file_operations pidfd_fops; |
|---|
| 74 | 77 | |
|---|
| 78 | +struct file; |
|---|
| 79 | + |
|---|
| 80 | +extern struct pid *pidfd_pid(const struct file *file); |
|---|
| 81 | +struct pid *pidfd_get_pid(unsigned int fd, unsigned int *flags); |
|---|
| 82 | + |
|---|
| 75 | 83 | static inline struct pid *get_pid(struct pid *pid) |
|---|
| 76 | 84 | { |
|---|
| 77 | 85 | if (pid) |
|---|
| 78 | | - atomic_inc(&pid->count); |
|---|
| 86 | + refcount_inc(&pid->count); |
|---|
| 79 | 87 | return pid; |
|---|
| 80 | 88 | } |
|---|
| 81 | 89 | |
|---|
| 82 | 90 | extern void put_pid(struct pid *pid); |
|---|
| 83 | 91 | extern struct task_struct *pid_task(struct pid *pid, enum pid_type); |
|---|
| 92 | +static inline bool pid_has_task(struct pid *pid, enum pid_type type) |
|---|
| 93 | +{ |
|---|
| 94 | + return !hlist_empty(&pid->tasks[type]); |
|---|
| 95 | +} |
|---|
| 84 | 96 | extern struct task_struct *get_pid_task(struct pid *pid, enum pid_type); |
|---|
| 85 | 97 | |
|---|
| 86 | 98 | extern struct pid *get_task_pid(struct task_struct *task, enum pid_type type); |
|---|
| .. | .. |
|---|
| 92 | 104 | extern void detach_pid(struct task_struct *task, enum pid_type); |
|---|
| 93 | 105 | extern void change_pid(struct task_struct *task, enum pid_type, |
|---|
| 94 | 106 | struct pid *pid); |
|---|
| 107 | +extern void exchange_tids(struct task_struct *task, struct task_struct *old); |
|---|
| 95 | 108 | extern void transfer_pid(struct task_struct *old, struct task_struct *new, |
|---|
| 96 | 109 | enum pid_type); |
|---|
| 97 | 110 | |
|---|
| 98 | 111 | struct pid_namespace; |
|---|
| 99 | 112 | extern struct pid_namespace init_pid_ns; |
|---|
| 113 | + |
|---|
| 114 | +extern int pid_max; |
|---|
| 115 | +extern int pid_max_min, pid_max_max; |
|---|
| 100 | 116 | |
|---|
| 101 | 117 | /* |
|---|
| 102 | 118 | * look up a PID in the hash table. Must be called with the tasklist_lock |
|---|
| .. | .. |
|---|
| 115 | 131 | */ |
|---|
| 116 | 132 | extern struct pid *find_get_pid(int nr); |
|---|
| 117 | 133 | extern struct pid *find_ge_pid(int nr, struct pid_namespace *); |
|---|
| 118 | | -int next_pidmap(struct pid_namespace *pid_ns, unsigned int last); |
|---|
| 119 | 134 | |
|---|
| 120 | | -extern struct pid *alloc_pid(struct pid_namespace *ns); |
|---|
| 135 | +extern struct pid *alloc_pid(struct pid_namespace *ns, pid_t *set_tid, |
|---|
| 136 | + size_t set_tid_size); |
|---|
| 121 | 137 | extern void free_pid(struct pid *pid); |
|---|
| 122 | 138 | extern void disable_pid_allocation(struct pid_namespace *ns); |
|---|
| 123 | 139 | |
|---|