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
|
|
|
|
|
* notice, this list of conditions and the following disclaimer
|
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
1996-01-05 19:52:49 +00:00
|
|
|
|
|
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>
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#include <sys/proc.h>
|
1997-10-28 10:50:02 +00:00
|
|
|
|
#include <sys/sem.h>
|
1995-06-25 17:32:43 +00:00
|
|
|
|
#include <sys/shm.h>
|
|
|
|
|
|
1995-11-22 07:43:53 +00:00
|
|
|
|
#include <i386/linux/linux.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 <i386/linux/linux_proto.h>
|
|
|
|
|
#include <i386/linux/linux_util.h>
|
|
|
|
|
|
1997-11-06 19:29:57 +00:00
|
|
|
|
static int linux_semop __P((struct proc *, struct linux_ipc_args *));
|
|
|
|
|
static int linux_semget __P((struct proc *, struct linux_ipc_args *));
|
|
|
|
|
static int linux_semctl __P((struct proc *, struct linux_ipc_args *));
|
|
|
|
|
static int linux_msgsnd __P((struct proc *, struct linux_ipc_args *));
|
|
|
|
|
static int linux_msgrcv __P((struct proc *, struct linux_ipc_args *));
|
|
|
|
|
static int linux_msgctl __P((struct proc *, struct linux_ipc_args *));
|
|
|
|
|
static int linux_shmat __P((struct proc *, struct linux_ipc_args *));
|
|
|
|
|
static int linux_shmdt __P((struct proc *, struct linux_ipc_args *));
|
|
|
|
|
static int linux_shmget __P((struct proc *, struct linux_ipc_args *));
|
|
|
|
|
static int linux_shmctl __P((struct proc *, struct linux_ipc_args *));
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
|
|
|
|
struct linux_ipc_perm {
|
|
|
|
|
linux_key_t key;
|
|
|
|
|
unsigned short uid;
|
|
|
|
|
unsigned short gid;
|
|
|
|
|
unsigned short cuid;
|
|
|
|
|
unsigned short cgid;
|
|
|
|
|
unsigned short mode;
|
|
|
|
|
unsigned short seq;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
linux_to_bsd_ipc_perm(struct linux_ipc_perm *lpp, struct ipc_perm *bpp)
|
|
|
|
|
{
|
|
|
|
|
bpp->key = lpp->key;
|
|
|
|
|
bpp->uid = lpp->uid;
|
|
|
|
|
bpp->gid = lpp->gid;
|
|
|
|
|
bpp->cuid = lpp->cuid;
|
|
|
|
|
bpp->cgid = lpp->cgid;
|
|
|
|
|
bpp->mode = lpp->mode;
|
|
|
|
|
bpp->seq = lpp->seq;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
bsd_to_linux_ipc_perm(struct ipc_perm *bpp, struct linux_ipc_perm *lpp)
|
|
|
|
|
{
|
|
|
|
|
lpp->key = bpp->key;
|
|
|
|
|
lpp->uid = bpp->uid;
|
|
|
|
|
lpp->gid = bpp->gid;
|
|
|
|
|
lpp->cuid = bpp->cuid;
|
|
|
|
|
lpp->cgid = bpp->cgid;
|
|
|
|
|
lpp->mode = bpp->mode;
|
|
|
|
|
lpp->seq = bpp->seq;
|
|
|
|
|
}
|
|
|
|
|
|
1997-10-28 10:50:02 +00:00
|
|
|
|
struct linux_semid_ds {
|
|
|
|
|
struct linux_ipc_perm sem_perm;
|
|
|
|
|
linux_time_t sem_otime;
|
|
|
|
|
linux_time_t sem_ctime;
|
|
|
|
|
void *sem_base;
|
|
|
|
|
void *sem_pending;
|
|
|
|
|
void *sem_pending_last;
|
|
|
|
|
void *undo;
|
|
|
|
|
ushort sem_nsems;
|
|
|
|
|
};
|
|
|
|
|
|
1995-06-25 17:32:43 +00:00
|
|
|
|
struct linux_shmid_ds {
|
|
|
|
|
struct linux_ipc_perm shm_perm;
|
|
|
|
|
int shm_segsz;
|
|
|
|
|
linux_time_t shm_atime;
|
|
|
|
|
linux_time_t shm_dtime;
|
|
|
|
|
linux_time_t shm_ctime;
|
|
|
|
|
ushort shm_cpid;
|
|
|
|
|
ushort shm_lpid;
|
|
|
|
|
short shm_nattch;
|
|
|
|
|
ushort private1;
|
|
|
|
|
void *private2;
|
|
|
|
|
void *private3;
|
|
|
|
|
};
|
|
|
|
|
|
1997-10-28 10:50:02 +00:00
|
|
|
|
static void
|
|
|
|
|
linux_to_bsd_semid_ds(struct linux_semid_ds *lsp, struct semid_ds *bsp)
|
|
|
|
|
{
|
|
|
|
|
linux_to_bsd_ipc_perm(&lsp->sem_perm, &bsp->sem_perm);
|
|
|
|
|
bsp->sem_otime = lsp->sem_otime;
|
|
|
|
|
bsp->sem_ctime = lsp->sem_ctime;
|
|
|
|
|
bsp->sem_nsems = lsp->sem_nsems;
|
|
|
|
|
bsp->sem_base = lsp->sem_base;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
bsd_to_linux_semid_ds(struct semid_ds *bsp, struct linux_semid_ds *lsp)
|
|
|
|
|
{
|
|
|
|
|
bsd_to_linux_ipc_perm(&bsp->sem_perm, &lsp->sem_perm);
|
|
|
|
|
lsp->sem_otime = bsp->sem_otime;
|
|
|
|
|
lsp->sem_ctime = bsp->sem_ctime;
|
|
|
|
|
lsp->sem_nsems = bsp->sem_nsems;
|
|
|
|
|
lsp->sem_base = bsp->sem_base;
|
|
|
|
|
}
|
|
|
|
|
|
1995-06-25 17:32:43 +00:00
|
|
|
|
static void
|
|
|
|
|
linux_to_bsd_shmid_ds(struct linux_shmid_ds *lsp, struct shmid_ds *bsp)
|
|
|
|
|
{
|
|
|
|
|
linux_to_bsd_ipc_perm(&lsp->shm_perm, &bsp->shm_perm);
|
|
|
|
|
bsp->shm_segsz = lsp->shm_segsz;
|
|
|
|
|
bsp->shm_lpid = lsp->shm_lpid;
|
|
|
|
|
bsp->shm_cpid = lsp->shm_cpid;
|
|
|
|
|
bsp->shm_nattch = lsp->shm_nattch;
|
|
|
|
|
bsp->shm_atime = lsp->shm_atime;
|
|
|
|
|
bsp->shm_dtime = lsp->shm_dtime;
|
|
|
|
|
bsp->shm_ctime = lsp->shm_ctime;
|
|
|
|
|
bsp->shm_internal = lsp->private3; /* this goes (yet) SOS */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
bsd_to_linux_shmid_ds(struct shmid_ds *bsp, struct linux_shmid_ds *lsp)
|
|
|
|
|
{
|
|
|
|
|
bsd_to_linux_ipc_perm(&bsp->shm_perm, &lsp->shm_perm);
|
|
|
|
|
lsp->shm_segsz = bsp->shm_segsz;
|
|
|
|
|
lsp->shm_lpid = bsp->shm_lpid;
|
|
|
|
|
lsp->shm_cpid = bsp->shm_cpid;
|
|
|
|
|
lsp->shm_nattch = bsp->shm_nattch;
|
|
|
|
|
lsp->shm_atime = bsp->shm_atime;
|
|
|
|
|
lsp->shm_dtime = bsp->shm_dtime;
|
|
|
|
|
lsp->shm_ctime = bsp->shm_ctime;
|
|
|
|
|
lsp->private3 = bsp->shm_internal; /* this goes (yet) SOS */
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
static int
|
1997-11-06 19:29:57 +00:00
|
|
|
|
linux_semop(struct proc *p, struct linux_ipc_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
{
|
1997-10-28 10:50:02 +00:00
|
|
|
|
struct semop_args /* {
|
|
|
|
|
int semid;
|
|
|
|
|
struct sembuf *sops;
|
|
|
|
|
int nsops;
|
|
|
|
|
} */ bsd_args;
|
|
|
|
|
|
|
|
|
|
bsd_args.semid = args->arg1;
|
|
|
|
|
bsd_args.sops = (struct sembuf *)args->ptr;
|
|
|
|
|
bsd_args.nsops = args->arg2;
|
1997-11-06 19:29:57 +00:00
|
|
|
|
return semop(p, &bsd_args);
|
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
|
|
|
|
static int
|
1997-11-06 19:29:57 +00:00
|
|
|
|
linux_semget(struct proc *p, struct linux_ipc_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
{
|
1997-10-28 10:50:02 +00:00
|
|
|
|
struct semget_args /* {
|
|
|
|
|
key_t key;
|
|
|
|
|
int nsems;
|
|
|
|
|
int semflg;
|
|
|
|
|
} */ bsd_args;
|
|
|
|
|
|
|
|
|
|
bsd_args.key = args->arg1;
|
|
|
|
|
bsd_args.nsems = args->arg2;
|
|
|
|
|
bsd_args.semflg = args->arg3;
|
1997-11-06 19:29:57 +00:00
|
|
|
|
return semget(p, &bsd_args);
|
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
|
|
|
|
static int
|
1997-11-06 19:29:57 +00:00
|
|
|
|
linux_semctl(struct proc *p, struct linux_ipc_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
{
|
1997-10-28 10:50:02 +00:00
|
|
|
|
struct linux_semid_ds linux_semid;
|
|
|
|
|
struct semid_ds bsd_semid;
|
|
|
|
|
struct __semctl_args /* {
|
|
|
|
|
int semid;
|
|
|
|
|
int semnum;
|
|
|
|
|
int cmd;
|
|
|
|
|
union semun *arg;
|
|
|
|
|
} */ bsd_args;
|
|
|
|
|
int error;
|
|
|
|
|
caddr_t sg, unptr, dsp, ldsp;
|
|
|
|
|
|
|
|
|
|
sg = stackgap_init();
|
|
|
|
|
bsd_args.semid = args->arg1;
|
|
|
|
|
bsd_args.semnum = args->arg2;
|
|
|
|
|
bsd_args.cmd = args->arg3;
|
|
|
|
|
bsd_args.arg = (union semun *)args->ptr;
|
|
|
|
|
|
|
|
|
|
switch (args->arg3) {
|
|
|
|
|
case LINUX_IPC_RMID:
|
|
|
|
|
bsd_args.cmd = IPC_RMID;
|
|
|
|
|
break;
|
|
|
|
|
case LINUX_GETNCNT:
|
|
|
|
|
bsd_args.cmd = GETNCNT;
|
|
|
|
|
break;
|
|
|
|
|
case LINUX_GETPID:
|
|
|
|
|
bsd_args.cmd = GETPID;
|
|
|
|
|
break;
|
|
|
|
|
case LINUX_GETVAL:
|
|
|
|
|
bsd_args.cmd = GETVAL;
|
|
|
|
|
break;
|
|
|
|
|
case LINUX_GETZCNT:
|
|
|
|
|
bsd_args.cmd = GETZCNT;
|
|
|
|
|
break;
|
|
|
|
|
case LINUX_SETVAL:
|
|
|
|
|
bsd_args.cmd = SETVAL;
|
|
|
|
|
break;
|
|
|
|
|
case LINUX_IPC_SET:
|
|
|
|
|
bsd_args.cmd = IPC_SET;
|
|
|
|
|
error = copyin(args->ptr, &ldsp, sizeof(ldsp));
|
|
|
|
|
if (error)
|
|
|
|
|
return error;
|
|
|
|
|
error = copyin(ldsp, (caddr_t)&linux_semid, sizeof(linux_semid));
|
|
|
|
|
if (error)
|
|
|
|
|
return error;
|
|
|
|
|
linux_to_bsd_semid_ds(&linux_semid, &bsd_semid);
|
|
|
|
|
unptr = stackgap_alloc(&sg, sizeof(union semun));
|
|
|
|
|
dsp = stackgap_alloc(&sg, sizeof(struct semid_ds));
|
|
|
|
|
error = copyout((caddr_t)&bsd_semid, dsp, sizeof(bsd_semid));
|
|
|
|
|
if (error)
|
|
|
|
|
return error;
|
|
|
|
|
error = copyout((caddr_t)&dsp, unptr, sizeof(dsp));
|
|
|
|
|
if (error)
|
|
|
|
|
return error;
|
|
|
|
|
bsd_args.arg = (union semun *)unptr;
|
1997-11-06 19:29:57 +00:00
|
|
|
|
return __semctl(p, &bsd_args);
|
1997-10-28 10:50:02 +00:00
|
|
|
|
case LINUX_IPC_STAT:
|
|
|
|
|
bsd_args.cmd = IPC_STAT;
|
|
|
|
|
unptr = stackgap_alloc(&sg, sizeof(union semun *));
|
|
|
|
|
dsp = stackgap_alloc(&sg, sizeof(struct semid_ds));
|
|
|
|
|
error = copyout((caddr_t)&dsp, unptr, sizeof(dsp));
|
|
|
|
|
if (error)
|
|
|
|
|
return error;
|
|
|
|
|
bsd_args.arg = (union semun *)unptr;
|
1997-11-06 19:29:57 +00:00
|
|
|
|
error = __semctl(p, &bsd_args);
|
1997-10-28 10:50:02 +00:00
|
|
|
|
if (error)
|
|
|
|
|
return error;
|
|
|
|
|
error = copyin(dsp, (caddr_t)&bsd_semid, sizeof(bsd_semid));
|
|
|
|
|
if (error)
|
|
|
|
|
return error;
|
|
|
|
|
bsd_to_linux_semid_ds(&bsd_semid, &linux_semid);
|
|
|
|
|
error = copyin(args->ptr, &ldsp, sizeof(ldsp));
|
|
|
|
|
if (error)
|
|
|
|
|
return error;
|
|
|
|
|
return copyout((caddr_t)&linux_semid, ldsp, sizeof(linux_semid));
|
|
|
|
|
case LINUX_GETALL:
|
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
|
case LINUX_SETALL:
|
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
|
default:
|
|
|
|
|
uprintf("LINUX: 'ipc' typ=%d not implemented\n", args->what);
|
|
|
|
|
return EINVAL;
|
|
|
|
|
}
|
1997-11-06 19:29:57 +00:00
|
|
|
|
return __semctl(p, &bsd_args);
|
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
|
|
|
|
static int
|
1997-11-06 19:29:57 +00:00
|
|
|
|
linux_msgsnd(struct proc *p, struct linux_ipc_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
{
|
1995-12-29 22:12:14 +00:00
|
|
|
|
struct msgsnd_args /* {
|
|
|
|
|
int msqid;
|
|
|
|
|
void *msgp;
|
|
|
|
|
size_t msgsz;
|
|
|
|
|
int msgflg;
|
|
|
|
|
} */ bsd_args;
|
|
|
|
|
|
|
|
|
|
bsd_args.msqid = args->arg1;
|
|
|
|
|
bsd_args.msgp = args->ptr;
|
|
|
|
|
bsd_args.msgsz = args->arg2;
|
|
|
|
|
bsd_args.msgflg = args->arg3;
|
1997-11-06 19:29:57 +00:00
|
|
|
|
return msgsnd(p, &bsd_args);
|
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
|
|
|
|
static int
|
1997-11-06 19:29:57 +00:00
|
|
|
|
linux_msgrcv(struct proc *p, struct linux_ipc_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
{
|
1995-12-29 22:12:14 +00:00
|
|
|
|
struct msgrcv_args /* {
|
|
|
|
|
int msqid;
|
|
|
|
|
void *msgp;
|
|
|
|
|
size_t msgsz;
|
|
|
|
|
long msgtyp;
|
|
|
|
|
int msgflg;
|
|
|
|
|
} */ bsd_args;
|
|
|
|
|
|
|
|
|
|
bsd_args.msqid = args->arg1;
|
|
|
|
|
bsd_args.msgp = args->ptr;
|
|
|
|
|
bsd_args.msgsz = args->arg2;
|
|
|
|
|
bsd_args.msgtyp = 0;
|
|
|
|
|
bsd_args.msgflg = args->arg3;
|
1997-11-06 19:29:57 +00:00
|
|
|
|
return msgrcv(p, &bsd_args);
|
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
|
|
|
|
static int
|
1997-11-06 19:29:57 +00:00
|
|
|
|
linux_msgget(struct proc *p, struct linux_ipc_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
{
|
1995-12-29 22:12:14 +00:00
|
|
|
|
struct msgget_args /* {
|
|
|
|
|
key_t key;
|
|
|
|
|
int msgflg;
|
|
|
|
|
} */ bsd_args;
|
|
|
|
|
|
|
|
|
|
bsd_args.key = args->arg1;
|
|
|
|
|
bsd_args.msgflg = args->arg2;
|
1997-11-06 19:29:57 +00:00
|
|
|
|
return msgget(p, &bsd_args);
|
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
|
|
|
|
static int
|
1997-11-06 19:29:57 +00:00
|
|
|
|
linux_msgctl(struct proc *p, struct linux_ipc_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
{
|
1995-12-29 22:12:14 +00:00
|
|
|
|
struct msgctl_args /* {
|
|
|
|
|
int msqid;
|
|
|
|
|
int cmd;
|
|
|
|
|
struct msqid_ds *buf;
|
|
|
|
|
} */ bsd_args;
|
1999-09-23 09:57:45 +00:00
|
|
|
|
int error;
|
1995-12-29 22:12:14 +00:00
|
|
|
|
|
|
|
|
|
bsd_args.msqid = args->arg1;
|
|
|
|
|
bsd_args.cmd = args->arg2;
|
|
|
|
|
bsd_args.buf = (struct msqid_ds *)args->ptr;
|
1999-09-23 09:57:45 +00:00
|
|
|
|
error = msgctl(p, &bsd_args);
|
|
|
|
|
return ((args->arg2 == LINUX_IPC_RMID && error == EINVAL) ? 0 : 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
|
|
|
|
static int
|
1997-11-06 19:29:57 +00:00
|
|
|
|
linux_shmat(struct proc *p, struct linux_ipc_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
{
|
1995-12-15 05:07:20 +00:00
|
|
|
|
struct shmat_args /* {
|
1995-06-25 17:32:43 +00:00
|
|
|
|
int shmid;
|
|
|
|
|
void *shmaddr;
|
|
|
|
|
int shmflg;
|
1995-12-15 05:07:20 +00:00
|
|
|
|
} */ bsd_args;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
int error;
|
|
|
|
|
|
|
|
|
|
bsd_args.shmid = args->arg1;
|
|
|
|
|
bsd_args.shmaddr = args->ptr;
|
|
|
|
|
bsd_args.shmflg = args->arg2;
|
1997-11-06 19:29:57 +00:00
|
|
|
|
if ((error = shmat(p, &bsd_args)))
|
1995-06-25 17:32:43 +00:00
|
|
|
|
return error;
|
1997-11-06 19:29:57 +00:00
|
|
|
|
if ((error = copyout(p->p_retval, (caddr_t)args->arg3, sizeof(int))))
|
1995-06-25 17:32:43 +00:00
|
|
|
|
return error;
|
1997-11-06 19:29:57 +00:00
|
|
|
|
p->p_retval[0] = 0;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
return 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
|
|
|
|
static int
|
1997-11-06 19:29:57 +00:00
|
|
|
|
linux_shmdt(struct proc *p, struct linux_ipc_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
{
|
1995-12-15 05:07:20 +00:00
|
|
|
|
struct shmdt_args /* {
|
1995-06-25 17:32:43 +00:00
|
|
|
|
void *shmaddr;
|
1995-12-15 05:07:20 +00:00
|
|
|
|
} */ bsd_args;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
|
|
|
|
bsd_args.shmaddr = args->ptr;
|
1997-11-06 19:29:57 +00:00
|
|
|
|
return shmdt(p, &bsd_args);
|
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
|
|
|
|
static int
|
1997-11-06 19:29:57 +00:00
|
|
|
|
linux_shmget(struct proc *p, struct linux_ipc_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
{
|
1995-12-15 05:07:20 +00:00
|
|
|
|
struct shmget_args /* {
|
1995-06-25 17:32:43 +00:00
|
|
|
|
key_t key;
|
|
|
|
|
int size;
|
|
|
|
|
int shmflg;
|
1995-12-15 05:07:20 +00:00
|
|
|
|
} */ bsd_args;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
|
|
|
|
bsd_args.key = args->arg1;
|
|
|
|
|
bsd_args.size = args->arg2;
|
|
|
|
|
bsd_args.shmflg = args->arg3;
|
1997-11-06 19:29:57 +00:00
|
|
|
|
return shmget(p, &bsd_args);
|
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
|
|
|
|
static int
|
1997-11-06 19:29:57 +00:00
|
|
|
|
linux_shmctl(struct proc *p, struct linux_ipc_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
{
|
|
|
|
|
struct shmid_ds bsd_shmid;
|
|
|
|
|
struct linux_shmid_ds linux_shmid;
|
1995-12-15 05:07:20 +00:00
|
|
|
|
struct shmctl_args /* {
|
1995-06-25 17:32:43 +00:00
|
|
|
|
int shmid;
|
|
|
|
|
int cmd;
|
|
|
|
|
struct shmid_ds *buf;
|
1995-12-15 05:07:20 +00:00
|
|
|
|
} */ bsd_args;
|
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 = stackgap_init();
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
|
|
|
|
switch (args->arg2) {
|
|
|
|
|
case LINUX_IPC_STAT:
|
|
|
|
|
bsd_args.shmid = args->arg1;
|
|
|
|
|
bsd_args.cmd = IPC_STAT;
|
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
|
|
|
|
bsd_args.buf = (struct shmid_ds*)stackgap_alloc(&sg, sizeof(struct shmid_ds));
|
1997-11-06 19:29:57 +00:00
|
|
|
|
if ((error = shmctl(p, &bsd_args)))
|
1995-06-25 17:32:43 +00:00
|
|
|
|
return error;
|
1997-08-10 18:15:20 +00:00
|
|
|
|
if ((error = copyin((caddr_t)bsd_args.buf, (caddr_t)&bsd_shmid,
|
1995-06-25 17:32:43 +00:00
|
|
|
|
sizeof(struct shmid_ds))))
|
|
|
|
|
return error;
|
|
|
|
|
bsd_to_linux_shmid_ds(&bsd_shmid, &linux_shmid);
|
|
|
|
|
return copyout((caddr_t)&linux_shmid, args->ptr, sizeof(linux_shmid));
|
|
|
|
|
|
|
|
|
|
case LINUX_IPC_SET:
|
|
|
|
|
if ((error = copyin(args->ptr, (caddr_t)&linux_shmid,
|
|
|
|
|
sizeof(linux_shmid))))
|
|
|
|
|
return error;
|
|
|
|
|
linux_to_bsd_shmid_ds(&linux_shmid, &bsd_shmid);
|
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
|
|
|
|
bsd_args.buf = (struct shmid_ds*)stackgap_alloc(&sg, sizeof(struct shmid_ds));
|
1995-06-25 17:32:43 +00:00
|
|
|
|
if ((error = copyout((caddr_t)&bsd_shmid, (caddr_t)bsd_args.buf,
|
|
|
|
|
sizeof(struct shmid_ds))))
|
|
|
|
|
return error;
|
|
|
|
|
bsd_args.shmid = args->arg1;
|
|
|
|
|
bsd_args.cmd = IPC_SET;
|
1997-11-06 19:29:57 +00:00
|
|
|
|
return shmctl(p, &bsd_args);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
|
|
|
|
case LINUX_IPC_RMID:
|
|
|
|
|
bsd_args.shmid = args->arg1;
|
|
|
|
|
bsd_args.cmd = IPC_RMID;
|
1998-06-02 12:38:31 +00:00
|
|
|
|
if (NULL == args->ptr)
|
|
|
|
|
bsd_args.buf = NULL;
|
|
|
|
|
else {
|
|
|
|
|
if ((error = copyin(args->ptr, (caddr_t)&linux_shmid,
|
|
|
|
|
sizeof(linux_shmid))))
|
|
|
|
|
return error;
|
|
|
|
|
linux_to_bsd_shmid_ds(&linux_shmid, &bsd_shmid);
|
|
|
|
|
bsd_args.buf = (struct shmid_ds*)stackgap_alloc(&sg, sizeof(struct shmid_ds));
|
|
|
|
|
if ((error = copyout((caddr_t)&bsd_shmid, (caddr_t)bsd_args.buf,
|
|
|
|
|
sizeof(struct shmid_ds))))
|
|
|
|
|
return error;
|
|
|
|
|
}
|
1997-11-06 19:29:57 +00:00
|
|
|
|
return shmctl(p, &bsd_args);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
|
|
|
|
|
case LINUX_IPC_INFO:
|
|
|
|
|
case LINUX_SHM_STAT:
|
|
|
|
|
case LINUX_SHM_INFO:
|
|
|
|
|
case LINUX_SHM_LOCK:
|
|
|
|
|
case LINUX_SHM_UNLOCK:
|
|
|
|
|
default:
|
|
|
|
|
uprintf("LINUX: 'ipc' typ=%d not implemented\n", args->what);
|
|
|
|
|
return EINVAL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
1997-11-06 19:29:57 +00:00
|
|
|
|
linux_ipc(struct proc *p, struct linux_ipc_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
|
{
|
|
|
|
|
switch (args->what) {
|
|
|
|
|
case LINUX_SEMOP:
|
1997-11-06 19:29:57 +00:00
|
|
|
|
return linux_semop(p, args);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
case LINUX_SEMGET:
|
1997-11-06 19:29:57 +00:00
|
|
|
|
return linux_semget(p, args);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
case LINUX_SEMCTL:
|
1997-11-06 19:29:57 +00:00
|
|
|
|
return linux_semctl(p, args);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
case LINUX_MSGSND:
|
1997-11-06 19:29:57 +00:00
|
|
|
|
return linux_msgsnd(p, args);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
case LINUX_MSGRCV:
|
1997-11-06 19:29:57 +00:00
|
|
|
|
return linux_msgrcv(p, args);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
case LINUX_MSGGET:
|
1997-11-06 19:29:57 +00:00
|
|
|
|
return linux_msgget(p, args);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
case LINUX_MSGCTL:
|
1997-11-06 19:29:57 +00:00
|
|
|
|
return linux_msgctl(p, args);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
case LINUX_SHMAT:
|
1997-11-06 19:29:57 +00:00
|
|
|
|
return linux_shmat(p, args);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
case LINUX_SHMDT:
|
1997-11-06 19:29:57 +00:00
|
|
|
|
return linux_shmdt(p, args);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
case LINUX_SHMGET:
|
1997-11-06 19:29:57 +00:00
|
|
|
|
return linux_shmget(p, args);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
case LINUX_SHMCTL:
|
1997-11-06 19:29:57 +00:00
|
|
|
|
return linux_shmctl(p, args);
|
1995-06-25 17:32:43 +00:00
|
|
|
|
default:
|
|
|
|
|
uprintf("LINUX: 'ipc' typ=%d not implemented\n", args->what);
|
|
|
|
|
return ENOSYS;
|
|
|
|
|
}
|
|
|
|
|
}
|