1995-06-25 17:32:43 +00:00
|
|
|
|
/*-
|
2004-08-15 12:34:15 +00:00
|
|
|
|
* Copyright (c) 2002 Doug Rabson
|
1995-06-25 17:32:43 +00:00
|
|
|
|
* Copyright (c) 1994-1995 S<EFBFBD>ren Schmidt
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
|
* are met:
|
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
* notice, this list of conditions and the following disclaimer
|
1995-06-25 17:32:43 +00:00
|
|
|
|
* in this position and unchanged.
|
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
2002-06-02 20:05:59 +00:00
|
|
|
|
* derived from this software without specific prior written permission
|
1995-06-25 17:32:43 +00:00
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
*/
|
|
|
|
|
|
2003-06-10 21:29:12 +00:00
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
|
2006-03-19 11:10:33 +00:00
|
|
|
|
#include "opt_compat.h"
|
2002-08-01 22:23:02 +00:00
|
|
|
|
#include "opt_mac.h"
|
1999-08-15 13:28:35 +00:00
|
|
|
|
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#include <sys/param.h>
|
2002-09-05 08:13:20 +00:00
|
|
|
|
#include <sys/blist.h>
|
1997-03-23 03:37:54 +00:00
|
|
|
|
#include <sys/fcntl.h>
|
2006-05-10 20:38:16 +00:00
|
|
|
|
#if defined(__i386__)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#include <sys/imgact_aout.h>
|
2004-08-16 07:28:16 +00:00
|
|
|
|
#endif
|
2002-02-27 15:06:33 +00:00
|
|
|
|
#include <sys/jail.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
|
#include <sys/kernel.h>
|
2003-04-29 13:36:06 +00:00
|
|
|
|
#include <sys/limits.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
|
#include <sys/lock.h>
|
2002-08-01 22:23:02 +00:00
|
|
|
|
#include <sys/mac.h>
|
2002-09-05 08:13:20 +00:00
|
|
|
|
#include <sys/malloc.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
|
#include <sys/mman.h>
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#include <sys/mount.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
|
#include <sys/mutex.h>
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#include <sys/namei.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
|
#include <sys/proc.h>
|
2001-02-16 14:42:11 +00:00
|
|
|
|
#include <sys/reboot.h>
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#include <sys/resourcevar.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
|
#include <sys/signalvar.h>
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#include <sys/stat.h>
|
2002-09-01 22:30:27 +00:00
|
|
|
|
#include <sys/syscallsubr.h>
|
1995-11-22 07:43:53 +00:00
|
|
|
|
#include <sys/sysctl.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
|
#include <sys/sysproto.h>
|
2002-09-05 08:13:20 +00:00
|
|
|
|
#include <sys/systm.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
|
#include <sys/time.h>
|
2001-07-23 06:22:10 +00:00
|
|
|
|
#include <sys/vmmeter.h>
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
|
#include <sys/wait.h>
|
|
|
|
|
|
1995-12-06 19:14:16 +00:00
|
|
|
|
#include <vm/vm.h>
|
1995-12-09 08:17:24 +00:00
|
|
|
|
#include <vm/pmap.h>
|
1995-11-22 07:43:53 +00:00
|
|
|
|
#include <vm/vm_kern.h>
|
1995-12-09 08:17:24 +00:00
|
|
|
|
#include <vm/vm_map.h>
|
1995-12-14 22:35:45 +00:00
|
|
|
|
#include <vm/vm_extern.h>
|
2001-07-23 06:22:10 +00:00
|
|
|
|
#include <vm/vm_object.h>
|
|
|
|
|
#include <vm/swap_pager.h>
|
1995-11-22 07:43:53 +00:00
|
|
|
|
|
1999-08-15 17:28:40 +00:00
|
|
|
|
#include <posix4/sched.h>
|
|
|
|
|
|
2005-03-07 00:18:06 +00:00
|
|
|
|
#include <compat/linux/linux_sysproto.h>
|
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
2006-08-15 12:54:30 +00:00
|
|
|
|
#include <compat/linux/linux_emul.h>
|
2005-03-07 00:18:06 +00:00
|
|
|
|
|
2005-01-14 04:44:56 +00:00
|
|
|
|
#ifdef COMPAT_LINUX32
|
2004-08-16 07:28:16 +00:00
|
|
|
|
#include <machine/../linux32/linux.h>
|
|
|
|
|
#include <machine/../linux32/linux32_proto.h>
|
2005-01-14 04:44:56 +00:00
|
|
|
|
#else
|
|
|
|
|
#include <machine/../linux/linux.h>
|
|
|
|
|
#include <machine/../linux/linux_proto.h>
|
2004-08-16 07:28:16 +00:00
|
|
|
|
#endif
|
2002-09-05 08:13:20 +00:00
|
|
|
|
|
2000-08-22 01:46:50 +00:00
|
|
|
|
#include <compat/linux/linux_mib.h>
|
|
|
|
|
#include <compat/linux/linux_util.h>
|
|
|
|
|
|
2003-07-29 10:03:15 +00:00
|
|
|
|
#ifdef __i386__
|
|
|
|
|
#include <machine/cputypes.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
1999-09-29 15:12:18 +00:00
|
|
|
|
#define BSD_TO_LINUX_SIGNAL(sig) \
|
|
|
|
|
(((sig) <= LINUX_SIGTBLSZ) ? bsd_to_linux_signal[_SIG_IDX(sig)] : sig)
|
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
|
static unsigned int linux_to_bsd_resource[LINUX_RLIM_NLIMITS] = {
|
|
|
|
|
RLIMIT_CPU, RLIMIT_FSIZE, RLIMIT_DATA, RLIMIT_STACK,
|
|
|
|
|
RLIMIT_CORE, RLIMIT_RSS, RLIMIT_NPROC, RLIMIT_NOFILE,
|
|
|
|
|
RLIMIT_MEMLOCK, -1
|
1999-08-11 13:34:31 +00:00
|
|
|
|
};
|
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
|
struct l_sysinfo {
|
|
|
|
|
l_long uptime; /* Seconds since boot */
|
|
|
|
|
l_ulong loads[3]; /* 1, 5, and 15 minute load averages */
|
2003-11-16 15:07:10 +00:00
|
|
|
|
#define LINUX_SYSINFO_LOADS_SCALE 65536
|
2001-09-08 19:07:04 +00:00
|
|
|
|
l_ulong totalram; /* Total usable main memory size */
|
|
|
|
|
l_ulong freeram; /* Available memory size */
|
|
|
|
|
l_ulong sharedram; /* Amount of shared memory */
|
|
|
|
|
l_ulong bufferram; /* Memory used by buffers */
|
|
|
|
|
l_ulong totalswap; /* Total swap space size */
|
|
|
|
|
l_ulong freeswap; /* swap space still available */
|
|
|
|
|
l_ushort procs; /* Number of current processes */
|
2003-11-16 15:07:10 +00:00
|
|
|
|
l_ulong totalbig;
|
|
|
|
|
l_ulong freebig;
|
|
|
|
|
l_uint mem_unit;
|
|
|
|
|
char _f[6]; /* Pads structure to 64 bytes */
|
2001-07-23 06:22:10 +00:00
|
|
|
|
};
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
|
linux_sysinfo(struct thread *td, struct linux_sysinfo_args *args)
|
2001-07-23 06:22:10 +00:00
|
|
|
|
{
|
2001-09-08 19:07:04 +00:00
|
|
|
|
struct l_sysinfo sysinfo;
|
|
|
|
|
vm_object_t object;
|
2003-07-18 10:26:09 +00:00
|
|
|
|
int i, j;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
struct timespec ts;
|
|
|
|
|
|
|
|
|
|
getnanouptime(&ts);
|
2005-07-07 19:17:55 +00:00
|
|
|
|
if (ts.tv_nsec != 0)
|
|
|
|
|
ts.tv_sec++;
|
|
|
|
|
sysinfo.uptime = ts.tv_sec;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
|
|
|
|
/* Use the information from the mib to get our load averages */
|
|
|
|
|
for (i = 0; i < 3; i++)
|
2003-11-16 15:07:10 +00:00
|
|
|
|
sysinfo.loads[i] = averunnable.ldavg[i] *
|
|
|
|
|
LINUX_SYSINFO_LOADS_SCALE / averunnable.fscale;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
|
|
|
|
sysinfo.totalram = physmem * PAGE_SIZE;
|
|
|
|
|
sysinfo.freeram = sysinfo.totalram - cnt.v_wire_count * PAGE_SIZE;
|
|
|
|
|
|
|
|
|
|
sysinfo.sharedram = 0;
|
2004-01-02 19:29:31 +00:00
|
|
|
|
mtx_lock(&vm_object_list_mtx);
|
|
|
|
|
TAILQ_FOREACH(object, &vm_object_list, object_list)
|
2001-09-08 19:07:04 +00:00
|
|
|
|
if (object->shadow_count > 1)
|
|
|
|
|
sysinfo.sharedram += object->resident_page_count;
|
2004-01-02 19:29:31 +00:00
|
|
|
|
mtx_unlock(&vm_object_list_mtx);
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
|
|
|
|
sysinfo.sharedram *= PAGE_SIZE;
|
|
|
|
|
sysinfo.bufferram = 0;
|
|
|
|
|
|
2003-07-18 10:26:09 +00:00
|
|
|
|
swap_pager_status(&i, &j);
|
|
|
|
|
sysinfo.totalswap= i * PAGE_SIZE;
|
|
|
|
|
sysinfo.freeswap = (i - j) * PAGE_SIZE;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
2003-11-16 15:07:10 +00:00
|
|
|
|
sysinfo.procs = nprocs;
|
|
|
|
|
|
|
|
|
|
/* The following are only present in newer Linux kernels. */
|
|
|
|
|
sysinfo.totalbig = 0;
|
|
|
|
|
sysinfo.freebig = 0;
|
|
|
|
|
sysinfo.mem_unit = 1;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
2003-03-03 09:14:26 +00:00
|
|
|
|
return copyout(&sysinfo, args->info, sizeof(sysinfo));
|
2001-07-23 06:22:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-06-25 17:32:43 +00:00
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
|
linux_alarm(struct thread *td, struct linux_alarm_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
{
|
2001-09-08 19:07:04 +00:00
|
|
|
|
struct itimerval it, old_it;
|
2005-02-07 18:36:21 +00:00
|
|
|
|
int error;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
|
if (ldebug(alarm))
|
|
|
|
|
printf(ARGS(alarm, "%u"), args->secs);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#endif
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
|
|
|
|
if (args->secs > 100000000)
|
2005-02-07 18:36:21 +00:00
|
|
|
|
return (EINVAL);
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
|
|
|
|
it.it_value.tv_sec = (long)args->secs;
|
|
|
|
|
it.it_value.tv_usec = 0;
|
|
|
|
|
it.it_interval.tv_sec = 0;
|
|
|
|
|
it.it_interval.tv_usec = 0;
|
2005-02-07 18:36:21 +00:00
|
|
|
|
error = kern_setitimer(td, ITIMER_REAL, &it, &old_it);
|
|
|
|
|
if (error)
|
|
|
|
|
return (error);
|
|
|
|
|
if (timevalisset(&old_it.it_value)) {
|
2001-09-08 19:07:04 +00:00
|
|
|
|
if (old_it.it_value.tv_usec != 0)
|
|
|
|
|
old_it.it_value.tv_sec++;
|
2001-09-12 08:38:13 +00:00
|
|
|
|
td->td_retval[0] = old_it.it_value.tv_sec;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
}
|
2005-02-07 18:36:21 +00:00
|
|
|
|
return (0);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
|
linux_brk(struct thread *td, struct linux_brk_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
{
|
2001-09-12 08:38:13 +00:00
|
|
|
|
struct vmspace *vm = td->td_proc->p_vmspace;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
vm_offset_t new, old;
|
|
|
|
|
struct obreak_args /* {
|
|
|
|
|
char * nsize;
|
|
|
|
|
} */ tmp;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
|
if (ldebug(brk))
|
2004-08-16 11:12:57 +00:00
|
|
|
|
printf(ARGS(brk, "%p"), (void *)(uintptr_t)args->dsend);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#endif
|
2001-09-08 19:07:04 +00:00
|
|
|
|
old = (vm_offset_t)vm->vm_daddr + ctob(vm->vm_dsize);
|
|
|
|
|
new = (vm_offset_t)args->dsend;
|
|
|
|
|
tmp.nsize = (char *) new;
|
2001-09-12 08:38:13 +00:00
|
|
|
|
if (((caddr_t)new > vm->vm_daddr) && !obreak(td, &tmp))
|
|
|
|
|
td->td_retval[0] = (long)new;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
else
|
2001-09-12 08:38:13 +00:00
|
|
|
|
td->td_retval[0] = (long)old;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
|
|
|
|
return 0;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-05-10 20:38:16 +00:00
|
|
|
|
#if defined(__i386__)
|
|
|
|
|
/* XXX: what about amd64/linux32? */
|
2004-08-16 07:28:16 +00:00
|
|
|
|
|
1995-06-25 17:32:43 +00:00
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
|
linux_uselib(struct thread *td, struct linux_uselib_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
{
|
2001-09-08 19:07:04 +00:00
|
|
|
|
struct nameidata ni;
|
|
|
|
|
struct vnode *vp;
|
|
|
|
|
struct exec *a_out;
|
|
|
|
|
struct vattr attr;
|
|
|
|
|
vm_offset_t vmaddr;
|
|
|
|
|
unsigned long file_offset;
|
|
|
|
|
vm_offset_t buffer;
|
|
|
|
|
unsigned long bss_size;
|
2002-09-01 22:30:27 +00:00
|
|
|
|
char *library;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
int error;
|
2006-07-21 20:22:13 +00:00
|
|
|
|
int locked, vfslocked;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
2002-09-01 22:30:27 +00:00
|
|
|
|
LCONVPATHEXIST(td, args->library, &library);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
|
if (ldebug(uselib))
|
2002-09-01 22:30:27 +00:00
|
|
|
|
printf(ARGS(uselib, "%s"), library);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
|
a_out = NULL;
|
2006-07-21 20:22:13 +00:00
|
|
|
|
vfslocked = 0;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
locked = 0;
|
|
|
|
|
vp = NULL;
|
|
|
|
|
|
2006-07-21 20:22:13 +00:00
|
|
|
|
NDINIT(&ni, LOOKUP, ISOPEN | FOLLOW | LOCKLEAF | MPSAFE | AUDITVNODE1,
|
|
|
|
|
UIO_SYSSPACE, library, td);
|
2001-09-08 19:07:04 +00:00
|
|
|
|
error = namei(&ni);
|
2002-09-01 22:30:27 +00:00
|
|
|
|
LFREEPATH(library);
|
2001-09-08 19:07:04 +00:00
|
|
|
|
if (error)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
|
|
vp = ni.ni_vp;
|
2006-07-21 20:22:13 +00:00
|
|
|
|
vfslocked = NDHASGIANT(&ni);
|
2001-09-08 19:07:04 +00:00
|
|
|
|
NDFREE(&ni, NDF_ONLY_PNBUF);
|
1996-02-16 18:40:50 +00:00
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
|
/*
|
|
|
|
|
* From here on down, we have a locked vnode that must be unlocked.
|
2006-07-21 20:22:13 +00:00
|
|
|
|
* XXX: The code below largely duplicates exec_check_permissions().
|
2001-09-08 19:07:04 +00:00
|
|
|
|
*/
|
2006-07-21 20:22:13 +00:00
|
|
|
|
locked = 1;
|
1996-02-16 18:40:50 +00:00
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
|
/* Writable? */
|
|
|
|
|
if (vp->v_writecount) {
|
|
|
|
|
error = ETXTBSY;
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
|
/* Executable? */
|
2002-02-27 18:32:23 +00:00
|
|
|
|
error = VOP_GETATTR(vp, &attr, td->td_ucred, td);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
if (error)
|
2001-09-08 19:07:04 +00:00
|
|
|
|
goto cleanup;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
|
if ((vp->v_mount->mnt_flag & MNT_NOEXEC) ||
|
|
|
|
|
((attr.va_mode & 0111) == 0) || (attr.va_type != VREG)) {
|
2006-07-21 20:22:13 +00:00
|
|
|
|
/* EACCESS is what exec(2) returns. */
|
2001-09-08 19:07:04 +00:00
|
|
|
|
error = ENOEXEC;
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
|
/* Sensible size? */
|
|
|
|
|
if (attr.va_size == 0) {
|
|
|
|
|
error = ENOEXEC;
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
|
/* Can we access it? */
|
2002-02-27 18:32:23 +00:00
|
|
|
|
error = VOP_ACCESS(vp, VEXEC, td->td_ucred, td);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
if (error)
|
2001-09-08 19:07:04 +00:00
|
|
|
|
goto cleanup;
|
|
|
|
|
|
2002-06-14 07:24:01 +00:00
|
|
|
|
/*
|
|
|
|
|
* XXX: This should use vn_open() so that it is properly authorized,
|
|
|
|
|
* and to reduce code redundancy all over the place here.
|
2006-07-21 20:22:13 +00:00
|
|
|
|
* XXX: Not really, it duplicates far more of exec_check_permissions()
|
|
|
|
|
* than vn_open().
|
2002-06-14 07:24:01 +00:00
|
|
|
|
*/
|
2002-08-01 22:23:02 +00:00
|
|
|
|
#ifdef MAC
|
|
|
|
|
error = mac_check_vnode_open(td->td_ucred, vp, FREAD);
|
|
|
|
|
if (error)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
#endif
|
2003-07-26 07:32:23 +00:00
|
|
|
|
error = VOP_OPEN(vp, FREAD, td->td_ucred, td, -1);
|
2001-09-08 19:07:04 +00:00
|
|
|
|
if (error)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
|
2002-09-25 02:42:04 +00:00
|
|
|
|
/* Pull in executable header into kernel_map */
|
|
|
|
|
error = vm_mmap(kernel_map, (vm_offset_t *)&a_out, PAGE_SIZE,
|
2005-04-01 20:00:11 +00:00
|
|
|
|
VM_PROT_READ, VM_PROT_READ, 0, OBJT_VNODE, vp, 0);
|
2001-09-08 19:07:04 +00:00
|
|
|
|
if (error)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
|
|
/* Is it a Linux binary ? */
|
|
|
|
|
if (((a_out->a_magic >> 16) & 0xff) != 0x64) {
|
|
|
|
|
error = ENOEXEC;
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
1996-02-16 18:40:50 +00:00
|
|
|
|
|
|
|
|
|
/*
|
2001-09-08 19:07:04 +00:00
|
|
|
|
* While we are here, we should REALLY do some more checks
|
1996-02-16 18:40:50 +00:00
|
|
|
|
*/
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
|
|
|
|
/* Set file/virtual offset based on a.out variant. */
|
|
|
|
|
switch ((int)(a_out->a_magic & 0xffff)) {
|
|
|
|
|
case 0413: /* ZMAGIC */
|
|
|
|
|
file_offset = 1024;
|
|
|
|
|
break;
|
|
|
|
|
case 0314: /* QMAGIC */
|
|
|
|
|
file_offset = 0;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
error = ENOEXEC;
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bss_size = round_page(a_out->a_bss);
|
|
|
|
|
|
|
|
|
|
/* Check various fields in header for validity/bounds. */
|
|
|
|
|
if (a_out->a_text & PAGE_MASK || a_out->a_data & PAGE_MASK) {
|
|
|
|
|
error = ENOEXEC;
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* text + data can't exceed file size */
|
|
|
|
|
if (a_out->a_data + a_out->a_text > attr.va_size) {
|
|
|
|
|
error = EFAULT;
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* text/data/bss must not exceed limits
|
|
|
|
|
* XXX - this is not complete. it should check current usage PLUS
|
|
|
|
|
* the resources needed by this library.
|
1996-02-16 18:40:50 +00:00
|
|
|
|
*/
|
2004-02-04 21:52:57 +00:00
|
|
|
|
PROC_LOCK(td->td_proc);
|
2001-10-10 23:06:54 +00:00
|
|
|
|
if (a_out->a_text > maxtsiz ||
|
2004-02-04 21:52:57 +00:00
|
|
|
|
a_out->a_data + bss_size > lim_cur(td->td_proc, RLIMIT_DATA)) {
|
|
|
|
|
PROC_UNLOCK(td->td_proc);
|
2001-09-08 19:07:04 +00:00
|
|
|
|
error = ENOMEM;
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
2004-02-04 21:52:57 +00:00
|
|
|
|
PROC_UNLOCK(td->td_proc);
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
2006-07-21 20:22:13 +00:00
|
|
|
|
/*
|
|
|
|
|
* Prevent more writers.
|
|
|
|
|
* XXX: Note that if any of the VM operations fail below we don't
|
|
|
|
|
* clear this flag.
|
|
|
|
|
*/
|
2002-08-04 10:29:36 +00:00
|
|
|
|
vp->v_vflag |= VV_TEXT;
|
1996-02-16 18:40:50 +00:00
|
|
|
|
|
2006-07-21 20:22:13 +00:00
|
|
|
|
/*
|
|
|
|
|
* Lock no longer needed
|
|
|
|
|
*/
|
|
|
|
|
locked = 0;
|
|
|
|
|
VOP_UNLOCK(vp, 0, td);
|
|
|
|
|
VFS_UNLOCK_GIANT(vfslocked);
|
|
|
|
|
|
1996-02-16 18:40:50 +00:00
|
|
|
|
/*
|
2001-09-08 19:07:04 +00:00
|
|
|
|
* Check if file_offset page aligned. Currently we cannot handle
|
|
|
|
|
* misalinged file offsets, and so we read in the entire image
|
|
|
|
|
* (what a waste).
|
1996-02-16 18:40:50 +00:00
|
|
|
|
*/
|
2001-09-08 19:07:04 +00:00
|
|
|
|
if (file_offset & PAGE_MASK) {
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
printf("uselib: Non page aligned binary %lu\n", file_offset);
|
|
|
|
|
#endif
|
|
|
|
|
/* Map text+data read/write/execute */
|
|
|
|
|
|
|
|
|
|
/* a_entry is the load address and is page aligned */
|
|
|
|
|
vmaddr = trunc_page(a_out->a_entry);
|
|
|
|
|
|
|
|
|
|
/* get anon user mapping, read+write+execute */
|
2001-09-12 08:38:13 +00:00
|
|
|
|
error = vm_map_find(&td->td_proc->p_vmspace->vm_map, NULL, 0,
|
|
|
|
|
&vmaddr, a_out->a_text + a_out->a_data, FALSE, VM_PROT_ALL,
|
2001-09-08 19:07:04 +00:00
|
|
|
|
VM_PROT_ALL, 0);
|
|
|
|
|
if (error)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
|
|
/* map file into kernel_map */
|
|
|
|
|
error = vm_mmap(kernel_map, &buffer,
|
|
|
|
|
round_page(a_out->a_text + a_out->a_data + file_offset),
|
2005-04-01 20:00:11 +00:00
|
|
|
|
VM_PROT_READ, VM_PROT_READ, 0, OBJT_VNODE, vp,
|
2001-09-08 19:07:04 +00:00
|
|
|
|
trunc_page(file_offset));
|
|
|
|
|
if (error)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
|
|
/* copy from kernel VM space to user space */
|
2004-08-16 07:28:16 +00:00
|
|
|
|
error = copyout(PTRIN(buffer + file_offset),
|
2003-03-03 09:14:26 +00:00
|
|
|
|
(void *)vmaddr, a_out->a_text + a_out->a_data);
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
|
|
|
|
/* release temporary kernel space */
|
|
|
|
|
vm_map_remove(kernel_map, buffer, buffer +
|
|
|
|
|
round_page(a_out->a_text + a_out->a_data + file_offset));
|
|
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
} else {
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
printf("uselib: Page aligned binary %lu\n", file_offset);
|
|
|
|
|
#endif
|
|
|
|
|
/*
|
|
|
|
|
* for QMAGIC, a_entry is 20 bytes beyond the load address
|
|
|
|
|
* to skip the executable header
|
|
|
|
|
*/
|
|
|
|
|
vmaddr = trunc_page(a_out->a_entry);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Map it all into the process's space as a single
|
|
|
|
|
* copy-on-write "data" segment.
|
|
|
|
|
*/
|
2001-09-12 08:38:13 +00:00
|
|
|
|
error = vm_mmap(&td->td_proc->p_vmspace->vm_map, &vmaddr,
|
2001-09-08 19:07:04 +00:00
|
|
|
|
a_out->a_text + a_out->a_data, VM_PROT_ALL, VM_PROT_ALL,
|
2005-04-01 20:00:11 +00:00
|
|
|
|
MAP_PRIVATE | MAP_FIXED, OBJT_VNODE, vp, file_offset);
|
2001-09-08 19:07:04 +00:00
|
|
|
|
if (error)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
printf("mem=%08lx = %08lx %08lx\n", (long)vmaddr, ((long*)vmaddr)[0],
|
|
|
|
|
((long*)vmaddr)[1]);
|
|
|
|
|
#endif
|
|
|
|
|
if (bss_size != 0) {
|
|
|
|
|
/* Calculate BSS start address */
|
|
|
|
|
vmaddr = trunc_page(a_out->a_entry) + a_out->a_text +
|
|
|
|
|
a_out->a_data;
|
|
|
|
|
|
|
|
|
|
/* allocate some 'anon' space */
|
2001-09-12 08:38:13 +00:00
|
|
|
|
error = vm_map_find(&td->td_proc->p_vmspace->vm_map, NULL, 0,
|
|
|
|
|
&vmaddr, bss_size, FALSE, VM_PROT_ALL, VM_PROT_ALL, 0);
|
2001-09-08 19:07:04 +00:00
|
|
|
|
if (error)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
1996-02-16 18:40:50 +00:00
|
|
|
|
|
|
|
|
|
cleanup:
|
2001-09-08 19:07:04 +00:00
|
|
|
|
/* Unlock vnode if needed */
|
2006-07-21 20:22:13 +00:00
|
|
|
|
if (locked) {
|
2001-09-12 08:38:13 +00:00
|
|
|
|
VOP_UNLOCK(vp, 0, td);
|
2006-07-21 20:22:13 +00:00
|
|
|
|
VFS_UNLOCK_GIANT(vfslocked);
|
|
|
|
|
}
|
1996-02-16 18:40:50 +00:00
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
|
/* Release the kernel mapping. */
|
|
|
|
|
if (a_out)
|
|
|
|
|
vm_map_remove(kernel_map, (vm_offset_t)a_out,
|
|
|
|
|
(vm_offset_t)a_out + PAGE_SIZE);
|
1996-02-16 18:40:50 +00:00
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
|
return error;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-05-10 20:38:16 +00:00
|
|
|
|
#endif /* __i386__ */
|
2004-08-16 07:28:16 +00:00
|
|
|
|
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
|
linux_select(struct thread *td, struct linux_select_args *args)
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
{
|
2004-08-15 12:24:05 +00:00
|
|
|
|
l_timeval ltv;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
struct timeval tv0, tv1, utv, *tvp;
|
|
|
|
|
int error;
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#ifdef DEBUG
|
2001-09-08 19:07:04 +00:00
|
|
|
|
if (ldebug(select))
|
|
|
|
|
printf(ARGS(select, "%d, %p, %p, %p, %p"), args->nfds,
|
|
|
|
|
(void *)args->readfds, (void *)args->writefds,
|
|
|
|
|
(void *)args->exceptfds, (void *)args->timeout);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#endif
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Store current time for computation of the amount of
|
|
|
|
|
* time left.
|
|
|
|
|
*/
|
|
|
|
|
if (args->timeout) {
|
2004-08-15 12:24:05 +00:00
|
|
|
|
if ((error = copyin(args->timeout, <v, sizeof(ltv))))
|
2001-09-08 19:07:04 +00:00
|
|
|
|
goto select_out;
|
2004-08-15 12:24:05 +00:00
|
|
|
|
utv.tv_sec = ltv.tv_sec;
|
|
|
|
|
utv.tv_usec = ltv.tv_usec;
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
#ifdef DEBUG
|
2001-09-08 19:07:04 +00:00
|
|
|
|
if (ldebug(select))
|
2005-12-28 07:08:54 +00:00
|
|
|
|
printf(LMSG("incoming timeout (%jd/%ld)"),
|
|
|
|
|
(intmax_t)utv.tv_sec, utv.tv_usec);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
#endif
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
|
|
|
|
if (itimerfix(&utv)) {
|
|
|
|
|
/*
|
|
|
|
|
* The timeval was invalid. Convert it to something
|
|
|
|
|
* valid that will act as it does under Linux.
|
|
|
|
|
*/
|
|
|
|
|
utv.tv_sec += utv.tv_usec / 1000000;
|
|
|
|
|
utv.tv_usec %= 1000000;
|
|
|
|
|
if (utv.tv_usec < 0) {
|
|
|
|
|
utv.tv_sec -= 1;
|
|
|
|
|
utv.tv_usec += 1000000;
|
|
|
|
|
}
|
|
|
|
|
if (utv.tv_sec < 0)
|
|
|
|
|
timevalclear(&utv);
|
|
|
|
|
}
|
|
|
|
|
microtime(&tv0);
|
2002-09-01 22:30:27 +00:00
|
|
|
|
tvp = &utv;
|
|
|
|
|
} else
|
|
|
|
|
tvp = NULL;
|
|
|
|
|
|
|
|
|
|
error = kern_select(td, args->nfds, args->readfds, args->writefds,
|
|
|
|
|
args->exceptfds, tvp);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-09-08 19:07:04 +00:00
|
|
|
|
if (ldebug(select))
|
2001-02-16 16:40:43 +00:00
|
|
|
|
printf(LMSG("real select returns %d"), error);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
#endif
|
2001-09-08 19:07:04 +00:00
|
|
|
|
if (error) {
|
|
|
|
|
/*
|
|
|
|
|
* See fs/select.c in the Linux kernel. Without this,
|
|
|
|
|
* Maelstrom doesn't work.
|
|
|
|
|
*/
|
|
|
|
|
if (error == ERESTART)
|
|
|
|
|
error = EINTR;
|
|
|
|
|
goto select_out;
|
|
|
|
|
}
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
|
if (args->timeout) {
|
2001-09-12 08:38:13 +00:00
|
|
|
|
if (td->td_retval[0]) {
|
2001-09-08 19:07:04 +00:00
|
|
|
|
/*
|
|
|
|
|
* Compute how much time was left of the timeout,
|
|
|
|
|
* by subtracting the current time and the time
|
|
|
|
|
* before we started the call, and subtracting
|
|
|
|
|
* that result from the user-supplied value.
|
|
|
|
|
*/
|
|
|
|
|
microtime(&tv1);
|
|
|
|
|
timevalsub(&tv1, &tv0);
|
|
|
|
|
timevalsub(&utv, &tv1);
|
|
|
|
|
if (utv.tv_sec < 0)
|
|
|
|
|
timevalclear(&utv);
|
|
|
|
|
} else
|
|
|
|
|
timevalclear(&utv);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
#ifdef DEBUG
|
2001-09-08 19:07:04 +00:00
|
|
|
|
if (ldebug(select))
|
2005-12-28 07:08:54 +00:00
|
|
|
|
printf(LMSG("outgoing timeout (%jd/%ld)"),
|
|
|
|
|
(intmax_t)utv.tv_sec, utv.tv_usec);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
#endif
|
2004-08-15 12:24:05 +00:00
|
|
|
|
ltv.tv_sec = utv.tv_sec;
|
|
|
|
|
ltv.tv_usec = utv.tv_usec;
|
|
|
|
|
if ((error = copyout(<v, args->timeout, sizeof(ltv))))
|
2001-09-08 19:07:04 +00:00
|
|
|
|
goto select_out;
|
|
|
|
|
}
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
|
|
|
|
|
select_out:
|
|
|
|
|
#ifdef DEBUG
|
2001-09-08 19:07:04 +00:00
|
|
|
|
if (ldebug(select))
|
|
|
|
|
printf(LMSG("select_out -> %d"), error);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
#endif
|
2001-09-08 19:07:04 +00:00
|
|
|
|
return error;
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
}
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
2003-03-03 09:17:12 +00:00
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
|
linux_mremap(struct thread *td, struct linux_mremap_args *args)
|
1998-07-10 22:30:08 +00:00
|
|
|
|
{
|
|
|
|
|
struct munmap_args /* {
|
|
|
|
|
void *addr;
|
|
|
|
|
size_t len;
|
2003-03-03 09:17:12 +00:00
|
|
|
|
} */ bsd_args;
|
1998-07-10 22:30:08 +00:00
|
|
|
|
int error = 0;
|
2003-03-03 09:17:12 +00:00
|
|
|
|
|
1998-07-10 22:30:08 +00:00
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
|
if (ldebug(mremap))
|
|
|
|
|
printf(ARGS(mremap, "%p, %08lx, %08lx, %08lx"),
|
2004-08-16 11:12:57 +00:00
|
|
|
|
(void *)(uintptr_t)args->addr,
|
2003-03-03 09:17:12 +00:00
|
|
|
|
(unsigned long)args->old_len,
|
2001-02-16 16:40:43 +00:00
|
|
|
|
(unsigned long)args->new_len,
|
|
|
|
|
(unsigned long)args->flags);
|
1998-07-10 22:30:08 +00:00
|
|
|
|
#endif
|
|
|
|
|
args->new_len = round_page(args->new_len);
|
|
|
|
|
args->old_len = round_page(args->old_len);
|
|
|
|
|
|
|
|
|
|
if (args->new_len > args->old_len) {
|
2001-09-12 08:38:13 +00:00
|
|
|
|
td->td_retval[0] = 0;
|
1998-07-10 22:30:08 +00:00
|
|
|
|
return ENOMEM;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (args->new_len < args->old_len) {
|
2004-08-16 07:28:16 +00:00
|
|
|
|
bsd_args.addr =
|
|
|
|
|
(caddr_t)((uintptr_t)args->addr + args->new_len);
|
1998-07-10 22:30:08 +00:00
|
|
|
|
bsd_args.len = args->old_len - args->new_len;
|
2001-09-12 08:38:13 +00:00
|
|
|
|
error = munmap(td, &bsd_args);
|
1998-07-10 22:30:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-09-05 12:30:54 +00:00
|
|
|
|
td->td_retval[0] = error ? 0 : (uintptr_t)args->addr;
|
1998-07-10 22:30:08 +00:00
|
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
|
2002-09-19 19:02:54 +00:00
|
|
|
|
#define LINUX_MS_ASYNC 0x0001
|
|
|
|
|
#define LINUX_MS_INVALIDATE 0x0002
|
|
|
|
|
#define LINUX_MS_SYNC 0x0004
|
|
|
|
|
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
|
linux_msync(struct thread *td, struct linux_msync_args *args)
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
{
|
|
|
|
|
struct msync_args bsd_args;
|
|
|
|
|
|
2004-08-16 07:28:16 +00:00
|
|
|
|
bsd_args.addr = (caddr_t)(uintptr_t)args->addr;
|
|
|
|
|
bsd_args.len = (uintptr_t)args->len;
|
2002-09-19 19:02:54 +00:00
|
|
|
|
bsd_args.flags = args->fl & ~LINUX_MS_SYNC;
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
|
return msync(td, &bsd_args);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
}
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
|
linux_time(struct thread *td, struct linux_time_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
{
|
2001-09-08 19:07:04 +00:00
|
|
|
|
struct timeval tv;
|
|
|
|
|
l_time_t tm;
|
|
|
|
|
int error;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
|
if (ldebug(time))
|
|
|
|
|
printf(ARGS(time, "*"));
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#endif
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
|
|
|
|
microtime(&tv);
|
|
|
|
|
tm = tv.tv_sec;
|
2003-03-03 09:14:26 +00:00
|
|
|
|
if (args->tm && (error = copyout(&tm, args->tm, sizeof(tm))))
|
2001-09-08 19:07:04 +00:00
|
|
|
|
return error;
|
2001-09-12 08:38:13 +00:00
|
|
|
|
td->td_retval[0] = tm;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
return 0;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
|
struct l_times_argv {
|
|
|
|
|
l_long tms_utime;
|
|
|
|
|
l_long tms_stime;
|
|
|
|
|
l_long tms_cutime;
|
|
|
|
|
l_long tms_cstime;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
};
|
|
|
|
|
|
1996-03-04 21:03:11 +00:00
|
|
|
|
#define CLK_TCK 100 /* Linux uses 100 */
|
2001-03-23 19:22:21 +00:00
|
|
|
|
|
1996-03-04 21:03:11 +00:00
|
|
|
|
#define CONVTCK(r) (r.tv_sec * CLK_TCK + r.tv_usec / (1000000 / CLK_TCK))
|
|
|
|
|
|
1995-06-25 17:32:43 +00:00
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
|
linux_times(struct thread *td, struct linux_times_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
{
|
2004-10-05 18:51:11 +00:00
|
|
|
|
struct timeval tv, utime, stime, cutime, cstime;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
struct l_times_argv tms;
|
2004-10-05 18:51:11 +00:00
|
|
|
|
struct proc *p;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
int error;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
|
if (ldebug(times))
|
|
|
|
|
printf(ARGS(times, "*"));
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#endif
|
1996-03-04 21:03:11 +00:00
|
|
|
|
|
2006-06-23 18:49:38 +00:00
|
|
|
|
if (args->buf != NULL) {
|
|
|
|
|
p = td->td_proc;
|
|
|
|
|
PROC_LOCK(p);
|
|
|
|
|
calcru(p, &utime, &stime);
|
|
|
|
|
calccru(p, &cutime, &cstime);
|
|
|
|
|
PROC_UNLOCK(p);
|
1996-03-04 21:03:11 +00:00
|
|
|
|
|
2006-06-23 18:49:38 +00:00
|
|
|
|
tms.tms_utime = CONVTCK(utime);
|
|
|
|
|
tms.tms_stime = CONVTCK(stime);
|
1996-03-04 21:03:11 +00:00
|
|
|
|
|
2006-06-23 18:49:38 +00:00
|
|
|
|
tms.tms_cutime = CONVTCK(cutime);
|
|
|
|
|
tms.tms_cstime = CONVTCK(cstime);
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
2006-06-23 18:49:38 +00:00
|
|
|
|
if ((error = copyout(&tms, args->buf, sizeof(tms))))
|
|
|
|
|
return error;
|
|
|
|
|
}
|
1996-03-04 21:03:11 +00:00
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
|
microuptime(&tv);
|
2001-09-12 08:38:13 +00:00
|
|
|
|
td->td_retval[0] = (int)CONVTCK(tv);
|
2001-09-08 19:07:04 +00:00
|
|
|
|
return 0;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
|
linux_newuname(struct thread *td, struct linux_newuname_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
{
|
2001-09-08 19:07:04 +00:00
|
|
|
|
struct l_new_utsname utsname;
|
o Introduce pr_mtx into struct prison, providing protection for the
mutable contents of struct prison (hostname, securelevel, refcount,
pr_linux, ...)
o Generally introduce mtx_lock()/mtx_unlock() calls throughout kern/
so as to enforce these protections, in particular, in kern_mib.c
protection sysctl access to the hostname and securelevel, as well as
kern_prot.c access to the securelevel for access control purposes.
o Rewrite linux emulator abstractions for accessing per-jail linux
mib entries (osname, osrelease, osversion) so that they don't return
a pointer to the text in the struct linux_prison, rather, a copy
to an array passed into the calls. Likewise, update linprocfs to
use these primitives.
o Update in_pcb.c to always use prison_getip() rather than directly
accessing struct prison.
Reviewed by: jhb
2001-12-03 16:12:27 +00:00
|
|
|
|
char osname[LINUX_MAX_UTSNAME];
|
|
|
|
|
char osrelease[LINUX_MAX_UTSNAME];
|
2003-07-29 10:03:15 +00:00
|
|
|
|
char *p;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
|
if (ldebug(newuname))
|
|
|
|
|
printf(ARGS(newuname, "*"));
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#endif
|
1999-08-25 11:19:03 +00:00
|
|
|
|
|
2003-03-13 22:45:43 +00:00
|
|
|
|
linux_get_osname(td, osname);
|
|
|
|
|
linux_get_osrelease(td, osrelease);
|
1999-08-27 19:47:41 +00:00
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
|
bzero(&utsname, sizeof(utsname));
|
2002-10-17 22:00:30 +00:00
|
|
|
|
strlcpy(utsname.sysname, osname, LINUX_MAX_UTSNAME);
|
|
|
|
|
getcredhostname(td->td_ucred, utsname.nodename, LINUX_MAX_UTSNAME);
|
|
|
|
|
strlcpy(utsname.release, osrelease, LINUX_MAX_UTSNAME);
|
|
|
|
|
strlcpy(utsname.version, version, LINUX_MAX_UTSNAME);
|
2003-07-29 10:03:15 +00:00
|
|
|
|
for (p = utsname.version; *p != '\0'; ++p)
|
|
|
|
|
if (*p == '\n') {
|
|
|
|
|
*p = '\0';
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
#ifdef __i386__
|
|
|
|
|
{
|
|
|
|
|
const char *class;
|
|
|
|
|
switch (cpu_class) {
|
|
|
|
|
case CPUCLASS_686:
|
|
|
|
|
class = "i686";
|
|
|
|
|
break;
|
|
|
|
|
case CPUCLASS_586:
|
|
|
|
|
class = "i586";
|
|
|
|
|
break;
|
|
|
|
|
case CPUCLASS_486:
|
|
|
|
|
class = "i486";
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
class = "i386";
|
|
|
|
|
}
|
|
|
|
|
strlcpy(utsname.machine, class, LINUX_MAX_UTSNAME);
|
|
|
|
|
}
|
2005-01-14 03:45:26 +00:00
|
|
|
|
#elif defined(__amd64__) /* XXX: Linux can change 'personality'. */
|
|
|
|
|
#ifdef COMPAT_LINUX32
|
|
|
|
|
strlcpy(utsname.machine, "i686", LINUX_MAX_UTSNAME);
|
2003-07-29 10:03:15 +00:00
|
|
|
|
#else
|
2005-01-14 03:45:26 +00:00
|
|
|
|
strlcpy(utsname.machine, "x86_64", LINUX_MAX_UTSNAME);
|
|
|
|
|
#endif /* COMPAT_LINUX32 */
|
|
|
|
|
#else /* something other than i386 or amd64 - assume we and Linux agree */
|
2002-10-17 22:00:30 +00:00
|
|
|
|
strlcpy(utsname.machine, machine, LINUX_MAX_UTSNAME);
|
2005-01-14 03:45:26 +00:00
|
|
|
|
#endif /* __i386__ */
|
2002-10-17 22:00:30 +00:00
|
|
|
|
strlcpy(utsname.domainname, domainname, LINUX_MAX_UTSNAME);
|
1999-08-25 11:19:03 +00:00
|
|
|
|
|
2003-03-03 09:14:26 +00:00
|
|
|
|
return (copyout(&utsname, args->buf, sizeof(utsname)));
|
1995-06-25 17:32:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-01-14 04:44:56 +00:00
|
|
|
|
#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
|
2001-09-08 19:07:04 +00:00
|
|
|
|
struct l_utimbuf {
|
|
|
|
|
l_time_t l_actime;
|
|
|
|
|
l_time_t l_modtime;
|
1996-03-04 21:03:11 +00:00
|
|
|
|
};
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
|
linux_utime(struct thread *td, struct linux_utime_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
{
|
2001-09-08 19:07:04 +00:00
|
|
|
|
struct timeval tv[2], *tvp;
|
|
|
|
|
struct l_utimbuf lut;
|
2002-09-01 22:30:27 +00:00
|
|
|
|
char *fname;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
int error;
|
|
|
|
|
|
2002-09-01 22:30:27 +00:00
|
|
|
|
LCONVPATHEXIST(td, args->fname, &fname);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
|
if (ldebug(utime))
|
2002-09-01 22:30:27 +00:00
|
|
|
|
printf(ARGS(utime, "%s, *"), fname);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#endif
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
|
|
|
|
if (args->times) {
|
2003-03-03 09:14:26 +00:00
|
|
|
|
if ((error = copyin(args->times, &lut, sizeof lut))) {
|
2002-09-01 22:30:27 +00:00
|
|
|
|
LFREEPATH(fname);
|
2001-09-08 19:07:04 +00:00
|
|
|
|
return error;
|
2002-09-01 22:30:27 +00:00
|
|
|
|
}
|
2001-09-08 19:07:04 +00:00
|
|
|
|
tv[0].tv_sec = lut.l_actime;
|
|
|
|
|
tv[0].tv_usec = 0;
|
|
|
|
|
tv[1].tv_sec = lut.l_modtime;
|
|
|
|
|
tv[1].tv_usec = 0;
|
2002-09-01 22:30:27 +00:00
|
|
|
|
tvp = tv;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
} else
|
2002-09-01 22:30:27 +00:00
|
|
|
|
tvp = NULL;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
2002-09-01 22:30:27 +00:00
|
|
|
|
error = kern_utimes(td, fname, UIO_SYSSPACE, tvp, UIO_SYSSPACE);
|
|
|
|
|
LFREEPATH(fname);
|
|
|
|
|
return (error);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
}
|
2004-08-16 07:28:16 +00:00
|
|
|
|
#endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
1999-03-02 00:28:09 +00:00
|
|
|
|
#define __WCLONE 0x80000000
|
|
|
|
|
|
1995-06-25 17:32:43 +00:00
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
|
linux_waitpid(struct thread *td, struct linux_waitpid_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
{
|
2004-03-17 20:00:00 +00:00
|
|
|
|
int error, options, tmpstat;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
|
if (ldebug(waitpid))
|
|
|
|
|
printf(ARGS(waitpid, "%d, %p, %d"),
|
|
|
|
|
args->pid, (void *)args->status, args->options);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#endif
|
1999-01-26 02:38:12 +00:00
|
|
|
|
|
2004-03-17 20:00:00 +00:00
|
|
|
|
options = (args->options & (WNOHANG | WUNTRACED));
|
2001-09-08 19:07:04 +00:00
|
|
|
|
/* WLINUXCLONE should be equal to __WCLONE, but we make sure */
|
|
|
|
|
if (args->options & __WCLONE)
|
2004-03-17 20:00:00 +00:00
|
|
|
|
options |= WLINUXCLONE;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
2004-03-17 20:00:00 +00:00
|
|
|
|
error = kern_wait(td, args->pid, &tmpstat, options, NULL);
|
|
|
|
|
if (error)
|
2001-09-08 19:07:04 +00:00
|
|
|
|
return error;
|
|
|
|
|
|
|
|
|
|
if (args->status) {
|
|
|
|
|
tmpstat &= 0xffff;
|
|
|
|
|
if (WIFSIGNALED(tmpstat))
|
|
|
|
|
tmpstat = (tmpstat & 0xffffff80) |
|
|
|
|
|
BSD_TO_LINUX_SIGNAL(WTERMSIG(tmpstat));
|
|
|
|
|
else if (WIFSTOPPED(tmpstat))
|
|
|
|
|
tmpstat = (tmpstat & 0xffff00ff) |
|
|
|
|
|
(BSD_TO_LINUX_SIGNAL(WSTOPSIG(tmpstat)) << 8);
|
2003-03-03 09:14:26 +00:00
|
|
|
|
return copyout(&tmpstat, args->status, sizeof(int));
|
2001-09-08 19:07:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
return 0;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
|
linux_wait4(struct thread *td, struct linux_wait4_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
{
|
2004-03-17 20:00:00 +00:00
|
|
|
|
int error, options, tmpstat;
|
2004-10-05 18:51:11 +00:00
|
|
|
|
struct rusage ru, *rup;
|
2003-04-17 22:02:47 +00:00
|
|
|
|
struct proc *p;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
|
if (ldebug(wait4))
|
|
|
|
|
printf(ARGS(wait4, "%d, %p, %d, %p"),
|
|
|
|
|
args->pid, (void *)args->status, args->options,
|
|
|
|
|
(void *)args->rusage);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#endif
|
1996-01-14 10:59:58 +00:00
|
|
|
|
|
2004-03-17 20:00:00 +00:00
|
|
|
|
options = (args->options & (WNOHANG | WUNTRACED));
|
2001-09-08 19:07:04 +00:00
|
|
|
|
/* WLINUXCLONE should be equal to __WCLONE, but we make sure */
|
|
|
|
|
if (args->options & __WCLONE)
|
2004-03-17 20:00:00 +00:00
|
|
|
|
options |= WLINUXCLONE;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
2004-10-05 18:51:11 +00:00
|
|
|
|
if (args->rusage != NULL)
|
|
|
|
|
rup = &ru;
|
|
|
|
|
else
|
|
|
|
|
rup = NULL;
|
|
|
|
|
error = kern_wait(td, args->pid, &tmpstat, options, rup);
|
2004-03-17 20:00:00 +00:00
|
|
|
|
if (error)
|
2001-09-08 19:07:04 +00:00
|
|
|
|
return error;
|
|
|
|
|
|
2003-04-17 22:02:47 +00:00
|
|
|
|
p = td->td_proc;
|
|
|
|
|
PROC_LOCK(p);
|
1. Change prototype of trapsignal and sendsig to use ksiginfo_t *, most
changes in MD code are trivial, before this change, trapsignal and
sendsig use discrete parameters, now they uses member fields of
ksiginfo_t structure. For sendsig, this change allows us to pass
POSIX realtime signal value to user code.
2. Remove cpu_thread_siginfo, it is no longer needed because we now always
generate ksiginfo_t data and feed it to libpthread.
3. Add p_sigqueue to proc structure to hold shared signals which were
blocked by all threads in the proc.
4. Add td_sigqueue to thread structure to hold all signals delivered to
thread.
5. i386 and amd64 now return POSIX standard si_code, other arches will
be fixed.
6. In this sigqueue implementation, pending signal set is kept as before,
an extra siginfo list holds additional siginfo_t data for signals.
kernel code uses psignal() still behavior as before, it won't be failed
even under memory pressure, only exception is when deleting a signal,
we should call sigqueue_delete to remove signal from sigqueue but
not SIGDELSET. Current there is no kernel code will deliver a signal
with additional data, so kernel should be as stable as before,
a ksiginfo can carry more information, for example, allow signal to
be delivered but throw away siginfo data if memory is not enough.
SIGKILL and SIGSTOP have fast path in sigqueue_add, because they can
not be caught or masked.
The sigqueue() syscall allows user code to queue a signal to target
process, if resource is unavailable, EAGAIN will be returned as
specification said.
Just before thread exits, signal queue memory will be freed by
sigqueue_flush.
Current, all signals are allowed to be queued, not only realtime signals.
Earlier patch reviewed by: jhb, deischen
Tested on: i386, amd64
2005-10-14 12:43:47 +00:00
|
|
|
|
sigqueue_delete(&p->p_sigqueue, SIGCHLD);
|
2003-04-17 22:02:47 +00:00
|
|
|
|
PROC_UNLOCK(p);
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
|
|
|
|
if (args->status) {
|
|
|
|
|
tmpstat &= 0xffff;
|
|
|
|
|
if (WIFSIGNALED(tmpstat))
|
|
|
|
|
tmpstat = (tmpstat & 0xffffff80) |
|
|
|
|
|
BSD_TO_LINUX_SIGNAL(WTERMSIG(tmpstat));
|
|
|
|
|
else if (WIFSTOPPED(tmpstat))
|
|
|
|
|
tmpstat = (tmpstat & 0xffff00ff) |
|
|
|
|
|
(BSD_TO_LINUX_SIGNAL(WSTOPSIG(tmpstat)) << 8);
|
2004-03-17 20:00:00 +00:00
|
|
|
|
error = copyout(&tmpstat, args->status, sizeof(int));
|
2001-09-08 19:07:04 +00:00
|
|
|
|
}
|
2004-03-17 20:00:00 +00:00
|
|
|
|
if (args->rusage != NULL && error == 0)
|
|
|
|
|
error = copyout(&ru, args->rusage, sizeof(ru));
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
2004-03-17 20:00:00 +00:00
|
|
|
|
return (error);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
}
|
1996-01-14 10:59:58 +00:00
|
|
|
|
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
|
linux_mknod(struct thread *td, struct linux_mknod_args *args)
|
1996-01-14 10:59:58 +00:00
|
|
|
|
{
|
2002-09-01 22:30:27 +00:00
|
|
|
|
char *path;
|
|
|
|
|
int error;
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
|
2002-09-01 22:30:27 +00:00
|
|
|
|
LCONVPATHCREAT(td, args->path, &path);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
|
if (ldebug(mknod))
|
2002-09-01 22:30:27 +00:00
|
|
|
|
printf(ARGS(mknod, "%s, %d, %d"), path, args->mode, args->dev);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2002-09-01 22:30:27 +00:00
|
|
|
|
if (args->mode & S_IFIFO)
|
|
|
|
|
error = kern_mkfifo(td, path, UIO_SYSSPACE, args->mode);
|
|
|
|
|
else
|
|
|
|
|
error = kern_mknod(td, path, UIO_SYSSPACE, args->mode,
|
|
|
|
|
args->dev);
|
|
|
|
|
LFREEPATH(path);
|
|
|
|
|
return (error);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* UGH! This is just about the dumbest idea I've ever heard!!
|
|
|
|
|
*/
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
|
linux_personality(struct thread *td, struct linux_personality_args *args)
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
|
if (ldebug(personality))
|
2003-04-16 20:43:10 +00:00
|
|
|
|
printf(ARGS(personality, "%lu"), (unsigned long)args->per);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
#endif
|
|
|
|
|
if (args->per != 0)
|
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
|
|
/* Yes Jim, it's still a Linux... */
|
2001-09-12 08:38:13 +00:00
|
|
|
|
td->td_retval[0] = 0;
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-15 12:34:15 +00:00
|
|
|
|
struct l_itimerval {
|
|
|
|
|
l_timeval it_interval;
|
|
|
|
|
l_timeval it_value;
|
|
|
|
|
};
|
|
|
|
|
|
2005-01-25 21:28:28 +00:00
|
|
|
|
#define B2L_ITIMERVAL(bip, lip) \
|
|
|
|
|
(bip)->it_interval.tv_sec = (lip)->it_interval.tv_sec; \
|
|
|
|
|
(bip)->it_interval.tv_usec = (lip)->it_interval.tv_usec; \
|
|
|
|
|
(bip)->it_value.tv_sec = (lip)->it_value.tv_sec; \
|
|
|
|
|
(bip)->it_value.tv_usec = (lip)->it_value.tv_usec;
|
|
|
|
|
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
int
|
2004-08-15 12:34:15 +00:00
|
|
|
|
linux_setitimer(struct thread *td, struct linux_setitimer_args *uap)
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
{
|
|
|
|
|
int error;
|
2005-01-25 21:28:28 +00:00
|
|
|
|
struct l_itimerval ls;
|
|
|
|
|
struct itimerval aitv, oitv;
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
|
if (ldebug(setitimer))
|
|
|
|
|
printf(ARGS(setitimer, "%p, %p"),
|
2004-08-16 10:36:12 +00:00
|
|
|
|
(void *)uap->itv, (void *)uap->oitv);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
#endif
|
2005-01-25 21:28:28 +00:00
|
|
|
|
|
|
|
|
|
if (uap->itv == NULL) {
|
|
|
|
|
uap->itv = uap->oitv;
|
|
|
|
|
return (linux_getitimer(td, (struct linux_getitimer_args *)uap));
|
2004-08-15 12:34:15 +00:00
|
|
|
|
}
|
2005-01-25 21:28:28 +00:00
|
|
|
|
|
|
|
|
|
error = copyin(uap->itv, &ls, sizeof(ls));
|
2004-08-15 12:34:15 +00:00
|
|
|
|
if (error != 0)
|
|
|
|
|
return (error);
|
2005-01-25 21:28:28 +00:00
|
|
|
|
B2L_ITIMERVAL(&aitv, &ls);
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
if (ldebug(setitimer)) {
|
2005-12-28 07:08:54 +00:00
|
|
|
|
printf("setitimer: value: sec: %jd, usec: %ld\n",
|
|
|
|
|
(intmax_t)aitv.it_value.tv_sec, aitv.it_value.tv_usec);
|
|
|
|
|
printf("setitimer: interval: sec: %jd, usec: %ld\n",
|
|
|
|
|
(intmax_t)aitv.it_interval.tv_sec, aitv.it_interval.tv_usec);
|
2004-08-15 12:34:15 +00:00
|
|
|
|
}
|
2005-01-25 21:28:28 +00:00
|
|
|
|
#endif
|
|
|
|
|
error = kern_setitimer(td, uap->which, &aitv, &oitv);
|
|
|
|
|
if (error != 0 || uap->oitv == NULL)
|
|
|
|
|
return (error);
|
|
|
|
|
B2L_ITIMERVAL(&ls, &oitv);
|
|
|
|
|
|
|
|
|
|
return (copyout(&ls, uap->oitv, sizeof(ls)));
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2004-08-15 12:34:15 +00:00
|
|
|
|
linux_getitimer(struct thread *td, struct linux_getitimer_args *uap)
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
{
|
2004-08-15 12:34:15 +00:00
|
|
|
|
int error;
|
2005-01-25 21:28:28 +00:00
|
|
|
|
struct l_itimerval ls;
|
|
|
|
|
struct itimerval aitv;
|
2004-08-15 12:34:15 +00:00
|
|
|
|
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
|
if (ldebug(getitimer))
|
2004-08-16 10:36:12 +00:00
|
|
|
|
printf(ARGS(getitimer, "%p"), (void *)uap->itv);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
#endif
|
2005-01-25 21:28:28 +00:00
|
|
|
|
error = kern_getitimer(td, uap->which, &aitv);
|
2004-08-15 12:34:15 +00:00
|
|
|
|
if (error != 0)
|
|
|
|
|
return (error);
|
2005-01-25 21:28:28 +00:00
|
|
|
|
B2L_ITIMERVAL(&ls, &aitv);
|
|
|
|
|
return (copyout(&ls, uap->itv, sizeof(ls)));
|
1996-01-14 10:59:58 +00:00
|
|
|
|
}
|
1997-10-29 08:17:14 +00:00
|
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
|
linux_nice(struct thread *td, struct linux_nice_args *args)
|
1997-10-29 08:17:14 +00:00
|
|
|
|
{
|
|
|
|
|
struct setpriority_args bsd_args;
|
|
|
|
|
|
|
|
|
|
bsd_args.which = PRIO_PROCESS;
|
|
|
|
|
bsd_args.who = 0; /* current process */
|
|
|
|
|
bsd_args.prio = args->inc;
|
2001-09-12 08:38:13 +00:00
|
|
|
|
return setpriority(td, &bsd_args);
|
1997-10-29 08:17:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-12-30 21:01:34 +00:00
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
|
linux_setgroups(struct thread *td, struct linux_setgroups_args *args)
|
1998-12-30 21:01:34 +00:00
|
|
|
|
{
|
o Merge contents of struct pcred into struct ucred. Specifically, add the
real uid, saved uid, real gid, and saved gid to ucred, as well as the
pcred->pc_uidinfo, which was associated with the real uid, only rename
it to cr_ruidinfo so as not to conflict with cr_uidinfo, which
corresponds to the effective uid.
o Remove p_cred from struct proc; add p_ucred to struct proc, replacing
original macro that pointed.
p->p_ucred to p->p_cred->pc_ucred.
o Universally update code so that it makes use of ucred instead of pcred,
p->p_ucred instead of p->p_pcred, cr_ruidinfo instead of p_uidinfo,
cr_{r,sv}{u,g}id instead of p_*, etc.
o Remove pcred0 and its initialization from init_main.c; initialize
cr_ruidinfo there.
o Restruction many credential modification chunks to always crdup while
we figure out locking and optimizations; generally speaking, this
means moving to a structure like this:
newcred = crdup(oldcred);
...
p->p_ucred = newcred;
crfree(oldcred);
It's not race-free, but better than nothing. There are also races
in sys_process.c, all inter-process authorization, fork, exec, and
exit.
o Remove sigio->sio_ruid since sigio->sio_ucred now contains the ruid;
remove comments indicating that the old arrangement was a problem.
o Restructure exec1() a little to use newcred/oldcred arrangement, and
use improved uid management primitives.
o Clean up exit1() so as to do less work in credential cleanup due to
pcred removal.
o Clean up fork1() so as to do less work in credential cleanup and
allocation.
o Clean up ktrcanset() to take into account changes, and move to using
suser_xxx() instead of performing a direct uid==0 comparision.
o Improve commenting in various kern_prot.c credential modification
calls to better document current behavior. In a couple of places,
current behavior is a little questionable and we need to check
POSIX.1 to make sure it's "right". More commenting work still
remains to be done.
o Update credential management calls, such as crfree(), to take into
account new ruidinfo reference.
o Modify or add the following uid and gid helper routines:
change_euid()
change_egid()
change_ruid()
change_rgid()
change_svuid()
change_svgid()
In each case, the call now acts on a credential not a process, and as
such no longer requires more complicated process locking/etc. They
now assume the caller will do any necessary allocation of an
exclusive credential reference. Each is commented to document its
reference requirements.
o CANSIGIO() is simplified to require only credentials, not processes
and pcreds.
o Remove lots of (p_pcred==NULL) checks.
o Add an XXX to authorization code in nfs_lock.c, since it's
questionable, and needs to be considered carefully.
o Simplify posix4 authorization code to require only credentials, not
processes and pcreds. Note that this authorization, as well as
CANSIGIO(), needs to be updated to use the p_cansignal() and
p_cansched() centralized authorization routines, as they currently
do not take into account some desirable restrictions that are handled
by the centralized routines, as well as being inconsistent with other
similar authorization instances.
o Update libkvm to take these changes into account.
Obtained from: TrustedBSD Project
Reviewed by: green, bde, jhb, freebsd-arch, freebsd-audit
2001-05-25 16:59:11 +00:00
|
|
|
|
struct ucred *newcred, *oldcred;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
l_gid_t linux_gidset[NGROUPS];
|
1999-08-25 14:11:01 +00:00
|
|
|
|
gid_t *bsd_gidset;
|
|
|
|
|
int ngrp, error;
|
2002-04-13 23:11:23 +00:00
|
|
|
|
struct proc *p;
|
1998-12-30 21:01:34 +00:00
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
|
ngrp = args->gidsetsize;
|
2003-10-21 11:00:33 +00:00
|
|
|
|
if (ngrp < 0 || ngrp >= NGROUPS)
|
2002-04-13 23:11:23 +00:00
|
|
|
|
return (EINVAL);
|
2003-03-03 09:14:26 +00:00
|
|
|
|
error = copyin(args->grouplist, linux_gidset, ngrp * sizeof(l_gid_t));
|
2002-04-13 23:11:23 +00:00
|
|
|
|
if (error)
|
|
|
|
|
return (error);
|
|
|
|
|
newcred = crget();
|
|
|
|
|
p = td->td_proc;
|
|
|
|
|
PROC_LOCK(p);
|
|
|
|
|
oldcred = p->p_ucred;
|
1998-12-30 21:01:34 +00:00
|
|
|
|
|
1999-08-25 14:11:01 +00:00
|
|
|
|
/*
|
|
|
|
|
* cr_groups[0] holds egid. Setting the whole set from
|
|
|
|
|
* the supplied set will cause egid to be changed too.
|
|
|
|
|
* Keep cr_groups[0] unchanged to prevent that.
|
|
|
|
|
*/
|
1998-12-30 21:01:34 +00:00
|
|
|
|
|
2004-07-26 07:24:04 +00:00
|
|
|
|
if ((error = suser_cred(oldcred, SUSER_ALLOWJAIL)) != 0) {
|
2002-04-13 23:11:23 +00:00
|
|
|
|
PROC_UNLOCK(p);
|
|
|
|
|
crfree(newcred);
|
1999-08-25 14:11:01 +00:00
|
|
|
|
return (error);
|
2002-04-13 23:11:23 +00:00
|
|
|
|
}
|
1998-12-30 21:01:34 +00:00
|
|
|
|
|
2002-04-13 23:11:23 +00:00
|
|
|
|
crcopy(newcred, oldcred);
|
1999-08-25 14:11:01 +00:00
|
|
|
|
if (ngrp > 0) {
|
o Merge contents of struct pcred into struct ucred. Specifically, add the
real uid, saved uid, real gid, and saved gid to ucred, as well as the
pcred->pc_uidinfo, which was associated with the real uid, only rename
it to cr_ruidinfo so as not to conflict with cr_uidinfo, which
corresponds to the effective uid.
o Remove p_cred from struct proc; add p_ucred to struct proc, replacing
original macro that pointed.
p->p_ucred to p->p_cred->pc_ucred.
o Universally update code so that it makes use of ucred instead of pcred,
p->p_ucred instead of p->p_pcred, cr_ruidinfo instead of p_uidinfo,
cr_{r,sv}{u,g}id instead of p_*, etc.
o Remove pcred0 and its initialization from init_main.c; initialize
cr_ruidinfo there.
o Restruction many credential modification chunks to always crdup while
we figure out locking and optimizations; generally speaking, this
means moving to a structure like this:
newcred = crdup(oldcred);
...
p->p_ucred = newcred;
crfree(oldcred);
It's not race-free, but better than nothing. There are also races
in sys_process.c, all inter-process authorization, fork, exec, and
exit.
o Remove sigio->sio_ruid since sigio->sio_ucred now contains the ruid;
remove comments indicating that the old arrangement was a problem.
o Restructure exec1() a little to use newcred/oldcred arrangement, and
use improved uid management primitives.
o Clean up exit1() so as to do less work in credential cleanup due to
pcred removal.
o Clean up fork1() so as to do less work in credential cleanup and
allocation.
o Clean up ktrcanset() to take into account changes, and move to using
suser_xxx() instead of performing a direct uid==0 comparision.
o Improve commenting in various kern_prot.c credential modification
calls to better document current behavior. In a couple of places,
current behavior is a little questionable and we need to check
POSIX.1 to make sure it's "right". More commenting work still
remains to be done.
o Update credential management calls, such as crfree(), to take into
account new ruidinfo reference.
o Modify or add the following uid and gid helper routines:
change_euid()
change_egid()
change_ruid()
change_rgid()
change_svuid()
change_svgid()
In each case, the call now acts on a credential not a process, and as
such no longer requires more complicated process locking/etc. They
now assume the caller will do any necessary allocation of an
exclusive credential reference. Each is commented to document its
reference requirements.
o CANSIGIO() is simplified to require only credentials, not processes
and pcreds.
o Remove lots of (p_pcred==NULL) checks.
o Add an XXX to authorization code in nfs_lock.c, since it's
questionable, and needs to be considered carefully.
o Simplify posix4 authorization code to require only credentials, not
processes and pcreds. Note that this authorization, as well as
CANSIGIO(), needs to be updated to use the p_cansignal() and
p_cansched() centralized authorization routines, as they currently
do not take into account some desirable restrictions that are handled
by the centralized routines, as well as being inconsistent with other
similar authorization instances.
o Update libkvm to take these changes into account.
Obtained from: TrustedBSD Project
Reviewed by: green, bde, jhb, freebsd-arch, freebsd-audit
2001-05-25 16:59:11 +00:00
|
|
|
|
newcred->cr_ngroups = ngrp + 1;
|
1999-08-25 14:11:01 +00:00
|
|
|
|
|
o Merge contents of struct pcred into struct ucred. Specifically, add the
real uid, saved uid, real gid, and saved gid to ucred, as well as the
pcred->pc_uidinfo, which was associated with the real uid, only rename
it to cr_ruidinfo so as not to conflict with cr_uidinfo, which
corresponds to the effective uid.
o Remove p_cred from struct proc; add p_ucred to struct proc, replacing
original macro that pointed.
p->p_ucred to p->p_cred->pc_ucred.
o Universally update code so that it makes use of ucred instead of pcred,
p->p_ucred instead of p->p_pcred, cr_ruidinfo instead of p_uidinfo,
cr_{r,sv}{u,g}id instead of p_*, etc.
o Remove pcred0 and its initialization from init_main.c; initialize
cr_ruidinfo there.
o Restruction many credential modification chunks to always crdup while
we figure out locking and optimizations; generally speaking, this
means moving to a structure like this:
newcred = crdup(oldcred);
...
p->p_ucred = newcred;
crfree(oldcred);
It's not race-free, but better than nothing. There are also races
in sys_process.c, all inter-process authorization, fork, exec, and
exit.
o Remove sigio->sio_ruid since sigio->sio_ucred now contains the ruid;
remove comments indicating that the old arrangement was a problem.
o Restructure exec1() a little to use newcred/oldcred arrangement, and
use improved uid management primitives.
o Clean up exit1() so as to do less work in credential cleanup due to
pcred removal.
o Clean up fork1() so as to do less work in credential cleanup and
allocation.
o Clean up ktrcanset() to take into account changes, and move to using
suser_xxx() instead of performing a direct uid==0 comparision.
o Improve commenting in various kern_prot.c credential modification
calls to better document current behavior. In a couple of places,
current behavior is a little questionable and we need to check
POSIX.1 to make sure it's "right". More commenting work still
remains to be done.
o Update credential management calls, such as crfree(), to take into
account new ruidinfo reference.
o Modify or add the following uid and gid helper routines:
change_euid()
change_egid()
change_ruid()
change_rgid()
change_svuid()
change_svgid()
In each case, the call now acts on a credential not a process, and as
such no longer requires more complicated process locking/etc. They
now assume the caller will do any necessary allocation of an
exclusive credential reference. Each is commented to document its
reference requirements.
o CANSIGIO() is simplified to require only credentials, not processes
and pcreds.
o Remove lots of (p_pcred==NULL) checks.
o Add an XXX to authorization code in nfs_lock.c, since it's
questionable, and needs to be considered carefully.
o Simplify posix4 authorization code to require only credentials, not
processes and pcreds. Note that this authorization, as well as
CANSIGIO(), needs to be updated to use the p_cansignal() and
p_cansched() centralized authorization routines, as they currently
do not take into account some desirable restrictions that are handled
by the centralized routines, as well as being inconsistent with other
similar authorization instances.
o Update libkvm to take these changes into account.
Obtained from: TrustedBSD Project
Reviewed by: green, bde, jhb, freebsd-arch, freebsd-audit
2001-05-25 16:59:11 +00:00
|
|
|
|
bsd_gidset = newcred->cr_groups;
|
1999-08-25 14:11:01 +00:00
|
|
|
|
ngrp--;
|
|
|
|
|
while (ngrp >= 0) {
|
|
|
|
|
bsd_gidset[ngrp + 1] = linux_gidset[ngrp];
|
|
|
|
|
ngrp--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
o Merge contents of struct pcred into struct ucred. Specifically, add the
real uid, saved uid, real gid, and saved gid to ucred, as well as the
pcred->pc_uidinfo, which was associated with the real uid, only rename
it to cr_ruidinfo so as not to conflict with cr_uidinfo, which
corresponds to the effective uid.
o Remove p_cred from struct proc; add p_ucred to struct proc, replacing
original macro that pointed.
p->p_ucred to p->p_cred->pc_ucred.
o Universally update code so that it makes use of ucred instead of pcred,
p->p_ucred instead of p->p_pcred, cr_ruidinfo instead of p_uidinfo,
cr_{r,sv}{u,g}id instead of p_*, etc.
o Remove pcred0 and its initialization from init_main.c; initialize
cr_ruidinfo there.
o Restruction many credential modification chunks to always crdup while
we figure out locking and optimizations; generally speaking, this
means moving to a structure like this:
newcred = crdup(oldcred);
...
p->p_ucred = newcred;
crfree(oldcred);
It's not race-free, but better than nothing. There are also races
in sys_process.c, all inter-process authorization, fork, exec, and
exit.
o Remove sigio->sio_ruid since sigio->sio_ucred now contains the ruid;
remove comments indicating that the old arrangement was a problem.
o Restructure exec1() a little to use newcred/oldcred arrangement, and
use improved uid management primitives.
o Clean up exit1() so as to do less work in credential cleanup due to
pcred removal.
o Clean up fork1() so as to do less work in credential cleanup and
allocation.
o Clean up ktrcanset() to take into account changes, and move to using
suser_xxx() instead of performing a direct uid==0 comparision.
o Improve commenting in various kern_prot.c credential modification
calls to better document current behavior. In a couple of places,
current behavior is a little questionable and we need to check
POSIX.1 to make sure it's "right". More commenting work still
remains to be done.
o Update credential management calls, such as crfree(), to take into
account new ruidinfo reference.
o Modify or add the following uid and gid helper routines:
change_euid()
change_egid()
change_ruid()
change_rgid()
change_svuid()
change_svgid()
In each case, the call now acts on a credential not a process, and as
such no longer requires more complicated process locking/etc. They
now assume the caller will do any necessary allocation of an
exclusive credential reference. Each is commented to document its
reference requirements.
o CANSIGIO() is simplified to require only credentials, not processes
and pcreds.
o Remove lots of (p_pcred==NULL) checks.
o Add an XXX to authorization code in nfs_lock.c, since it's
questionable, and needs to be considered carefully.
o Simplify posix4 authorization code to require only credentials, not
processes and pcreds. Note that this authorization, as well as
CANSIGIO(), needs to be updated to use the p_cansignal() and
p_cansched() centralized authorization routines, as they currently
do not take into account some desirable restrictions that are handled
by the centralized routines, as well as being inconsistent with other
similar authorization instances.
o Update libkvm to take these changes into account.
Obtained from: TrustedBSD Project
Reviewed by: green, bde, jhb, freebsd-arch, freebsd-audit
2001-05-25 16:59:11 +00:00
|
|
|
|
newcred->cr_ngroups = 1;
|
1998-12-30 21:01:34 +00:00
|
|
|
|
|
2002-04-13 23:11:23 +00:00
|
|
|
|
setsugid(p);
|
|
|
|
|
p->p_ucred = newcred;
|
|
|
|
|
PROC_UNLOCK(p);
|
o Merge contents of struct pcred into struct ucred. Specifically, add the
real uid, saved uid, real gid, and saved gid to ucred, as well as the
pcred->pc_uidinfo, which was associated with the real uid, only rename
it to cr_ruidinfo so as not to conflict with cr_uidinfo, which
corresponds to the effective uid.
o Remove p_cred from struct proc; add p_ucred to struct proc, replacing
original macro that pointed.
p->p_ucred to p->p_cred->pc_ucred.
o Universally update code so that it makes use of ucred instead of pcred,
p->p_ucred instead of p->p_pcred, cr_ruidinfo instead of p_uidinfo,
cr_{r,sv}{u,g}id instead of p_*, etc.
o Remove pcred0 and its initialization from init_main.c; initialize
cr_ruidinfo there.
o Restruction many credential modification chunks to always crdup while
we figure out locking and optimizations; generally speaking, this
means moving to a structure like this:
newcred = crdup(oldcred);
...
p->p_ucred = newcred;
crfree(oldcred);
It's not race-free, but better than nothing. There are also races
in sys_process.c, all inter-process authorization, fork, exec, and
exit.
o Remove sigio->sio_ruid since sigio->sio_ucred now contains the ruid;
remove comments indicating that the old arrangement was a problem.
o Restructure exec1() a little to use newcred/oldcred arrangement, and
use improved uid management primitives.
o Clean up exit1() so as to do less work in credential cleanup due to
pcred removal.
o Clean up fork1() so as to do less work in credential cleanup and
allocation.
o Clean up ktrcanset() to take into account changes, and move to using
suser_xxx() instead of performing a direct uid==0 comparision.
o Improve commenting in various kern_prot.c credential modification
calls to better document current behavior. In a couple of places,
current behavior is a little questionable and we need to check
POSIX.1 to make sure it's "right". More commenting work still
remains to be done.
o Update credential management calls, such as crfree(), to take into
account new ruidinfo reference.
o Modify or add the following uid and gid helper routines:
change_euid()
change_egid()
change_ruid()
change_rgid()
change_svuid()
change_svgid()
In each case, the call now acts on a credential not a process, and as
such no longer requires more complicated process locking/etc. They
now assume the caller will do any necessary allocation of an
exclusive credential reference. Each is commented to document its
reference requirements.
o CANSIGIO() is simplified to require only credentials, not processes
and pcreds.
o Remove lots of (p_pcred==NULL) checks.
o Add an XXX to authorization code in nfs_lock.c, since it's
questionable, and needs to be considered carefully.
o Simplify posix4 authorization code to require only credentials, not
processes and pcreds. Note that this authorization, as well as
CANSIGIO(), needs to be updated to use the p_cansignal() and
p_cansched() centralized authorization routines, as they currently
do not take into account some desirable restrictions that are handled
by the centralized routines, as well as being inconsistent with other
similar authorization instances.
o Update libkvm to take these changes into account.
Obtained from: TrustedBSD Project
Reviewed by: green, bde, jhb, freebsd-arch, freebsd-audit
2001-05-25 16:59:11 +00:00
|
|
|
|
crfree(oldcred);
|
1999-08-25 14:11:01 +00:00
|
|
|
|
return (0);
|
1998-12-30 21:01:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
|
linux_getgroups(struct thread *td, struct linux_getgroups_args *args)
|
1998-12-30 21:01:34 +00:00
|
|
|
|
{
|
o Merge contents of struct pcred into struct ucred. Specifically, add the
real uid, saved uid, real gid, and saved gid to ucred, as well as the
pcred->pc_uidinfo, which was associated with the real uid, only rename
it to cr_ruidinfo so as not to conflict with cr_uidinfo, which
corresponds to the effective uid.
o Remove p_cred from struct proc; add p_ucred to struct proc, replacing
original macro that pointed.
p->p_ucred to p->p_cred->pc_ucred.
o Universally update code so that it makes use of ucred instead of pcred,
p->p_ucred instead of p->p_pcred, cr_ruidinfo instead of p_uidinfo,
cr_{r,sv}{u,g}id instead of p_*, etc.
o Remove pcred0 and its initialization from init_main.c; initialize
cr_ruidinfo there.
o Restruction many credential modification chunks to always crdup while
we figure out locking and optimizations; generally speaking, this
means moving to a structure like this:
newcred = crdup(oldcred);
...
p->p_ucred = newcred;
crfree(oldcred);
It's not race-free, but better than nothing. There are also races
in sys_process.c, all inter-process authorization, fork, exec, and
exit.
o Remove sigio->sio_ruid since sigio->sio_ucred now contains the ruid;
remove comments indicating that the old arrangement was a problem.
o Restructure exec1() a little to use newcred/oldcred arrangement, and
use improved uid management primitives.
o Clean up exit1() so as to do less work in credential cleanup due to
pcred removal.
o Clean up fork1() so as to do less work in credential cleanup and
allocation.
o Clean up ktrcanset() to take into account changes, and move to using
suser_xxx() instead of performing a direct uid==0 comparision.
o Improve commenting in various kern_prot.c credential modification
calls to better document current behavior. In a couple of places,
current behavior is a little questionable and we need to check
POSIX.1 to make sure it's "right". More commenting work still
remains to be done.
o Update credential management calls, such as crfree(), to take into
account new ruidinfo reference.
o Modify or add the following uid and gid helper routines:
change_euid()
change_egid()
change_ruid()
change_rgid()
change_svuid()
change_svgid()
In each case, the call now acts on a credential not a process, and as
such no longer requires more complicated process locking/etc. They
now assume the caller will do any necessary allocation of an
exclusive credential reference. Each is commented to document its
reference requirements.
o CANSIGIO() is simplified to require only credentials, not processes
and pcreds.
o Remove lots of (p_pcred==NULL) checks.
o Add an XXX to authorization code in nfs_lock.c, since it's
questionable, and needs to be considered carefully.
o Simplify posix4 authorization code to require only credentials, not
processes and pcreds. Note that this authorization, as well as
CANSIGIO(), needs to be updated to use the p_cansignal() and
p_cansched() centralized authorization routines, as they currently
do not take into account some desirable restrictions that are handled
by the centralized routines, as well as being inconsistent with other
similar authorization instances.
o Update libkvm to take these changes into account.
Obtained from: TrustedBSD Project
Reviewed by: green, bde, jhb, freebsd-arch, freebsd-audit
2001-05-25 16:59:11 +00:00
|
|
|
|
struct ucred *cred;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
l_gid_t linux_gidset[NGROUPS];
|
1999-08-25 14:11:01 +00:00
|
|
|
|
gid_t *bsd_gidset;
|
|
|
|
|
int bsd_gidsetsz, ngrp, error;
|
1998-12-30 21:01:34 +00:00
|
|
|
|
|
2002-04-11 21:00:05 +00:00
|
|
|
|
cred = td->td_ucred;
|
o Merge contents of struct pcred into struct ucred. Specifically, add the
real uid, saved uid, real gid, and saved gid to ucred, as well as the
pcred->pc_uidinfo, which was associated with the real uid, only rename
it to cr_ruidinfo so as not to conflict with cr_uidinfo, which
corresponds to the effective uid.
o Remove p_cred from struct proc; add p_ucred to struct proc, replacing
original macro that pointed.
p->p_ucred to p->p_cred->pc_ucred.
o Universally update code so that it makes use of ucred instead of pcred,
p->p_ucred instead of p->p_pcred, cr_ruidinfo instead of p_uidinfo,
cr_{r,sv}{u,g}id instead of p_*, etc.
o Remove pcred0 and its initialization from init_main.c; initialize
cr_ruidinfo there.
o Restruction many credential modification chunks to always crdup while
we figure out locking and optimizations; generally speaking, this
means moving to a structure like this:
newcred = crdup(oldcred);
...
p->p_ucred = newcred;
crfree(oldcred);
It's not race-free, but better than nothing. There are also races
in sys_process.c, all inter-process authorization, fork, exec, and
exit.
o Remove sigio->sio_ruid since sigio->sio_ucred now contains the ruid;
remove comments indicating that the old arrangement was a problem.
o Restructure exec1() a little to use newcred/oldcred arrangement, and
use improved uid management primitives.
o Clean up exit1() so as to do less work in credential cleanup due to
pcred removal.
o Clean up fork1() so as to do less work in credential cleanup and
allocation.
o Clean up ktrcanset() to take into account changes, and move to using
suser_xxx() instead of performing a direct uid==0 comparision.
o Improve commenting in various kern_prot.c credential modification
calls to better document current behavior. In a couple of places,
current behavior is a little questionable and we need to check
POSIX.1 to make sure it's "right". More commenting work still
remains to be done.
o Update credential management calls, such as crfree(), to take into
account new ruidinfo reference.
o Modify or add the following uid and gid helper routines:
change_euid()
change_egid()
change_ruid()
change_rgid()
change_svuid()
change_svgid()
In each case, the call now acts on a credential not a process, and as
such no longer requires more complicated process locking/etc. They
now assume the caller will do any necessary allocation of an
exclusive credential reference. Each is commented to document its
reference requirements.
o CANSIGIO() is simplified to require only credentials, not processes
and pcreds.
o Remove lots of (p_pcred==NULL) checks.
o Add an XXX to authorization code in nfs_lock.c, since it's
questionable, and needs to be considered carefully.
o Simplify posix4 authorization code to require only credentials, not
processes and pcreds. Note that this authorization, as well as
CANSIGIO(), needs to be updated to use the p_cansignal() and
p_cansched() centralized authorization routines, as they currently
do not take into account some desirable restrictions that are handled
by the centralized routines, as well as being inconsistent with other
similar authorization instances.
o Update libkvm to take these changes into account.
Obtained from: TrustedBSD Project
Reviewed by: green, bde, jhb, freebsd-arch, freebsd-audit
2001-05-25 16:59:11 +00:00
|
|
|
|
bsd_gidset = cred->cr_groups;
|
|
|
|
|
bsd_gidsetsz = cred->cr_ngroups - 1;
|
1998-12-30 21:01:34 +00:00
|
|
|
|
|
1999-08-25 14:11:01 +00:00
|
|
|
|
/*
|
|
|
|
|
* cr_groups[0] holds egid. Returning the whole set
|
|
|
|
|
* here will cause a duplicate. Exclude cr_groups[0]
|
|
|
|
|
* to prevent that.
|
|
|
|
|
*/
|
1998-12-30 21:01:34 +00:00
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
|
if ((ngrp = args->gidsetsize) == 0) {
|
2001-09-12 08:38:13 +00:00
|
|
|
|
td->td_retval[0] = bsd_gidsetsz;
|
1999-08-25 14:11:01 +00:00
|
|
|
|
return (0);
|
|
|
|
|
}
|
1998-12-30 21:01:34 +00:00
|
|
|
|
|
1999-08-29 08:52:38 +00:00
|
|
|
|
if (ngrp < bsd_gidsetsz)
|
1999-08-25 14:11:01 +00:00
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
1999-08-29 08:52:38 +00:00
|
|
|
|
ngrp = 0;
|
1999-08-25 14:11:01 +00:00
|
|
|
|
while (ngrp < bsd_gidsetsz) {
|
1999-08-29 08:52:38 +00:00
|
|
|
|
linux_gidset[ngrp] = bsd_gidset[ngrp + 1];
|
1999-08-25 14:11:01 +00:00
|
|
|
|
ngrp++;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-03 09:14:26 +00:00
|
|
|
|
if ((error = copyout(linux_gidset, args->grouplist,
|
2001-09-08 19:07:04 +00:00
|
|
|
|
ngrp * sizeof(l_gid_t))))
|
1999-08-25 14:11:01 +00:00
|
|
|
|
return (error);
|
1998-12-30 21:01:34 +00:00
|
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
|
td->td_retval[0] = ngrp;
|
1999-08-25 14:11:01 +00:00
|
|
|
|
return (0);
|
1998-12-30 21:01:34 +00:00
|
|
|
|
}
|
1999-08-11 13:34:31 +00:00
|
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
|
linux_setrlimit(struct thread *td, struct linux_setrlimit_args *args)
|
1999-08-11 13:34:31 +00:00
|
|
|
|
{
|
2002-09-01 22:30:27 +00:00
|
|
|
|
struct rlimit bsd_rlim;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
struct l_rlimit rlim;
|
2002-09-01 22:30:27 +00:00
|
|
|
|
u_int which;
|
2000-08-26 02:18:41 +00:00
|
|
|
|
int error;
|
1999-08-15 13:28:35 +00:00
|
|
|
|
|
1999-08-11 13:34:31 +00:00
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
|
if (ldebug(setrlimit))
|
|
|
|
|
printf(ARGS(setrlimit, "%d, %p"),
|
2001-09-08 19:07:04 +00:00
|
|
|
|
args->resource, (void *)args->rlim);
|
1999-08-11 13:34:31 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
|
if (args->resource >= LINUX_RLIM_NLIMITS)
|
2000-08-26 02:18:41 +00:00
|
|
|
|
return (EINVAL);
|
1999-08-11 13:34:31 +00:00
|
|
|
|
|
2002-09-01 22:30:27 +00:00
|
|
|
|
which = linux_to_bsd_resource[args->resource];
|
|
|
|
|
if (which == -1)
|
2000-08-26 02:18:41 +00:00
|
|
|
|
return (EINVAL);
|
1999-08-11 13:34:31 +00:00
|
|
|
|
|
2003-03-03 09:14:26 +00:00
|
|
|
|
error = copyin(args->rlim, &rlim, sizeof(rlim));
|
2000-08-26 02:18:41 +00:00
|
|
|
|
if (error)
|
|
|
|
|
return (error);
|
1999-08-11 13:34:31 +00:00
|
|
|
|
|
2002-09-01 22:30:27 +00:00
|
|
|
|
bsd_rlim.rlim_cur = (rlim_t)rlim.rlim_cur;
|
|
|
|
|
bsd_rlim.rlim_max = (rlim_t)rlim.rlim_max;
|
2004-02-04 21:52:57 +00:00
|
|
|
|
return (kern_setrlimit(td, which, &bsd_rlim));
|
1999-08-11 13:34:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
|
linux_old_getrlimit(struct thread *td, struct linux_old_getrlimit_args *args)
|
1999-08-11 13:34:31 +00:00
|
|
|
|
{
|
2001-09-08 19:07:04 +00:00
|
|
|
|
struct l_rlimit rlim;
|
2002-09-01 22:30:27 +00:00
|
|
|
|
struct proc *p = td->td_proc;
|
2004-02-04 21:52:57 +00:00
|
|
|
|
struct rlimit bsd_rlim;
|
2002-09-01 22:30:27 +00:00
|
|
|
|
u_int which;
|
1999-08-15 13:28:35 +00:00
|
|
|
|
|
1999-08-11 13:34:31 +00:00
|
|
|
|
#ifdef DEBUG
|
2001-09-08 19:07:04 +00:00
|
|
|
|
if (ldebug(old_getrlimit))
|
|
|
|
|
printf(ARGS(old_getrlimit, "%d, %p"),
|
|
|
|
|
args->resource, (void *)args->rlim);
|
1999-08-11 13:34:31 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
|
if (args->resource >= LINUX_RLIM_NLIMITS)
|
2000-08-26 02:18:41 +00:00
|
|
|
|
return (EINVAL);
|
1999-08-11 13:34:31 +00:00
|
|
|
|
|
2002-09-01 22:30:27 +00:00
|
|
|
|
which = linux_to_bsd_resource[args->resource];
|
|
|
|
|
if (which == -1)
|
2000-08-26 02:18:41 +00:00
|
|
|
|
return (EINVAL);
|
1999-08-11 13:34:31 +00:00
|
|
|
|
|
2004-02-04 21:52:57 +00:00
|
|
|
|
PROC_LOCK(p);
|
|
|
|
|
lim_rlimit(p, which, &bsd_rlim);
|
|
|
|
|
PROC_UNLOCK(p);
|
|
|
|
|
|
2005-01-14 04:44:56 +00:00
|
|
|
|
#ifdef COMPAT_LINUX32
|
2004-08-16 07:28:16 +00:00
|
|
|
|
rlim.rlim_cur = (unsigned int)bsd_rlim.rlim_cur;
|
|
|
|
|
if (rlim.rlim_cur == UINT_MAX)
|
|
|
|
|
rlim.rlim_cur = INT_MAX;
|
|
|
|
|
rlim.rlim_max = (unsigned int)bsd_rlim.rlim_max;
|
|
|
|
|
if (rlim.rlim_max == UINT_MAX)
|
|
|
|
|
rlim.rlim_max = INT_MAX;
|
2005-01-14 04:44:56 +00:00
|
|
|
|
#else
|
|
|
|
|
rlim.rlim_cur = (unsigned long)bsd_rlim.rlim_cur;
|
|
|
|
|
if (rlim.rlim_cur == ULONG_MAX)
|
|
|
|
|
rlim.rlim_cur = LONG_MAX;
|
|
|
|
|
rlim.rlim_max = (unsigned long)bsd_rlim.rlim_max;
|
|
|
|
|
if (rlim.rlim_max == ULONG_MAX)
|
|
|
|
|
rlim.rlim_max = LONG_MAX;
|
2004-08-16 07:28:16 +00:00
|
|
|
|
#endif
|
2003-03-03 09:14:26 +00:00
|
|
|
|
return (copyout(&rlim, args->rlim, sizeof(rlim)));
|
2001-09-08 19:07:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
|
linux_getrlimit(struct thread *td, struct linux_getrlimit_args *args)
|
2001-09-08 19:07:04 +00:00
|
|
|
|
{
|
|
|
|
|
struct l_rlimit rlim;
|
2002-09-01 22:30:27 +00:00
|
|
|
|
struct proc *p = td->td_proc;
|
2004-02-04 21:52:57 +00:00
|
|
|
|
struct rlimit bsd_rlim;
|
2002-09-01 22:30:27 +00:00
|
|
|
|
u_int which;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
if (ldebug(getrlimit))
|
|
|
|
|
printf(ARGS(getrlimit, "%d, %p"),
|
|
|
|
|
args->resource, (void *)args->rlim);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (args->resource >= LINUX_RLIM_NLIMITS)
|
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
2002-09-01 22:30:27 +00:00
|
|
|
|
which = linux_to_bsd_resource[args->resource];
|
|
|
|
|
if (which == -1)
|
2001-09-08 19:07:04 +00:00
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
2004-02-04 21:52:57 +00:00
|
|
|
|
PROC_LOCK(p);
|
|
|
|
|
lim_rlimit(p, which, &bsd_rlim);
|
|
|
|
|
PROC_UNLOCK(p);
|
|
|
|
|
|
|
|
|
|
rlim.rlim_cur = (l_ulong)bsd_rlim.rlim_cur;
|
|
|
|
|
rlim.rlim_max = (l_ulong)bsd_rlim.rlim_max;
|
2003-03-03 09:14:26 +00:00
|
|
|
|
return (copyout(&rlim, args->rlim, sizeof(rlim)));
|
1999-08-11 13:34:31 +00:00
|
|
|
|
}
|
1999-08-15 17:28:40 +00:00
|
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
|
linux_sched_setscheduler(struct thread *td,
|
2001-09-08 19:07:04 +00:00
|
|
|
|
struct linux_sched_setscheduler_args *args)
|
1999-08-15 17:28:40 +00:00
|
|
|
|
{
|
|
|
|
|
struct sched_setscheduler_args bsd;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
|
if (ldebug(sched_setscheduler))
|
|
|
|
|
printf(ARGS(sched_setscheduler, "%d, %d, %p"),
|
2001-09-08 19:07:04 +00:00
|
|
|
|
args->pid, args->policy, (const void *)args->param);
|
1999-08-15 17:28:40 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
|
switch (args->policy) {
|
1999-08-15 17:28:40 +00:00
|
|
|
|
case LINUX_SCHED_OTHER:
|
|
|
|
|
bsd.policy = SCHED_OTHER;
|
|
|
|
|
break;
|
|
|
|
|
case LINUX_SCHED_FIFO:
|
|
|
|
|
bsd.policy = SCHED_FIFO;
|
|
|
|
|
break;
|
|
|
|
|
case LINUX_SCHED_RR:
|
|
|
|
|
bsd.policy = SCHED_RR;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
|
bsd.pid = args->pid;
|
|
|
|
|
bsd.param = (struct sched_param *)args->param;
|
2001-09-12 08:38:13 +00:00
|
|
|
|
return sched_setscheduler(td, &bsd);
|
1999-08-15 17:28:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
|
linux_sched_getscheduler(struct thread *td,
|
2001-09-08 19:07:04 +00:00
|
|
|
|
struct linux_sched_getscheduler_args *args)
|
1999-08-15 17:28:40 +00:00
|
|
|
|
{
|
|
|
|
|
struct sched_getscheduler_args bsd;
|
|
|
|
|
int error;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
|
if (ldebug(sched_getscheduler))
|
2001-09-08 19:07:04 +00:00
|
|
|
|
printf(ARGS(sched_getscheduler, "%d"), args->pid);
|
1999-08-15 17:28:40 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
|
bsd.pid = args->pid;
|
2001-09-12 08:38:13 +00:00
|
|
|
|
error = sched_getscheduler(td, &bsd);
|
1999-08-15 17:28:40 +00:00
|
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
|
switch (td->td_retval[0]) {
|
1999-08-15 17:28:40 +00:00
|
|
|
|
case SCHED_OTHER:
|
2001-09-12 08:38:13 +00:00
|
|
|
|
td->td_retval[0] = LINUX_SCHED_OTHER;
|
1999-08-15 17:28:40 +00:00
|
|
|
|
break;
|
|
|
|
|
case SCHED_FIFO:
|
2001-09-12 08:38:13 +00:00
|
|
|
|
td->td_retval[0] = LINUX_SCHED_FIFO;
|
1999-08-15 17:28:40 +00:00
|
|
|
|
break;
|
|
|
|
|
case SCHED_RR:
|
2001-09-12 08:38:13 +00:00
|
|
|
|
td->td_retval[0] = LINUX_SCHED_RR;
|
1999-08-15 17:28:40 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return error;
|
|
|
|
|
}
|
2001-02-16 14:42:11 +00:00
|
|
|
|
|
2001-04-01 06:37:40 +00:00
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
|
linux_sched_get_priority_max(struct thread *td,
|
2001-09-08 19:07:04 +00:00
|
|
|
|
struct linux_sched_get_priority_max_args *args)
|
2001-04-01 06:37:40 +00:00
|
|
|
|
{
|
|
|
|
|
struct sched_get_priority_max_args bsd;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
if (ldebug(sched_get_priority_max))
|
2001-09-08 19:07:04 +00:00
|
|
|
|
printf(ARGS(sched_get_priority_max, "%d"), args->policy);
|
2001-04-01 06:37:40 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
|
switch (args->policy) {
|
2001-04-01 06:37:40 +00:00
|
|
|
|
case LINUX_SCHED_OTHER:
|
|
|
|
|
bsd.policy = SCHED_OTHER;
|
|
|
|
|
break;
|
|
|
|
|
case LINUX_SCHED_FIFO:
|
|
|
|
|
bsd.policy = SCHED_FIFO;
|
|
|
|
|
break;
|
|
|
|
|
case LINUX_SCHED_RR:
|
|
|
|
|
bsd.policy = SCHED_RR;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return EINVAL;
|
|
|
|
|
}
|
2001-09-12 08:38:13 +00:00
|
|
|
|
return sched_get_priority_max(td, &bsd);
|
2001-04-01 06:37:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
|
linux_sched_get_priority_min(struct thread *td,
|
2001-09-08 19:07:04 +00:00
|
|
|
|
struct linux_sched_get_priority_min_args *args)
|
2001-04-01 06:37:40 +00:00
|
|
|
|
{
|
|
|
|
|
struct sched_get_priority_min_args bsd;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
if (ldebug(sched_get_priority_min))
|
2001-09-08 19:07:04 +00:00
|
|
|
|
printf(ARGS(sched_get_priority_min, "%d"), args->policy);
|
2001-04-01 06:37:40 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
|
switch (args->policy) {
|
2001-04-01 06:37:40 +00:00
|
|
|
|
case LINUX_SCHED_OTHER:
|
|
|
|
|
bsd.policy = SCHED_OTHER;
|
|
|
|
|
break;
|
|
|
|
|
case LINUX_SCHED_FIFO:
|
|
|
|
|
bsd.policy = SCHED_FIFO;
|
|
|
|
|
break;
|
|
|
|
|
case LINUX_SCHED_RR:
|
|
|
|
|
bsd.policy = SCHED_RR;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return EINVAL;
|
|
|
|
|
}
|
2001-09-12 08:38:13 +00:00
|
|
|
|
return sched_get_priority_min(td, &bsd);
|
2001-04-01 06:37:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-02-16 14:42:11 +00:00
|
|
|
|
#define REBOOT_CAD_ON 0x89abcdef
|
|
|
|
|
#define REBOOT_CAD_OFF 0
|
|
|
|
|
#define REBOOT_HALT 0xcdef0123
|
|
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
|
linux_reboot(struct thread *td, struct linux_reboot_args *args)
|
2001-02-16 14:42:11 +00:00
|
|
|
|
{
|
|
|
|
|
struct reboot_args bsd_args;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
if (ldebug(reboot))
|
2001-09-08 19:07:04 +00:00
|
|
|
|
printf(ARGS(reboot, "0x%x"), args->cmd);
|
2001-02-16 14:42:11 +00:00
|
|
|
|
#endif
|
2001-09-08 19:07:04 +00:00
|
|
|
|
if (args->cmd == REBOOT_CAD_ON || args->cmd == REBOOT_CAD_OFF)
|
2001-02-16 14:42:11 +00:00
|
|
|
|
return (0);
|
2001-09-08 19:07:04 +00:00
|
|
|
|
bsd_args.opt = (args->cmd == REBOOT_HALT) ? RB_HALT : 0;
|
2001-09-12 08:38:13 +00:00
|
|
|
|
return (reboot(td, &bsd_args));
|
2001-02-16 14:42:11 +00:00
|
|
|
|
}
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
2002-01-23 22:46:14 +00:00
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
|
/*
|
|
|
|
|
* The FreeBSD native getpid(2), getgid(2) and getuid(2) also modify
|
2004-06-11 11:16:26 +00:00
|
|
|
|
* td->td_retval[1] when COMPAT_43 is defined. This
|
2001-09-08 19:07:04 +00:00
|
|
|
|
* globbers registers that are assumed to be preserved. The following
|
|
|
|
|
* lightweight syscalls fixes this. See also linux_getgid16() and
|
|
|
|
|
* linux_getuid16() in linux_uid16.c.
|
|
|
|
|
*
|
|
|
|
|
* linux_getpid() - MP SAFE
|
|
|
|
|
* linux_getgid() - MP SAFE
|
|
|
|
|
* linux_getuid() - MP SAFE
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
|
linux_getpid(struct thread *td, struct linux_getpid_args *args)
|
2001-09-08 19:07:04 +00:00
|
|
|
|
{
|
2006-08-15 15:15:17 +00:00
|
|
|
|
#ifdef __i386__
|
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
2006-08-15 12:54:30 +00:00
|
|
|
|
struct linux_emuldata *em;
|
2006-08-17 21:21:30 +00:00
|
|
|
|
char osrel[LINUX_MAX_UTSNAME];
|
|
|
|
|
|
|
|
|
|
linux_get_osrelease(td, osrel);
|
|
|
|
|
if (strlen(osrel) >= 3 && osrel[2] == '6') {
|
|
|
|
|
em = em_find(td->td_proc, EMUL_UNLOCKED);
|
|
|
|
|
KASSERT(em != NULL, ("getpid: emuldata not found.\n"));
|
|
|
|
|
td->td_retval[0] = em->shared->group_pid;
|
|
|
|
|
EMUL_UNLOCK(&emul_lock);
|
|
|
|
|
} else {
|
|
|
|
|
PROC_LOCK(td->td_proc);
|
|
|
|
|
td->td_retval[0] = td->td_proc->p_pid;
|
|
|
|
|
PROC_UNLOCK(td->td_proc);
|
|
|
|
|
}
|
2006-08-15 15:15:17 +00:00
|
|
|
|
#else
|
2006-08-17 21:21:30 +00:00
|
|
|
|
PROC_LOCK(td->td_proc);
|
2006-08-15 15:15:17 +00:00
|
|
|
|
td->td_retval[0] = td->td_proc->p_pid;
|
2006-08-17 21:21:30 +00:00
|
|
|
|
PROC_UNLOCK(td->td_proc);
|
2006-08-15 15:15:17 +00:00
|
|
|
|
#endif
|
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
2006-08-15 12:54:30 +00:00
|
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
linux_gettid(struct thread *td, struct linux_gettid_args *args)
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
if (ldebug(gettid))
|
|
|
|
|
printf(ARGS(gettid, ""));
|
|
|
|
|
#endif
|
2001-09-12 08:38:13 +00:00
|
|
|
|
|
|
|
|
|
td->td_retval[0] = td->td_proc->p_pid;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
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
2006-08-15 12:54:30 +00:00
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
linux_getppid(struct thread *td, struct linux_getppid_args *args)
|
|
|
|
|
{
|
2006-08-17 21:21:30 +00:00
|
|
|
|
#ifdef __i386__
|
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
2006-08-15 12:54:30 +00:00
|
|
|
|
struct linux_emuldata *em;
|
|
|
|
|
struct proc *p, *pp;
|
2006-08-17 21:21:30 +00:00
|
|
|
|
char osrel[LINUX_MAX_UTSNAME];
|
|
|
|
|
|
|
|
|
|
linux_get_osrelease(td, osrel);
|
|
|
|
|
if (strlen(osrel) >= 3 && osrel[2] != '6') {
|
|
|
|
|
PROC_LOCK(td->td_proc);
|
|
|
|
|
td->td_retval[0] = td->td_proc->p_pptr->p_pid;
|
|
|
|
|
PROC_UNLOCK(td->td_proc);
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
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
2006-08-15 12:54:30 +00:00
|
|
|
|
|
|
|
|
|
em = em_find(td->td_proc, EMUL_UNLOCKED);
|
|
|
|
|
|
|
|
|
|
KASSERT(em != NULL, ("getppid: process emuldata not found.\n"));
|
|
|
|
|
|
|
|
|
|
/* find the group leader */
|
|
|
|
|
p = pfind(em->shared->group_pid);
|
|
|
|
|
|
|
|
|
|
if (p == NULL) {
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
printf(LMSG("parent process not found.\n"));
|
|
|
|
|
#endif
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pp = p->p_pptr; /* switch to parent */
|
|
|
|
|
PROC_LOCK(pp);
|
|
|
|
|
PROC_UNLOCK(p);
|
|
|
|
|
|
|
|
|
|
/* if its also linux process */
|
|
|
|
|
if (pp->p_sysent == &elf_linux_sysvec) {
|
|
|
|
|
em = em_find(pp, EMUL_LOCKED);
|
|
|
|
|
KASSERT(em != NULL, ("getppid: parent emuldata not found.\n"));
|
|
|
|
|
|
2006-08-17 21:21:30 +00:00
|
|
|
|
td->td_retval[0] = em->shared->group_pid;
|
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
2006-08-15 12:54:30 +00:00
|
|
|
|
} else
|
|
|
|
|
td->td_retval[0] = pp->p_pid;
|
|
|
|
|
|
|
|
|
|
EMUL_UNLOCK(&emul_lock);
|
|
|
|
|
PROC_UNLOCK(pp);
|
2006-08-15 15:15:17 +00:00
|
|
|
|
#else
|
|
|
|
|
return getppid(td, (struct getppid_args *) args);
|
|
|
|
|
#endif
|
2006-08-17 21:21:30 +00:00
|
|
|
|
|
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
2006-08-15 12:54:30 +00:00
|
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
|
linux_getgid(struct thread *td, struct linux_getgid_args *args)
|
2001-09-08 19:07:04 +00:00
|
|
|
|
{
|
2001-09-12 08:38:13 +00:00
|
|
|
|
|
2002-04-11 21:00:05 +00:00
|
|
|
|
td->td_retval[0] = td->td_ucred->cr_rgid;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
|
linux_getuid(struct thread *td, struct linux_getuid_args *args)
|
2001-09-08 19:07:04 +00:00
|
|
|
|
{
|
2001-09-12 08:38:13 +00:00
|
|
|
|
|
2002-04-11 21:00:05 +00:00
|
|
|
|
td->td_retval[0] = td->td_ucred->cr_ruid;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
return (0);
|
|
|
|
|
}
|
2001-09-15 09:57:30 +00:00
|
|
|
|
|
2002-01-23 22:46:14 +00:00
|
|
|
|
|
2001-09-15 09:57:30 +00:00
|
|
|
|
int
|
|
|
|
|
linux_getsid(struct thread *td, struct linux_getsid_args *args)
|
|
|
|
|
{
|
|
|
|
|
struct getsid_args bsd;
|
|
|
|
|
bsd.pid = args->pid;
|
|
|
|
|
return getsid(td, &bsd);
|
|
|
|
|
}
|
2005-03-07 00:18:06 +00:00
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
linux_nosys(struct thread *td, struct nosys_args *ignore)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return (ENOSYS);
|
|
|
|
|
}
|
2005-06-08 20:41:28 +00:00
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
linux_getpriority(struct thread *td, struct linux_getpriority_args *args)
|
|
|
|
|
{
|
|
|
|
|
struct getpriority_args bsd_args;
|
|
|
|
|
int error;
|
|
|
|
|
|
|
|
|
|
bsd_args.which = args->which;
|
|
|
|
|
bsd_args.who = args->who;
|
|
|
|
|
error = getpriority(td, &bsd_args);
|
|
|
|
|
td->td_retval[0] = 20 - td->td_retval[0];
|
|
|
|
|
return error;
|
|
|
|
|
}
|
2006-03-18 18:20:17 +00:00
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
linux_sethostname(struct thread *td, struct linux_sethostname_args *args)
|
|
|
|
|
{
|
|
|
|
|
int name[2];
|
|
|
|
|
int error;
|
|
|
|
|
|
|
|
|
|
name[0] = CTL_KERN;
|
|
|
|
|
name[1] = KERN_HOSTNAME;
|
2006-03-27 19:16:31 +00:00
|
|
|
|
if ((error = suser_cred(td->td_ucred, SUSER_ALLOWJAIL)))
|
2006-03-18 18:20:17 +00:00
|
|
|
|
return (error);
|
|
|
|
|
return (userland_sysctl(td, name, 2, 0, 0, 0, args->hostname,
|
|
|
|
|
args->len, 0, 0));
|
|
|
|
|
}
|
|
|
|
|
|
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
2006-08-15 12:54:30 +00:00
|
|
|
|
int
|
|
|
|
|
linux_exit_group(struct thread *td, struct linux_exit_group_args *args)
|
|
|
|
|
{
|
2006-08-17 21:21:30 +00:00
|
|
|
|
#ifdef __i386__
|
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
2006-08-15 12:54:30 +00:00
|
|
|
|
struct linux_emuldata *em, *td_em, *tmp_em;
|
|
|
|
|
struct proc *sp;
|
2006-08-17 21:21:30 +00:00
|
|
|
|
char osrel[LINUX_MAX_UTSNAME];
|
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
2006-08-15 12:54:30 +00:00
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
if (ldebug(exit_group))
|
|
|
|
|
printf(ARGS(exit_group, "%i"), args->error_code);
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-08-17 21:21:30 +00:00
|
|
|
|
linux_get_osrelease(td, osrel);
|
|
|
|
|
if (strlen(osrel) >= 3 && osrel[2] == '6') {
|
|
|
|
|
td_em = em_find(td->td_proc, EMUL_UNLOCKED);
|
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
2006-08-15 12:54:30 +00:00
|
|
|
|
|
2006-08-17 21:21:30 +00:00
|
|
|
|
KASSERT(td_em != NULL, ("exit_group: emuldata not found.\n"));
|
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
2006-08-15 12:54:30 +00:00
|
|
|
|
|
2006-08-17 21:21:30 +00:00
|
|
|
|
EMUL_SHARED_RLOCK(&emul_shared_lock);
|
|
|
|
|
LIST_FOREACH_SAFE(em, &td_em->shared->threads, threads, tmp_em) {
|
|
|
|
|
if (em->pid == td_em->pid)
|
|
|
|
|
continue;
|
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
2006-08-15 12:54:30 +00:00
|
|
|
|
|
2006-08-17 21:21:30 +00:00
|
|
|
|
sp = pfind(em->pid);
|
|
|
|
|
psignal(sp, SIGKILL);
|
|
|
|
|
PROC_UNLOCK(sp);
|
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
2006-08-15 12:54:30 +00:00
|
|
|
|
#ifdef DEBUG
|
2006-08-17 21:21:30 +00:00
|
|
|
|
printf(LMSG("linux_sys_exit_group: kill PID %d\n"), em->pid);
|
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
2006-08-15 12:54:30 +00:00
|
|
|
|
#endif
|
2006-08-17 21:21:30 +00:00
|
|
|
|
}
|
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
2006-08-15 12:54:30 +00:00
|
|
|
|
|
2006-08-17 21:21:30 +00:00
|
|
|
|
EMUL_SHARED_RUNLOCK(&emul_shared_lock);
|
|
|
|
|
EMUL_UNLOCK(&emul_lock);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
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
2006-08-15 12:54:30 +00:00
|
|
|
|
|
|
|
|
|
exit1(td, W_EXITCODE(args->error_code,0));
|
|
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|