Deleted Added
sdiff udiff text old ( 191269 ) new ( 215664 )
full compact
1/*-
2 * Copyright (c) 2006 Roman Divacky
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/compat/linux/linux_emul.c 191269 2009-04-19 13:48:42Z dchagin $");
31
32#include "opt_compat.h"
33
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/imgact.h>
37#include <sys/kernel.h>
38#include <sys/lock.h>

--- 111 unchanged lines hidden (view full) ---

150
151 return (0);
152}
153
154void
155linux_proc_exit(void *arg __unused, struct proc *p)
156{
157 struct linux_emuldata *em;
158 int error;
159 struct thread *td = FIRST_THREAD_IN_PROC(p);
160 int *child_clear_tid;
161 struct proc *q, *nq;
162
163 if (__predict_true(p->p_sysent != &elf_linux_sysvec))
164 return;
165
166 release_futexes(p);

--- 15 unchanged lines hidden (view full) ---

182 PROC_UNLOCK(p);
183 sx_xunlock(&proctree_lock);
184 } else {
185 child_clear_tid = em->child_clear_tid;
186 EMUL_UNLOCK(&emul_lock);
187 }
188
189 EMUL_SHARED_WLOCK(&emul_shared_lock);
190 LIST_REMOVE(em, threads);
191
192 em->shared->refs--;
193 if (em->shared->refs == 0) {
194 EMUL_SHARED_WUNLOCK(&emul_shared_lock);
195 free(em->shared, M_LINUX);
196 } else
197 EMUL_SHARED_WUNLOCK(&emul_shared_lock);
198
199 if (child_clear_tid != NULL) {
200 struct linux_sys_futex_args cup;
201 int null = 0;
202
203 error = copyout(&null, child_clear_tid, sizeof(null));
204 if (error) {
205 free(em, M_LINUX);
206 return;

--- 45 unchanged lines hidden (view full) ---

252 * process.
253 */
254void
255linux_proc_exec(void *arg __unused, struct proc *p, struct image_params *imgp)
256{
257 if (__predict_false(imgp->sysent == &elf_linux_sysvec
258 && p->p_sysent != &elf_linux_sysvec))
259 linux_proc_init(FIRST_THREAD_IN_PROC(p), p->p_pid, 0);
260 if (__predict_false(imgp->sysent != &elf_linux_sysvec
261 && p->p_sysent == &elf_linux_sysvec)) {
262 struct linux_emuldata *em;
263
264 /*
265 * XXX:There's a race because here we assign p->p_emuldata NULL
266 * but the process is still counted as linux one for a short
267 * time so some other process might reference it and try to

--- 61 unchanged lines hidden (view full) ---

329 KASSERT(em != NULL, ("set_tid_address: emuldata not found.\n"));
330
331 em->child_clear_tid = args->tidptr;
332 td->td_retval[0] = td->td_proc->p_pid;
333
334 EMUL_UNLOCK(&emul_lock);
335 return 0;
336}