2000-04-28 16:52:52 +04:00
|
|
|
/* $NetBSD: ultrix_misc.c,v 1.57 2000/04/28 12:52:52 simonb 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.
|
|
|
|
* 3. 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, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
* from: Header: sun_misc.c,v 1.16 93/04/07 02:46:27 torek Exp
|
|
|
|
*/
|
|
|
|
|
1998-07-04 00:03:04 +04:00
|
|
|
#include "opt_nfsserver.h"
|
1998-10-20 02:43:58 +04:00
|
|
|
#include "opt_sysv.h"
|
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.
|
|
|
|
*/
|
|
|
|
|
1998-02-19 03:46:02 +03:00
|
|
|
#include "fs_nfs.h"
|
|
|
|
|
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>
|
|
|
|
|
|
|
|
#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>
|
|
|
|
|
1997-06-09 15:57:43 +04:00
|
|
|
#include <vm/vm.h> /* pmap declarations */
|
1994-06-02 10:25:37 +04:00
|
|
|
|
1996-04-07 21:23:04 +04:00
|
|
|
#include <sys/conf.h> /* iszerodev() */
|
|
|
|
#include <sys/socketvar.h> /* sosetopt() */
|
|
|
|
|
1999-07-30 20:03:49 +04:00
|
|
|
#include <compat/ultrix/ultrix_flock.h>
|
|
|
|
|
|
|
|
static int ultrix_to_bsd_flock __P((struct ultrix_flock *, struct flock *));
|
|
|
|
static void bsd_to_ultrix_flock __P((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[];
|
|
|
|
extern char *ultrix_syscallnames[];
|
1996-04-07 20:38:03 +04:00
|
|
|
|
1997-06-09 15:57:43 +04:00
|
|
|
|
1996-04-07 20:38:03 +04:00
|
|
|
/*
|
|
|
|
* Select the appropriate setregs callback for the target architecture.
|
|
|
|
*/
|
1998-10-20 05:46:27 +04:00
|
|
|
#ifdef __mips__
|
1997-05-24 14:26:30 +04:00
|
|
|
#include <machine/ecoff_machdep.h>
|
1996-04-07 20:38:03 +04:00
|
|
|
#define ULTRIX_EXEC_SETREGS cpu_exec_ecoff_setregs
|
|
|
|
#endif /* mips */
|
|
|
|
|
1998-10-20 05:46:27 +04:00
|
|
|
#ifdef __vax__
|
1996-04-07 20:38:03 +04:00
|
|
|
#define ULTRIX_EXEC_SETREGS setregs
|
1998-10-20 05:46:27 +04:00
|
|
|
#endif /* vax */
|
1996-04-07 20:38:03 +04:00
|
|
|
|
|
|
|
|
|
|
|
extern void ULTRIX_EXEC_SETREGS __P((struct proc *, struct exec_package *,
|
1997-09-24 06:13:11 +04:00
|
|
|
u_long));
|
1998-10-02 22:53:23 +04:00
|
|
|
extern char ultrix_sigcode[], ultrix_esigcode[];
|
1996-01-04 00:07:33 +03:00
|
|
|
|
1995-04-22 23:48:19 +04:00
|
|
|
struct emul emul_ultrix = {
|
|
|
|
"ultrix",
|
|
|
|
NULL,
|
|
|
|
sendsig,
|
|
|
|
ULTRIX_SYS_syscall,
|
|
|
|
ULTRIX_SYS_MAXSYSCALL,
|
|
|
|
ultrix_sysent,
|
|
|
|
ultrix_syscallnames,
|
|
|
|
0,
|
|
|
|
copyargs,
|
1996-04-07 20:38:03 +04:00
|
|
|
ULTRIX_EXEC_SETREGS,
|
1998-10-02 22:53:23 +04:00
|
|
|
ultrix_sigcode,
|
|
|
|
ultrix_esigcode,
|
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
|
1995-10-07 09:25:19 +03:00
|
|
|
ultrix_sys_getsysinfo(p, v, retval)
|
1994-08-01 18:15:06 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:49:22 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-08-01 18:15:06 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ultrix_sys_getsysinfo_args *uap = v;
|
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;
|
1995-10-07 09:25:19 +03:00
|
|
|
return (copyout(&progenv, SCARG(uap, buffer), sizeof(short)));
|
1994-08-01 18:15:06 +04:00
|
|
|
default:
|
|
|
|
*retval = 0; /* info unavail */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-04-07 21:23:04 +04:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ultrix_sys_setsysinfo(p, v, retval)
|
1994-08-01 18:15:06 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:49:22 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-08-01 18:15:06 +04:00
|
|
|
{
|
1996-04-07 21:23:04 +04:00
|
|
|
|
|
|
|
#ifdef notyet
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ultrix_sys_setsysinfo_args *uap = v;
|
1996-04-07 21:23:04 +04:00
|
|
|
#endif
|
|
|
|
|
1994-08-01 18:15:06 +04:00
|
|
|
*retval = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1996-04-07 21:23:04 +04:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ultrix_sys_waitpid(p, v, retval)
|
1994-06-02 10:25:37 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:49:22 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1994-06-02 10:25:37 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ultrix_sys_waitpid_args *uap = v;
|
|
|
|
struct sys_wait4_args ua;
|
1994-06-02 10:25:37 +04:00
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
SCARG(&ua, pid) = SCARG(uap, pid);
|
|
|
|
SCARG(&ua, status) = SCARG(uap, status);
|
|
|
|
SCARG(&ua, options) = SCARG(uap, options);
|
|
|
|
SCARG(&ua, rusage) = 0;
|
1994-06-02 10:25:37 +04:00
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
return (sys_wait4(p, &ua, retval));
|
1994-06-15 09:18:01 +04:00
|
|
|
}
|
|
|
|
|
1996-04-07 21:23:04 +04:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ultrix_sys_wait3(p, v, retval)
|
1994-06-15 09:18:01 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:49:22 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1994-06-15 09:18:01 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ultrix_sys_wait3_args *uap = v;
|
|
|
|
struct sys_wait4_args ua;
|
1994-06-15 09:18:01 +04:00
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
SCARG(&ua, pid) = -1;
|
|
|
|
SCARG(&ua, status) = SCARG(uap, status);
|
|
|
|
SCARG(&ua, options) = SCARG(uap, options);
|
|
|
|
SCARG(&ua, rusage) = SCARG(uap, rusage);
|
1994-06-15 09:18:01 +04:00
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
return (sys_wait4(p, &ua, 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.
|
1996-04-07 21:23:04 +04:00
|
|
|
* Since we can't have more than the (native) FD_MAX descriptors open,
|
|
|
|
* limit nfds to at most FD_MAX.
|
1996-01-07 16:38:49 +03:00
|
|
|
*/
|
1996-04-07 21:23:04 +04:00
|
|
|
int
|
1995-12-26 07:22:30 +03:00
|
|
|
ultrix_sys_select(p, v, retval)
|
|
|
|
struct proc *p;
|
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct sys_select_args *uap = v;
|
1996-04-07 21:23:04 +04:00
|
|
|
struct timeval atv;
|
1995-12-26 07:22:30 +03:00
|
|
|
int error;
|
|
|
|
|
|
|
|
/* Limit number of FDs selected on to the native maximum */
|
|
|
|
|
|
|
|
if (SCARG(uap, nd) > FD_SETSIZE)
|
|
|
|
SCARG(uap, nd) = FD_SETSIZE;
|
|
|
|
|
|
|
|
/* Check for negative timeval */
|
|
|
|
if (SCARG(uap, tv)) {
|
|
|
|
error = copyin((caddr_t)SCARG(uap, tv), (caddr_t)&atv,
|
|
|
|
sizeof(atv));
|
|
|
|
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
|
|
|
/*tvp = (timeval *)STACKGAPBASE;*/
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
error = sys_select(p, (void*) uap, retval);
|
|
|
|
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
|
1995-10-07 09:25:19 +03:00
|
|
|
async_daemon(p, v, retval)
|
1994-06-02 10:25:37 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:49:22 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
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
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
return (sys_nfssvc(p, &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
|
1995-10-07 09:25:19 +03:00
|
|
|
ultrix_sys_mmap(p, v, retval)
|
2000-03-30 15:24:16 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:49:22 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1994-06-02 10:25:37 +04:00
|
|
|
{
|
2000-03-30 15:24:16 +04:00
|
|
|
struct ultrix_sys_mmap_args *uap = v;
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sys_mmap_args ouap;
|
2000-03-30 15:24:16 +04:00
|
|
|
struct filedesc *fdp;
|
|
|
|
struct file *fp;
|
|
|
|
struct vnode *vp;
|
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))
|
1994-06-02 10:25:37 +04:00
|
|
|
return (EINVAL); /* XXX still needed? */
|
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
if ((SCARG(uap, flags) & SUN__MAP_NEW) == 0)
|
1994-06-02 10:25:37 +04:00
|
|
|
return (EINVAL);
|
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
SCARG(&ouap, flags) = SCARG(uap, flags) & ~SUN__MAP_NEW;
|
|
|
|
SCARG(&ouap, addr) = SCARG(uap, addr);
|
|
|
|
|
|
|
|
if ((SCARG(&ouap, flags) & MAP_FIXED) == 0 &&
|
|
|
|
SCARG(&ouap, addr) != 0 &&
|
2000-03-27 00:42:21 +04:00
|
|
|
SCARG(&ouap, addr) < (void *)round_page((vaddr_t)p->p_vmspace->vm_daddr+MAXDSIZ))
|
|
|
|
SCARG(&ouap, addr) = (void *)round_page((vaddr_t)p->p_vmspace->vm_daddr+MAXDSIZ);
|
1995-10-07 09:25:19 +03:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
/*
|
|
|
|
* Special case: if fd refers to /dev/zero, map as MAP_ANON. (XXX)
|
|
|
|
*/
|
|
|
|
fdp = p->p_fd;
|
1995-10-07 09:25:19 +03:00
|
|
|
if ((unsigned)SCARG(&ouap, fd) < fdp->fd_nfiles && /*XXX*/
|
|
|
|
(fp = fdp->fd_ofiles[SCARG(&ouap, fd)]) != NULL && /*XXX*/
|
1994-06-02 10:25:37 +04:00
|
|
|
fp->f_type == DTYPE_VNODE && /*XXX*/
|
|
|
|
(vp = (struct vnode *)fp->f_data)->v_type == VCHR && /*XXX*/
|
|
|
|
iszerodev(vp->v_rdev)) { /*XXX*/
|
1995-10-07 09:25:19 +03:00
|
|
|
SCARG(&ouap, flags) |= MAP_ANON;
|
|
|
|
SCARG(&ouap, fd) = -1;
|
1994-06-02 10:25:37 +04:00
|
|
|
}
|
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
return (sys_mmap(p, &ouap, retval));
|
1994-06-02 10:25:37 +04:00
|
|
|
}
|
|
|
|
|
1996-04-07 21:23:04 +04:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ultrix_sys_setsockopt(p, v, retval)
|
1994-06-02 10:25:37 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:49:22 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1994-06-02 10:25:37 +04:00
|
|
|
{
|
2000-03-30 15:24:16 +04:00
|
|
|
struct ultrix_sys_setsockopt_args *uap = v;
|
1994-06-02 10:25:37 +04:00
|
|
|
struct file *fp;
|
|
|
|
struct mbuf *m = NULL;
|
|
|
|
int error;
|
|
|
|
|
1999-05-06 00:01:01 +04:00
|
|
|
/* getsock() will use the descriptor for us */
|
1996-04-07 21:23:04 +04:00
|
|
|
if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0)
|
1994-06-02 10:25:37 +04:00
|
|
|
return (error);
|
|
|
|
#define SO_DONTLINGER (~SO_LINGER)
|
1995-10-07 09:25:19 +03:00
|
|
|
if (SCARG(uap, 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);
|
1999-05-06 00:01:01 +04:00
|
|
|
error = sosetopt((struct socket *)fp->f_data, SCARG(uap, level),
|
|
|
|
SO_LINGER, m);
|
1994-06-02 10:25:37 +04:00
|
|
|
}
|
1997-04-07 03:26:52 +04:00
|
|
|
if (SCARG(uap, level) == IPPROTO_IP) {
|
|
|
|
#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
|
|
|
|
static int ipoptxlat[] = {
|
|
|
|
IP_MULTICAST_IF,
|
|
|
|
IP_MULTICAST_TTL,
|
|
|
|
IP_MULTICAST_LOOP,
|
|
|
|
IP_ADD_MEMBERSHIP,
|
|
|
|
IP_DROP_MEMBERSHIP
|
|
|
|
};
|
|
|
|
if (SCARG(uap, name) >= EMUL_IP_MULTICAST_IF &&
|
|
|
|
SCARG(uap, name) <= EMUL_IP_DROP_MEMBERSHIP) {
|
|
|
|
SCARG(uap, name) =
|
|
|
|
ipoptxlat[SCARG(uap, name) - EMUL_IP_MULTICAST_IF];
|
|
|
|
}
|
|
|
|
}
|
1999-05-06 00:01:01 +04:00
|
|
|
if (SCARG(uap, valsize) > MLEN) {
|
|
|
|
error = EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
1995-10-07 09:25:19 +03:00
|
|
|
if (SCARG(uap, val)) {
|
1994-06-02 10:25:37 +04:00
|
|
|
m = m_get(M_WAIT, MT_SOOPTS);
|
1997-04-07 03:26:52 +04:00
|
|
|
error = copyin(SCARG(uap, val), mtod(m, caddr_t),
|
|
|
|
(u_int)SCARG(uap, valsize));
|
|
|
|
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
|
|
|
}
|
1995-10-07 09:25:19 +03:00
|
|
|
m->m_len = SCARG(uap, valsize);
|
1994-06-02 10:25:37 +04:00
|
|
|
}
|
1999-05-06 00:01:01 +04:00
|
|
|
error = sosetopt((struct socket *)fp->f_data, SCARG(uap, level),
|
|
|
|
SCARG(uap, name), m);
|
|
|
|
out:
|
|
|
|
FILE_UNUSE(fp, p);
|
|
|
|
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
|
1995-10-07 09:25:19 +03:00
|
|
|
ultrix_sys_uname(p, v, retval)
|
1994-06-02 10:25:37 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:49:22 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1994-06-02 10:25:37 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ultrix_sys_uname_args *uap = v;
|
|
|
|
struct ultrix_utsname sut;
|
2000-04-28 16:52:52 +04:00
|
|
|
char *cp, *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);
|
|
|
|
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';
|
|
|
|
strncpy(sut.machine, machine, sizeof(sut.machine) - 1);
|
1994-06-02 10:25:37 +04:00
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
return copyout((caddr_t)&sut, (caddr_t)SCARG(uap, name),
|
|
|
|
sizeof(struct ultrix_utsname));
|
1994-06-02 10:25:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ultrix_sys_setpgrp(p, v, retval)
|
1994-06-02 10:25:37 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:49:22 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1994-06-02 10:25:37 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ultrix_sys_setpgrp_args *uap = v;
|
1995-09-20 02:49:22 +04:00
|
|
|
|
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.
|
|
|
|
*/
|
1995-10-07 09:25:19 +03:00
|
|
|
if (!SCARG(uap, pgid) &&
|
|
|
|
(!SCARG(uap, pid) || SCARG(uap, pid) == p->p_pid))
|
|
|
|
return sys_setsid(p, uap, retval);
|
1994-06-02 10:25:37 +04:00
|
|
|
else
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_setpgid(p, uap, retval);
|
1994-06-02 10:25:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#if defined (NFSSERVER)
|
1996-01-07 16:38:49 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ultrix_sys_nfssvc(p, v, retval)
|
1994-06-02 10:25:37 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:49:22 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
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 ultrix_sys_nfssvc_args *uap = v;
|
|
|
|
struct emul *e = p->p_emul;
|
|
|
|
struct sys_nfssvc_args outuap;
|
1994-06-02 10:25:37 +04:00
|
|
|
struct sockaddr sa;
|
|
|
|
int error;
|
|
|
|
|
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);
|
|
|
|
SCARG(&outuap, mskval) = STACKGAPBASE;
|
|
|
|
SCARG(&outuap, msklen) = sizeof sa;
|
|
|
|
SCARG(&outuap, mtchval) = outuap.mskval + sizeof sa;
|
|
|
|
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)))
|
1994-06-02 10:25:37 +04:00
|
|
|
return (error);
|
1995-10-07 09:25:19 +03:00
|
|
|
if (error = copyout(&sa, SCARG(&outuap, mtchval), SCARG(&outuap, mtchlen)))
|
1994-06-02 10:25:37 +04:00
|
|
|
return (error);
|
|
|
|
|
|
|
|
return nfssvc(p, &outuap, retval);
|
1995-10-07 09:25:19 +03:00
|
|
|
#else
|
|
|
|
return (ENOSYS);
|
|
|
|
#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 */
|
|
|
|
ino_t f_tinode; /* total inodes free */
|
|
|
|
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
|
1995-10-07 09:25:19 +03:00
|
|
|
ultrix_sys_ustat(p, v, retval)
|
1994-06-02 10:25:37 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:49:22 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1994-06-02 10:25:37 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ultrix_sys_ustat_args *uap = v;
|
|
|
|
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)
|
1994-06-02 10:25:37 +04:00
|
|
|
return (error);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1996-01-07 16:38:49 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ultrix_sys_quotactl(p, v, retval)
|
1994-06-02 10:25:37 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:49:22 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1994-06-02 10:25:37 +04:00
|
|
|
{
|
1996-04-07 21:23:04 +04:00
|
|
|
|
|
|
|
#ifdef notyet
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ultrix_sys_quotactl_args *uap = v;
|
1996-04-07 21:23:04 +04:00
|
|
|
#endif
|
1995-09-20 02:49:22 +04:00
|
|
|
|
1994-06-02 10:25:37 +04:00
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
1996-01-07 16:38:49 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ultrix_sys_vhangup(p, v, retval)
|
1994-06-02 10:25:37 +04:00
|
|
|
struct proc *p;
|
1995-10-07 09:25:19 +03:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
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
|
|
|
|
ultrix_sys_cacheflush(p, v, retval)
|
2000-03-30 15:24:16 +04:00
|
|
|
struct proc *p;
|
1997-06-09 15:57:43 +04:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
2000-03-30 15:24:16 +04:00
|
|
|
struct ultrix_sys_cacheflush_args /* {
|
1997-06-09 15:57:43 +04:00
|
|
|
syscallarg(void *) addr;
|
|
|
|
syscallarg(int) nbytes;
|
|
|
|
syscallarg(int) flag;
|
|
|
|
} */ *uap = v;
|
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
|
|
|
|
|
|
|
return (mips_user_cacheflush(p, va, nbytes, whichcache));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
ultrix_sys_cachectl(p, v, retval)
|
2000-03-30 15:24:16 +04:00
|
|
|
struct proc *p;
|
1997-06-09 15:57:43 +04:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
2000-03-30 15:24:16 +04:00
|
|
|
struct ultrix_sys_cachectl_args /* {
|
1997-06-09 15:57:43 +04:00
|
|
|
syscallarg(void *) addr;
|
|
|
|
syscallarg(int) nbytes;
|
|
|
|
syscallarg(int) cacheop;
|
|
|
|
} */ *uap = v;
|
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
|
1995-10-07 09:25:19 +03:00
|
|
|
ultrix_sys_exportfs(p, v, retval)
|
1994-06-02 10:25:37 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:49:22 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1994-06-02 10:25:37 +04:00
|
|
|
{
|
1996-04-07 21:23:04 +04:00
|
|
|
#ifdef notyet
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ultrix_sys_exportfs_args *uap = v;
|
1996-04-07 21:23:04 +04:00
|
|
|
#endif
|
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
|
|
|
|
ultrix_sys_sigpending(p, v, retval)
|
|
|
|
struct proc *p;
|
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct ultrix_sys_sigpending_args *uap = v;
|
1998-09-26 19:32:26 +04:00
|
|
|
sigset_t ss;
|
|
|
|
int mask;
|
|
|
|
|
|
|
|
sigpending1(p, &ss);
|
|
|
|
mask = ss.__bits[0];
|
1996-01-04 00:07:33 +03:00
|
|
|
|
|
|
|
return (copyout((caddr_t)&mask, (caddr_t)SCARG(uap, mask), sizeof(int)));
|
|
|
|
}
|
|
|
|
|
1998-09-26 20:24:14 +04:00
|
|
|
int
|
|
|
|
ultrix_sys_sigreturn(p, v, retval)
|
|
|
|
struct proc *p;
|
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct ultrix_sys_sigreturn_args *uap = v;
|
|
|
|
|
1998-10-02 22:53:23 +04:00
|
|
|
/* struct sigcontext13 is close enough to Ultrix */
|
|
|
|
|
|
|
|
return (compat_13_sys_sigreturn(p, uap, retval));
|
1998-09-26 20:24:14 +04:00
|
|
|
}
|
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
int
|
|
|
|
ultrix_sys_sigcleanup(p, v, retval)
|
1995-06-01 20:38:15 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:49:22 +04:00
|
|
|
void *v;
|
1995-06-01 20:38:15 +04:00
|
|
|
register_t *retval;
|
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ultrix_sys_sigcleanup_args *uap = v;
|
1995-09-20 02:49:22 +04:00
|
|
|
|
1998-10-02 22:53:23 +04:00
|
|
|
/* struct sigcontext13 is close enough to Ultrix */
|
|
|
|
|
|
|
|
return (compat_13_sys_sigreturn(p, uap, 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
|
|
|
|
ultrix_sys_sigsuspend(p, v, retval)
|
|
|
|
struct proc *p;
|
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct ultrix_sys_sigsuspend_args *uap = v;
|
|
|
|
int mask = SCARG(uap, mask);
|
|
|
|
sigset_t ss;
|
|
|
|
|
|
|
|
ss.__bits[0] = mask;
|
|
|
|
ss.__bits[1] = 0;
|
|
|
|
ss.__bits[2] = 0;
|
|
|
|
ss.__bits[3] = 0;
|
|
|
|
|
|
|
|
return (sigsuspend1(p, &ss));
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
ultrix_sys_sigvec(p, v, retval)
|
|
|
|
struct proc *p;
|
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct ultrix_sys_sigvec_args *uap = v;
|
|
|
|
struct sigvec nsv, osv;
|
|
|
|
struct sigaction nsa, osa;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
if (SCARG(uap, nsv)) {
|
|
|
|
error = copyin(SCARG(uap, nsv), &nsv, sizeof(nsv));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
error = sigaction1(p, SCARG(uap, signum),
|
|
|
|
SCARG(uap, nsv) ? &nsa : 0, SCARG(uap, osv) ? &osa : 0);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
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)
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
1997-04-07 03:26:52 +04:00
|
|
|
|
1997-05-24 13:53:11 +04:00
|
|
|
int
|
1997-04-07 03:26:52 +04:00
|
|
|
ultrix_sys_shmsys(p, v, retval)
|
|
|
|
struct proc *p;
|
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifdef SYSVSHM
|
|
|
|
|
|
|
|
/* Ultrix SVSHM weirndess: */
|
|
|
|
struct ultrix_sys_shmsys_args *uap = v;
|
|
|
|
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);
|
|
|
|
return (sys_shmat(p, &shmat_args, retval));
|
|
|
|
|
|
|
|
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);
|
|
|
|
return (compat_14_sys_shmctl(p, &shmctl_args, retval));
|
1997-04-07 03:26:52 +04:00
|
|
|
|
|
|
|
case 2: /* Ultrix shmdt() */
|
|
|
|
SCARG(&shmat_args, shmaddr) = (void *)SCARG(uap, a2);
|
|
|
|
return (sys_shmdt(p, &shmdt_args, retval));
|
|
|
|
|
|
|
|
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);
|
|
|
|
return (sys_shmget(p, &shmget_args, retval));
|
|
|
|
|
|
|
|
default:
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
1997-04-26 06:00:11 +04:00
|
|
|
#else
|
1997-04-07 03:26:52 +04: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
|
|
|
|
ultrix_to_bsd_flock(ufl, fl)
|
|
|
|
struct ultrix_flock *ufl;
|
|
|
|
struct flock *fl;
|
|
|
|
{
|
|
|
|
|
|
|
|
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:
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
bsd_to_ultrix_flock(fl, ufl)
|
|
|
|
struct flock *fl;
|
|
|
|
struct ultrix_flock *ufl;
|
|
|
|
{
|
|
|
|
|
|
|
|
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
|
|
|
|
ultrix_sys_fcntl(p, v, retval)
|
|
|
|
struct proc *p;
|
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct ultrix_sys_fcntl_args *uap = v;
|
|
|
|
int error;
|
|
|
|
struct ultrix_flock ufl;
|
|
|
|
struct flock fl, *flp;
|
|
|
|
caddr_t sg;
|
|
|
|
struct sys_fcntl_args *args, fca;
|
|
|
|
|
|
|
|
switch (SCARG(uap, cmd)) {
|
|
|
|
case F_GETLK:
|
|
|
|
case F_SETLK:
|
|
|
|
case F_SETLKW:
|
|
|
|
error = copyin(SCARG(uap, arg), &ufl, sizeof(ufl));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
error = ultrix_to_bsd_flock(&ufl, &fl);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
sg = stackgap_init(p->p_emul);
|
|
|
|
flp = (struct flock *)stackgap_alloc(&sg, sizeof(*flp));
|
|
|
|
error = copyout(&fl, flp, sizeof(*flp));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
SCARG(&fca, fd) = SCARG(uap, fd);
|
|
|
|
SCARG(&fca, cmd) = SCARG(uap, cmd);
|
|
|
|
SCARG(&fca, arg) = flp;
|
|
|
|
args = &fca;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
args = v;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = sys_fcntl(p, args, retval);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
switch (SCARG(uap, cmd)) {
|
|
|
|
case F_GETLK:
|
|
|
|
error = copyin(flp, &fl, sizeof(fl));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
bsd_to_ultrix_flock(&fl, &ufl);
|
|
|
|
error = copyout(&ufl, SCARG(uap, arg), sizeof(ufl));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|