1996-10-19 16:40:31 +04:00
|
|
|
/* $NetBSD: ultrix_misc.c,v 1.28 1996/10/19 12:40:31 jonathan Exp $ */
|
1996-04-07 21:23:04 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1995
|
|
|
|
* Jonathan Stone (hereinafter referred to as the author)
|
|
|
|
*
|
|
|
|
* 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:
|
|
|
|
* This product includes software developed by Matthew R. Green for
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SunOS compatibility module.
|
|
|
|
*
|
|
|
|
* SunOS system calls that are implemented differently in BSD are
|
|
|
|
* handled here.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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>
|
1996-01-07 16:38:49 +03:00
|
|
|
/*#include <sys/stat.h>*/
|
|
|
|
/*#include <sys/ioctl.h>*/
|
1994-06-02 10:25:37 +04:00
|
|
|
#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>
|
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>
|
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>
|
|
|
|
|
1994-06-02 10:25:37 +04:00
|
|
|
#include <vm/vm.h>
|
|
|
|
|
1996-04-07 21:23:04 +04:00
|
|
|
#include <sys/conf.h> /* iszerodev() */
|
|
|
|
#include <sys/socketvar.h> /* sosetopt() */
|
|
|
|
|
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
|
|
|
|
|
|
|
/*
|
|
|
|
* Select the appropriate setregs callback for the target architecture.
|
|
|
|
*/
|
|
|
|
#ifdef mips
|
|
|
|
#define ULTRIX_EXEC_SETREGS cpu_exec_ecoff_setregs
|
|
|
|
#endif /* mips */
|
|
|
|
|
|
|
|
#ifdef vax
|
|
|
|
#define ULTRIX_EXEC_SETREGS setregs
|
|
|
|
#endif /* mips */
|
|
|
|
|
|
|
|
|
|
|
|
extern void ULTRIX_EXEC_SETREGS __P((struct proc *, struct exec_package *,
|
1995-04-22 23:48:19 +04:00
|
|
|
u_long, register_t *));
|
1996-01-04 00:07:33 +03:00
|
|
|
extern char sigcode[], esigcode[];
|
|
|
|
|
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,
|
1996-01-04 00:07:33 +03:00
|
|
|
sigcode,
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
#if defined(NFSCLIENT)
|
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
|
|
|
}
|
|
|
|
#endif /* NFSCLIENT */
|
|
|
|
|
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)
|
1994-06-02 10:25:37 +04:00
|
|
|
register 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
|
|
|
register struct ultrix_sys_mmap_args *uap = v;
|
|
|
|
struct sys_mmap_args ouap;
|
1994-06-02 10:25:37 +04:00
|
|
|
register struct filedesc *fdp;
|
|
|
|
register struct file *fp;
|
|
|
|
register struct vnode *vp;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 &&
|
|
|
|
SCARG(&ouap, addr) < (caddr_t)round_page(p->p_vmspace->vm_daddr+MAXDSIZ))
|
|
|
|
SCARG(&ouap, addr) = (caddr_t)round_page(p->p_vmspace->vm_daddr+MAXDSIZ);
|
|
|
|
|
|
|
|
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
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
register struct ultrix_sys_setsockopt_args *uap = v;
|
1994-06-02 10:25:37 +04:00
|
|
|
struct file *fp;
|
|
|
|
struct mbuf *m = NULL;
|
|
|
|
int error;
|
|
|
|
|
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);
|
1995-10-07 09:25:19 +03:00
|
|
|
return (sosetopt((struct socket *)fp->f_data, SCARG(uap, level),
|
1994-06-02 10:25:37 +04:00
|
|
|
SO_LINGER, m));
|
|
|
|
}
|
1995-10-07 09:25:19 +03:00
|
|
|
if (SCARG(uap, valsize) > MLEN)
|
1994-06-02 10:25:37 +04:00
|
|
|
return (EINVAL);
|
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);
|
1996-04-07 21:23:04 +04:00
|
|
|
if ((error = copyin(SCARG(uap, val), mtod(m, caddr_t),
|
|
|
|
(u_int)SCARG(uap, valsize))) != 0) {
|
1994-06-02 10:25:37 +04:00
|
|
|
(void) m_free(m);
|
|
|
|
return (error);
|
|
|
|
}
|
1995-10-07 09:25:19 +03:00
|
|
|
m->m_len = SCARG(uap, valsize);
|
1994-06-02 10:25:37 +04:00
|
|
|
}
|
1995-10-07 09:25:19 +03:00
|
|
|
return (sosetopt((struct socket *)fp->f_data, SCARG(uap, level),
|
|
|
|
SCARG(uap, name), m));
|
1994-06-02 10:25:37 +04:00
|
|
|
}
|
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ultrix_utsname {
|
1994-06-02 10:25:37 +04:00
|
|
|
char sysname[9];
|
|
|
|
char nodename[9];
|
|
|
|
char nodeext[65-9];
|
|
|
|
char release[9];
|
|
|
|
char version[9];
|
|
|
|
char machine[9];
|
|
|
|
};
|
|
|
|
|
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;
|
1994-06-02 10:25:37 +04:00
|
|
|
extern char ostype[], machine[], osrelease[];
|
|
|
|
|
|
|
|
bzero(&sut, sizeof(sut));
|
|
|
|
|
|
|
|
bcopy(ostype, sut.sysname, sizeof(sut.sysname) - 1);
|
|
|
|
bcopy(hostname, sut.nodename, sizeof(sut.nodename));
|
|
|
|
sut.nodename[sizeof(sut.nodename)-1] = '\0';
|
|
|
|
bcopy(osrelease, sut.release, sizeof(sut.release) - 1);
|
|
|
|
bcopy("1", sut.version, sizeof(sut.version) - 1);
|
|
|
|
bcopy(machine, sut.machine, sizeof(sut.machine) - 1);
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
bzero(&outuap, 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
|
|
|
|
|
|
|
bzero(&sa, 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;
|
|
|
|
|
|
|
|
bzero(&us, sizeof us);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
int mask = p->p_siglist & p->p_sigmask;
|
|
|
|
|
|
|
|
return (copyout((caddr_t)&mask, (caddr_t)SCARG(uap, mask), sizeof(int)));
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_sigreturn(p, (struct sys_sigreturn_args *)uap, retval);
|
1995-06-01 20:38:15 +04:00
|
|
|
}
|
1996-01-04 00:07:33 +03:00
|
|
|
|
|
|
|
int
|
|
|
|
ultrix_sys_sigreturn(p, v, retval)
|
|
|
|
struct proc *p;
|
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct ultrix_sys_sigcleanup_args *uap = v;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
1996-10-13 04:46:49 +04:00
|
|
|
printf("ultrix sigreturn\n");
|
1996-01-04 00:07:33 +03:00
|
|
|
#endif
|
|
|
|
return sys_sigreturn(p, (struct sys_sigreturn_args *)uap, retval);
|
|
|
|
}
|