2008-04-24 03:34:11 +04:00
|
|
|
/* $NetBSD: ultrix_misc.c,v 1.112 2008/04/23 23:34:11 christos Exp $ */
|
1996-04-07 21:23:04 +04:00
|
|
|
|
|
|
|
/*
|
1997-04-07 03:26:52 +04:00
|
|
|
* Copyright (c) 1995, 1997 Jonathan Stone (hereinafter referred to as the author)
|
|
|
|
* All rights reserved.
|
1996-04-07 21:23:04 +04:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
* 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.
|
1996-10-19 16:40:31 +04:00
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
1997-10-10 12:31:10 +04:00
|
|
|
* This product includes software developed by Jonathan Stone for
|
1996-10-19 16:40:31 +04:00
|
|
|
* the NetBSD Project.
|
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
1996-04-07 21:23:04 +04:00
|
|
|
* derived from this software without 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.
|
|
|
|
*/
|
1994-06-29 10:29:24 +04:00
|
|
|
|
1994-06-02 10:25:37 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1992, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* This software was developed by the Computer Systems Engineering group
|
|
|
|
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
|
|
|
|
* contributed to Berkeley.
|
|
|
|
*
|
|
|
|
* All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Lawrence Berkeley Laboratory.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
* 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.
|
2003-08-07 20:26:28 +04:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1994-06-02 10:25:37 +04:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
|
|
|
|
*
|
1994-06-29 10:29:24 +04:00
|
|
|
*
|
1994-06-02 10:25:37 +04:00
|
|
|
* @(#)sun_misc.c 8.1 (Berkeley) 6/18/93
|
|
|
|
*
|
2005-02-27 01:58:54 +03:00
|
|
|
* from: Header: sun_misc.c,v 1.16 93/04/07 02:46:27 torek Exp
|
1994-06-02 10:25:37 +04:00
|
|
|
*/
|
|
|
|
|
2001-11-13 05:07:52 +03:00
|
|
|
#include <sys/cdefs.h>
|
2008-04-24 03:34:11 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: ultrix_misc.c,v 1.112 2008/04/23 23:34:11 christos Exp $");
|
2001-11-13 05:07:52 +03:00
|
|
|
|
2001-05-30 15:37:21 +04:00
|
|
|
#if defined(_KERNEL_OPT)
|
1998-07-04 00:03:04 +04:00
|
|
|
#include "opt_nfsserver.h"
|
1998-10-20 02:43:58 +04:00
|
|
|
#include "opt_sysv.h"
|
2000-12-01 22:26:57 +03:00
|
|
|
#endif
|
1998-07-04 00:03:04 +04:00
|
|
|
|
1997-10-19 04:15:31 +04:00
|
|
|
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
|
|
|
|
1994-06-02 10:25:37 +04:00
|
|
|
/*
|
1998-10-26 21:31:01 +03:00
|
|
|
* Ultrix compatibility module.
|
1994-06-02 10:25:37 +04:00
|
|
|
*
|
1998-10-26 21:31:01 +03:00
|
|
|
* Ultrix system calls that are implemented differently in BSD are
|
1994-06-02 10:25:37 +04:00
|
|
|
* handled here.
|
|
|
|
*/
|
|
|
|
|
2001-05-30 15:37:21 +04:00
|
|
|
#if defined(_KERNEL_OPT)
|
1998-02-19 03:46:02 +03:00
|
|
|
#include "fs_nfs.h"
|
2000-12-01 22:26:57 +03:00
|
|
|
#endif
|
1998-02-19 03:46:02 +03:00
|
|
|
|
1994-06-02 10:25:37 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/namei.h>
|
1996-08-10 13:08:26 +04:00
|
|
|
#include <sys/dirent.h>
|
1994-06-02 10:25:37 +04:00
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/filedesc.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/exec.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <sys/mount.h>
|
|
|
|
#include <sys/resource.h>
|
|
|
|
#include <sys/resourcevar.h>
|
|
|
|
#include <sys/signal.h>
|
|
|
|
#include <sys/signalvar.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
#include <sys/uio.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <sys/utsname.h>
|
|
|
|
#include <sys/unistd.h>
|
1997-04-07 03:26:52 +04:00
|
|
|
#include <sys/ipc.h>
|
1996-01-07 16:38:49 +03:00
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
#include <sys/syscallargs.h>
|
|
|
|
|
2005-03-26 08:12:34 +03:00
|
|
|
#include <uvm/uvm_extern.h>
|
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
#include <compat/ultrix/ultrix_syscall.h>
|
|
|
|
#include <compat/ultrix/ultrix_syscallargs.h>
|
1997-04-07 03:26:52 +04:00
|
|
|
#include <compat/common/compat_util.h>
|
1994-06-02 10:25:37 +04:00
|
|
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
|
|
|
#include <miscfs/specfs/specdev.h>
|
|
|
|
|
1994-06-22 07:37:15 +04:00
|
|
|
#include <nfs/rpcv2.h>
|
1996-02-19 18:41:38 +03:00
|
|
|
#include <nfs/nfsproto.h>
|
1994-06-22 07:37:15 +04:00
|
|
|
#include <nfs/nfs.h>
|
|
|
|
|
1996-04-07 21:23:04 +04:00
|
|
|
#include <sys/socketvar.h> /* sosetopt() */
|
|
|
|
|
1999-07-30 20:03:49 +04:00
|
|
|
#include <compat/ultrix/ultrix_flock.h>
|
|
|
|
|
2005-09-16 21:09:52 +04:00
|
|
|
#include <compat/sys/signal.h>
|
|
|
|
#include <compat/sys/signalvar.h>
|
|
|
|
|
2001-01-07 07:13:16 +03:00
|
|
|
#ifdef __mips
|
|
|
|
#include <mips/cachectl.h>
|
2005-01-24 13:08:02 +03:00
|
|
|
#include <mips/frame.h>
|
2001-01-07 07:13:16 +03:00
|
|
|
#endif
|
|
|
|
|
2004-04-21 11:05:07 +04:00
|
|
|
static int ultrix_to_bsd_flock(struct ultrix_flock *, struct flock *);
|
|
|
|
static void bsd_to_ultrix_flock(struct flock *, struct ultrix_flock *);
|
1997-06-09 15:57:43 +04:00
|
|
|
|
1995-04-22 23:48:19 +04:00
|
|
|
extern struct sysent ultrix_sysent[];
|
2000-11-19 15:47:51 +03:00
|
|
|
extern const char * const ultrix_syscallnames[];
|
1998-10-02 22:53:23 +04:00
|
|
|
extern char ultrix_sigcode[], ultrix_esigcode[];
|
1996-01-04 00:07:33 +03:00
|
|
|
|
2003-08-24 21:52:28 +04:00
|
|
|
struct uvm_object *emul_ultrix_object;
|
|
|
|
|
2005-07-10 08:23:30 +04:00
|
|
|
#ifndef __HAVE_SYSCALL_INTERN
|
|
|
|
void syscall(void);
|
|
|
|
#endif
|
|
|
|
|
2000-11-21 03:37:49 +03:00
|
|
|
const struct emul emul_ultrix = {
|
1995-04-22 23:48:19 +04:00
|
|
|
"ultrix",
|
2000-12-01 15:28:30 +03:00
|
|
|
"/emul/ultrix",
|
2001-01-16 00:33:52 +03:00
|
|
|
#ifndef __HAVE_MINIMAL_EMUL
|
2000-12-16 16:30:08 +03:00
|
|
|
0,
|
1995-04-22 23:48:19 +04:00
|
|
|
NULL,
|
|
|
|
ULTRIX_SYS_syscall,
|
2002-11-01 22:26:21 +03:00
|
|
|
ULTRIX_SYS_NSYSENT,
|
2001-01-16 00:33:52 +03:00
|
|
|
#endif
|
1995-04-22 23:48:19 +04:00
|
|
|
ultrix_sysent,
|
|
|
|
ultrix_syscallnames,
|
2005-01-25 17:56:09 +03:00
|
|
|
#ifdef __mips
|
2005-01-24 13:08:02 +03:00
|
|
|
sendsig_sigcontext,
|
2005-01-25 17:56:09 +03:00
|
|
|
#else /* vax */
|
|
|
|
sendsig,
|
|
|
|
#endif
|
2001-06-18 06:00:48 +04:00
|
|
|
trapsignal,
|
2003-12-20 22:01:29 +03:00
|
|
|
NULL,
|
1998-10-02 22:53:23 +04:00
|
|
|
ultrix_sigcode,
|
|
|
|
ultrix_esigcode,
|
2003-08-24 21:52:28 +04:00
|
|
|
&emul_ultrix_object,
|
2001-09-18 23:36:32 +04:00
|
|
|
setregs,
|
2000-12-09 15:19:28 +03:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2003-12-20 21:22:16 +03:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2001-01-16 00:33:52 +03:00
|
|
|
#ifdef __HAVE_SYSCALL_INTERN
|
|
|
|
syscall_intern,
|
|
|
|
#else
|
|
|
|
syscall,
|
|
|
|
#endif
|
- Introduce a e_fault field in struct proc to provide emulation specific
memory fault handler. IRIX uses irix_vm_fault, and all other emulation
use NULL, which means to use uvm_fault.
- While we are there, explicitely set to NULL the uninitialized fields in
struct emul: e_fault and e_sysctl on most ports
- e_fault is used by the trap handler, for now only on mips. In order to avoid
intrusive modifications in UVM, the function pointed by e_fault does not
has exactly the same protoype as uvm_fault:
int uvm_fault __P((struct vm_map *, vaddr_t, vm_fault_t, vm_prot_t));
int e_fault __P((struct proc *, vaddr_t, vm_fault_t, vm_prot_t));
- In IRIX share groups, all the VM space is shared, except one page.
This bounds us to have different VM spaces and synchronize modifications
to the VM space accross share group members. We need an IRIX specific hook
to the page fault handler in order to propagate VM space modifications
caused by page faults.
2002-09-22 01:14:54 +04:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2005-03-26 08:12:34 +03:00
|
|
|
|
|
|
|
uvm_default_mapaddr,
|
2007-12-27 20:18:11 +03:00
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
NULL
|
1995-04-22 23:48:19 +04:00
|
|
|
};
|
|
|
|
|
1994-08-01 18:15:06 +04:00
|
|
|
#define GSI_PROG_ENV 1
|
|
|
|
|
1996-04-07 21:23:04 +04:00
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
ultrix_sys_getsysinfo(struct lwp *l, const struct ultrix_sys_getsysinfo_args *uap, register_t *retval)
|
1994-08-01 18:15:06 +04:00
|
|
|
{
|
|
|
|
static short progenv = 0;
|
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
switch (SCARG(uap, op)) {
|
1994-08-01 18:15:06 +04:00
|
|
|
/* operations implemented: */
|
|
|
|
case GSI_PROG_ENV:
|
1995-10-07 09:25:19 +03:00
|
|
|
if (SCARG(uap, nbytes) < sizeof(short))
|
1994-08-01 18:15:06 +04:00
|
|
|
return EINVAL;
|
|
|
|
*retval = 1;
|
2007-12-27 20:18:11 +03:00
|
|
|
return copyout(&progenv, SCARG(uap, buffer), sizeof(progenv));
|
1994-08-01 18:15:06 +04:00
|
|
|
default:
|
|
|
|
*retval = 0; /* info unavail */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-04-07 21:23:04 +04:00
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
ultrix_sys_setsysinfo(struct lwp *l, const struct ultrix_sys_setsysinfo_args *uap, register_t *retval)
|
1994-08-01 18:15:06 +04:00
|
|
|
{
|
1996-04-07 21:23:04 +04:00
|
|
|
|
1994-08-01 18:15:06 +04:00
|
|
|
*retval = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1996-04-07 21:23:04 +04:00
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
ultrix_sys_waitpid(struct lwp *l, const struct ultrix_sys_waitpid_args *uap, register_t *retval)
|
1994-06-02 10:25:37 +04:00
|
|
|
{
|
2007-12-27 20:18:11 +03:00
|
|
|
struct sys_wait4_args ap;
|
1994-06-02 10:25:37 +04:00
|
|
|
|
2007-12-27 20:18:11 +03:00
|
|
|
SCARG(&ap, pid) = SCARG(uap, pid);
|
|
|
|
SCARG(&ap, status) = SCARG(uap, status);
|
|
|
|
SCARG(&ap, options) = SCARG(uap, options);
|
|
|
|
SCARG(&ap, rusage) = 0;
|
1994-06-02 10:25:37 +04:00
|
|
|
|
2007-12-27 20:18:11 +03:00
|
|
|
return sys_wait4(l, &ap, retval);
|
1994-06-15 09:18:01 +04:00
|
|
|
}
|
|
|
|
|
1996-04-07 21:23:04 +04:00
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
ultrix_sys_wait3(struct lwp *l, const struct ultrix_sys_wait3_args *uap, register_t *retval)
|
1994-06-15 09:18:01 +04:00
|
|
|
{
|
2007-12-27 20:18:11 +03:00
|
|
|
struct sys_wait4_args ap;
|
1994-06-15 09:18:01 +04:00
|
|
|
|
2007-12-27 20:18:11 +03:00
|
|
|
SCARG(&ap, pid) = -1;
|
|
|
|
SCARG(&ap, status) = SCARG(uap, status);
|
|
|
|
SCARG(&ap, options) = SCARG(uap, options);
|
|
|
|
SCARG(&ap, rusage) = SCARG(uap, rusage);
|
1994-06-15 09:18:01 +04:00
|
|
|
|
2007-12-27 20:18:11 +03:00
|
|
|
return sys_wait4(l, &ap, retval);
|
1994-06-02 10:25:37 +04:00
|
|
|
}
|
|
|
|
|
1996-01-07 16:38:49 +03:00
|
|
|
/*
|
|
|
|
* Ultrix binaries pass in FD_MAX as the first arg to select().
|
1996-04-07 21:23:04 +04:00
|
|
|
* On Ultrix, FD_MAX is 4096, which is more than the NetBSD sys_select()
|
1996-01-07 16:38:49 +03:00
|
|
|
* can handle.
|
2005-02-27 01:58:54 +03:00
|
|
|
* Since we can't have more than the (native) FD_MAX descriptors open,
|
1996-04-07 21:23:04 +04:00
|
|
|
* limit nfds to at most FD_MAX.
|
1996-01-07 16:38:49 +03:00
|
|
|
*/
|
1996-04-07 21:23:04 +04:00
|
|
|
int
|
2007-12-27 20:18:11 +03:00
|
|
|
ultrix_sys_select(struct lwp *l, const struct ultrix_sys_select_args *uap, register_t *retval)
|
1995-12-26 07:22:30 +03:00
|
|
|
{
|
1996-04-07 21:23:04 +04:00
|
|
|
struct timeval atv;
|
1995-12-26 07:22:30 +03:00
|
|
|
int error;
|
2007-12-27 20:18:11 +03:00
|
|
|
struct sys_select_args ap;
|
1995-12-26 07:22:30 +03:00
|
|
|
|
|
|
|
/* Limit number of FDs selected on to the native maximum */
|
|
|
|
|
|
|
|
if (SCARG(uap, nd) > FD_SETSIZE)
|
2007-12-27 20:18:11 +03:00
|
|
|
SCARG(&ap, nd) = FD_SETSIZE;
|
|
|
|
else
|
|
|
|
SCARG(&ap, nd) = SCARG(uap, nd);
|
1995-12-26 07:22:30 +03:00
|
|
|
|
2007-12-27 20:18:11 +03:00
|
|
|
SCARG(&ap, in) = SCARG(uap, in);
|
|
|
|
SCARG(&ap, ou) = SCARG(uap, ou);
|
|
|
|
SCARG(&ap, ex) = SCARG(uap, ex);
|
|
|
|
SCARG(&ap, tv) = SCARG(uap, tv);
|
1995-12-26 07:22:30 +03:00
|
|
|
/* Check for negative timeval */
|
2007-12-27 20:18:11 +03:00
|
|
|
if (SCARG(&ap, tv)) {
|
|
|
|
error = copyin(SCARG(uap, tv), &atv, sizeof(atv));
|
1995-12-26 07:22:30 +03:00
|
|
|
if (error)
|
|
|
|
goto done;
|
|
|
|
#ifdef DEBUG
|
|
|
|
/* Ultrix clients sometimes give negative timeouts? */
|
|
|
|
if (atv.tv_sec < 0 || atv.tv_usec < 0)
|
1996-10-13 04:46:49 +04:00
|
|
|
printf("ultrix select( %ld, %ld): negative timeout\n",
|
1996-10-10 21:47:29 +04:00
|
|
|
atv.tv_sec, atv.tv_usec);
|
1995-12-26 07:22:30 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
2007-12-27 20:18:11 +03:00
|
|
|
error = sys_select(l, &ap, retval);
|
1995-12-26 07:22:30 +03:00
|
|
|
if (error == EINVAL)
|
1996-10-13 04:46:49 +04:00
|
|
|
printf("ultrix select: bad args?\n");
|
1995-12-26 07:22:30 +03:00
|
|
|
|
|
|
|
done:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
1997-01-31 05:20:03 +03:00
|
|
|
#if defined(NFS)
|
1996-04-07 21:23:04 +04:00
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
async_daemon(struct lwp *l, const void *v, register_t *retval)
|
1994-06-02 10:25:37 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sys_nfssvc_args ouap;
|
1994-06-02 10:25:37 +04:00
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
SCARG(&ouap, flag) = NFSSVC_BIOD;
|
|
|
|
SCARG(&ouap, argp) = NULL;
|
1994-06-02 10:25:37 +04:00
|
|
|
|
2007-12-27 20:18:11 +03:00
|
|
|
return sys_nfssvc(l, &ouap, retval);
|
1994-06-22 07:37:15 +04:00
|
|
|
}
|
1997-01-31 05:20:03 +03:00
|
|
|
#endif /* NFS */
|
1994-06-22 07:37:15 +04:00
|
|
|
|
1994-06-02 10:25:37 +04:00
|
|
|
|
|
|
|
#define SUN__MAP_NEW 0x80000000 /* if not, old mmap & cannot handle */
|
|
|
|
|
1996-01-07 16:38:49 +03:00
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
ultrix_sys_mmap(struct lwp *l, const struct ultrix_sys_mmap_args *uap, register_t *retval)
|
1994-06-02 10:25:37 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sys_mmap_args ouap;
|
1994-06-02 10:25:37 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Verify the arguments.
|
|
|
|
*/
|
1995-10-07 09:25:19 +03:00
|
|
|
if (SCARG(uap, prot) & ~(PROT_READ|PROT_WRITE|PROT_EXEC))
|
2007-12-27 20:18:11 +03:00
|
|
|
return EINVAL; /* XXX still needed? */
|
1994-06-02 10:25:37 +04:00
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
if ((SCARG(uap, flags) & SUN__MAP_NEW) == 0)
|
2007-12-27 20:18:11 +03:00
|
|
|
return EINVAL;
|
1994-06-02 10:25:37 +04:00
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
SCARG(&ouap, flags) = SCARG(uap, flags) & ~SUN__MAP_NEW;
|
|
|
|
SCARG(&ouap, addr) = SCARG(uap, addr);
|
|
|
|
SCARG(&ouap, len) = SCARG(uap, len);
|
|
|
|
SCARG(&ouap, prot) = SCARG(uap, prot);
|
|
|
|
SCARG(&ouap, fd) = SCARG(uap, fd);
|
|
|
|
SCARG(&ouap, pos) = SCARG(uap, pos);
|
1994-06-02 10:25:37 +04:00
|
|
|
|
2007-12-27 20:18:11 +03:00
|
|
|
return sys_mmap(l, &ouap, retval);
|
1994-06-02 10:25:37 +04:00
|
|
|
}
|
|
|
|
|
1996-04-07 21:23:04 +04:00
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
ultrix_sys_setsockopt(struct lwp *l, const struct ultrix_sys_setsockopt_args *uap, register_t *retval)
|
1994-06-02 10:25:37 +04:00
|
|
|
{
|
2008-03-22 00:54:58 +03:00
|
|
|
struct socket *so;
|
1994-06-02 10:25:37 +04:00
|
|
|
struct mbuf *m = NULL;
|
|
|
|
int error;
|
2007-12-27 20:18:11 +03:00
|
|
|
struct sys_setsockopt_args ap;
|
|
|
|
|
|
|
|
SCARG(&ap, s) = SCARG(uap, s);
|
|
|
|
SCARG(&ap, level) = SCARG(uap, level);
|
|
|
|
SCARG(&ap, name) = SCARG(uap, name);
|
|
|
|
SCARG(&ap, val) = SCARG(uap, val);
|
|
|
|
SCARG(&ap, valsize) = SCARG(uap, valsize);
|
1994-06-02 10:25:37 +04:00
|
|
|
|
1999-05-06 00:01:01 +04:00
|
|
|
/* getsock() will use the descriptor for us */
|
2008-03-22 00:54:58 +03:00
|
|
|
if ((error = fd_getsock(SCARG(&ap, s), &so)) != 0)
|
2007-12-27 20:18:11 +03:00
|
|
|
return error;
|
1994-06-02 10:25:37 +04:00
|
|
|
#define SO_DONTLINGER (~SO_LINGER)
|
2007-12-27 20:18:11 +03:00
|
|
|
if (SCARG(&ap, name) == SO_DONTLINGER) {
|
1994-06-02 10:25:37 +04:00
|
|
|
m = m_get(M_WAIT, MT_SOOPTS);
|
|
|
|
mtod(m, struct linger *)->l_onoff = 0;
|
|
|
|
m->m_len = sizeof(struct linger);
|
2008-03-22 00:54:58 +03:00
|
|
|
error = sosetopt(so, SCARG(&ap, level), SO_LINGER, m);
|
1994-06-02 10:25:37 +04:00
|
|
|
}
|
2007-12-27 20:18:11 +03:00
|
|
|
if (SCARG(&ap, level) == IPPROTO_IP) {
|
1997-04-07 03:26:52 +04:00
|
|
|
#define EMUL_IP_MULTICAST_IF 2
|
|
|
|
#define EMUL_IP_MULTICAST_TTL 3
|
|
|
|
#define EMUL_IP_MULTICAST_LOOP 4
|
|
|
|
#define EMUL_IP_ADD_MEMBERSHIP 5
|
|
|
|
#define EMUL_IP_DROP_MEMBERSHIP 6
|
2004-04-25 10:02:20 +04:00
|
|
|
static const int ipoptxlat[] = {
|
1997-04-07 03:26:52 +04:00
|
|
|
IP_MULTICAST_IF,
|
|
|
|
IP_MULTICAST_TTL,
|
|
|
|
IP_MULTICAST_LOOP,
|
|
|
|
IP_ADD_MEMBERSHIP,
|
|
|
|
IP_DROP_MEMBERSHIP
|
|
|
|
};
|
2007-12-27 20:18:11 +03:00
|
|
|
if (SCARG(&ap, name) >= EMUL_IP_MULTICAST_IF &&
|
|
|
|
SCARG(&ap, name) <= EMUL_IP_DROP_MEMBERSHIP) {
|
|
|
|
SCARG(&ap, name) =
|
|
|
|
ipoptxlat[SCARG(&ap, name) - EMUL_IP_MULTICAST_IF];
|
1997-04-07 03:26:52 +04:00
|
|
|
}
|
|
|
|
}
|
2007-12-27 20:18:11 +03:00
|
|
|
if (SCARG(&ap, valsize) > MLEN) {
|
1999-05-06 00:01:01 +04:00
|
|
|
error = EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
2007-12-27 20:18:11 +03:00
|
|
|
if (SCARG(&ap, val)) {
|
1994-06-02 10:25:37 +04:00
|
|
|
m = m_get(M_WAIT, MT_SOOPTS);
|
2007-12-27 20:18:11 +03:00
|
|
|
error = copyin(SCARG(&ap, val), mtod(m, void *),
|
|
|
|
(u_int)SCARG(&ap, valsize));
|
1997-04-07 03:26:52 +04:00
|
|
|
if (error) {
|
1994-06-02 10:25:37 +04:00
|
|
|
(void) m_free(m);
|
1999-05-06 00:01:01 +04:00
|
|
|
goto out;
|
1994-06-02 10:25:37 +04:00
|
|
|
}
|
2007-12-27 20:18:11 +03:00
|
|
|
m->m_len = SCARG(&ap, valsize);
|
1994-06-02 10:25:37 +04:00
|
|
|
}
|
2008-03-22 00:54:58 +03:00
|
|
|
error = sosetopt(so, SCARG(&ap, level), SCARG(&ap, name), m);
|
1999-05-06 00:01:01 +04:00
|
|
|
out:
|
2008-03-22 00:54:58 +03:00
|
|
|
fd_putfile(SCARG(uap, s));
|
2007-12-27 20:18:11 +03:00
|
|
|
return error;
|
1994-06-02 10:25:37 +04:00
|
|
|
}
|
|
|
|
|
2000-04-28 16:52:52 +04:00
|
|
|
#define ULTRIX__SYS_NMLN 32
|
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ultrix_utsname {
|
2000-04-28 16:52:52 +04:00
|
|
|
char sysname[ULTRIX__SYS_NMLN];
|
|
|
|
char nodename[ULTRIX__SYS_NMLN];
|
|
|
|
char release[ULTRIX__SYS_NMLN];
|
|
|
|
char version[ULTRIX__SYS_NMLN];
|
|
|
|
char machine[ULTRIX__SYS_NMLN];
|
1994-06-02 10:25:37 +04:00
|
|
|
};
|
|
|
|
|
1996-01-07 16:38:49 +03:00
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
ultrix_sys_uname(struct lwp *l, const struct ultrix_sys_uname_args *uap, register_t *retval)
|
1994-06-02 10:25:37 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ultrix_utsname sut;
|
2000-07-20 12:29:41 +04:00
|
|
|
const char *cp;
|
|
|
|
char *dp, *ep;
|
1994-06-02 10:25:37 +04:00
|
|
|
|
1998-08-10 00:36:58 +04:00
|
|
|
memset(&sut, 0, sizeof(sut));
|
1994-06-02 10:25:37 +04:00
|
|
|
|
2000-04-28 16:52:52 +04:00
|
|
|
strncpy(sut.sysname, ostype, sizeof(sut.sysname) - 1);
|
|
|
|
strncpy(sut.nodename, hostname, sizeof(sut.nodename) - 1);
|
|
|
|
strncpy(sut.release, osrelease, sizeof(sut.release) - 1);
|
2000-07-20 12:29:41 +04:00
|
|
|
dp = sut.version;
|
|
|
|
ep = &sut.version[sizeof(sut.version) - 1];
|
|
|
|
for (cp = version; *cp && *cp != '('; cp++)
|
|
|
|
;
|
|
|
|
for (cp++; *cp && *cp != ')' && dp < ep; cp++)
|
|
|
|
*dp++ = *cp;
|
|
|
|
for (; *cp && *cp != '#'; cp++)
|
|
|
|
;
|
|
|
|
for (; *cp && *cp != ':' && dp < ep; cp++)
|
|
|
|
*dp++ = *cp;
|
|
|
|
*dp = '\0';
|
2000-04-28 16:52:52 +04:00
|
|
|
strncpy(sut.machine, machine, sizeof(sut.machine) - 1);
|
1994-06-02 10:25:37 +04:00
|
|
|
|
2007-12-27 20:18:11 +03:00
|
|
|
return copyout(&sut, SCARG(uap, name), sizeof(sut));
|
1994-06-02 10:25:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
ultrix_sys_setpgrp(struct lwp *l, const struct ultrix_sys_setpgrp_args *uap, register_t *retval)
|
1994-06-02 10:25:37 +04:00
|
|
|
{
|
2003-01-18 11:49:22 +03:00
|
|
|
struct proc *p = l->l_proc;
|
2007-12-27 20:18:11 +03:00
|
|
|
struct sys_setpgid_args ap;
|
1995-09-20 02:49:22 +04:00
|
|
|
|
2007-12-27 20:18:11 +03:00
|
|
|
SCARG(&ap, pid) = SCARG(uap, pid);
|
|
|
|
SCARG(&ap, pgid) = SCARG(uap, pgid);
|
1994-06-02 10:25:37 +04:00
|
|
|
/*
|
|
|
|
* difference to our setpgid call is to include backwards
|
|
|
|
* compatibility to pre-setsid() binaries. Do setsid()
|
|
|
|
* instead of setpgid() in those cases where the process
|
|
|
|
* tries to create a new session the old way.
|
|
|
|
*/
|
2007-12-27 20:18:11 +03:00
|
|
|
if (!SCARG(&ap, pgid) &&
|
|
|
|
(!SCARG(&ap, pid) || SCARG(&ap, pid) == p->p_pid))
|
|
|
|
return sys_setsid(l, &ap, retval);
|
1994-06-02 10:25:37 +04:00
|
|
|
else
|
2007-12-27 20:18:11 +03:00
|
|
|
return sys_setpgid(l, &ap, retval);
|
1994-06-02 10:25:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#if defined (NFSSERVER)
|
1996-01-07 16:38:49 +03:00
|
|
|
int
|
2008-04-24 03:34:11 +04:00
|
|
|
ultrix_sys_nfssvc(struct lwp *l, const struct ultrix_sys_nfssvc_args *uap,
|
|
|
|
register_t *retval)
|
1994-06-02 10:25:37 +04:00
|
|
|
{
|
1996-04-07 21:23:04 +04:00
|
|
|
|
|
|
|
#if 0 /* XXX */
|
1995-10-07 09:25:19 +03:00
|
|
|
struct emul *e = p->p_emul;
|
|
|
|
struct sys_nfssvc_args outuap;
|
1994-06-02 10:25:37 +04:00
|
|
|
struct sockaddr sa;
|
|
|
|
int error;
|
2007-03-04 08:59:00 +03:00
|
|
|
void *sg = stackgap_init(p, 0);
|
1994-06-02 10:25:37 +04:00
|
|
|
|
1998-08-10 00:36:58 +04:00
|
|
|
memset(&outuap, 0, sizeof outuap);
|
1995-10-07 09:25:19 +03:00
|
|
|
SCARG(&outuap, fd) = SCARG(uap, fd);
|
2002-03-17 02:55:57 +03:00
|
|
|
SCARG(&outuap, mskval) = stackgap_alloc(p, &sg, sizeof sa);
|
1995-10-07 09:25:19 +03:00
|
|
|
SCARG(&outuap, msklen) = sizeof sa;
|
2002-03-17 02:55:57 +03:00
|
|
|
SCARG(&outuap, mtchval) = stackgap_alloc(p, &sg, sizeof sa);
|
1995-10-07 09:25:19 +03:00
|
|
|
SCARG(&outuap, mtchlen) = sizeof sa;
|
1994-06-02 10:25:37 +04:00
|
|
|
|
1998-08-10 00:36:58 +04:00
|
|
|
memset(&sa, 0, sizeof sa);
|
1995-10-07 09:25:19 +03:00
|
|
|
if (error = copyout(&sa, SCARG(&outuap, mskval), SCARG(&outuap, msklen)))
|
2007-12-27 20:18:11 +03:00
|
|
|
return error;
|
1995-10-07 09:25:19 +03:00
|
|
|
if (error = copyout(&sa, SCARG(&outuap, mtchval), SCARG(&outuap, mtchlen)))
|
2007-12-27 20:18:11 +03:00
|
|
|
return error;
|
1994-06-02 10:25:37 +04:00
|
|
|
|
2003-01-18 11:49:22 +03:00
|
|
|
return nfssvc(l, &outuap, retval);
|
1995-10-07 09:25:19 +03:00
|
|
|
#else
|
2007-12-27 20:18:11 +03:00
|
|
|
return ENOSYS;
|
1995-10-07 09:25:19 +03:00
|
|
|
#endif
|
1994-06-02 10:25:37 +04:00
|
|
|
}
|
|
|
|
#endif /* NFSSERVER */
|
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ultrix_ustat {
|
1994-06-02 10:25:37 +04:00
|
|
|
daddr_t f_tfree; /* total free */
|
2005-08-19 06:03:49 +04:00
|
|
|
uint32_t f_tinode; /* total inodes free */
|
1994-06-02 10:25:37 +04:00
|
|
|
char f_fname[6]; /* filsys name */
|
|
|
|
char f_fpack[6]; /* filsys pack name */
|
|
|
|
};
|
1995-10-07 09:25:19 +03:00
|
|
|
|
1996-01-07 16:38:49 +03:00
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
ultrix_sys_ustat(struct lwp *l, const struct ultrix_sys_ustat_args *uap, register_t *retval)
|
1994-06-02 10:25:37 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ultrix_ustat us;
|
1994-06-02 10:25:37 +04:00
|
|
|
int error;
|
|
|
|
|
1998-08-10 00:36:58 +04:00
|
|
|
memset(&us, 0, sizeof us);
|
1994-06-02 10:25:37 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX: should set f_tfree and f_tinode at least
|
1995-10-07 09:25:19 +03:00
|
|
|
* How do we translate dev -> fstat? (and then to ultrix_ustat)
|
1994-06-02 10:25:37 +04:00
|
|
|
*/
|
|
|
|
|
1996-04-07 21:23:04 +04:00
|
|
|
if ((error = copyout(&us, SCARG(uap, buf), sizeof us)) != 0)
|
2007-12-27 20:18:11 +03:00
|
|
|
return error;
|
1994-06-02 10:25:37 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1996-01-07 16:38:49 +03:00
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
ultrix_sys_quotactl(struct lwp *l, const struct ultrix_sys_quotactl_args *uap, register_t *retval)
|
1994-06-02 10:25:37 +04:00
|
|
|
{
|
1996-04-07 21:23:04 +04:00
|
|
|
|
1994-06-02 10:25:37 +04:00
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
1996-01-07 16:38:49 +03:00
|
|
|
int
|
2007-12-27 20:18:11 +03:00
|
|
|
ultrix_sys_vhangup(struct lwp *l, const void *uap, register_t *retval)
|
1994-06-02 10:25:37 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
|
1994-06-02 10:25:37 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1997-06-09 15:57:43 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* RISC Ultrix cache control syscalls
|
|
|
|
*/
|
|
|
|
#ifdef __mips
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
ultrix_sys_cacheflush(struct lwp *l, const struct ultrix_sys_cacheflush_args *uap, register_t *retval)
|
1997-06-09 15:57:43 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1997-06-09 15:57:43 +04:00
|
|
|
syscallarg(void *) addr;
|
2004-10-27 23:29:57 +04:00
|
|
|
syscallarg(unsigned) nbytes;
|
1997-06-09 15:57:43 +04:00
|
|
|
syscallarg(int) flag;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
2003-01-18 11:49:22 +03:00
|
|
|
struct proc *p = l->l_proc;
|
2000-03-30 15:24:16 +04:00
|
|
|
vaddr_t va = (vaddr_t)SCARG(uap, addr);
|
|
|
|
int nbytes = SCARG(uap, nbytes);
|
|
|
|
int whichcache = SCARG(uap, whichcache);
|
1997-06-09 15:57:43 +04:00
|
|
|
|
2007-12-27 20:18:11 +03:00
|
|
|
return mips_user_cacheflush(p, va, nbytes, whichcache);
|
1997-06-09 15:57:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
ultrix_sys_cachectl(struct lwp *l, const struct ultrix_sys_cachectl_args *uap, register_t *retval)
|
1997-06-09 15:57:43 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1997-06-09 15:57:43 +04:00
|
|
|
syscallarg(void *) addr;
|
|
|
|
syscallarg(int) nbytes;
|
|
|
|
syscallarg(int) cacheop;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
2003-01-18 11:49:22 +03:00
|
|
|
struct proc *p = l->l_proc;
|
2000-03-30 15:24:16 +04:00
|
|
|
vaddr_t va = (vaddr_t)SCARG(uap, addr);
|
|
|
|
int nbytes = SCARG(uap, nbytes);
|
|
|
|
int cacheop = SCARG(uap, cacheop);
|
1997-06-09 15:57:43 +04:00
|
|
|
|
|
|
|
return mips_user_cachectl(p, va, nbytes, cacheop);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* __mips */
|
|
|
|
|
|
|
|
|
1996-01-07 16:38:49 +03:00
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
ultrix_sys_exportfs(struct lwp *l, const struct ultrix_sys_exportfs_args *uap, register_t *retval)
|
1994-06-02 10:25:37 +04:00
|
|
|
{
|
1995-09-20 02:49:22 +04:00
|
|
|
|
1994-06-02 10:25:37 +04:00
|
|
|
/*
|
|
|
|
* XXX: should perhaps translate into a mount(2)
|
|
|
|
* with MOUNT_EXPORT?
|
|
|
|
*/
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1996-01-04 00:07:33 +03:00
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
ultrix_sys_sigpending(struct lwp *l, const struct ultrix_sys_sigpending_args *uap, register_t *retval)
|
1996-01-04 00:07:33 +03:00
|
|
|
{
|
1998-09-26 19:32:26 +04:00
|
|
|
sigset_t ss;
|
|
|
|
int mask;
|
|
|
|
|
2007-02-10 00:55:00 +03:00
|
|
|
sigpending1(l, &ss);
|
1998-09-26 19:32:26 +04:00
|
|
|
mask = ss.__bits[0];
|
1996-01-04 00:07:33 +03:00
|
|
|
|
2007-12-27 20:18:11 +03:00
|
|
|
return copyout(&mask, SCARG(uap, mask), sizeof(int));
|
1996-01-04 00:07:33 +03:00
|
|
|
}
|
|
|
|
|
1998-09-26 20:24:14 +04:00
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
ultrix_sys_sigreturn(struct lwp *l, const struct ultrix_sys_sigreturn_args *uap, register_t *retval)
|
1998-09-26 20:24:14 +04:00
|
|
|
{
|
1998-10-02 22:53:23 +04:00
|
|
|
/* struct sigcontext13 is close enough to Ultrix */
|
2007-12-27 20:18:11 +03:00
|
|
|
struct compat_13_sys_sigreturn_args ap;
|
|
|
|
|
|
|
|
SCARG(&ap, sigcntxp) = (void *)SCARG(uap, sigcntxp);
|
1998-10-02 22:53:23 +04:00
|
|
|
|
2007-12-27 20:18:11 +03:00
|
|
|
return compat_13_sys_sigreturn(l, &ap, retval);
|
1998-09-26 20:24:14 +04:00
|
|
|
}
|
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
ultrix_sys_sigcleanup(struct lwp *l, const struct ultrix_sys_sigcleanup_args *uap, register_t *retval)
|
1995-06-01 20:38:15 +04:00
|
|
|
{
|
1995-09-20 02:49:22 +04:00
|
|
|
|
1998-10-02 22:53:23 +04:00
|
|
|
/* struct sigcontext13 is close enough to Ultrix */
|
2007-12-27 20:18:11 +03:00
|
|
|
struct compat_13_sys_sigreturn_args ap;
|
1998-10-02 22:53:23 +04:00
|
|
|
|
2007-12-27 20:18:11 +03:00
|
|
|
SCARG(&ap, sigcntxp) = (void *)SCARG(uap, sigcntxp);
|
|
|
|
|
|
|
|
return compat_13_sys_sigreturn(l, &ap, retval);
|
1995-06-01 20:38:15 +04:00
|
|
|
}
|
1996-01-04 00:07:33 +03:00
|
|
|
|
1998-09-26 20:24:14 +04:00
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
ultrix_sys_sigsuspend(struct lwp *l, const struct ultrix_sys_sigsuspend_args *uap, register_t *retval)
|
1998-09-26 20:24:14 +04:00
|
|
|
{
|
|
|
|
int mask = SCARG(uap, mask);
|
|
|
|
sigset_t ss;
|
|
|
|
|
|
|
|
ss.__bits[0] = mask;
|
|
|
|
ss.__bits[1] = 0;
|
|
|
|
ss.__bits[2] = 0;
|
|
|
|
ss.__bits[3] = 0;
|
|
|
|
|
2007-12-27 20:18:11 +03:00
|
|
|
return sigsuspend1(l, &ss);
|
1998-09-26 20:24:14 +04:00
|
|
|
}
|
|
|
|
|
1998-10-03 20:13:20 +04:00
|
|
|
#define ULTRIX_SV_ONSTACK 0x0001 /* take signal on signal stack */
|
|
|
|
#define ULTRIX_SV_INTERRUPT 0x0002 /* do not restart system on signal return */
|
|
|
|
#define ULTRIX_SV_OLDSIG 0x1000 /* Emulate old signal() for POSIX */
|
|
|
|
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
ultrix_sys_sigvec(struct lwp *l, const struct ultrix_sys_sigvec_args *uap, register_t *retval)
|
1998-10-03 20:13:20 +04:00
|
|
|
{
|
|
|
|
struct sigvec nsv, osv;
|
|
|
|
struct sigaction nsa, osa;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
if (SCARG(uap, nsv)) {
|
|
|
|
error = copyin(SCARG(uap, nsv), &nsv, sizeof(nsv));
|
|
|
|
if (error)
|
2007-12-27 20:18:11 +03:00
|
|
|
return error;
|
1998-10-03 20:13:20 +04:00
|
|
|
nsa.sa_handler = nsv.sv_handler;
|
|
|
|
#if 0 /* documentation */
|
|
|
|
/* ONSTACK is identical */
|
|
|
|
nsa.sa_flags = nsv.sv_flags & ULTRIX_SV_ONSTACK;
|
|
|
|
if ((nsv.sv_flags & ULTRIX_SV_OLDSIG)
|
|
|
|
/* old signal() - always restart */
|
|
|
|
|| (!(nsv.sv_flags & ULTRIX_SV_INTERRUPT))
|
|
|
|
/* inverted meaning (same bit) */
|
|
|
|
)
|
|
|
|
nsa.sa_flags |= SA_RESTART;
|
|
|
|
#else /* optimized - assuming ULTRIX_SV_OLDSIG=>!ULTRIX_SV_INTERRUPT */
|
|
|
|
nsa.sa_flags = nsv.sv_flags & ~ULTRIX_SV_OLDSIG;
|
|
|
|
nsa.sa_flags ^= SA_RESTART;
|
|
|
|
#endif
|
|
|
|
native_sigset13_to_sigset(&nsv.sv_mask, &nsa.sa_mask);
|
|
|
|
}
|
2007-02-10 00:55:00 +03:00
|
|
|
error = sigaction1(l, SCARG(uap, signum),
|
2002-07-05 03:32:02 +04:00
|
|
|
SCARG(uap, nsv) ? &nsa : 0, SCARG(uap, osv) ? &osa : 0,
|
|
|
|
NULL, 0);
|
1998-10-03 20:13:20 +04:00
|
|
|
if (error)
|
2007-12-27 20:18:11 +03:00
|
|
|
return error;
|
1998-10-03 20:13:20 +04:00
|
|
|
if (SCARG(uap, osv)) {
|
|
|
|
osv.sv_handler = osa.sa_handler;
|
|
|
|
osv.sv_flags = osa.sa_flags ^ SA_RESTART;
|
|
|
|
osv.sv_flags &= (ULTRIX_SV_ONSTACK | ULTRIX_SV_INTERRUPT);
|
|
|
|
native_sigset_to_sigset13(&osa.sa_mask, &osv.sv_mask);
|
|
|
|
error = copyout(&osv, SCARG(uap, osv), sizeof(osv));
|
|
|
|
if (error)
|
2007-12-27 20:18:11 +03:00
|
|
|
return error;
|
1998-10-03 20:13:20 +04:00
|
|
|
}
|
2007-12-27 20:18:11 +03:00
|
|
|
return 0;
|
1998-10-03 20:13:20 +04:00
|
|
|
}
|
1997-04-07 03:26:52 +04:00
|
|
|
|
1997-05-24 13:53:11 +04:00
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
ultrix_sys_shmsys(struct lwp *l, const struct ultrix_sys_shmsys_args *uap, register_t *retval)
|
1997-04-07 03:26:52 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
#ifdef SYSVSHM
|
|
|
|
/* Ultrix SVSHM weirndess: */
|
|
|
|
struct sys_shmat_args shmat_args;
|
1999-08-25 08:52:06 +04:00
|
|
|
struct compat_14_sys_shmctl_args shmctl_args;
|
1997-04-07 03:26:52 +04:00
|
|
|
struct sys_shmdt_args shmdt_args;
|
|
|
|
struct sys_shmget_args shmget_args;
|
|
|
|
|
|
|
|
|
|
|
|
switch (SCARG(uap, shmop)) {
|
|
|
|
case 0: /* Ultrix shmat() */
|
|
|
|
SCARG(&shmat_args, shmid) = SCARG(uap, a2);
|
|
|
|
SCARG(&shmat_args, shmaddr) = (void *)SCARG(uap, a3);
|
|
|
|
SCARG(&shmat_args, shmflg) = SCARG(uap, a4);
|
2007-12-27 20:18:11 +03:00
|
|
|
return sys_shmat(l, &shmat_args, retval);
|
1997-04-07 03:26:52 +04:00
|
|
|
|
|
|
|
case 1: /* Ultrix shmctl() */
|
|
|
|
SCARG(&shmctl_args, shmid) = SCARG(uap, a2);
|
|
|
|
SCARG(&shmctl_args, cmd) = SCARG(uap, a3);
|
1999-08-25 08:52:06 +04:00
|
|
|
SCARG(&shmctl_args, buf) = (struct shmid_ds14 *)SCARG(uap, a4);
|
2007-12-27 20:18:11 +03:00
|
|
|
return compat_14_sys_shmctl(l, &shmctl_args, retval);
|
1997-04-07 03:26:52 +04:00
|
|
|
|
|
|
|
case 2: /* Ultrix shmdt() */
|
|
|
|
SCARG(&shmat_args, shmaddr) = (void *)SCARG(uap, a2);
|
2007-12-27 20:18:11 +03:00
|
|
|
return sys_shmdt(l, &shmdt_args, retval);
|
1997-04-07 03:26:52 +04:00
|
|
|
|
|
|
|
case 3: /* Ultrix shmget() */
|
|
|
|
SCARG(&shmget_args, key) = SCARG(uap, a2);
|
|
|
|
SCARG(&shmget_args, size) = SCARG(uap, a3);
|
|
|
|
SCARG(&shmget_args, shmflg) = SCARG(uap, a4)
|
|
|
|
& (IPC_CREAT|IPC_EXCL|IPC_NOWAIT);
|
2007-12-27 20:18:11 +03:00
|
|
|
return sys_shmget(l, &shmget_args, retval);
|
1997-04-07 03:26:52 +04:00
|
|
|
|
|
|
|
default:
|
2007-12-27 20:18:11 +03:00
|
|
|
return EINVAL;
|
1997-04-07 03:26:52 +04:00
|
|
|
}
|
1997-04-26 06:00:11 +04:00
|
|
|
#else
|
2007-12-27 20:18:11 +03:00
|
|
|
return EOPNOTSUPP;
|
1997-04-26 06:00:11 +04:00
|
|
|
#endif /* SYSVSHM */
|
1997-04-07 03:26:52 +04:00
|
|
|
}
|
1999-07-30 20:03:49 +04:00
|
|
|
|
|
|
|
static int
|
2004-04-21 11:05:07 +04:00
|
|
|
ultrix_to_bsd_flock(struct ultrix_flock *ufl, struct flock *fl)
|
1999-07-30 20:03:49 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
fl->l_start = ufl->l_start;
|
|
|
|
fl->l_len = ufl->l_len;
|
|
|
|
fl->l_pid = ufl->l_pid;
|
|
|
|
fl->l_whence = ufl->l_whence;
|
|
|
|
|
|
|
|
switch (ufl->l_type) {
|
|
|
|
case ULTRIX_F_RDLCK:
|
|
|
|
fl->l_type = F_RDLCK;
|
|
|
|
break;
|
|
|
|
case ULTRIX_F_WRLCK:
|
|
|
|
fl->l_type = F_WRLCK;
|
|
|
|
break;
|
|
|
|
case ULTRIX_F_UNLCK:
|
|
|
|
fl->l_type = F_UNLCK;
|
|
|
|
break;
|
|
|
|
default:
|
2007-12-27 20:18:11 +03:00
|
|
|
return EINVAL;
|
1999-07-30 20:03:49 +04:00
|
|
|
}
|
|
|
|
|
2007-12-27 20:18:11 +03:00
|
|
|
return 0;
|
1999-07-30 20:03:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-04-21 11:05:07 +04:00
|
|
|
bsd_to_ultrix_flock(struct flock *fl, struct ultrix_flock *ufl)
|
1999-07-30 20:03:49 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
ufl->l_start = fl->l_start;
|
|
|
|
ufl->l_len = fl->l_len;
|
|
|
|
ufl->l_pid = fl->l_pid;
|
|
|
|
ufl->l_whence = fl->l_whence;
|
|
|
|
|
|
|
|
switch (fl->l_type) {
|
|
|
|
case F_RDLCK:
|
|
|
|
ufl->l_type = ULTRIX_F_RDLCK;
|
|
|
|
break;
|
|
|
|
case F_WRLCK:
|
|
|
|
ufl->l_type = ULTRIX_F_WRLCK;
|
|
|
|
break;
|
|
|
|
case F_UNLCK:
|
|
|
|
ufl->l_type = ULTRIX_F_UNLCK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
ultrix_sys_fcntl(struct lwp *l, const struct ultrix_sys_fcntl_args *uap, register_t *retval)
|
1999-07-30 20:03:49 +04:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
struct ultrix_flock ufl;
|
2007-05-13 03:02:49 +04:00
|
|
|
struct flock fl;
|
1999-07-30 20:03:49 +04:00
|
|
|
|
|
|
|
switch (SCARG(uap, cmd)) {
|
|
|
|
case F_GETLK:
|
|
|
|
case F_SETLK:
|
|
|
|
case F_SETLKW:
|
|
|
|
error = copyin(SCARG(uap, arg), &ufl, sizeof(ufl));
|
|
|
|
if (error)
|
2007-12-27 20:18:11 +03:00
|
|
|
return error;
|
1999-07-30 20:03:49 +04:00
|
|
|
error = ultrix_to_bsd_flock(&ufl, &fl);
|
|
|
|
if (error)
|
2007-12-27 20:18:11 +03:00
|
|
|
return error;
|
2008-03-22 00:54:58 +03:00
|
|
|
error = do_fcntl_lock(SCARG(uap, fd), SCARG(uap, cmd), &fl);
|
2007-05-13 03:02:49 +04:00
|
|
|
if (SCARG(uap, cmd) != F_GETLK || error != 0)
|
|
|
|
return error;
|
|
|
|
bsd_to_ultrix_flock(&fl, &ufl);
|
|
|
|
return copyout(&ufl, SCARG(uap, arg), sizeof(ufl));
|
1999-07-30 20:03:49 +04:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-12-21 02:02:38 +03:00
|
|
|
return sys_fcntl(l, (const void *)uap, retval);
|
1999-07-30 20:03:49 +04:00
|
|
|
}
|