Skip to contentSkip to conversation

Make alloc_pid(), free_pid() and put_pid() work with struct upid

PATCH In review [email protected] 1 participant 1 message Aug 10, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 7/20 Make alloc_pid(), free_pid() and put_pid() work with struct upid

Each struct upid element of struct pid has to be initialized properly, i.e. its nr mst be allocated from appropriate pidmap and ns set to appropriate namespace.

When allocating a new pid, we need to know the namespace this pid will live in, so the additional argument is added to alloc_pid().

On the other hand, the rest of the kernel still uses the pid->nr and pid->pid_chain fields, so these ones are still initialized, but this will be removed soon.

---

 include/linux/pid.h |    2 +-
 kernel/fork.c       |    2 +-
 kernel/pid.c        |   49 ++++++++++++++++++++++++++++++++++---------------
 3 files changed, 36 insertions(+), 17 deletions(-)
include/linux/pid.h renamed from include/linux/pid.h.ve8 +1 -1
@@ -111,7 +111,7 @@ extern struct pid *FASTCALL(find_pid(int
 extern struct pid *find_get_pid(int nr);
 extern struct pid *find_ge_pid(int nr);
 
-extern struct pid *alloc_pid(void);
+extern struct pid *alloc_pid(struct pid_namespace *ns);
 extern void FASTCALL(free_pid(struct pid *pid));
 
 static inline pid_t pid_nr(struct pid *pid)
kernel/fork.c renamed from kernel/fork.c.ve8 +1 -1
@@ -1029,7 +1029,7 @@ static struct task_struct *copy_process(
 		goto bad_fork_cleanup_put_domain;
 
 	if (pid != &init_struct_pid) {
-		pid = alloc_pid();
+		pid = alloc_pid(task_active_pid_ns(p));
 		if (!pid)
 			goto bad_fork_put_binfmt_module;
 	}
kernel/pid.c renamed from kernel/pid.c.ve8 +34 -15

104 lines not on this page · raw message