From ec2ba5d85d7c127eef674f77e45cc0bea81d8850 Mon Sep 17 00:00:00 2001 From: netchild Date: Tue, 15 Aug 2006 12:54:30 +0000 Subject: Add the linux 2.6.x stuff (not used by default!): - TLS - complete - pid/tid mangling - complete - thread area - complete - futexes - complete with issues - clone() extension - complete with some possible minor issues - mq*/timer*/clock* stuff - complete but untested and the mq* stuff is disabled when not build as part of the kernel with native FreeBSD mq* support (module support for this will come later) Tested with: - linux-firefox - works, tested - linux-opera - works, tested - linux-realplay - doesnt work, issue with futexes - linux-skype - doesnt work, issue with futexes - linux-rt2-demo - works, tested - linux-acroread - doesnt work, unknown reason (coredump) and sometimes issue with futexes - various unix utilities in linux-base-gentoo3 and linux-base-fc4: everything tried worked On amd64 not everything is supported like on i386, the catchup is planned for later when the remaining bugs in the new functions are fixed. To test this new stuff, you have to run sysctl compat.linux.osrelease=2.6.16 to switch back use sysctl compat.linux.osrelease=2.4.2 Don't switch while running a linux program, strange things may or may not happen. Sponsored by: Google SoC 2006 Submitted by: rdivacky Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild --- sys/compat/linux/linux_signal.c | 58 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'sys/compat/linux/linux_signal.c') diff --git a/sys/compat/linux/linux_signal.c b/sys/compat/linux/linux_signal.c index 081b7c0..50a05fa 100644 --- a/sys/compat/linux/linux_signal.c +++ b/sys/compat/linux/linux_signal.c @@ -49,6 +49,10 @@ __FBSDID("$FreeBSD$"); #endif #include #include +#include + +extern struct sx emul_shared_lock; +extern struct sx emul_lock; void linux_to_bsd_sigset(l_sigset_t *lss, sigset_t *bss) @@ -447,3 +451,57 @@ linux_kill(struct thread *td, struct linux_kill_args *args) tmp.pid = args->pid; return (kill(td, &tmp)); } + +int +linux_tgkill(struct thread *td, struct linux_tgkill_args *args) +{ + struct linux_emuldata *em; + struct linux_kill_args ka; + struct proc *p; + +#ifdef DEBUG + if (ldebug(tgkill)) + printf(ARGS(tgkill, "%d, %d, %d"), args->tgid, args->pid, args->sig); +#endif + + ka.pid = args->pid; + ka.signum = args->sig; + + if (args->tgid == -1) + return linux_kill(td, &ka); + + if ((p = pfind(args->pid)) == NULL) + return ESRCH; + + if (p->p_sysent != &elf_linux_sysvec) + return ESRCH; + + PROC_UNLOCK(p); + + em = em_find(p, EMUL_UNLOCKED); + + if (em == NULL) { +#ifdef DEBUG + printf("emuldata not found in tgkill.\n"); +#endif + return ESRCH; + } + + if (em->shared->group_pid != args->tgid) + return ESRCH; + + EMUL_UNLOCK(&emul_lock); + + return linux_kill(td, &ka); +} + +int +linux_tkill(struct thread *td, struct linux_tkill_args *args) +{ +#ifdef DEBUG + if (ldebug(tkill)) + printf(ARGS(tkill, "%i, %i"), args->tid, args->sig); +#endif + + return (linux_kill(td, (struct linux_kill_args *) args)); +} -- cgit v1.1