1997-10-19 22:48:00 +04:00
|
|
|
/* $NetBSD: sunos_misc.c,v 1.85 1997/10/19 18:48:00 christos Exp $ */
|
1994-06-29 10:29:24 +04:00
|
|
|
|
1993-10-02 13:22:00 +03: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-10-26 02:03:22 +03:00
|
|
|
* @(#)sunos_misc.c 8.1 (Berkeley) 6/18/93
|
1993-10-02 13:22:00 +03:00
|
|
|
*
|
1994-10-26 02:03:22 +03:00
|
|
|
* Header: sunos_misc.c,v 1.16 93/04/07 02:46:27 torek Exp
|
1993-10-02 13:22:00 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SunOS compatibility module.
|
|
|
|
*
|
|
|
|
* SunOS system calls that are implemented differently in BSD are
|
|
|
|
* handled here.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
1993-12-12 23:43:18 +03:00
|
|
|
#include <sys/namei.h>
|
1993-10-02 13:22:00 +03:00
|
|
|
#include <sys/proc.h>
|
1996-02-28 04:41:25 +03:00
|
|
|
#include <sys/dirent.h>
|
1993-10-02 13:22:00 +03:00
|
|
|
#include <sys/file.h>
|
1993-12-12 23:43:18 +03:00
|
|
|
#include <sys/stat.h>
|
1993-10-02 13:22:00 +03:00
|
|
|
#include <sys/filedesc.h>
|
|
|
|
#include <sys/ioctl.h>
|
1993-11-20 06:08:16 +03:00
|
|
|
#include <sys/kernel.h>
|
1995-04-23 03:45:29 +04:00
|
|
|
#include <sys/reboot.h>
|
1993-10-02 13:22:00 +03:00
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <sys/mount.h>
|
1994-11-21 00:31:10 +03:00
|
|
|
#include <sys/ptrace.h>
|
1993-10-02 13:22:00 +03:00
|
|
|
#include <sys/resource.h>
|
|
|
|
#include <sys/resourcevar.h>
|
|
|
|
#include <sys/signal.h>
|
|
|
|
#include <sys/signalvar.h>
|
|
|
|
#include <sys/socket.h>
|
1996-01-05 19:53:14 +03:00
|
|
|
#include <sys/tty.h>
|
1993-10-02 13:22:00 +03:00
|
|
|
#include <sys/vnode.h>
|
|
|
|
#include <sys/uio.h>
|
|
|
|
#include <sys/wait.h>
|
1993-11-20 06:08:16 +03:00
|
|
|
#include <sys/utsname.h>
|
1994-03-03 17:08:25 +03:00
|
|
|
#include <sys/unistd.h>
|
1994-10-26 02:03:22 +03:00
|
|
|
#include <sys/syscallargs.h>
|
1996-03-14 22:33:44 +03:00
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/socketvar.h>
|
1996-10-13 04:56:02 +04:00
|
|
|
#include <sys/exec.h>
|
1995-10-07 09:25:19 +03:00
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
#include <compat/sunos/sunos.h>
|
|
|
|
#include <compat/sunos/sunos_syscallargs.h>
|
1995-06-12 02:33:50 +04:00
|
|
|
#include <compat/sunos/sunos_util.h>
|
1995-10-09 14:23:57 +03:00
|
|
|
#include <compat/sunos/sunos_dirent.h>
|
1993-10-02 13:22:00 +03:00
|
|
|
|
1993-12-12 23:43:18 +03:00
|
|
|
#include <netinet/in.h>
|
|
|
|
|
1993-11-12 06:23:51 +03:00
|
|
|
#include <miscfs/specfs/specdev.h>
|
1993-10-02 13:22:00 +03:00
|
|
|
|
1994-06-10 13:26:18 +04:00
|
|
|
#include <nfs/rpcv2.h>
|
1996-02-18 17:46:25 +03:00
|
|
|
#include <nfs/nfsproto.h>
|
1994-06-10 13:26:18 +04:00
|
|
|
#include <nfs/nfs.h>
|
|
|
|
|
1993-10-02 13:22:00 +03:00
|
|
|
#include <vm/vm.h>
|
1997-06-12 23:18:15 +04:00
|
|
|
#include <vm/vm_swap.h>
|
1993-10-02 13:22:00 +03:00
|
|
|
|
1996-03-14 22:33:44 +03:00
|
|
|
static int sunstatfs __P((struct statfs *, caddr_t));
|
1996-08-31 03:07:49 +04:00
|
|
|
|
|
|
|
int
|
|
|
|
sunos_sys_stime(p, v, retval)
|
|
|
|
struct proc *p;
|
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct sunos_sys_stime_args *uap = v;
|
|
|
|
struct sys_settimeofday_args ap;
|
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
1996-12-29 01:37:03 +03:00
|
|
|
struct timeval tv, *sgtvp;
|
1996-08-31 03:07:49 +04:00
|
|
|
int error;
|
|
|
|
|
|
|
|
error = copyin(SCARG(uap, tp), &tv.tv_sec, sizeof(tv.tv_sec));
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
tv.tv_usec = 0;
|
|
|
|
|
1996-12-29 01:37:03 +03:00
|
|
|
SCARG(&ap, tv) = sgtvp = stackgap_alloc(&sg, sizeof(struct timeval));
|
1996-08-31 03:07:49 +04:00
|
|
|
SCARG(&ap, tzp) = NULL;
|
|
|
|
|
1996-12-29 01:37:03 +03:00
|
|
|
error = copyout(&tv, sgtvp, sizeof(struct timeval));
|
1996-08-31 03:07:49 +04:00
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
return sys_settimeofday(p, &ap, retval);
|
|
|
|
}
|
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_wait4(p, v, retval)
|
1993-10-02 13:22:00 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:42:02 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-10-02 13:22:00 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sunos_sys_wait4_args *uap = v;
|
1994-10-26 02:03:22 +03:00
|
|
|
if (SCARG(uap, pid) == 0)
|
|
|
|
SCARG(uap, pid) = WAIT_ANY;
|
1995-10-07 09:25:19 +03:00
|
|
|
return (sys_wait4(p, uap, retval));
|
1993-10-02 13:22:00 +03:00
|
|
|
}
|
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_creat(p, v, retval)
|
1993-10-02 13:22:00 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:42:02 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-10-02 13:22:00 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sunos_sys_creat_args *uap = v;
|
|
|
|
struct sys_open_args ouap;
|
1994-10-26 02:03:22 +03:00
|
|
|
|
1995-06-25 00:22:33 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
|
|
|
SUNOS_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
|
1995-06-12 02:33:50 +04:00
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
SCARG(&ouap, path) = SCARG(uap, path);
|
|
|
|
SCARG(&ouap, flags) = O_WRONLY | O_CREAT | O_TRUNC;
|
|
|
|
SCARG(&ouap, mode) = SCARG(uap, mode);
|
1995-10-07 09:25:19 +03:00
|
|
|
|
|
|
|
return (sys_open(p, &ouap, retval));
|
1993-10-02 13:22:00 +03:00
|
|
|
}
|
|
|
|
|
1995-06-12 02:33:50 +04:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_access(p, v, retval)
|
1995-06-12 02:33:50 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:42:02 +04:00
|
|
|
void *v;
|
1995-06-12 02:33:50 +04:00
|
|
|
register_t *retval;
|
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sunos_sys_access_args *uap = v;
|
1995-06-25 00:22:33 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
|
|
|
SUNOS_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
|
1995-06-12 02:33:50 +04:00
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
return (sys_access(p, uap, retval));
|
1995-06-12 02:33:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_stat(p, v, retval)
|
1995-06-12 02:33:50 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:42:02 +04:00
|
|
|
void *v;
|
1995-06-12 02:33:50 +04:00
|
|
|
register_t *retval;
|
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sunos_sys_stat_args *uap = v;
|
1995-06-25 00:22:33 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
|
|
|
SUNOS_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
|
1995-06-12 02:33:50 +04:00
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
return (compat_43_sys_stat(p, uap, retval));
|
1995-06-12 02:33:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_lstat(p, v, retval)
|
1995-06-12 02:33:50 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:42:02 +04:00
|
|
|
void *v;
|
1995-06-12 02:33:50 +04:00
|
|
|
register_t *retval;
|
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sunos_sys_lstat_args *uap = v;
|
1995-06-25 00:22:33 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
|
|
|
SUNOS_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
|
1995-06-12 02:33:50 +04:00
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
return (compat_43_sys_lstat(p, uap, retval));
|
1995-06-12 02:33:50 +04:00
|
|
|
}
|
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_execv(p, v, retval)
|
1993-10-02 13:22:00 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:42:02 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-10-02 13:22:00 +03:00
|
|
|
{
|
1996-09-03 07:12:17 +04:00
|
|
|
struct sunos_sys_execv_args /* {
|
|
|
|
syscallarg(char *) path;
|
|
|
|
syscallarg(char **) argv;
|
|
|
|
} */ *uap = v;
|
|
|
|
struct sys_execve_args ap;
|
|
|
|
caddr_t sg;
|
|
|
|
|
|
|
|
sg = stackgap_init(p->p_emul);
|
1995-06-25 00:22:33 +04:00
|
|
|
SUNOS_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
|
1995-06-12 02:33:50 +04:00
|
|
|
|
1996-09-03 07:12:17 +04:00
|
|
|
SCARG(&ap, path) = SCARG(uap, path);
|
|
|
|
SCARG(&ap, argp) = SCARG(uap, argp);
|
|
|
|
SCARG(&ap, envp) = NULL;
|
1995-10-07 09:25:19 +03:00
|
|
|
|
1996-09-03 07:12:17 +04:00
|
|
|
return (sys_execve(p, &ap, retval));
|
1993-10-02 13:22:00 +03:00
|
|
|
}
|
|
|
|
|
1996-08-27 02:49:43 +04:00
|
|
|
int
|
|
|
|
sunos_sys_execve(p, v, retval)
|
|
|
|
struct proc *p;
|
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
1996-09-03 07:12:17 +04:00
|
|
|
struct sunos_sys_execve_args /* {
|
|
|
|
syscallarg(char *) path;
|
|
|
|
syscallarg(char **) argv;
|
|
|
|
syscallarg(char **) envp;
|
|
|
|
} */ *uap = v;
|
|
|
|
struct sys_execve_args ap;
|
|
|
|
caddr_t sg;
|
|
|
|
|
|
|
|
sg = stackgap_init(p->p_emul);
|
1996-08-27 02:49:43 +04:00
|
|
|
SUNOS_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
|
|
|
|
|
1996-09-03 07:12:17 +04:00
|
|
|
SCARG(&ap, path) = SCARG(uap, path);
|
|
|
|
SCARG(&ap, argp) = SCARG(uap, argp);
|
|
|
|
SCARG(&ap, envp) = SCARG(uap, envp);
|
1996-08-27 02:49:43 +04:00
|
|
|
|
1996-09-03 07:12:17 +04:00
|
|
|
return (sys_execve(p, &ap, retval));
|
1996-08-27 02:49:43 +04:00
|
|
|
}
|
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_omsync(p, v, retval)
|
1993-10-02 13:22:00 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:42:02 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-10-02 13:22:00 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sunos_sys_omsync_args *uap = v;
|
|
|
|
struct sys_msync_args ouap;
|
1993-10-02 13:22:00 +03:00
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
if (SCARG(uap, flags))
|
1993-10-02 13:22:00 +03:00
|
|
|
return (EINVAL);
|
1994-10-26 02:03:22 +03:00
|
|
|
SCARG(&ouap, addr) = SCARG(uap, addr);
|
|
|
|
SCARG(&ouap, len) = SCARG(uap, len);
|
1995-10-07 09:25:19 +03:00
|
|
|
|
|
|
|
return (sys_msync(p, &ouap, retval));
|
1993-10-02 13:22:00 +03:00
|
|
|
}
|
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_unmount(p, v, retval)
|
1993-10-02 13:22:00 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:42:02 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-10-02 13:22:00 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sunos_sys_unmount_args *uap = v;
|
|
|
|
struct sys_unmount_args ouap;
|
1995-09-20 02:42:02 +04:00
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
SCARG(&ouap, path) = SCARG(uap, path);
|
|
|
|
SCARG(&ouap, flags) = 0;
|
|
|
|
|
|
|
|
return (sys_unmount(p, &ouap, retval));
|
1993-10-02 13:22:00 +03:00
|
|
|
}
|
|
|
|
|
1996-02-18 17:46:25 +03:00
|
|
|
/*
|
|
|
|
* Conversion table for SunOS NFS mount flags.
|
|
|
|
*/
|
|
|
|
static struct {
|
|
|
|
int sun_flg;
|
|
|
|
int bsd_flg;
|
|
|
|
} sunnfs_flgtab[] = {
|
|
|
|
{ SUNNFS_SOFT, NFSMNT_SOFT },
|
|
|
|
{ SUNNFS_WSIZE, NFSMNT_WSIZE },
|
|
|
|
{ SUNNFS_RSIZE, NFSMNT_RSIZE },
|
|
|
|
{ SUNNFS_TIMEO, NFSMNT_TIMEO },
|
|
|
|
{ SUNNFS_RETRANS, NFSMNT_RETRANS },
|
|
|
|
{ SUNNFS_HOSTNAME, 0 }, /* Ignored */
|
|
|
|
{ SUNNFS_INT, NFSMNT_INT },
|
|
|
|
{ SUNNFS_NOAC, 0 }, /* Ignored */
|
|
|
|
{ SUNNFS_ACREGMIN, 0 }, /* Ignored */
|
|
|
|
{ SUNNFS_ACREGMAX, 0 }, /* Ignored */
|
|
|
|
{ SUNNFS_ACDIRMIN, 0 }, /* Ignored */
|
|
|
|
{ SUNNFS_ACDIRMAX, 0 }, /* Ignored */
|
|
|
|
{ SUNNFS_SECURE, 0 }, /* Ignored */
|
|
|
|
{ SUNNFS_NOCTO, 0 }, /* Ignored */
|
|
|
|
{ SUNNFS_POSIX, 0 } /* Ignored */
|
|
|
|
};
|
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_mount(p, v, retval)
|
1993-10-02 13:22:00 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:42:02 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-10-02 13:22:00 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sunos_sys_mount_args *uap = v;
|
1994-10-26 02:03:22 +03:00
|
|
|
int oflags = SCARG(uap, flags), nflags, error;
|
1994-04-24 15:37:49 +04:00
|
|
|
char fsname[MFSNAMELEN];
|
1996-10-13 05:16:19 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
1994-04-24 15:37:49 +04:00
|
|
|
|
1993-10-02 13:22:00 +03:00
|
|
|
if (oflags & (SUNM_NOSUB | SUNM_SYS5))
|
|
|
|
return (EINVAL);
|
1994-04-24 15:37:49 +04:00
|
|
|
if ((oflags & SUNM_NEWTYPE) == 0)
|
|
|
|
return (EINVAL);
|
1993-10-02 13:22:00 +03:00
|
|
|
nflags = 0;
|
|
|
|
if (oflags & SUNM_RDONLY)
|
|
|
|
nflags |= MNT_RDONLY;
|
|
|
|
if (oflags & SUNM_NOSUID)
|
|
|
|
nflags |= MNT_NOSUID;
|
|
|
|
if (oflags & SUNM_REMOUNT)
|
|
|
|
nflags |= MNT_UPDATE;
|
1994-10-26 02:03:22 +03:00
|
|
|
SCARG(uap, flags) = nflags;
|
1993-12-12 23:43:18 +03:00
|
|
|
|
1996-03-14 22:33:44 +03:00
|
|
|
error = copyinstr((caddr_t)SCARG(uap, type), fsname,
|
|
|
|
sizeof fsname, (size_t *)0);
|
|
|
|
if (error)
|
1994-04-24 15:37:49 +04:00
|
|
|
return (error);
|
|
|
|
|
1995-06-18 18:45:14 +04:00
|
|
|
if (strncmp(fsname, "4.2", sizeof fsname) == 0) {
|
1996-10-13 05:16:19 +04:00
|
|
|
SCARG(uap, type) = stackgap_alloc(&sg, sizeof("ffs"));
|
1996-03-14 22:33:44 +03:00
|
|
|
error = copyout("ffs", SCARG(uap, type), sizeof("ffs"));
|
|
|
|
if (error)
|
1994-04-24 15:37:49 +04:00
|
|
|
return (error);
|
1995-06-18 18:45:14 +04:00
|
|
|
} else if (strncmp(fsname, "nfs", sizeof fsname) == 0) {
|
1994-10-26 02:03:22 +03:00
|
|
|
struct sunos_nfs_args sna;
|
1993-12-12 23:43:18 +03:00
|
|
|
struct sockaddr_in sain;
|
|
|
|
struct nfs_args na;
|
|
|
|
struct sockaddr sa;
|
1996-02-18 17:46:25 +03:00
|
|
|
int n;
|
1993-12-12 23:43:18 +03:00
|
|
|
|
1996-03-14 22:33:44 +03:00
|
|
|
error = copyin(SCARG(uap, data), &sna, sizeof sna);
|
|
|
|
if (error)
|
1993-12-12 23:43:18 +03:00
|
|
|
return (error);
|
1996-03-14 22:33:44 +03:00
|
|
|
error = copyin(sna.addr, &sain, sizeof sain);
|
|
|
|
if (error)
|
1993-12-12 23:43:18 +03:00
|
|
|
return (error);
|
|
|
|
bcopy(&sain, &sa, sizeof sa);
|
|
|
|
sa.sa_len = sizeof(sain);
|
1996-10-13 05:16:19 +04:00
|
|
|
SCARG(uap, data) = stackgap_alloc(&sg, sizeof(na));
|
1996-02-18 17:46:25 +03:00
|
|
|
na.version = NFS_ARGSVERSION;
|
1996-10-13 05:16:19 +04:00
|
|
|
na.addr = stackgap_alloc(&sg, sizeof(struct sockaddr));
|
1994-06-22 12:24:53 +04:00
|
|
|
na.addrlen = sizeof(struct sockaddr);
|
1993-12-12 23:43:18 +03:00
|
|
|
na.sotype = SOCK_DGRAM;
|
|
|
|
na.proto = IPPROTO_UDP;
|
1996-02-18 17:46:25 +03:00
|
|
|
na.fh = (void *)sna.fh;
|
|
|
|
na.fhsize = NFSX_V2FH;
|
|
|
|
na.flags = 0;
|
|
|
|
n = sizeof(sunnfs_flgtab) / sizeof(sunnfs_flgtab[0]);
|
|
|
|
while (--n >= 0)
|
|
|
|
if (sna.flags & sunnfs_flgtab[n].sun_flg)
|
|
|
|
na.flags |= sunnfs_flgtab[n].bsd_flg;
|
1993-12-12 23:43:18 +03:00
|
|
|
na.wsize = sna.wsize;
|
|
|
|
na.rsize = sna.rsize;
|
1996-02-25 16:27:01 +03:00
|
|
|
if (na.flags & NFSMNT_RSIZE) {
|
|
|
|
na.flags |= NFSMNT_READDIRSIZE;
|
|
|
|
na.readdirsize = na.rsize;
|
|
|
|
}
|
1993-12-12 23:43:18 +03:00
|
|
|
na.timeo = sna.timeo;
|
|
|
|
na.retrans = sna.retrans;
|
|
|
|
na.hostname = sna.hostname;
|
|
|
|
|
1996-03-14 22:33:44 +03:00
|
|
|
error = copyout(&sa, na.addr, sizeof sa);
|
|
|
|
if (error)
|
1993-12-12 23:43:18 +03:00
|
|
|
return (error);
|
1996-03-14 22:33:44 +03:00
|
|
|
error = copyout(&na, SCARG(uap, data), sizeof na);
|
|
|
|
if (error)
|
1993-12-12 23:43:18 +03:00
|
|
|
return (error);
|
|
|
|
}
|
1995-10-07 09:25:19 +03:00
|
|
|
return (sys_mount(p, (struct sys_mount_args *)uap, retval));
|
1993-10-02 13:22:00 +03:00
|
|
|
}
|
|
|
|
|
1997-01-31 05:18:54 +03:00
|
|
|
#if defined(NFS)
|
1994-10-26 02:03:22 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
async_daemon(p, v, retval)
|
1994-06-10 13:26:18 +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-10 13:26:18 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sys_nfssvc_args ouap;
|
1994-06-10 13:26:18 +04:00
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
SCARG(&ouap, flag) = NFSSVC_BIOD;
|
|
|
|
SCARG(&ouap, argp) = NULL;
|
1995-10-07 09:25:19 +03:00
|
|
|
|
|
|
|
return (sys_nfssvc(p, &ouap, retval));
|
1994-06-10 13:26:18 +04:00
|
|
|
}
|
1997-01-31 05:18:54 +03:00
|
|
|
#endif /* NFS */
|
1994-06-10 13:26:18 +04:00
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_sigpending(p, v, retval)
|
1993-10-02 13:22:00 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:42:02 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-10-02 13:22:00 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sunos_sys_sigpending_args *uap = v;
|
1994-05-05 13:36:23 +04:00
|
|
|
int mask = p->p_siglist & p->p_sigmask;
|
1993-10-02 13:22:00 +03:00
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
return (copyout((caddr_t)&mask, (caddr_t)SCARG(uap, mask), sizeof(int)));
|
1993-10-02 13:22:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read Sun-style directory entries. We suck them into kernel space so
|
|
|
|
* that they can be massaged before being copied out to user code. Like
|
|
|
|
* SunOS, we squish out `empty' entries.
|
|
|
|
*
|
|
|
|
* This is quite ugly, but what do you expect from compatibility code?
|
|
|
|
*/
|
1994-10-26 02:03:22 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_getdents(p, v, retval)
|
1993-10-02 13:22:00 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:42:02 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-10-02 13:22:00 +03:00
|
|
|
{
|
1995-10-09 14:23:57 +03:00
|
|
|
struct sunos_sys_getdents_args *uap = v;
|
|
|
|
struct dirent *bdp;
|
|
|
|
struct vnode *vp;
|
|
|
|
caddr_t inp, buf; /* BSD-format */
|
|
|
|
int len, reclen; /* BSD-format */
|
|
|
|
caddr_t outp; /* Sun-format */
|
|
|
|
int resid, sunos_reclen;/* Sun-format */
|
1993-10-02 13:22:00 +03:00
|
|
|
struct file *fp;
|
|
|
|
struct uio auio;
|
|
|
|
struct iovec aiov;
|
1995-10-09 14:23:57 +03:00
|
|
|
struct sunos_dirent idb;
|
1993-10-02 13:22:00 +03:00
|
|
|
off_t off; /* true file offset */
|
|
|
|
int buflen, error, eofflag;
|
1997-10-10 05:47:41 +04:00
|
|
|
off_t *cookiebuf, *cookie;
|
1995-10-09 14:23:57 +03:00
|
|
|
int ncookies;
|
1993-10-02 13:22:00 +03:00
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
|
1993-10-02 13:22:00 +03:00
|
|
|
return (error);
|
1995-10-09 14:23:57 +03:00
|
|
|
|
1993-10-02 13:22:00 +03:00
|
|
|
if ((fp->f_flag & FREAD) == 0)
|
|
|
|
return (EBADF);
|
1995-10-09 14:23:57 +03:00
|
|
|
|
1993-10-02 13:22:00 +03:00
|
|
|
vp = (struct vnode *)fp->f_data;
|
1995-10-09 14:23:57 +03:00
|
|
|
|
1993-10-02 13:22:00 +03:00
|
|
|
if (vp->v_type != VDIR) /* XXX vnode readdir op should do this */
|
|
|
|
return (EINVAL);
|
1995-10-09 14:23:57 +03:00
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
buflen = min(MAXBSIZE, SCARG(uap, nbytes));
|
1993-10-02 13:22:00 +03:00
|
|
|
buf = malloc(buflen, M_TEMP, M_WAITOK);
|
1995-10-09 14:23:57 +03:00
|
|
|
ncookies = buflen / 16;
|
|
|
|
cookiebuf = malloc(ncookies * sizeof(*cookiebuf), M_TEMP, M_WAITOK);
|
1993-10-02 13:22:00 +03:00
|
|
|
VOP_LOCK(vp);
|
|
|
|
off = fp->f_offset;
|
|
|
|
again:
|
|
|
|
aiov.iov_base = buf;
|
|
|
|
aiov.iov_len = buflen;
|
|
|
|
auio.uio_iov = &aiov;
|
|
|
|
auio.uio_iovcnt = 1;
|
|
|
|
auio.uio_rw = UIO_READ;
|
|
|
|
auio.uio_segflg = UIO_SYSSPACE;
|
|
|
|
auio.uio_procp = p;
|
|
|
|
auio.uio_resid = buflen;
|
|
|
|
auio.uio_offset = off;
|
|
|
|
/*
|
|
|
|
* First we read into the malloc'ed buffer, then
|
|
|
|
* we massage it into user space, one record at a time.
|
|
|
|
*/
|
1995-10-09 14:23:57 +03:00
|
|
|
error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, cookiebuf,
|
|
|
|
ncookies);
|
1995-12-14 21:44:44 +03:00
|
|
|
if (error)
|
|
|
|
goto out;
|
1995-10-09 14:23:57 +03:00
|
|
|
|
1993-10-02 13:22:00 +03:00
|
|
|
inp = buf;
|
1994-10-26 02:03:22 +03:00
|
|
|
outp = SCARG(uap, buf);
|
|
|
|
resid = SCARG(uap, nbytes);
|
1997-10-11 02:16:04 +04:00
|
|
|
if ((len = buflen - auio.uio_resid) == 0)
|
1993-10-02 13:22:00 +03:00
|
|
|
goto eof;
|
1995-10-09 14:23:57 +03:00
|
|
|
|
|
|
|
for (cookie = cookiebuf; len > 0; len -= reclen) {
|
|
|
|
bdp = (struct dirent *)inp;
|
|
|
|
reclen = bdp->d_reclen;
|
1993-10-02 13:22:00 +03:00
|
|
|
if (reclen & 3)
|
1994-10-26 02:03:22 +03:00
|
|
|
panic("sunos_getdents");
|
1997-10-10 05:47:41 +04:00
|
|
|
if ((*cookie >> 32) != 0) {
|
|
|
|
compat_offseterr(vp, "sunos_getdents");
|
|
|
|
error = EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
1995-10-09 14:23:57 +03:00
|
|
|
if (bdp->d_fileno == 0) {
|
1993-10-02 13:22:00 +03:00
|
|
|
inp += reclen; /* it is a hole; squish it out */
|
1997-08-04 13:48:07 +04:00
|
|
|
off = *cookie++;
|
1993-10-02 13:22:00 +03:00
|
|
|
continue;
|
|
|
|
}
|
1995-10-09 14:23:57 +03:00
|
|
|
sunos_reclen = SUNOS_RECLEN(&idb, bdp->d_namlen);
|
|
|
|
if (reclen > len || resid < sunos_reclen) {
|
1993-10-02 13:22:00 +03:00
|
|
|
/* entry too big for buffer, so just stop */
|
|
|
|
outp++;
|
|
|
|
break;
|
|
|
|
}
|
1997-08-04 13:48:07 +04:00
|
|
|
off = *cookie++; /* each entry points to next */
|
1993-10-02 13:22:00 +03:00
|
|
|
/*
|
|
|
|
* Massage in place to make a Sun-shaped dirent (otherwise
|
|
|
|
* we have to worry about touching user memory outside of
|
|
|
|
* the copyout() call).
|
|
|
|
*/
|
1995-10-09 14:23:57 +03:00
|
|
|
idb.d_fileno = bdp->d_fileno;
|
|
|
|
idb.d_off = off;
|
|
|
|
idb.d_reclen = sunos_reclen;
|
|
|
|
idb.d_namlen = bdp->d_namlen;
|
|
|
|
strcpy(idb.d_name, bdp->d_name);
|
|
|
|
if ((error = copyout((caddr_t)&idb, outp, sunos_reclen)) != 0)
|
1993-10-02 13:22:00 +03:00
|
|
|
goto out;
|
|
|
|
/* advance past this real entry */
|
|
|
|
inp += reclen;
|
|
|
|
/* advance output past Sun-shaped entry */
|
1995-10-09 14:23:57 +03:00
|
|
|
outp += sunos_reclen;
|
|
|
|
resid -= sunos_reclen;
|
1993-10-02 13:22:00 +03:00
|
|
|
}
|
1995-10-09 14:23:57 +03:00
|
|
|
|
1993-10-02 13:22:00 +03:00
|
|
|
/* if we squished out the whole block, try again */
|
1994-10-26 02:03:22 +03:00
|
|
|
if (outp == SCARG(uap, buf))
|
1993-10-02 13:22:00 +03:00
|
|
|
goto again;
|
|
|
|
fp->f_offset = off; /* update the vnode offset */
|
1995-10-09 14:23:57 +03:00
|
|
|
|
1993-10-02 13:22:00 +03:00
|
|
|
eof:
|
1994-10-26 02:03:22 +03:00
|
|
|
*retval = SCARG(uap, nbytes) - resid;
|
1993-10-02 13:22:00 +03:00
|
|
|
out:
|
|
|
|
VOP_UNLOCK(vp);
|
1995-10-09 14:23:57 +03:00
|
|
|
free(cookiebuf, M_TEMP);
|
1993-10-02 13:22:00 +03:00
|
|
|
free(buf, M_TEMP);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
#define SUNOS__MAP_NEW 0x80000000 /* if not, old mmap & cannot handle */
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_mmap(p, v, retval)
|
1993-10-02 13:22:00 +03:00
|
|
|
register struct proc *p;
|
1995-09-20 02:42:02 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-10-02 13:22:00 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
register struct sunos_sys_mmap_args *uap = v;
|
|
|
|
struct sys_mmap_args ouap;
|
1993-10-02 13:22:00 +03:00
|
|
|
register struct filedesc *fdp;
|
|
|
|
register struct file *fp;
|
|
|
|
register struct vnode *vp;
|
1997-10-19 22:48:00 +04:00
|
|
|
void *rp;
|
1993-10-02 13:22:00 +03:00
|
|
|
|
|
|
|
/*
|
1994-03-27 13:08:02 +04:00
|
|
|
* Verify the arguments.
|
1993-10-02 13:22:00 +03:00
|
|
|
*/
|
1994-10-26 02:03:22 +03:00
|
|
|
if (SCARG(uap, prot) & ~(PROT_READ|PROT_WRITE|PROT_EXEC))
|
1994-03-27 13:08:02 +04:00
|
|
|
return (EINVAL); /* XXX still needed? */
|
1993-10-15 14:28:29 +03:00
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
if ((SCARG(uap, flags) & SUNOS__MAP_NEW) == 0)
|
1993-10-02 13:22:00 +03:00
|
|
|
return (EINVAL);
|
1993-10-15 14:28:29 +03:00
|
|
|
|
1994-11-14 10:33:48 +03:00
|
|
|
SCARG(&ouap, flags) = SCARG(uap, flags) & ~SUNOS__MAP_NEW;
|
|
|
|
SCARG(&ouap, addr) = SCARG(uap, addr);
|
|
|
|
|
1997-10-19 22:48:00 +04:00
|
|
|
rp = (void *) round_page(p->p_vmspace->vm_daddr+MAXDSIZ);
|
1994-11-14 10:33:48 +03:00
|
|
|
if ((SCARG(&ouap, flags) & MAP_FIXED) == 0 &&
|
1997-10-19 22:48:00 +04:00
|
|
|
SCARG(&ouap, addr) != 0 && SCARG(&ouap, addr) < rp)
|
|
|
|
SCARG(&ouap, addr) = rp;
|
1994-11-14 10:33:48 +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);
|
1993-12-12 23:43:18 +03:00
|
|
|
|
1993-10-02 13:22:00 +03:00
|
|
|
/*
|
|
|
|
* Special case: if fd refers to /dev/zero, map as MAP_ANON. (XXX)
|
|
|
|
*/
|
|
|
|
fdp = p->p_fd;
|
1994-11-14 10:33:48 +03:00
|
|
|
if ((unsigned)SCARG(&ouap, fd) < fdp->fd_nfiles && /*XXX*/
|
|
|
|
(fp = fdp->fd_ofiles[SCARG(&ouap, fd)]) != NULL && /*XXX*/
|
1993-10-02 13:22:00 +03:00
|
|
|
fp->f_type == DTYPE_VNODE && /*XXX*/
|
|
|
|
(vp = (struct vnode *)fp->f_data)->v_type == VCHR && /*XXX*/
|
1994-05-21 12:44:26 +04:00
|
|
|
iszerodev(vp->v_rdev)) { /*XXX*/
|
1994-11-14 10:33:48 +03:00
|
|
|
SCARG(&ouap, flags) |= MAP_ANON;
|
|
|
|
SCARG(&ouap, fd) = -1;
|
1994-03-27 13:08:02 +04:00
|
|
|
}
|
1993-10-15 14:28:29 +03:00
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
return (sys_mmap(p, &ouap, retval));
|
1993-10-02 13:22:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#define MC_SYNC 1
|
|
|
|
#define MC_LOCK 2
|
|
|
|
#define MC_UNLOCK 3
|
|
|
|
#define MC_ADVISE 4
|
|
|
|
#define MC_LOCKAS 5
|
|
|
|
#define MC_UNLOCKAS 6
|
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_mctl(p, v, retval)
|
1993-10-02 13:22:00 +03:00
|
|
|
register struct proc *p;
|
1995-09-20 02:42:02 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-10-02 13:22:00 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
register struct sunos_sys_mctl_args *uap = v;
|
1993-10-02 13:22:00 +03:00
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
switch (SCARG(uap, func)) {
|
1993-10-02 13:22:00 +03:00
|
|
|
case MC_ADVISE: /* ignore for now */
|
|
|
|
return (0);
|
|
|
|
case MC_SYNC: /* translate to msync */
|
1995-10-07 09:25:19 +03:00
|
|
|
return (sys_msync(p, uap, retval));
|
1993-10-02 13:22:00 +03:00
|
|
|
default:
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_setsockopt(p, v, retval)
|
1993-10-02 13:22:00 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:42:02 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-10-02 13:22:00 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
register struct sunos_sys_setsockopt_args *uap = v;
|
1993-10-02 13:22:00 +03:00
|
|
|
struct file *fp;
|
|
|
|
struct mbuf *m = NULL;
|
|
|
|
int error;
|
|
|
|
|
1996-03-14 22:33:44 +03:00
|
|
|
if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0)
|
1993-10-02 13:22:00 +03:00
|
|
|
return (error);
|
|
|
|
#define SO_DONTLINGER (~SO_LINGER)
|
1994-10-26 02:03:22 +03:00
|
|
|
if (SCARG(uap, name) == SO_DONTLINGER) {
|
1993-10-02 13:22:00 +03:00
|
|
|
m = m_get(M_WAIT, MT_SOOPTS);
|
|
|
|
mtod(m, struct linger *)->l_onoff = 0;
|
|
|
|
m->m_len = sizeof(struct linger);
|
1994-10-26 02:03:22 +03:00
|
|
|
return (sosetopt((struct socket *)fp->f_data, SCARG(uap, level),
|
1993-10-02 13:22:00 +03:00
|
|
|
SO_LINGER, m));
|
|
|
|
}
|
1994-11-30 12:40:23 +03:00
|
|
|
if (SCARG(uap, level) == IPPROTO_IP) {
|
|
|
|
#define SUNOS_IP_MULTICAST_IF 2
|
|
|
|
#define SUNOS_IP_MULTICAST_TTL 3
|
|
|
|
#define SUNOS_IP_MULTICAST_LOOP 4
|
|
|
|
#define SUNOS_IP_ADD_MEMBERSHIP 5
|
|
|
|
#define SUNOS_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) >= SUNOS_IP_MULTICAST_IF &&
|
|
|
|
SCARG(uap, name) <= SUNOS_IP_DROP_MEMBERSHIP) {
|
|
|
|
SCARG(uap, name) =
|
|
|
|
ipoptxlat[SCARG(uap, name) - SUNOS_IP_MULTICAST_IF];
|
|
|
|
}
|
|
|
|
}
|
1994-10-26 02:03:22 +03:00
|
|
|
if (SCARG(uap, valsize) > MLEN)
|
1993-10-02 13:22:00 +03:00
|
|
|
return (EINVAL);
|
1994-10-26 02:03:22 +03:00
|
|
|
if (SCARG(uap, val)) {
|
1993-10-02 13:22:00 +03:00
|
|
|
m = m_get(M_WAIT, MT_SOOPTS);
|
1996-03-14 22:33:44 +03:00
|
|
|
error = copyin(SCARG(uap, val), mtod(m, caddr_t),
|
|
|
|
(u_int)SCARG(uap, valsize));
|
|
|
|
if (error) {
|
1993-10-02 13:22:00 +03:00
|
|
|
(void) m_free(m);
|
|
|
|
return (error);
|
|
|
|
}
|
1994-10-26 02:03:22 +03:00
|
|
|
m->m_len = SCARG(uap, valsize);
|
1993-10-02 13:22:00 +03:00
|
|
|
}
|
1994-10-26 02:03:22 +03:00
|
|
|
return (sosetopt((struct socket *)fp->f_data, SCARG(uap, level),
|
|
|
|
SCARG(uap, name), m));
|
1993-10-02 13:22:00 +03:00
|
|
|
}
|
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_fchroot(p, v, retval)
|
1993-10-02 13:22:00 +03:00
|
|
|
register struct proc *p;
|
1995-09-20 02:42:02 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-10-02 13:22:00 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
register struct sunos_sys_fchroot_args *uap = v;
|
1993-10-02 13:22:00 +03:00
|
|
|
register struct filedesc *fdp = p->p_fd;
|
|
|
|
register struct vnode *vp;
|
|
|
|
struct file *fp;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
|
|
|
|
return (error);
|
1994-10-26 02:03:22 +03:00
|
|
|
if ((error = getvnode(fdp, SCARG(uap, fd), &fp)) != 0)
|
1993-10-02 13:22:00 +03:00
|
|
|
return (error);
|
|
|
|
vp = (struct vnode *)fp->f_data;
|
|
|
|
VOP_LOCK(vp);
|
|
|
|
if (vp->v_type != VDIR)
|
|
|
|
error = ENOTDIR;
|
|
|
|
else
|
1997-05-08 20:19:43 +04:00
|
|
|
error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p);
|
1993-10-02 13:22:00 +03:00
|
|
|
VOP_UNLOCK(vp);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
VREF(vp);
|
|
|
|
if (fdp->fd_rdir != NULL)
|
|
|
|
vrele(fdp->fd_rdir);
|
|
|
|
fdp->fd_rdir = vp;
|
|
|
|
return (0);
|
|
|
|
}
|
1993-10-13 05:31:47 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX: This needs cleaning up.
|
|
|
|
*/
|
1994-10-26 02:03:22 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_auditsys(p, v, retval)
|
1994-12-16 22:01:43 +03:00
|
|
|
struct proc *p;
|
1995-10-07 09:25:19 +03:00
|
|
|
void *v;
|
1994-12-16 22:01:43 +03:00
|
|
|
register_t *retval;
|
1993-10-13 05:31:47 +03:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
1993-11-20 06:08:16 +03:00
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_uname(p, v, retval)
|
1993-11-20 06:08:16 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:42:02 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-11-20 06:08:16 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sunos_sys_uname_args *uap = v;
|
1994-10-26 02:03:22 +03:00
|
|
|
struct sunos_utsname sut;
|
1994-05-20 02:11:54 +04:00
|
|
|
extern char ostype[], machine[], osrelease[];
|
1993-11-20 06:08:16 +03:00
|
|
|
|
|
|
|
bzero(&sut, sizeof(sut));
|
1994-05-20 02:11:54 +04:00
|
|
|
|
|
|
|
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);
|
1993-11-20 06:08:16 +03:00
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
return copyout((caddr_t)&sut, (caddr_t)SCARG(uap, name),
|
|
|
|
sizeof(struct sunos_utsname));
|
1993-11-20 06:08:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_setpgrp(p, v, retval)
|
1993-11-20 06:08:16 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:42:02 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-11-20 06:08:16 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sunos_sys_setpgrp_args *uap = v;
|
1995-09-20 02:42:02 +04:00
|
|
|
|
1993-11-20 06:08:16 +03: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);
|
1993-11-20 06:08:16 +03:00
|
|
|
else
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_setpgid(p, uap, retval);
|
1993-11-20 06:08:16 +03:00
|
|
|
}
|
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_open(p, v, retval)
|
1993-11-20 06:08:16 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:42:02 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-11-20 06:08:16 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sunos_sys_open_args *uap = v;
|
1993-11-20 06:08:16 +03:00
|
|
|
int l, r;
|
1994-12-15 12:41:36 +03:00
|
|
|
int noctty;
|
1993-11-20 06:08:16 +03:00
|
|
|
int ret;
|
|
|
|
|
1995-06-25 00:22:33 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
|
|
|
SUNOS_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
|
1995-06-12 02:33:50 +04:00
|
|
|
|
1993-11-20 06:08:16 +03:00
|
|
|
/* convert mode into NetBSD mode */
|
1994-12-15 12:41:36 +03:00
|
|
|
l = SCARG(uap, flags);
|
|
|
|
noctty = l & 0x8000;
|
1993-11-20 06:08:16 +03:00
|
|
|
r = (l & (0x0001 | 0x0002 | 0x0008 | 0x0040 | 0x0200 | 0x0400 | 0x0800));
|
|
|
|
r |= ((l & (0x0004 | 0x1000 | 0x4000)) ? O_NONBLOCK : 0);
|
|
|
|
r |= ((l & 0x0080) ? O_SHLOCK : 0);
|
|
|
|
r |= ((l & 0x0100) ? O_EXLOCK : 0);
|
|
|
|
r |= ((l & 0x2000) ? O_FSYNC : 0);
|
|
|
|
|
1994-12-15 12:41:36 +03:00
|
|
|
SCARG(uap, flags) = r;
|
1995-10-07 09:25:19 +03:00
|
|
|
ret = sys_open(p, (struct sys_open_args *)uap, retval);
|
1993-11-20 06:08:16 +03:00
|
|
|
|
1994-05-05 06:46:58 +04:00
|
|
|
if (!ret && !noctty && SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) {
|
1993-11-20 06:08:16 +03:00
|
|
|
struct filedesc *fdp = p->p_fd;
|
|
|
|
struct file *fp = fdp->fd_ofiles[*retval];
|
|
|
|
|
|
|
|
/* ignore any error, just give it a try */
|
|
|
|
if (fp->f_type == DTYPE_VNODE)
|
1995-10-07 09:25:19 +03:00
|
|
|
(fp->f_ops->fo_ioctl)(fp, TIOCSCTTY, (caddr_t)0, p);
|
1993-11-20 06:08:16 +03:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
1993-12-12 23:43:18 +03:00
|
|
|
|
1994-02-21 02:24:03 +03:00
|
|
|
#if defined (NFSSERVER)
|
1994-10-26 02:03:22 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_nfssvc(p, v, retval)
|
1993-12-12 23:43:18 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:42:02 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-12-12 23:43:18 +03:00
|
|
|
{
|
1996-03-14 22:33:44 +03:00
|
|
|
#if 0
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sunos_sys_nfssvc_args *uap = v;
|
1995-06-25 17:11:44 +04:00
|
|
|
struct emul *e = p->p_emul;
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sys_nfssvc_args outuap;
|
1993-12-12 23:43:18 +03:00
|
|
|
struct sockaddr sa;
|
|
|
|
int error;
|
1996-10-13 05:16:19 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
1993-12-12 23:43:18 +03:00
|
|
|
|
|
|
|
bzero(&outuap, sizeof outuap);
|
1994-10-26 02:03:22 +03:00
|
|
|
SCARG(&outuap, fd) = SCARG(uap, fd);
|
1996-10-13 05:16:19 +04:00
|
|
|
SCARG(&outuap, mskval) = stackgap_alloc(&sg, sizeof(sa));
|
|
|
|
SCARG(&outuap, msklen) = sizeof(sa);
|
|
|
|
SCARG(&outuap, mtchval) = stackgap_alloc(&sg, sizeof(sa));
|
|
|
|
SCARG(&outuap, mtchlen) = sizeof(sa);
|
1993-12-12 23:43:18 +03:00
|
|
|
|
|
|
|
bzero(&sa, sizeof sa);
|
1994-10-26 02:03:22 +03:00
|
|
|
if (error = copyout(&sa, SCARG(&outuap, mskval), SCARG(&outuap, msklen)))
|
1993-12-12 23:43:18 +03:00
|
|
|
return (error);
|
1994-10-26 02:03:22 +03:00
|
|
|
if (error = copyout(&sa, SCARG(&outuap, mtchval), SCARG(&outuap, mtchlen)))
|
1993-12-12 23:43:18 +03:00
|
|
|
return (error);
|
|
|
|
|
|
|
|
return nfssvc(p, &outuap, retval);
|
1994-10-26 02:03:22 +03:00
|
|
|
#else
|
|
|
|
return (ENOSYS);
|
|
|
|
#endif
|
1993-12-12 23:43:18 +03:00
|
|
|
}
|
1994-02-21 02:24:03 +03:00
|
|
|
#endif /* NFSSERVER */
|
1993-12-12 23:43:18 +03:00
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_ustat(p, v, retval)
|
1993-12-12 23:43:18 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:42:02 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-12-12 23:43:18 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sunos_sys_ustat_args *uap = v;
|
1994-10-26 02:03:22 +03:00
|
|
|
struct sunos_ustat us;
|
1993-12-12 23:43:18 +03:00
|
|
|
int error;
|
|
|
|
|
|
|
|
bzero(&us, sizeof us);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX: should set f_tfree and f_tinode at least
|
1994-10-26 02:03:22 +03:00
|
|
|
* How do we translate dev -> fstat? (and then to sunos_ustat)
|
1993-12-12 23:43:18 +03:00
|
|
|
*/
|
|
|
|
|
1996-03-14 22:33:44 +03:00
|
|
|
if ((error = copyout(&us, SCARG(uap, buf), sizeof us)) != 0)
|
1993-12-12 23:43:18 +03:00
|
|
|
return (error);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_quotactl(p, v, retval)
|
1993-12-12 23:43:18 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:42:02 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-12-12 23:43:18 +03:00
|
|
|
{
|
1995-09-20 02:42:02 +04:00
|
|
|
|
1993-12-12 23:43:18 +03:00
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_vhangup(p, v, retval)
|
1993-12-12 23:43:18 +03: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;
|
1993-12-12 23:43:18 +03:00
|
|
|
{
|
1996-01-05 19:53:14 +03:00
|
|
|
struct session *sp = p->p_session;
|
|
|
|
|
|
|
|
if (sp->s_ttyvp == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (sp->s_ttyp && sp->s_ttyp->t_session == sp && sp->s_ttyp->t_pgrp)
|
|
|
|
pgsignal(sp->s_ttyp->t_pgrp, SIGHUP, 1);
|
|
|
|
|
|
|
|
(void) ttywait(sp->s_ttyp);
|
|
|
|
if (sp->s_ttyvp)
|
|
|
|
vgoneall(sp->s_ttyvp);
|
|
|
|
if (sp->s_ttyvp)
|
|
|
|
vrele(sp->s_ttyvp);
|
|
|
|
sp->s_ttyvp = NULL;
|
1995-10-07 09:25:19 +03:00
|
|
|
|
1993-12-12 23:43:18 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1996-03-14 22:33:44 +03:00
|
|
|
static int
|
1993-12-12 23:43:18 +03:00
|
|
|
sunstatfs(sp, buf)
|
|
|
|
struct statfs *sp;
|
|
|
|
caddr_t buf;
|
|
|
|
{
|
1994-10-26 02:03:22 +03:00
|
|
|
struct sunos_statfs ssfs;
|
1993-12-12 23:43:18 +03:00
|
|
|
|
|
|
|
bzero(&ssfs, sizeof ssfs);
|
|
|
|
ssfs.f_type = 0;
|
1994-04-24 15:37:49 +04:00
|
|
|
ssfs.f_bsize = sp->f_bsize;
|
1993-12-12 23:43:18 +03:00
|
|
|
ssfs.f_blocks = sp->f_blocks;
|
|
|
|
ssfs.f_bfree = sp->f_bfree;
|
|
|
|
ssfs.f_bavail = sp->f_bavail;
|
|
|
|
ssfs.f_files = sp->f_files;
|
|
|
|
ssfs.f_ffree = sp->f_ffree;
|
|
|
|
ssfs.f_fsid = sp->f_fsid;
|
|
|
|
return copyout((caddr_t)&ssfs, buf, sizeof ssfs);
|
|
|
|
}
|
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_statfs(p, v, retval)
|
1993-12-12 23:43:18 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:42:02 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-12-12 23:43:18 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sunos_sys_statfs_args *uap = v;
|
1993-12-12 23:43:18 +03:00
|
|
|
register struct mount *mp;
|
|
|
|
register struct statfs *sp;
|
|
|
|
int error;
|
|
|
|
struct nameidata nd;
|
|
|
|
|
1995-06-25 00:22:33 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
|
|
|
SUNOS_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
|
1995-06-12 02:33:50 +04:00
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
|
1996-03-14 22:33:44 +03:00
|
|
|
if ((error = namei(&nd)) != 0)
|
1993-12-12 23:43:18 +03:00
|
|
|
return (error);
|
1994-06-10 13:26:18 +04:00
|
|
|
mp = nd.ni_vp->v_mount;
|
1993-12-12 23:43:18 +03:00
|
|
|
sp = &mp->mnt_stat;
|
1994-06-10 13:26:18 +04:00
|
|
|
vrele(nd.ni_vp);
|
1996-03-14 22:33:44 +03:00
|
|
|
if ((error = VFS_STATFS(mp, sp, p)) != 0)
|
1993-12-12 23:43:18 +03:00
|
|
|
return (error);
|
|
|
|
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
|
1994-10-26 02:03:22 +03:00
|
|
|
return sunstatfs(sp, (caddr_t)SCARG(uap, buf));
|
1993-12-12 23:43:18 +03:00
|
|
|
}
|
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_fstatfs(p, v, retval)
|
1993-12-12 23:43:18 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:42:02 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-12-12 23:43:18 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sunos_sys_fstatfs_args *uap = v;
|
1993-12-12 23:43:18 +03:00
|
|
|
struct file *fp;
|
|
|
|
struct mount *mp;
|
|
|
|
register struct statfs *sp;
|
|
|
|
int error;
|
|
|
|
|
1996-03-14 22:33:44 +03:00
|
|
|
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
|
1993-12-12 23:43:18 +03:00
|
|
|
return (error);
|
|
|
|
mp = ((struct vnode *)fp->f_data)->v_mount;
|
|
|
|
sp = &mp->mnt_stat;
|
1996-03-14 22:33:44 +03:00
|
|
|
if ((error = VFS_STATFS(mp, sp, p)) != 0)
|
1993-12-12 23:43:18 +03:00
|
|
|
return (error);
|
|
|
|
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
|
1994-10-26 02:03:22 +03:00
|
|
|
return sunstatfs(sp, (caddr_t)SCARG(uap, buf));
|
1993-12-12 23:43:18 +03:00
|
|
|
}
|
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_exportfs(p, v, retval)
|
1993-12-12 23:43:18 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:42:02 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-12-12 23:43:18 +03:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* XXX: should perhaps translate into a mount(2)
|
|
|
|
* with MOUNT_EXPORT?
|
|
|
|
*/
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_mknod(p, v, retval)
|
1993-12-12 23:43:18 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:42:02 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-12-12 23:43:18 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sunos_sys_mknod_args *uap = v;
|
|
|
|
|
1995-06-25 00:22:33 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
|
|
|
SUNOS_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
|
1995-06-12 02:33:50 +04:00
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
if (S_ISFIFO(SCARG(uap, mode)))
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_mkfifo(p, uap, retval);
|
1993-12-12 23:43:18 +03:00
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_mknod(p, (struct sys_mknod_args *)uap, retval);
|
1993-12-12 23:43:18 +03:00
|
|
|
}
|
1994-03-03 17:08:25 +03:00
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
#define SUNOS_SC_ARG_MAX 1
|
|
|
|
#define SUNOS_SC_CHILD_MAX 2
|
|
|
|
#define SUNOS_SC_CLK_TCK 3
|
|
|
|
#define SUNOS_SC_NGROUPS_MAX 4
|
|
|
|
#define SUNOS_SC_OPEN_MAX 5
|
|
|
|
#define SUNOS_SC_JOB_CONTROL 6
|
|
|
|
#define SUNOS_SC_SAVED_IDS 7
|
|
|
|
#define SUNOS_SC_VERSION 8
|
1994-03-03 17:08:25 +03:00
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_sysconf(p, v, retval)
|
1994-03-03 17:08:25 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:42:02 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1994-03-03 17:08:25 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sunos_sys_sysconf_args *uap = v;
|
1994-05-24 06:15:18 +04:00
|
|
|
extern int maxfiles;
|
1994-03-03 17:08:25 +03:00
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
switch(SCARG(uap, name)) {
|
|
|
|
case SUNOS_SC_ARG_MAX:
|
1994-03-03 17:08:25 +03:00
|
|
|
*retval = ARG_MAX;
|
1994-03-03 17:15:25 +03:00
|
|
|
break;
|
1994-10-26 02:03:22 +03:00
|
|
|
case SUNOS_SC_CHILD_MAX:
|
1994-03-03 17:08:25 +03:00
|
|
|
*retval = maxproc;
|
1994-03-03 17:15:25 +03:00
|
|
|
break;
|
1994-10-26 02:03:22 +03:00
|
|
|
case SUNOS_SC_CLK_TCK:
|
1994-03-03 17:08:25 +03:00
|
|
|
*retval = 60; /* should this be `hz', ie. 100? */
|
1994-03-03 17:15:25 +03:00
|
|
|
break;
|
1994-10-26 02:03:22 +03:00
|
|
|
case SUNOS_SC_NGROUPS_MAX:
|
1994-03-03 17:08:25 +03:00
|
|
|
*retval = NGROUPS_MAX;
|
1994-03-03 17:15:25 +03:00
|
|
|
break;
|
1994-10-26 02:03:22 +03:00
|
|
|
case SUNOS_SC_OPEN_MAX:
|
1994-05-24 06:15:18 +04:00
|
|
|
*retval = maxfiles;
|
1994-03-03 17:15:25 +03:00
|
|
|
break;
|
1994-10-26 02:03:22 +03:00
|
|
|
case SUNOS_SC_JOB_CONTROL:
|
1994-03-03 17:08:25 +03:00
|
|
|
*retval = 1;
|
1994-03-03 17:15:25 +03:00
|
|
|
break;
|
1994-10-26 02:03:22 +03:00
|
|
|
case SUNOS_SC_SAVED_IDS:
|
1994-03-03 17:08:25 +03:00
|
|
|
#ifdef _POSIX_SAVED_IDS
|
|
|
|
*retval = 1;
|
|
|
|
#else
|
|
|
|
*retval = 0;
|
|
|
|
#endif
|
1994-03-03 17:15:25 +03:00
|
|
|
break;
|
1994-10-26 02:03:22 +03:00
|
|
|
case SUNOS_SC_VERSION:
|
1994-03-03 17:08:25 +03:00
|
|
|
*retval = 198808;
|
1994-03-03 17:15:25 +03:00
|
|
|
break;
|
1994-03-03 17:08:25 +03:00
|
|
|
default:
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
1994-04-26 23:50:37 +04:00
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
#define SUNOS_RLIMIT_NOFILE 6 /* Other RLIMIT_* are the same */
|
|
|
|
#define SUNOS_RLIM_NLIMITS 7
|
1994-04-26 23:50:37 +04:00
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_getrlimit(p, v, retval)
|
1994-04-26 23:50:37 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:42:02 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1994-04-26 23:50:37 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sunos_sys_getrlimit_args *uap = v;
|
1995-09-20 02:42:02 +04:00
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
if (SCARG(uap, which) >= SUNOS_RLIM_NLIMITS)
|
1994-04-26 23:50:37 +04:00
|
|
|
return EINVAL;
|
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
if (SCARG(uap, which) == SUNOS_RLIMIT_NOFILE)
|
|
|
|
SCARG(uap, which) = RLIMIT_NOFILE;
|
1994-04-26 23:50:37 +04:00
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
return compat_43_sys_getrlimit(p, uap, retval);
|
1994-04-26 23:50:37 +04:00
|
|
|
}
|
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_setrlimit(p, v, retval)
|
1994-04-26 23:50:37 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:42:02 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1994-04-26 23:50:37 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sunos_sys_getrlimit_args *uap = v;
|
1995-09-20 02:42:02 +04:00
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
if (SCARG(uap, which) >= SUNOS_RLIM_NLIMITS)
|
1994-04-26 23:50:37 +04:00
|
|
|
return EINVAL;
|
|
|
|
|
1994-10-26 02:03:22 +03:00
|
|
|
if (SCARG(uap, which) == SUNOS_RLIMIT_NOFILE)
|
|
|
|
SCARG(uap, which) = RLIMIT_NOFILE;
|
1994-04-26 23:50:37 +04:00
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
return compat_43_sys_setrlimit(p, uap, retval);
|
1994-04-26 23:50:37 +04:00
|
|
|
}
|
1994-11-21 00:31:10 +03:00
|
|
|
|
1994-11-23 10:05:20 +03:00
|
|
|
/* for the m68k machines */
|
|
|
|
#ifndef PT_GETFPREGS
|
|
|
|
#define PT_GETFPREGS -1
|
|
|
|
#endif
|
|
|
|
#ifndef PT_SETFPREGS
|
|
|
|
#define PT_SETFPREGS -1
|
|
|
|
#endif
|
|
|
|
|
1994-11-21 00:31:10 +03:00
|
|
|
static int sreq2breq[] = {
|
|
|
|
PT_TRACE_ME, PT_READ_I, PT_READ_D, -1,
|
|
|
|
PT_WRITE_I, PT_WRITE_D, -1, PT_CONTINUE,
|
|
|
|
PT_KILL, -1, PT_ATTACH, PT_DETACH,
|
|
|
|
PT_GETREGS, PT_SETREGS, PT_GETFPREGS, PT_SETFPREGS
|
|
|
|
};
|
|
|
|
static int nreqs = sizeof(sreq2breq) / sizeof(sreq2breq[0]);
|
|
|
|
|
1996-03-14 22:33:44 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_ptrace(p, v, retval)
|
1994-11-21 00:31:10 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:42:02 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-11-21 00:31:10 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sunos_sys_ptrace_args *uap = v;
|
|
|
|
struct sys_ptrace_args pa;
|
1994-11-21 00:31:10 +03:00
|
|
|
int req;
|
|
|
|
|
|
|
|
req = SCARG(uap, req);
|
|
|
|
|
|
|
|
if (req < 0 || req >= nreqs)
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
req = sreq2breq[req];
|
|
|
|
if (req == -1)
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
SCARG(&pa, req) = req;
|
|
|
|
SCARG(&pa, pid) = (pid_t)SCARG(uap, pid);
|
|
|
|
SCARG(&pa, addr) = (caddr_t)SCARG(uap, addr);
|
|
|
|
SCARG(&pa, data) = SCARG(uap, data);
|
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_ptrace(p, &pa, retval);
|
1994-11-21 00:31:10 +03:00
|
|
|
}
|
|
|
|
|
1995-04-23 03:45:29 +04:00
|
|
|
/*
|
|
|
|
* SunOS reboot system call (for compatibility).
|
|
|
|
* Sun lets you pass in a boot string which the PROM
|
|
|
|
* saves and provides to the next boot program.
|
|
|
|
*/
|
1996-08-11 07:16:26 +04:00
|
|
|
|
|
|
|
#define SUNOS_RB_ASKNAME 0x001
|
|
|
|
#define SUNOS_RB_SINGLE 0x002
|
|
|
|
#define SUNOS_RB_NOSYNC 0x004
|
|
|
|
#define SUNOS_RB_HALT 0x008
|
|
|
|
#define SUNOS_RB_DUMP 0x080
|
|
|
|
#define SUNOS_RB_STRING 0x200
|
|
|
|
|
1995-04-23 03:45:29 +04:00
|
|
|
static struct sunos_howto_conv {
|
1995-04-27 03:12:02 +04:00
|
|
|
int sun_howto;
|
1995-04-23 03:45:29 +04:00
|
|
|
int bsd_howto;
|
|
|
|
} sunos_howto_conv[] = {
|
1996-08-11 07:16:26 +04:00
|
|
|
{ SUNOS_RB_ASKNAME, RB_ASKNAME },
|
|
|
|
{ SUNOS_RB_SINGLE, RB_SINGLE },
|
|
|
|
{ SUNOS_RB_NOSYNC, RB_NOSYNC },
|
|
|
|
{ SUNOS_RB_HALT, RB_HALT },
|
|
|
|
{ SUNOS_RB_DUMP, RB_DUMP },
|
|
|
|
{ SUNOS_RB_STRING, RB_STRING },
|
|
|
|
{ 0x000, 0 },
|
1995-04-23 03:45:29 +04:00
|
|
|
};
|
|
|
|
|
1995-04-27 03:12:02 +04:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_reboot(p, v, retval)
|
1995-04-23 03:45:29 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:42:02 +04:00
|
|
|
void *v;
|
1995-04-27 03:12:02 +04:00
|
|
|
register_t *retval;
|
1995-04-23 03:45:29 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sunos_sys_reboot_args *uap = v;
|
1996-08-11 07:16:26 +04:00
|
|
|
struct sys_reboot_args ua;
|
1995-04-23 03:45:29 +04:00
|
|
|
struct sunos_howto_conv *convp;
|
1995-04-27 03:12:02 +04:00
|
|
|
int error, bsd_howto, sun_howto;
|
1996-08-11 07:16:26 +04:00
|
|
|
char *bootstr;
|
1995-04-23 03:45:29 +04:00
|
|
|
|
1996-08-11 07:16:26 +04:00
|
|
|
if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
|
1995-04-23 03:45:29 +04:00
|
|
|
return (error);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Convert howto bits to BSD format.
|
|
|
|
*/
|
1995-04-27 03:12:02 +04:00
|
|
|
sun_howto = SCARG(uap, howto);
|
1995-04-23 03:45:29 +04:00
|
|
|
bsd_howto = 0;
|
|
|
|
convp = sunos_howto_conv;
|
1995-04-27 03:12:02 +04:00
|
|
|
while (convp->sun_howto) {
|
1996-08-11 07:16:26 +04:00
|
|
|
if (sun_howto & convp->sun_howto)
|
1995-04-23 03:45:29 +04:00
|
|
|
bsd_howto |= convp->bsd_howto;
|
|
|
|
convp++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Sun RB_STRING (Get user supplied bootstring.)
|
1995-04-27 03:12:02 +04:00
|
|
|
* If the machine supports passing a string to the
|
1996-08-09 14:30:23 +04:00
|
|
|
* next booted kernel.
|
1995-04-23 03:45:29 +04:00
|
|
|
*/
|
1995-04-27 03:12:02 +04:00
|
|
|
if (sun_howto & SUNOS_RB_STRING) {
|
|
|
|
char bs[128];
|
|
|
|
|
1995-04-27 16:05:37 +04:00
|
|
|
error = copyinstr(SCARG(uap, bootstr), bs, sizeof(bs), 0);
|
1996-08-09 14:30:23 +04:00
|
|
|
|
1996-08-11 07:16:26 +04:00
|
|
|
if (error)
|
|
|
|
bootstr = NULL;
|
|
|
|
else
|
|
|
|
bootstr = bs;
|
1996-08-09 14:30:23 +04:00
|
|
|
} else
|
1996-08-11 07:16:26 +04:00
|
|
|
bootstr = NULL;
|
1995-04-27 03:12:02 +04:00
|
|
|
|
1996-08-11 07:16:26 +04:00
|
|
|
SCARG(&ua, opt) = bsd_howto;
|
|
|
|
SCARG(&ua, bootstr) = bootstr;
|
|
|
|
sys_reboot(p, &ua, retval);
|
|
|
|
return(0);
|
1995-04-23 03:45:29 +04:00
|
|
|
}
|
1995-06-25 00:22:33 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Generalized interface signal handler, 4.3-compatible.
|
|
|
|
*/
|
|
|
|
/* ARGSUSED */
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
sunos_sys_sigvec(p, v, retval)
|
1995-06-25 00:22:33 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:42:02 +04:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
register struct sunos_sys_sigvec_args /* {
|
1995-06-25 00:22:33 +04:00
|
|
|
syscallarg(int) signum;
|
|
|
|
syscallarg(struct sigvec *) nsv;
|
|
|
|
syscallarg(struct sigvec *) osv;
|
1995-09-20 02:42:02 +04:00
|
|
|
} */ *uap = v;
|
1995-06-25 00:22:33 +04:00
|
|
|
struct sigvec vec;
|
|
|
|
register struct sigacts *ps = p->p_sigacts;
|
|
|
|
register struct sigvec *sv;
|
|
|
|
register int signum;
|
|
|
|
int bit, error;
|
|
|
|
|
|
|
|
signum = SCARG(uap, signum);
|
|
|
|
if (signum <= 0 || signum >= NSIG ||
|
|
|
|
signum == SIGKILL || signum == SIGSTOP)
|
|
|
|
return (EINVAL);
|
|
|
|
sv = &vec;
|
|
|
|
if (SCARG(uap, osv)) {
|
|
|
|
*(sig_t *)&sv->sv_handler = ps->ps_sigact[signum];
|
|
|
|
sv->sv_mask = ps->ps_catchmask[signum];
|
|
|
|
bit = sigmask(signum);
|
|
|
|
sv->sv_flags = 0;
|
|
|
|
if ((ps->ps_sigonstack & bit) != 0)
|
|
|
|
sv->sv_flags |= SV_ONSTACK;
|
|
|
|
if ((ps->ps_sigintr & bit) != 0)
|
|
|
|
sv->sv_flags |= SV_INTERRUPT;
|
1995-10-07 09:25:19 +03:00
|
|
|
if ((ps->ps_sigreset & bit) != 0)
|
|
|
|
sv->sv_flags |= SA_RESETHAND;
|
|
|
|
sv->sv_mask &= ~bit;
|
1996-03-14 22:33:44 +03:00
|
|
|
error = copyout((caddr_t)sv, (caddr_t)SCARG(uap, osv),
|
|
|
|
sizeof (vec));
|
|
|
|
if (error)
|
1995-06-25 00:22:33 +04:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
if (SCARG(uap, nsv)) {
|
1996-03-14 22:33:44 +03:00
|
|
|
error = copyin((caddr_t)SCARG(uap, nsv), (caddr_t)sv,
|
|
|
|
sizeof (vec));
|
|
|
|
if (error)
|
1995-06-25 00:22:33 +04:00
|
|
|
return (error);
|
|
|
|
/*
|
1995-08-15 21:28:02 +04:00
|
|
|
* SunOS uses the mask 0x0004 as SV_RESETHAND
|
|
|
|
* meaning: `reset to SIG_DFL on delivery'.
|
|
|
|
* We support only the bits in: 0xF
|
|
|
|
* (those bits are the same as ours)
|
1995-06-25 00:22:33 +04:00
|
|
|
*/
|
1995-08-15 21:28:02 +04:00
|
|
|
if (sv->sv_flags & ~0xF)
|
|
|
|
return (EINVAL);
|
|
|
|
/* SunOS binaries have a user-mode trampoline. */
|
|
|
|
sv->sv_flags |= SA_USERTRAMP;
|
|
|
|
/* Convert sigvec:SV_INTERRUPT to sigaction:SA_RESTART */
|
|
|
|
sv->sv_flags ^= SA_RESTART; /* same bit, inverted */
|
1995-06-25 00:22:33 +04:00
|
|
|
setsigvec(p, signum, (struct sigaction *)sv);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|