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
|
|
|
|
|
* derived from this software withough specific prior written permission
|
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
1999-08-28 01:08:13 +00:00
|
|
|
|
* $FreeBSD$
|
1995-06-25 17:32:43 +00:00
|
|
|
|
*/
|
|
|
|
|
|
1999-08-15 13:28:35 +00:00
|
|
|
|
#include "opt_compat.h"
|
|
|
|
|
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#include <sys/param.h>
|
|
|
|
|
#include <sys/systm.h>
|
1995-11-22 07:43:53 +00:00
|
|
|
|
#include <sys/sysproto.h>
|
|
|
|
|
#include <sys/kernel.h>
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#include <sys/mman.h>
|
|
|
|
|
#include <sys/proc.h>
|
1997-03-23 03:37:54 +00:00
|
|
|
|
#include <sys/fcntl.h>
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#include <sys/imgact_aout.h>
|
|
|
|
|
#include <sys/mount.h>
|
|
|
|
|
#include <sys/namei.h>
|
|
|
|
|
#include <sys/resourcevar.h>
|
|
|
|
|
#include <sys/stat.h>
|
1995-11-22 07:43:53 +00:00
|
|
|
|
#include <sys/sysctl.h>
|
1998-12-19 02:55:34 +00:00
|
|
|
|
#include <sys/unistd.h>
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
|
#include <sys/wait.h>
|
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
|
|
|
|
#include <sys/time.h>
|
1999-09-29 15:12:18 +00:00
|
|
|
|
#include <sys/signalvar.h>
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
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>
|
1995-11-22 07:43:53 +00:00
|
|
|
|
|
1997-10-30 10:53:30 +00:00
|
|
|
|
#include <machine/frame.h>
|
2000-08-26 05:08:10 +00:00
|
|
|
|
#include <machine/limits.h>
|
1997-10-29 08:17:14 +00:00
|
|
|
|
#include <machine/psl.h>
|
1999-09-02 21:50:42 +00:00
|
|
|
|
#include <machine/sysarch.h>
|
2000-11-01 19:48:35 +00:00
|
|
|
|
#ifdef __i386__
|
1999-09-02 21:50:42 +00:00
|
|
|
|
#include <machine/segments.h>
|
2000-11-01 19:48:35 +00:00
|
|
|
|
#endif
|
1997-10-29 08:17:14 +00:00
|
|
|
|
|
1999-08-15 17:28:40 +00:00
|
|
|
|
#include <posix4/sched.h>
|
|
|
|
|
|
2000-08-22 01:46:50 +00:00
|
|
|
|
#include <machine/../linux/linux.h>
|
2000-11-01 19:48:35 +00:00
|
|
|
|
#include <linux_proto.h>
|
2000-08-22 01:46:50 +00:00
|
|
|
|
#include <compat/linux/linux_mib.h>
|
|
|
|
|
#include <compat/linux/linux_util.h>
|
|
|
|
|
|
2000-11-01 19:48:35 +00:00
|
|
|
|
#ifdef __alpha__
|
|
|
|
|
#define BSD_TO_LINUX_SIGNAL(sig) (sig)
|
|
|
|
|
#else
|
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)
|
2000-11-01 19:48:35 +00:00
|
|
|
|
#endif
|
1999-09-29 15:12:18 +00:00
|
|
|
|
|
2000-08-26 02:18:41 +00:00
|
|
|
|
struct linux_rlimit {
|
|
|
|
|
unsigned long rlim_cur;
|
|
|
|
|
unsigned long rlim_max;
|
|
|
|
|
};
|
|
|
|
|
|
2000-11-01 19:48:35 +00:00
|
|
|
|
#ifndef __alpha__
|
1999-08-11 13:34:31 +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
|
|
|
|
|
};
|
2000-11-01 19:48:35 +00:00
|
|
|
|
#endif /*!__alpha__*/
|
1999-08-11 13:34:31 +00:00
|
|
|
|
|
2000-11-01 19:48:35 +00:00
|
|
|
|
#ifndef __alpha__
|
1995-06-25 17:32:43 +00:00
|
|
|
|
int
|
1997-11-06 19:29:57 +00:00
|
|
|
|
linux_alarm(struct proc *p, struct linux_alarm_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
{
|
|
|
|
|
struct itimerval it, old_it;
|
1995-12-15 03:06:57 +00:00
|
|
|
|
struct timeval tv;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
int s;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
1998-08-05 16:44:30 +00:00
|
|
|
|
printf("Linux-emul(%ld): alarm(%u)\n", (long)p->p_pid, args->secs);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#endif
|
1998-08-05 16:44:30 +00:00
|
|
|
|
if (args->secs > 100000000)
|
|
|
|
|
return EINVAL;
|
1995-06-25 17:32:43 +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;
|
1998-08-05 16:44:30 +00:00
|
|
|
|
s = splsoftclock();
|
1995-06-25 17:32:43 +00:00
|
|
|
|
old_it = p->p_realtimer;
|
1998-08-05 16:44:30 +00:00
|
|
|
|
getmicrouptime(&tv);
|
1998-04-06 08:26:08 +00:00
|
|
|
|
if (timevalisset(&old_it.it_value))
|
1998-08-05 16:44:30 +00:00
|
|
|
|
untimeout(realitexpire, (caddr_t)p, p->p_ithandle);
|
|
|
|
|
if (it.it_value.tv_sec != 0) {
|
|
|
|
|
p->p_ithandle = timeout(realitexpire, (caddr_t)p, tvtohz(&it.it_value));
|
1995-12-15 03:06:57 +00:00
|
|
|
|
timevaladd(&it.it_value, &tv);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
}
|
|
|
|
|
p->p_realtimer = it;
|
|
|
|
|
splx(s);
|
1998-08-05 16:44:30 +00:00
|
|
|
|
if (timevalcmp(&old_it.it_value, &tv, >)) {
|
|
|
|
|
timevalsub(&old_it.it_value, &tv);
|
|
|
|
|
if (old_it.it_value.tv_usec != 0)
|
|
|
|
|
old_it.it_value.tv_sec++;
|
|
|
|
|
p->p_retval[0] = old_it.it_value.tv_sec;
|
|
|
|
|
}
|
1995-06-25 17:32:43 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
2000-11-01 19:48:35 +00:00
|
|
|
|
#endif /*!__alpha__*/
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
|
|
|
|
int
|
1997-11-06 19:29:57 +00:00
|
|
|
|
linux_brk(struct proc *p, struct linux_brk_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
{
|
|
|
|
|
#if 0
|
|
|
|
|
struct vmspace *vm = p->p_vmspace;
|
|
|
|
|
vm_offset_t new, old;
|
|
|
|
|
int error;
|
|
|
|
|
|
|
|
|
|
if ((vm_offset_t)args->dsend < (vm_offset_t)vm->vm_daddr)
|
|
|
|
|
return EINVAL;
|
|
|
|
|
if (((caddr_t)args->dsend - (caddr_t)vm->vm_daddr)
|
|
|
|
|
> p->p_rlimit[RLIMIT_DATA].rlim_cur)
|
|
|
|
|
return ENOMEM;
|
|
|
|
|
|
|
|
|
|
old = round_page((vm_offset_t)vm->vm_daddr) + ctob(vm->vm_dsize);
|
|
|
|
|
new = round_page((vm_offset_t)args->dsend);
|
1997-11-06 19:29:57 +00:00
|
|
|
|
p->p_retval[0] = old;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
if ((new-old) > 0) {
|
|
|
|
|
if (swap_pager_full)
|
|
|
|
|
return ENOMEM;
|
1996-01-19 22:59:24 +00:00
|
|
|
|
error = vm_map_find(&vm->vm_map, NULL, 0, &old, (new-old), FALSE,
|
|
|
|
|
VM_PROT_ALL, VM_PROT_ALL, 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
|
|
|
|
if (error)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
return error;
|
|
|
|
|
vm->vm_dsize += btoc((new-old));
|
1997-11-06 19:29:57 +00:00
|
|
|
|
p->p_retval[0] = (int)(vm->vm_daddr + ctob(vm->vm_dsize));
|
1995-06-25 17:32:43 +00:00
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
#else
|
|
|
|
|
struct vmspace *vm = p->p_vmspace;
|
|
|
|
|
vm_offset_t new, old;
|
1995-12-15 03:06:57 +00:00
|
|
|
|
struct obreak_args /* {
|
|
|
|
|
char * nsize;
|
|
|
|
|
} */ tmp;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
1998-07-29 16:43:00 +00:00
|
|
|
|
printf("Linux-emul(%ld): brk(%p)\n", (long)p->p_pid, (void *)args->dsend);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#endif
|
|
|
|
|
old = (vm_offset_t)vm->vm_daddr + ctob(vm->vm_dsize);
|
|
|
|
|
new = (vm_offset_t)args->dsend;
|
1995-12-15 03:06:57 +00:00
|
|
|
|
tmp.nsize = (char *) new;
|
1997-11-06 19:29:57 +00:00
|
|
|
|
if (((caddr_t)new > vm->vm_daddr) && !obreak(p, &tmp))
|
2000-11-01 19:48:35 +00:00
|
|
|
|
p->p_retval[0] = (long)new;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
else
|
2000-11-01 19:48:35 +00:00
|
|
|
|
p->p_retval[0] = (long)old;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
1997-11-06 19:29:57 +00:00
|
|
|
|
linux_uselib(struct proc *p, struct linux_uselib_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
{
|
|
|
|
|
struct nameidata ni;
|
1995-11-06 12:52:37 +00:00
|
|
|
|
struct vnode *vp;
|
1996-02-16 18:40:50 +00:00
|
|
|
|
struct exec *a_out;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
struct vattr attr;
|
1996-03-19 15:03:00 +00:00
|
|
|
|
vm_offset_t vmaddr;
|
|
|
|
|
unsigned long file_offset;
|
|
|
|
|
vm_offset_t buffer;
|
|
|
|
|
unsigned long bss_size;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
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
|
|
|
|
caddr_t sg;
|
1996-02-16 18:40:50 +00:00
|
|
|
|
int locked;
|
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
|
|
|
|
sg = stackgap_init();
|
|
|
|
|
CHECKALTEXIST(p, &sg, args->library);
|
|
|
|
|
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#ifdef DEBUG
|
1999-08-17 10:09:06 +00:00
|
|
|
|
printf("Linux-emul(%ld): uselib(%s)\n", (long)p->p_pid, args->library);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
1996-02-16 18:40:50 +00:00
|
|
|
|
a_out = NULL;
|
|
|
|
|
locked = 0;
|
|
|
|
|
vp = NULL;
|
|
|
|
|
|
1999-08-08 11:26:46 +00:00
|
|
|
|
NDINIT(&ni, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, args->library, p);
|
1999-05-06 18:44:42 +00:00
|
|
|
|
error = namei(&ni);
|
|
|
|
|
if (error)
|
1996-02-16 18:40:50 +00:00
|
|
|
|
goto cleanup;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
1995-11-06 12:52:37 +00:00
|
|
|
|
vp = ni.ni_vp;
|
1999-12-15 23:02:35 +00:00
|
|
|
|
/*
|
|
|
|
|
* XXX This looks like a bogus check - a LOCKLEAF namei should not succeed
|
|
|
|
|
* without returning a vnode.
|
|
|
|
|
*/
|
1996-02-16 18:40:50 +00:00
|
|
|
|
if (vp == NULL) {
|
|
|
|
|
error = ENOEXEC; /* ?? */
|
|
|
|
|
goto cleanup;
|
1995-10-04 07:08:04 +00:00
|
|
|
|
}
|
1999-12-15 23:02:35 +00:00
|
|
|
|
NDFREE(&ni, NDF_ONLY_PNBUF);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
1996-02-16 18:40:50 +00:00
|
|
|
|
/*
|
|
|
|
|
* From here on down, we have a locked vnode that must be unlocked.
|
|
|
|
|
*/
|
|
|
|
|
locked++;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Writable?
|
|
|
|
|
*/
|
|
|
|
|
if (vp->v_writecount) {
|
|
|
|
|
error = ETXTBSY;
|
|
|
|
|
goto cleanup;
|
1995-10-04 07:08:04 +00:00
|
|
|
|
}
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
1996-02-16 18:40:50 +00:00
|
|
|
|
/*
|
|
|
|
|
* Executable?
|
|
|
|
|
*/
|
1999-05-06 18:44:42 +00:00
|
|
|
|
error = VOP_GETATTR(vp, &attr, p->p_ucred, p);
|
|
|
|
|
if (error)
|
1996-02-16 18:40:50 +00:00
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
|
|
if ((vp->v_mount->mnt_flag & MNT_NOEXEC) ||
|
|
|
|
|
((attr.va_mode & 0111) == 0) ||
|
|
|
|
|
(attr.va_type != VREG)) {
|
|
|
|
|
error = ENOEXEC;
|
|
|
|
|
goto cleanup;
|
1995-10-04 07:08:04 +00:00
|
|
|
|
}
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
1996-02-16 18:40:50 +00:00
|
|
|
|
/*
|
|
|
|
|
* Sensible size?
|
|
|
|
|
*/
|
1995-10-04 07:08:04 +00:00
|
|
|
|
if (attr.va_size == 0) {
|
1996-02-16 18:40:50 +00:00
|
|
|
|
error = ENOEXEC;
|
|
|
|
|
goto cleanup;
|
1995-10-04 07:08:04 +00:00
|
|
|
|
}
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
1996-02-16 18:40:50 +00:00
|
|
|
|
/*
|
|
|
|
|
* Can we access it?
|
|
|
|
|
*/
|
1999-05-06 18:44:42 +00:00
|
|
|
|
error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p);
|
|
|
|
|
if (error)
|
1996-02-16 18:40:50 +00:00
|
|
|
|
goto cleanup;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
1999-05-06 18:44:42 +00:00
|
|
|
|
error = VOP_OPEN(vp, FREAD, p->p_ucred, p);
|
|
|
|
|
if (error)
|
1996-02-16 18:40:50 +00:00
|
|
|
|
goto cleanup;
|
1995-10-04 07:08:04 +00:00
|
|
|
|
|
1996-02-16 18:40:50 +00:00
|
|
|
|
/*
|
|
|
|
|
* Lock no longer needed
|
|
|
|
|
*/
|
1997-02-10 16:34:16 +00:00
|
|
|
|
VOP_UNLOCK(vp, 0, p);
|
1996-02-16 18:40:50 +00:00
|
|
|
|
locked = 0;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
1996-02-16 18:40:50 +00:00
|
|
|
|
/*
|
|
|
|
|
* Pull in executable header into kernel_map
|
|
|
|
|
*/
|
|
|
|
|
error = vm_mmap(kernel_map, (vm_offset_t *)&a_out, PAGE_SIZE,
|
1995-11-06 12:52:37 +00:00
|
|
|
|
VM_PROT_READ, VM_PROT_READ, 0, (caddr_t)vp, 0);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
if (error)
|
1996-02-16 18:40:50 +00:00
|
|
|
|
goto cleanup;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Is it a Linux binary ?
|
|
|
|
|
*/
|
1996-02-16 18:40:50 +00:00
|
|
|
|
if (((a_out->a_magic >> 16) & 0xff) != 0x64) {
|
|
|
|
|
error = ENOEXEC;
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* While we are here, we should REALLY do some more checks */
|
1995-06-25 17:32:43 +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:
|
1996-02-16 18:40:50 +00:00
|
|
|
|
error = ENOEXEC;
|
|
|
|
|
goto cleanup;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bss_size = round_page(a_out->a_bss);
|
1996-02-16 18:40:50 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Check various fields in header for validity/bounds.
|
|
|
|
|
*/
|
1996-05-02 10:43:17 +00:00
|
|
|
|
if (a_out->a_text & PAGE_MASK || a_out->a_data & PAGE_MASK) {
|
1996-02-16 18:40:50 +00:00
|
|
|
|
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.
|
|
|
|
|
*/
|
1998-02-25 05:33:06 +00:00
|
|
|
|
if (a_out->a_text > MAXTSIZ ||
|
|
|
|
|
a_out->a_data + bss_size > p->p_rlimit[RLIMIT_DATA].rlim_cur) {
|
1996-02-16 18:40:50 +00:00
|
|
|
|
error = ENOMEM;
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* prevent more writers
|
|
|
|
|
*/
|
|
|
|
|
vp->v_flag |= VTEXT;
|
|
|
|
|
|
1995-06-25 17:32:43 +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-05-02 10:43:17 +00:00
|
|
|
|
if (file_offset & PAGE_MASK) {
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#ifdef DEBUG
|
1998-07-29 16:43:00 +00:00
|
|
|
|
printf("uselib: Non page aligned binary %lu\n", file_offset);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#endif
|
|
|
|
|
/*
|
|
|
|
|
* Map text+data read/write/execute
|
|
|
|
|
*/
|
1996-02-16 18:40:50 +00:00
|
|
|
|
|
|
|
|
|
/* a_entry is the load address and is page aligned */
|
|
|
|
|
vmaddr = trunc_page(a_out->a_entry);
|
|
|
|
|
|
|
|
|
|
/* get anon user mapping, read+write+execute */
|
1995-06-25 17:32:43 +00:00
|
|
|
|
error = vm_map_find(&p->p_vmspace->vm_map, NULL, 0, &vmaddr,
|
1996-02-16 18:40:50 +00:00
|
|
|
|
a_out->a_text + a_out->a_data, FALSE,
|
|
|
|
|
VM_PROT_ALL, VM_PROT_ALL, 0);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
if (error)
|
1996-02-16 18:40:50 +00:00
|
|
|
|
goto cleanup;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
1996-02-16 18:40:50 +00:00
|
|
|
|
/* map file into kernel_map */
|
1995-06-25 17:32:43 +00:00
|
|
|
|
error = vm_mmap(kernel_map, &buffer,
|
|
|
|
|
round_page(a_out->a_text + a_out->a_data + file_offset),
|
1996-03-12 06:20:19 +00:00
|
|
|
|
VM_PROT_READ, VM_PROT_READ, 0,
|
1995-11-06 12:52:37 +00:00
|
|
|
|
(caddr_t)vp, trunc_page(file_offset));
|
1995-06-25 17:32:43 +00:00
|
|
|
|
if (error)
|
1996-02-16 18:40:50 +00:00
|
|
|
|
goto cleanup;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
1996-02-16 18:40:50 +00:00
|
|
|
|
/* copy from kernel VM space to user space */
|
1998-08-16 01:21:52 +00:00
|
|
|
|
error = copyout((caddr_t)(void *)(uintptr_t)(buffer + file_offset),
|
|
|
|
|
(caddr_t)vmaddr, a_out->a_text + a_out->a_data);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
1996-02-16 18:40:50 +00:00
|
|
|
|
/* release temporary kernel space */
|
|
|
|
|
vm_map_remove(kernel_map, buffer,
|
1996-03-10 23:25:17 +00:00
|
|
|
|
buffer + round_page(a_out->a_text + a_out->a_data + file_offset));
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
|
|
|
|
if (error)
|
1996-02-16 18:40:50 +00:00
|
|
|
|
goto cleanup;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
#ifdef DEBUG
|
1998-07-29 16:43:00 +00:00
|
|
|
|
printf("uselib: Page aligned binary %lu\n", file_offset);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#endif
|
1996-02-16 18:40:50 +00:00
|
|
|
|
/*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
1995-06-25 17:32:43 +00:00
|
|
|
|
error = vm_mmap(&p->p_vmspace->vm_map, &vmaddr,
|
1996-02-16 18:40:50 +00:00
|
|
|
|
a_out->a_text + a_out->a_data,
|
1995-06-25 17:32:43 +00:00
|
|
|
|
VM_PROT_ALL, VM_PROT_ALL, MAP_PRIVATE | MAP_FIXED,
|
1995-11-06 12:52:37 +00:00
|
|
|
|
(caddr_t)vp, file_offset);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
if (error)
|
1996-02-16 18:40:50 +00:00
|
|
|
|
goto cleanup;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
}
|
|
|
|
|
#ifdef DEBUG
|
2000-11-01 19:48:35 +00:00
|
|
|
|
printf("mem=%08lx = %08lx %08lx\n", vmaddr, ((long*)vmaddr)[0], ((long*)vmaddr)[1]);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#endif
|
|
|
|
|
if (bss_size != 0) {
|
1996-02-16 18:40:50 +00:00
|
|
|
|
/*
|
|
|
|
|
* Calculate BSS start address
|
|
|
|
|
*/
|
|
|
|
|
vmaddr = trunc_page(a_out->a_entry) + a_out->a_text + a_out->a_data;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* allocate some 'anon' space
|
|
|
|
|
*/
|
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
|
|
|
|
error = vm_map_find(&p->p_vmspace->vm_map, NULL, 0, &vmaddr,
|
1996-01-19 22:59:24 +00:00
|
|
|
|
bss_size, FALSE,
|
1996-02-16 18:40:50 +00:00
|
|
|
|
VM_PROT_ALL, VM_PROT_ALL, 0);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
if (error)
|
1996-02-16 18:40:50 +00:00
|
|
|
|
goto cleanup;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
}
|
1996-02-16 18:40:50 +00:00
|
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
|
/*
|
|
|
|
|
* Unlock vnode if needed
|
|
|
|
|
*/
|
|
|
|
|
if (locked)
|
1997-02-10 16:34:16 +00:00
|
|
|
|
VOP_UNLOCK(vp, 0, p);
|
1996-02-16 18:40:50 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Release the kernel mapping.
|
|
|
|
|
*/
|
|
|
|
|
if (a_out)
|
1996-03-10 23:25:17 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
|
|
return error;
|
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
|
1997-11-06 19:29:57 +00:00
|
|
|
|
linux_newselect(struct proc *p, struct linux_newselect_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 select_args bsa;
|
|
|
|
|
struct timeval tv0, tv1, utv, *tvp;
|
|
|
|
|
caddr_t sg;
|
|
|
|
|
int error;
|
|
|
|
|
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#ifdef DEBUG
|
1998-07-29 16:43:00 +00:00
|
|
|
|
printf("Linux-emul(%ld): newselect(%d, %p, %p, %p, %p)\n",
|
|
|
|
|
(long)p->p_pid, args->nfds, (void *)args->readfds,
|
|
|
|
|
(void *)args->writefds, (void *)args->exceptfds,
|
|
|
|
|
(void *)args->timeout);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#endif
|
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
|
|
|
|
error = 0;
|
|
|
|
|
bsa.nd = args->nfds;
|
|
|
|
|
bsa.in = args->readfds;
|
|
|
|
|
bsa.ou = args->writefds;
|
|
|
|
|
bsa.ex = args->exceptfds;
|
|
|
|
|
bsa.tv = args->timeout;
|
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
|
|
|
|
/*
|
|
|
|
|
* Store current time for computation of the amount of
|
|
|
|
|
* time left.
|
|
|
|
|
*/
|
|
|
|
|
if (args->timeout) {
|
|
|
|
|
if ((error = copyin(args->timeout, &utv, sizeof(utv))))
|
|
|
|
|
goto select_out;
|
|
|
|
|
#ifdef DEBUG
|
1998-07-29 16:43:00 +00:00
|
|
|
|
printf("Linux-emul(%ld): incoming timeout (%ld/%ld)\n",
|
|
|
|
|
(long)p->p_pid, 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
|
|
|
|
|
if (itimerfix(&utv)) {
|
|
|
|
|
/*
|
|
|
|
|
* The timeval was invalid. Convert it to something
|
|
|
|
|
* valid that will act as it does under Linux.
|
|
|
|
|
*/
|
|
|
|
|
sg = stackgap_init();
|
|
|
|
|
tvp = stackgap_alloc(&sg, sizeof(utv));
|
|
|
|
|
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)
|
1998-04-06 08:26:08 +00:00
|
|
|
|
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
|
|
|
|
if ((error = copyout(&utv, tvp, sizeof(utv))))
|
|
|
|
|
goto select_out;
|
|
|
|
|
bsa.tv = tvp;
|
|
|
|
|
}
|
|
|
|
|
microtime(&tv0);
|
|
|
|
|
}
|
|
|
|
|
|
1997-11-06 19:29:57 +00:00
|
|
|
|
error = select(p, &bsa);
|
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
|
1999-08-17 10:09:06 +00:00
|
|
|
|
printf("Linux-emul(%ld): real select returns %d\n", (long)p->p_pid, 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
|
|
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
|
/*
|
|
|
|
|
* See fs/select.c in the Linux kernel. Without this,
|
|
|
|
|
* Maelstrom doesn't work.
|
|
|
|
|
*/
|
|
|
|
|
if (error == ERESTART)
|
|
|
|
|
error = EINTR;
|
|
|
|
|
goto select_out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (args->timeout) {
|
1997-11-06 19:29:57 +00:00
|
|
|
|
if (p->p_retval[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
|
|
|
|
/*
|
|
|
|
|
* 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)
|
1998-04-06 08:26:08 +00:00
|
|
|
|
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
|
|
|
|
} else
|
1998-04-06 08:26:08 +00:00
|
|
|
|
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
|
1998-07-29 16:43:00 +00:00
|
|
|
|
printf("Linux-emul(%ld): outgoing timeout (%ld/%ld)\n",
|
|
|
|
|
(long)p->p_pid, 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
|
|
|
|
|
if ((error = copyout(&utv, args->timeout, sizeof(utv))))
|
|
|
|
|
goto select_out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
select_out:
|
|
|
|
|
#ifdef DEBUG
|
1999-08-17 10:09:06 +00:00
|
|
|
|
printf("Linux-emul(%ld): newselect_out -> %d\n", (long)p->p_pid, 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
|
|
|
|
|
return error;
|
|
|
|
|
}
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
|
|
|
|
int
|
1997-11-06 19:29:57 +00:00
|
|
|
|
linux_getpgid(struct proc *p, struct linux_getpgid_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
{
|
1999-04-28 01:04:33 +00:00
|
|
|
|
struct proc *curp;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
1999-08-17 10:09:06 +00:00
|
|
|
|
printf("Linux-emul(%ld): getpgid(%d)\n", (long)p->p_pid, args->pid);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#endif
|
|
|
|
|
if (args->pid != p->p_pid) {
|
1999-04-28 01:04:33 +00:00
|
|
|
|
if (!(curp = pfind(args->pid)))
|
1995-06-25 17:32:43 +00:00
|
|
|
|
return ESRCH;
|
|
|
|
|
}
|
|
|
|
|
else
|
1999-04-28 01:04:33 +00:00
|
|
|
|
curp = p;
|
|
|
|
|
p->p_retval[0] = curp->p_pgid;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
1998-07-10 22:30:08 +00:00
|
|
|
|
int
|
|
|
|
|
linux_mremap(struct proc *p, struct linux_mremap_args *args)
|
|
|
|
|
{
|
|
|
|
|
struct munmap_args /* {
|
|
|
|
|
void *addr;
|
|
|
|
|
size_t len;
|
|
|
|
|
} */ bsd_args;
|
|
|
|
|
int error = 0;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2000-11-01 19:48:35 +00:00
|
|
|
|
printf("Linux-emul(%ld): mremap(%p, %08lx, %08lx, %08lx)\n",
|
|
|
|
|
(long)p->p_pid, (void *)args->addr,
|
|
|
|
|
(unsigned long)args->old_len,
|
|
|
|
|
(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) {
|
|
|
|
|
p->p_retval[0] = 0;
|
|
|
|
|
return ENOMEM;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (args->new_len < args->old_len) {
|
|
|
|
|
bsd_args.addr = args->addr + args->new_len;
|
|
|
|
|
bsd_args.len = args->old_len - args->new_len;
|
|
|
|
|
error = munmap(p, &bsd_args);
|
|
|
|
|
}
|
|
|
|
|
|
2000-11-01 19:48:35 +00:00
|
|
|
|
p->p_retval[0] = error ? 0 : (u_long)args->addr;
|
1998-07-10 22:30:08 +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
|
|
|
|
int
|
1997-11-06 19:29:57 +00:00
|
|
|
|
linux_msync(struct proc *p, 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;
|
|
|
|
|
|
|
|
|
|
bsd_args.addr = args->addr;
|
|
|
|
|
bsd_args.len = args->len;
|
|
|
|
|
bsd_args.flags = 0; /* XXX ignore */
|
|
|
|
|
|
1997-11-06 19:29:57 +00:00
|
|
|
|
return msync(p, &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
|
|
|
|
|
2000-11-01 19:48:35 +00:00
|
|
|
|
#ifndef __alpha__
|
1995-06-25 17:32:43 +00:00
|
|
|
|
int
|
1997-11-06 19:29:57 +00:00
|
|
|
|
linux_time(struct proc *p, struct linux_time_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
{
|
|
|
|
|
struct timeval tv;
|
|
|
|
|
linux_time_t tm;
|
|
|
|
|
int error;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
1999-08-17 10:09:06 +00:00
|
|
|
|
printf("Linux-emul(%ld): time(*)\n", (long)p->p_pid);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#endif
|
|
|
|
|
microtime(&tv);
|
|
|
|
|
tm = tv.tv_sec;
|
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
|
|
|
|
if (args->tm && (error = copyout(&tm, args->tm, sizeof(linux_time_t))))
|
1995-06-25 17:32:43 +00:00
|
|
|
|
return error;
|
1997-11-06 19:29:57 +00:00
|
|
|
|
p->p_retval[0] = tm;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
2000-11-01 19:48:35 +00:00
|
|
|
|
#endif /*!__alpha__*/
|
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
|
|
|
|
struct linux_times_argv {
|
1995-06-25 17:32:43 +00:00
|
|
|
|
long tms_utime;
|
|
|
|
|
long tms_stime;
|
|
|
|
|
long tms_cutime;
|
|
|
|
|
long tms_cstime;
|
|
|
|
|
};
|
|
|
|
|
|
1996-03-04 21:03:11 +00:00
|
|
|
|
#define CLK_TCK 100 /* Linux uses 100 */
|
|
|
|
|
#define CONVTCK(r) (r.tv_sec * CLK_TCK + r.tv_usec / (1000000 / CLK_TCK))
|
|
|
|
|
|
1995-06-25 17:32:43 +00:00
|
|
|
|
int
|
1997-11-06 19:29:57 +00:00
|
|
|
|
linux_times(struct proc *p, struct linux_times_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
{
|
|
|
|
|
struct timeval tv;
|
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 linux_times_argv tms;
|
1996-03-04 21:03:11 +00:00
|
|
|
|
struct rusage ru;
|
1996-06-12 05:11:41 +00:00
|
|
|
|
int error;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
1999-08-17 10:09:06 +00:00
|
|
|
|
printf("Linux-emul(%ld): times(*)\n", (long)p->p_pid);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#endif
|
1996-03-04 21:03:11 +00:00
|
|
|
|
calcru(p, &ru.ru_utime, &ru.ru_stime, NULL);
|
|
|
|
|
|
|
|
|
|
tms.tms_utime = CONVTCK(ru.ru_utime);
|
|
|
|
|
tms.tms_stime = CONVTCK(ru.ru_stime);
|
|
|
|
|
|
|
|
|
|
tms.tms_cutime = CONVTCK(p->p_stats->p_cru.ru_utime);
|
|
|
|
|
tms.tms_cstime = CONVTCK(p->p_stats->p_cru.ru_stime);
|
|
|
|
|
|
|
|
|
|
if ((error = copyout((caddr_t)&tms, (caddr_t)args->buf,
|
|
|
|
|
sizeof(struct linux_times_argv))))
|
|
|
|
|
return error;
|
|
|
|
|
|
1998-05-17 11:53:46 +00:00
|
|
|
|
microuptime(&tv);
|
1997-11-06 19:29:57 +00:00
|
|
|
|
p->p_retval[0] = (int)CONVTCK(tv);
|
1996-03-04 21:03:11 +00:00
|
|
|
|
return 0;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
1997-11-06 19:29:57 +00:00
|
|
|
|
linux_newuname(struct proc *p, struct linux_newuname_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
{
|
1999-08-25 11:19:03 +00:00
|
|
|
|
struct linux_new_utsname utsname;
|
1999-08-27 19:47:41 +00:00
|
|
|
|
char *osrelease, *osname;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
1999-08-25 11:19:03 +00:00
|
|
|
|
printf("Linux-emul(%ld): newuname(*)\n", (long)p->p_pid);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#endif
|
1999-08-25 11:19:03 +00:00
|
|
|
|
|
1999-08-27 19:47:41 +00:00
|
|
|
|
osname = linux_get_osname(p);
|
|
|
|
|
osrelease = linux_get_osrelease(p);
|
|
|
|
|
|
1999-08-25 11:19:03 +00:00
|
|
|
|
bzero(&utsname, sizeof(struct linux_new_utsname));
|
1999-08-27 19:47:41 +00:00
|
|
|
|
strncpy(utsname.sysname, osname, LINUX_MAX_UTSNAME-1);
|
1999-08-25 11:19:03 +00:00
|
|
|
|
strncpy(utsname.nodename, hostname, LINUX_MAX_UTSNAME-1);
|
1999-08-27 19:47:41 +00:00
|
|
|
|
strncpy(utsname.release, osrelease, LINUX_MAX_UTSNAME-1);
|
1999-08-25 11:19:03 +00:00
|
|
|
|
strncpy(utsname.version, version, LINUX_MAX_UTSNAME-1);
|
|
|
|
|
strncpy(utsname.machine, machine, LINUX_MAX_UTSNAME-1);
|
|
|
|
|
strncpy(utsname.domainname, domainname, LINUX_MAX_UTSNAME-1);
|
|
|
|
|
|
|
|
|
|
return (copyout((caddr_t)&utsname, (caddr_t)args->buf,
|
|
|
|
|
sizeof(struct linux_new_utsname)));
|
1995-06-25 17:32:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-03-04 21:03:11 +00:00
|
|
|
|
struct linux_utimbuf {
|
|
|
|
|
linux_time_t l_actime;
|
|
|
|
|
linux_time_t l_modtime;
|
|
|
|
|
};
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
|
|
|
|
int
|
1997-11-06 19:29:57 +00:00
|
|
|
|
linux_utime(struct proc *p, struct linux_utime_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
{
|
1995-12-15 03:06:57 +00:00
|
|
|
|
struct utimes_args /* {
|
|
|
|
|
char *path;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
struct timeval *tptr;
|
1995-12-15 03:06:57 +00:00
|
|
|
|
} */ bsdutimes;
|
1996-03-04 21:03:11 +00:00
|
|
|
|
struct timeval tv[2], *tvp;
|
|
|
|
|
struct linux_utimbuf lut;
|
|
|
|
|
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
|
|
|
|
caddr_t sg;
|
|
|
|
|
|
|
|
|
|
sg = stackgap_init();
|
|
|
|
|
CHECKALTEXIST(p, &sg, args->fname);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
1999-08-17 10:09:06 +00:00
|
|
|
|
printf("Linux-emul(%ld): utime(%s, *)\n", (long)p->p_pid, args->fname);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#endif
|
1996-03-04 21:03:11 +00:00
|
|
|
|
if (args->times) {
|
|
|
|
|
if ((error = copyin(args->times, &lut, sizeof lut)))
|
|
|
|
|
return error;
|
|
|
|
|
tv[0].tv_sec = lut.l_actime;
|
|
|
|
|
tv[0].tv_usec = 0;
|
|
|
|
|
tv[1].tv_sec = lut.l_modtime;
|
|
|
|
|
tv[1].tv_usec = 0;
|
|
|
|
|
/* so that utimes can copyin */
|
|
|
|
|
tvp = (struct timeval *)stackgap_alloc(&sg, sizeof(tv));
|
2000-07-23 16:54:18 +00:00
|
|
|
|
if (tvp == NULL)
|
|
|
|
|
return (ENAMETOOLONG);
|
1996-03-04 21:03:11 +00:00
|
|
|
|
if ((error = copyout(tv, tvp, sizeof(tv))))
|
|
|
|
|
return error;
|
|
|
|
|
bsdutimes.tptr = tvp;
|
|
|
|
|
} else
|
|
|
|
|
bsdutimes.tptr = NULL;
|
|
|
|
|
|
1995-12-15 03:06:57 +00:00
|
|
|
|
bsdutimes.path = args->fname;
|
1997-11-06 19:29:57 +00:00
|
|
|
|
return utimes(p, &bsdutimes);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-02 00:28:09 +00:00
|
|
|
|
#define __WCLONE 0x80000000
|
|
|
|
|
|
2000-11-01 19:48:35 +00:00
|
|
|
|
#ifndef __alpha__
|
1995-06-25 17:32:43 +00:00
|
|
|
|
int
|
1997-11-06 19:29:57 +00:00
|
|
|
|
linux_waitpid(struct proc *p, struct linux_waitpid_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
{
|
1995-12-15 03:06:57 +00:00
|
|
|
|
struct wait_args /* {
|
1995-06-25 17:32:43 +00:00
|
|
|
|
int pid;
|
|
|
|
|
int *status;
|
|
|
|
|
int options;
|
|
|
|
|
struct rusage *rusage;
|
1995-12-15 03:06:57 +00:00
|
|
|
|
} */ tmp;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
int error, tmpstat;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
1998-07-29 16:43:00 +00:00
|
|
|
|
printf("Linux-emul(%ld): waitpid(%d, %p, %d)\n",
|
|
|
|
|
(long)p->p_pid, args->pid, (void *)args->status, args->options);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#endif
|
|
|
|
|
tmp.pid = args->pid;
|
|
|
|
|
tmp.status = args->status;
|
1998-12-19 02:55:34 +00:00
|
|
|
|
tmp.options = (args->options & (WNOHANG | WUNTRACED));
|
1999-03-02 00:28:09 +00:00
|
|
|
|
/* WLINUXCLONE should be equal to __WCLONE, but we make sure */
|
|
|
|
|
if (args->options & __WCLONE)
|
|
|
|
|
tmp.options |= WLINUXCLONE;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
tmp.rusage = NULL;
|
|
|
|
|
|
1999-03-02 00:28:09 +00:00
|
|
|
|
if ((error = wait4(p, &tmp)) != 0)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
return error;
|
1999-01-26 02:38:12 +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
|
|
|
|
if (args->status) {
|
1999-03-02 00:28:09 +00:00
|
|
|
|
if ((error = copyin(args->status, &tmpstat, sizeof(int))) != 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 error;
|
2000-03-09 17:52:01 +00:00
|
|
|
|
tmpstat &= 0xffff;
|
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
|
|
|
|
if (WIFSIGNALED(tmpstat))
|
|
|
|
|
tmpstat = (tmpstat & 0xffffff80) |
|
1999-09-29 15:12:18 +00:00
|
|
|
|
BSD_TO_LINUX_SIGNAL(WTERMSIG(tmpstat));
|
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
|
|
|
|
else if (WIFSTOPPED(tmpstat))
|
|
|
|
|
tmpstat = (tmpstat & 0xffff00ff) |
|
1999-09-29 15:12:18 +00:00
|
|
|
|
(BSD_TO_LINUX_SIGNAL(WSTOPSIG(tmpstat)) << 8);
|
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 copyout(&tmpstat, args->status, sizeof(int));
|
|
|
|
|
} else
|
|
|
|
|
return 0;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
}
|
2000-11-01 19:48:35 +00:00
|
|
|
|
#endif /*!__alpha__*/
|
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
|
1997-11-06 19:29:57 +00:00
|
|
|
|
linux_wait4(struct proc *p, struct linux_wait4_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
{
|
1995-12-15 03:06:57 +00:00
|
|
|
|
struct wait_args /* {
|
1995-06-25 17:32:43 +00:00
|
|
|
|
int pid;
|
|
|
|
|
int *status;
|
|
|
|
|
int options;
|
|
|
|
|
struct rusage *rusage;
|
1995-12-15 03:06:57 +00:00
|
|
|
|
} */ tmp;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
int error, tmpstat;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
1998-07-29 16:43:00 +00:00
|
|
|
|
printf("Linux-emul(%ld): wait4(%d, %p, %d, %p)\n",
|
|
|
|
|
(long)p->p_pid, args->pid, (void *)args->status, args->options,
|
|
|
|
|
(void *)args->rusage);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#endif
|
|
|
|
|
tmp.pid = args->pid;
|
|
|
|
|
tmp.status = args->status;
|
1998-12-19 02:55:34 +00:00
|
|
|
|
tmp.options = (args->options & (WNOHANG | WUNTRACED));
|
1999-03-02 00:28:09 +00:00
|
|
|
|
/* WLINUXCLONE should be equal to __WCLONE, but we make sure */
|
|
|
|
|
if (args->options & __WCLONE)
|
|
|
|
|
tmp.options |= WLINUXCLONE;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
tmp.rusage = args->rusage;
|
|
|
|
|
|
1999-03-02 00:28:09 +00:00
|
|
|
|
if ((error = wait4(p, &tmp)) != 0)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
return error;
|
1996-01-14 10:59:58 +00:00
|
|
|
|
|
1999-09-29 15:12:18 +00:00
|
|
|
|
SIGDELSET(p->p_siglist, SIGCHLD);
|
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
|
|
|
|
|
|
|
|
|
if (args->status) {
|
1999-03-02 00:28:09 +00:00
|
|
|
|
if ((error = copyin(args->status, &tmpstat, sizeof(int))) != 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 error;
|
2000-03-09 17:52:01 +00:00
|
|
|
|
tmpstat &= 0xffff;
|
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
|
|
|
|
if (WIFSIGNALED(tmpstat))
|
|
|
|
|
tmpstat = (tmpstat & 0xffffff80) |
|
1999-09-29 15:12:18 +00:00
|
|
|
|
BSD_TO_LINUX_SIGNAL(WTERMSIG(tmpstat));
|
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
|
|
|
|
else if (WIFSTOPPED(tmpstat))
|
|
|
|
|
tmpstat = (tmpstat & 0xffff00ff) |
|
1999-09-29 15:12:18 +00:00
|
|
|
|
(BSD_TO_LINUX_SIGNAL(WSTOPSIG(tmpstat)) << 8);
|
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 copyout(&tmpstat, args->status, sizeof(int));
|
|
|
|
|
} else
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
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
|
1997-11-06 19:29:57 +00:00
|
|
|
|
linux_mknod(struct proc *p, struct linux_mknod_args *args)
|
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
|
|
|
|
caddr_t sg;
|
|
|
|
|
struct mknod_args bsd_mknod;
|
|
|
|
|
struct mkfifo_args bsd_mkfifo;
|
|
|
|
|
|
|
|
|
|
sg = stackgap_init();
|
|
|
|
|
|
|
|
|
|
CHECKALTCREAT(p, &sg, args->path);
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
1999-08-17 10:09:06 +00:00
|
|
|
|
printf("Linux-emul(%ld): mknod(%s, %d, %d)\n",
|
|
|
|
|
(long)p->p_pid, args->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
|
|
|
|
|
|
|
|
|
|
if (args->mode & S_IFIFO) {
|
|
|
|
|
bsd_mkfifo.path = args->path;
|
|
|
|
|
bsd_mkfifo.mode = args->mode;
|
1997-11-06 19:29:57 +00:00
|
|
|
|
return mkfifo(p, &bsd_mkfifo);
|
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
|
|
|
|
} else {
|
|
|
|
|
bsd_mknod.path = args->path;
|
|
|
|
|
bsd_mknod.mode = args->mode;
|
|
|
|
|
bsd_mknod.dev = args->dev;
|
1997-11-06 19:29:57 +00:00
|
|
|
|
return mknod(p, &bsd_mknod);
|
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
|
1997-11-06 19:29:57 +00:00
|
|
|
|
linux_personality(struct proc *p, 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
|
1999-08-17 10:09:06 +00:00
|
|
|
|
printf("Linux-emul(%ld): personality(%d)\n",
|
|
|
|
|
(long)p->p_pid, 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
|
2000-11-01 19:48:35 +00:00
|
|
|
|
#ifndef __alpha__
|
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
|
|
|
|
if (args->per != 0)
|
|
|
|
|
return EINVAL;
|
2000-11-01 19:48:35 +00:00
|
|
|
|
#endif
|
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
|
|
|
|
|
|
|
|
|
/* Yes Jim, it's still a Linux... */
|
1997-11-06 19:29:57 +00:00
|
|
|
|
p->p_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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Wrappers for get/setitimer for debugging..
|
|
|
|
|
*/
|
|
|
|
|
int
|
1997-11-06 19:29:57 +00:00
|
|
|
|
linux_setitimer(struct proc *p, struct linux_setitimer_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 setitimer_args bsa;
|
|
|
|
|
struct itimerval foo;
|
|
|
|
|
int error;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
1998-07-29 16:43:00 +00:00
|
|
|
|
printf("Linux-emul(%ld): setitimer(%p, %p)\n",
|
|
|
|
|
(long)p->p_pid, (void *)args->itv, (void *)args->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
|
|
|
|
|
bsa.which = args->which;
|
|
|
|
|
bsa.itv = args->itv;
|
|
|
|
|
bsa.oitv = args->oitv;
|
|
|
|
|
if (args->itv) {
|
|
|
|
|
if ((error = copyin((caddr_t)args->itv, (caddr_t)&foo,
|
|
|
|
|
sizeof(foo))))
|
|
|
|
|
return error;
|
|
|
|
|
#ifdef DEBUG
|
1998-07-29 16:43:00 +00:00
|
|
|
|
printf("setitimer: value: sec: %ld, usec: %ld\n",
|
|
|
|
|
foo.it_value.tv_sec, foo.it_value.tv_usec);
|
|
|
|
|
printf("setitimer: interval: sec: %ld, usec: %ld\n",
|
|
|
|
|
foo.it_interval.tv_sec, foo.it_interval.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
|
|
|
|
|
}
|
1997-11-06 19:29:57 +00:00
|
|
|
|
return setitimer(p, &bsa);
|
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
|
1997-11-06 19:29:57 +00:00
|
|
|
|
linux_getitimer(struct proc *p, struct linux_getitimer_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 getitimer_args bsa;
|
|
|
|
|
#ifdef DEBUG
|
1998-07-29 16:43:00 +00:00
|
|
|
|
printf("Linux-emul(%ld): getitimer(%p)\n",
|
|
|
|
|
(long)p->p_pid, (void *)args->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
|
|
|
|
|
bsa.which = args->which;
|
|
|
|
|
bsa.itv = args->itv;
|
1997-11-06 19:29:57 +00:00
|
|
|
|
return getitimer(p, &bsa);
|
1996-01-14 10:59:58 +00:00
|
|
|
|
}
|
1997-10-29 08:17:14 +00:00
|
|
|
|
|
2000-11-01 19:48:35 +00:00
|
|
|
|
#ifndef __alpha__
|
1997-10-29 08:17:14 +00:00
|
|
|
|
int
|
1997-11-06 19:29:57 +00:00
|
|
|
|
linux_nice(struct proc *p, 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;
|
1997-11-06 19:29:57 +00:00
|
|
|
|
return setpriority(p, &bsd_args);
|
1997-10-29 08:17:14 +00:00
|
|
|
|
}
|
2000-11-01 19:48:35 +00:00
|
|
|
|
#endif /*!__alpha__*/
|
1997-10-29 08:17:14 +00:00
|
|
|
|
|
1998-12-30 21:01:34 +00:00
|
|
|
|
int
|
|
|
|
|
linux_setgroups(p, uap)
|
1999-08-25 14:11:01 +00:00
|
|
|
|
struct proc *p;
|
|
|
|
|
struct linux_setgroups_args *uap;
|
1998-12-30 21:01:34 +00:00
|
|
|
|
{
|
1999-08-25 14:11:01 +00:00
|
|
|
|
struct pcred *pc;
|
|
|
|
|
linux_gid_t linux_gidset[NGROUPS];
|
|
|
|
|
gid_t *bsd_gidset;
|
|
|
|
|
int ngrp, error;
|
1998-12-30 21:01:34 +00:00
|
|
|
|
|
1999-08-25 14:11:01 +00:00
|
|
|
|
pc = p->p_cred;
|
|
|
|
|
ngrp = uap->gidsetsize;
|
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
|
|
|
|
|
1999-08-25 14:11:01 +00:00
|
|
|
|
if ((error = suser(p)) != 0)
|
|
|
|
|
return (error);
|
1998-12-30 21:01:34 +00:00
|
|
|
|
|
1999-08-25 14:11:01 +00:00
|
|
|
|
if (ngrp >= NGROUPS)
|
|
|
|
|
return (EINVAL);
|
1998-12-30 21:01:34 +00:00
|
|
|
|
|
1999-08-25 14:11:01 +00:00
|
|
|
|
pc->pc_ucred = crcopy(pc->pc_ucred);
|
|
|
|
|
if (ngrp > 0) {
|
|
|
|
|
error = copyin((caddr_t)uap->gidset, (caddr_t)linux_gidset,
|
|
|
|
|
ngrp * sizeof(linux_gid_t));
|
|
|
|
|
if (error)
|
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
|
|
pc->pc_ucred->cr_ngroups = ngrp + 1;
|
|
|
|
|
|
|
|
|
|
bsd_gidset = pc->pc_ucred->cr_groups;
|
|
|
|
|
ngrp--;
|
|
|
|
|
while (ngrp >= 0) {
|
|
|
|
|
bsd_gidset[ngrp + 1] = linux_gidset[ngrp];
|
|
|
|
|
ngrp--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
pc->pc_ucred->cr_ngroups = 1;
|
1998-12-30 21:01:34 +00:00
|
|
|
|
|
1999-08-25 14:11:01 +00:00
|
|
|
|
setsugid(p);
|
|
|
|
|
return (0);
|
1998-12-30 21:01:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
linux_getgroups(p, uap)
|
1999-08-25 14:11:01 +00:00
|
|
|
|
struct proc *p;
|
|
|
|
|
struct linux_getgroups_args *uap;
|
1998-12-30 21:01:34 +00:00
|
|
|
|
{
|
1999-08-25 14:11:01 +00:00
|
|
|
|
struct pcred *pc;
|
|
|
|
|
linux_gid_t linux_gidset[NGROUPS];
|
|
|
|
|
gid_t *bsd_gidset;
|
|
|
|
|
int bsd_gidsetsz, ngrp, error;
|
1998-12-30 21:01:34 +00:00
|
|
|
|
|
1999-08-25 14:11:01 +00:00
|
|
|
|
pc = p->p_cred;
|
|
|
|
|
bsd_gidset = pc->pc_ucred->cr_groups;
|
1999-08-29 08:52:38 +00:00
|
|
|
|
bsd_gidsetsz = pc->pc_ucred->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
|
|
|
|
|
1999-08-25 14:11:01 +00:00
|
|
|
|
if ((ngrp = uap->gidsetsize) == 0) {
|
1999-08-29 08:52:38 +00:00
|
|
|
|
p->p_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++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((error = copyout((caddr_t)linux_gidset, (caddr_t)uap->gidset,
|
|
|
|
|
ngrp * sizeof(linux_gid_t))))
|
|
|
|
|
return (error);
|
1998-12-30 21:01:34 +00:00
|
|
|
|
|
1999-08-29 08:52:38 +00:00
|
|
|
|
p->p_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
|
|
|
|
|
2000-11-01 19:48:35 +00:00
|
|
|
|
#ifndef __alpha__
|
1999-08-11 13:34:31 +00:00
|
|
|
|
int
|
|
|
|
|
linux_setrlimit(p, uap)
|
2000-08-26 02:18:41 +00:00
|
|
|
|
struct proc *p;
|
|
|
|
|
struct linux_setrlimit_args *uap;
|
1999-08-11 13:34:31 +00:00
|
|
|
|
{
|
2000-08-26 02:18:41 +00:00
|
|
|
|
struct __setrlimit_args bsd;
|
|
|
|
|
struct linux_rlimit rlim;
|
|
|
|
|
int error;
|
|
|
|
|
caddr_t sg = stackgap_init();
|
1999-08-15 13:28:35 +00:00
|
|
|
|
|
1999-08-11 13:34:31 +00:00
|
|
|
|
#ifdef DEBUG
|
2000-08-26 02:18:41 +00:00
|
|
|
|
printf("Linux-emul(%ld): setrlimit(%d, %p)\n", (long)p->p_pid,
|
|
|
|
|
uap->resource, (void *)uap->rlim);
|
1999-08-11 13:34:31 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2000-08-26 02:18:41 +00:00
|
|
|
|
if (uap->resource >= LINUX_RLIM_NLIMITS)
|
|
|
|
|
return (EINVAL);
|
1999-08-11 13:34:31 +00:00
|
|
|
|
|
2000-08-26 02:18:41 +00:00
|
|
|
|
bsd.which = linux_to_bsd_resource[uap->resource];
|
|
|
|
|
if (bsd.which == -1)
|
|
|
|
|
return (EINVAL);
|
1999-08-11 13:34:31 +00:00
|
|
|
|
|
2000-08-26 02:18:41 +00:00
|
|
|
|
error = copyin(uap->rlim, &rlim, sizeof(rlim));
|
|
|
|
|
if (error)
|
|
|
|
|
return (error);
|
1999-08-11 13:34:31 +00:00
|
|
|
|
|
2000-08-26 02:18:41 +00:00
|
|
|
|
bsd.rlp = stackgap_alloc(&sg, sizeof(struct rlimit));
|
|
|
|
|
bsd.rlp->rlim_cur = (rlim_t)rlim.rlim_cur;
|
|
|
|
|
bsd.rlp->rlim_max = (rlim_t)rlim.rlim_max;
|
|
|
|
|
return (setrlimit(p, &bsd));
|
1999-08-11 13:34:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
linux_getrlimit(p, uap)
|
2000-08-26 02:18:41 +00:00
|
|
|
|
struct proc *p;
|
|
|
|
|
struct linux_getrlimit_args *uap;
|
1999-08-11 13:34:31 +00:00
|
|
|
|
{
|
2000-08-26 02:18:41 +00:00
|
|
|
|
struct __getrlimit_args bsd;
|
|
|
|
|
struct linux_rlimit rlim;
|
|
|
|
|
int error;
|
|
|
|
|
caddr_t sg = stackgap_init();
|
1999-08-15 13:28:35 +00:00
|
|
|
|
|
1999-08-11 13:34:31 +00:00
|
|
|
|
#ifdef DEBUG
|
2000-08-26 02:18:41 +00:00
|
|
|
|
printf("Linux-emul(%ld): getrlimit(%d, %p)\n", (long)p->p_pid,
|
|
|
|
|
uap->resource, (void *)uap->rlim);
|
1999-08-11 13:34:31 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2000-08-26 02:18:41 +00:00
|
|
|
|
if (uap->resource >= LINUX_RLIM_NLIMITS)
|
|
|
|
|
return (EINVAL);
|
1999-08-11 13:34:31 +00:00
|
|
|
|
|
2000-08-26 02:18:41 +00:00
|
|
|
|
bsd.which = linux_to_bsd_resource[uap->resource];
|
|
|
|
|
if (bsd.which == -1)
|
|
|
|
|
return (EINVAL);
|
1999-08-11 13:34:31 +00:00
|
|
|
|
|
2000-08-26 02:18:41 +00:00
|
|
|
|
bsd.rlp = stackgap_alloc(&sg, sizeof(struct rlimit));
|
|
|
|
|
error = getrlimit(p, &bsd);
|
|
|
|
|
if (error)
|
|
|
|
|
return (error);
|
1999-08-11 13:34:31 +00:00
|
|
|
|
|
2000-08-26 02:18:41 +00:00
|
|
|
|
rlim.rlim_cur = (unsigned long)bsd.rlp->rlim_cur;
|
2000-08-26 05:08:10 +00:00
|
|
|
|
if (rlim.rlim_cur == ULONG_MAX)
|
|
|
|
|
rlim.rlim_cur = LONG_MAX;
|
2000-08-26 02:18:41 +00:00
|
|
|
|
rlim.rlim_max = (unsigned long)bsd.rlp->rlim_max;
|
2000-08-26 05:08:10 +00:00
|
|
|
|
if (rlim.rlim_max == ULONG_MAX)
|
|
|
|
|
rlim.rlim_max = LONG_MAX;
|
2000-08-26 02:18:41 +00:00
|
|
|
|
return (copyout(&rlim, uap->rlim, sizeof(rlim)));
|
1999-08-11 13:34:31 +00:00
|
|
|
|
}
|
2000-11-01 19:48:35 +00:00
|
|
|
|
#endif /*!__alpha__*/
|
1999-08-15 17:28:40 +00:00
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
linux_sched_setscheduler(p, uap)
|
|
|
|
|
struct proc *p;
|
|
|
|
|
struct linux_sched_setscheduler_args *uap;
|
|
|
|
|
{
|
|
|
|
|
struct sched_setscheduler_args bsd;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
printf("Linux-emul(%ld): sched_setscheduler(%d, %d, %p)\n",
|
1999-09-29 15:12:18 +00:00
|
|
|
|
(long)p->p_pid, uap->pid, uap->policy, (const void *)uap->param);
|
1999-08-15 17:28:40 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
switch (uap->policy) {
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bsd.pid = uap->pid;
|
|
|
|
|
bsd.param = uap->param;
|
|
|
|
|
return sched_setscheduler(p, &bsd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
linux_sched_getscheduler(p, uap)
|
|
|
|
|
struct proc *p;
|
|
|
|
|
struct linux_sched_getscheduler_args *uap;
|
|
|
|
|
{
|
|
|
|
|
struct sched_getscheduler_args bsd;
|
|
|
|
|
int error;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
printf("Linux-emul(%ld): sched_getscheduler(%d)\n",
|
|
|
|
|
(long)p->p_pid, uap->pid);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
bsd.pid = uap->pid;
|
|
|
|
|
error = sched_getscheduler(p, &bsd);
|
|
|
|
|
|
|
|
|
|
switch (p->p_retval[0]) {
|
|
|
|
|
case SCHED_OTHER:
|
|
|
|
|
p->p_retval[0] = LINUX_SCHED_OTHER;
|
|
|
|
|
break;
|
|
|
|
|
case SCHED_FIFO:
|
|
|
|
|
p->p_retval[0] = LINUX_SCHED_FIFO;
|
|
|
|
|
break;
|
|
|
|
|
case SCHED_RR:
|
|
|
|
|
p->p_retval[0] = LINUX_SCHED_RR;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return error;
|
|
|
|
|
}
|