hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/include/linux/pid.h
....@@ -4,6 +4,7 @@
44
55 #include <linux/rculist.h>
66 #include <linux/wait.h>
7
+#include <linux/refcount.h>
78
89 enum pid_type
910 {
....@@ -57,10 +58,12 @@
5758
5859 struct pid
5960 {
60
- atomic_t count;
61
+ refcount_t count;
6162 unsigned int level;
63
+ spinlock_t lock;
6264 /* lists of tasks that use this pid */
6365 struct hlist_head tasks[PIDTYPE_MAX];
66
+ struct hlist_head inodes;
6467 /* wait queue for pidfd notifications */
6568 wait_queue_head_t wait_pidfd;
6669 struct rcu_head rcu;
....@@ -71,15 +74,24 @@
7174
7275 extern const struct file_operations pidfd_fops;
7376
77
+struct file;
78
+
79
+extern struct pid *pidfd_pid(const struct file *file);
80
+struct pid *pidfd_get_pid(unsigned int fd, unsigned int *flags);
81
+
7482 static inline struct pid *get_pid(struct pid *pid)
7583 {
7684 if (pid)
77
- atomic_inc(&pid->count);
85
+ refcount_inc(&pid->count);
7886 return pid;
7987 }
8088
8189 extern void put_pid(struct pid *pid);
8290 extern struct task_struct *pid_task(struct pid *pid, enum pid_type);
91
+static inline bool pid_has_task(struct pid *pid, enum pid_type type)
92
+{
93
+ return !hlist_empty(&pid->tasks[type]);
94
+}
8395 extern struct task_struct *get_pid_task(struct pid *pid, enum pid_type);
8496
8597 extern struct pid *get_task_pid(struct task_struct *task, enum pid_type type);
....@@ -91,11 +103,15 @@
91103 extern void detach_pid(struct task_struct *task, enum pid_type);
92104 extern void change_pid(struct task_struct *task, enum pid_type,
93105 struct pid *pid);
106
+extern void exchange_tids(struct task_struct *task, struct task_struct *old);
94107 extern void transfer_pid(struct task_struct *old, struct task_struct *new,
95108 enum pid_type);
96109
97110 struct pid_namespace;
98111 extern struct pid_namespace init_pid_ns;
112
+
113
+extern int pid_max;
114
+extern int pid_max_min, pid_max_max;
99115
100116 /*
101117 * look up a PID in the hash table. Must be called with the tasklist_lock
....@@ -114,9 +130,9 @@
114130 */
115131 extern struct pid *find_get_pid(int nr);
116132 extern struct pid *find_ge_pid(int nr, struct pid_namespace *);
117
-int next_pidmap(struct pid_namespace *pid_ns, unsigned int last);
118133
119
-extern struct pid *alloc_pid(struct pid_namespace *ns);
134
+extern struct pid *alloc_pid(struct pid_namespace *ns, pid_t *set_tid,
135
+ size_t set_tid_size);
120136 extern void free_pid(struct pid *pid);
121137 extern void disable_pid_allocation(struct pid_namespace *ns);
122138