diff options
Diffstat (limited to 'ipc/util.c')
-rw-r--r-- | ipc/util.c | 61 |
1 files changed, 1 insertions, 60 deletions
diff --git a/ipc/util.c b/ipc/util.c index 76c1f3461e22..5432b8e34c9b 100644 --- a/ipc/util.c +++ b/ipc/util.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/audit.h> | 33 | #include <linux/audit.h> |
34 | #include <linux/nsproxy.h> | 34 | #include <linux/nsproxy.h> |
35 | #include <linux/rwsem.h> | 35 | #include <linux/rwsem.h> |
36 | #include <linux/ipc_namespace.h> | ||
36 | 37 | ||
37 | #include <asm/unistd.h> | 38 | #include <asm/unistd.h> |
38 | 39 | ||
@@ -51,66 +52,6 @@ struct ipc_namespace init_ipc_ns = { | |||
51 | }, | 52 | }, |
52 | }; | 53 | }; |
53 | 54 | ||
54 | static struct ipc_namespace *clone_ipc_ns(struct ipc_namespace *old_ns) | ||
55 | { | ||
56 | int err; | ||
57 | struct ipc_namespace *ns; | ||
58 | |||
59 | err = -ENOMEM; | ||
60 | ns = kmalloc(sizeof(struct ipc_namespace), GFP_KERNEL); | ||
61 | if (ns == NULL) | ||
62 | goto err_mem; | ||
63 | |||
64 | err = sem_init_ns(ns); | ||
65 | if (err) | ||
66 | goto err_sem; | ||
67 | err = msg_init_ns(ns); | ||
68 | if (err) | ||
69 | goto err_msg; | ||
70 | err = shm_init_ns(ns); | ||
71 | if (err) | ||
72 | goto err_shm; | ||
73 | |||
74 | kref_init(&ns->kref); | ||
75 | return ns; | ||
76 | |||
77 | err_shm: | ||
78 | msg_exit_ns(ns); | ||
79 | err_msg: | ||
80 | sem_exit_ns(ns); | ||
81 | err_sem: | ||
82 | kfree(ns); | ||
83 | err_mem: | ||
84 | return ERR_PTR(err); | ||
85 | } | ||
86 | |||
87 | struct ipc_namespace *copy_ipcs(unsigned long flags, struct ipc_namespace *ns) | ||
88 | { | ||
89 | struct ipc_namespace *new_ns; | ||
90 | |||
91 | BUG_ON(!ns); | ||
92 | get_ipc_ns(ns); | ||
93 | |||
94 | if (!(flags & CLONE_NEWIPC)) | ||
95 | return ns; | ||
96 | |||
97 | new_ns = clone_ipc_ns(ns); | ||
98 | |||
99 | put_ipc_ns(ns); | ||
100 | return new_ns; | ||
101 | } | ||
102 | |||
103 | void free_ipc_ns(struct kref *kref) | ||
104 | { | ||
105 | struct ipc_namespace *ns; | ||
106 | |||
107 | ns = container_of(kref, struct ipc_namespace, kref); | ||
108 | sem_exit_ns(ns); | ||
109 | msg_exit_ns(ns); | ||
110 | shm_exit_ns(ns); | ||
111 | kfree(ns); | ||
112 | } | ||
113 | |||
114 | /** | 55 | /** |
115 | * ipc_init - initialise IPC subsystem | 56 | * ipc_init - initialise IPC subsystem |
116 | * | 57 | * |