aboutsummaryrefslogtreecommitdiffstats
path: root/ipc/namespace.c
diff options
context:
space:
mode:
Diffstat (limited to 'ipc/namespace.c')
-rw-r--r--ipc/namespace.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/ipc/namespace.c b/ipc/namespace.c
index 1fed8922d475..1b967655eb35 100644
--- a/ipc/namespace.c
+++ b/ipc/namespace.c
@@ -44,6 +44,36 @@ struct ipc_namespace *copy_ipcs(unsigned long flags, struct ipc_namespace *ns)
44 return new_ns; 44 return new_ns;
45} 45}
46 46
47/*
48 * free_ipcs - free all ipcs of one type
49 * @ns: the namespace to remove the ipcs from
50 * @ids: the table of ipcs to free
51 * @free: the function called to free each individual ipc
52 *
53 * Called for each kind of ipc when an ipc_namespace exits.
54 */
55void free_ipcs(struct ipc_namespace *ns, struct ipc_ids *ids,
56 void (*free)(struct ipc_namespace *, struct kern_ipc_perm *))
57{
58 struct kern_ipc_perm *perm;
59 int next_id;
60 int total, in_use;
61
62 down_write(&ids->rw_mutex);
63
64 in_use = ids->in_use;
65
66 for (total = 0, next_id = 0; total < in_use; next_id++) {
67 perm = idr_find(&ids->ipcs_idr, next_id);
68 if (perm == NULL)
69 continue;
70 ipc_lock_by_ptr(perm);
71 free(ns, perm);
72 total++;
73 }
74 up_write(&ids->rw_mutex);
75}
76
47void free_ipc_ns(struct kref *kref) 77void free_ipc_ns(struct kref *kref)
48{ 78{
49 struct ipc_namespace *ns; 79 struct ipc_namespace *ns;