2001-11-13 05:07:52 +03:00
|
|
|
/* $NetBSD: ibcs2_misc.c,v 1.58 2001/11/13 02:08:26 lukem Exp $ */
|
1994-10-26 05:45:11 +03:00
|
|
|
|
1994-08-24 23:13:39 +04:00
|
|
|
/*
|
1998-02-09 05:30:42 +03:00
|
|
|
* Copyright (c) 1994, 1995, 1998 Scott Bartram
|
1994-08-24 23:13:39 +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.
|
|
|
|
*
|
|
|
|
* from: Header: sun_misc.c,v 1.16 93/04/07 02:46:27 torek Exp
|
|
|
|
*
|
|
|
|
* @(#)sun_misc.c 8.1 (Berkeley) 6/18/93
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* IBCS2 compatibility module.
|
|
|
|
*
|
|
|
|
* IBCS2 system calls that are implemented differently in BSD are
|
|
|
|
* handled here.
|
|
|
|
*/
|
|
|
|
|
2001-11-13 05:07:52 +03:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__KERNEL_RCSID(0, "$NetBSD: ibcs2_misc.c,v 1.58 2001/11/13 02:08:26 lukem Exp $");
|
|
|
|
|
1994-08-24 23:13:39 +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-08-24 23:13:39 +04:00
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/filedesc.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <sys/mount.h>
|
1994-09-05 05:28:57 +04:00
|
|
|
#include <sys/reboot.h>
|
1994-08-24 23:13:39 +04:00
|
|
|
#include <sys/resource.h>
|
|
|
|
#include <sys/resourcevar.h>
|
|
|
|
#include <sys/socket.h>
|
1995-03-14 18:12:17 +03:00
|
|
|
#include <sys/stat.h>
|
1998-06-28 05:20:06 +04:00
|
|
|
#include <sys/syslog.h>
|
1994-08-24 23:13:39 +04:00
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/times.h>
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
#include <sys/uio.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <sys/utsname.h>
|
|
|
|
#include <sys/unistd.h>
|
|
|
|
|
|
|
|
#include <netinet/in.h>
|
1995-03-14 18:12:17 +03:00
|
|
|
#include <sys/syscallargs.h>
|
1994-08-24 23:13:39 +04:00
|
|
|
|
|
|
|
#include <miscfs/specfs/specdev.h>
|
|
|
|
|
2000-06-28 19:39:24 +04:00
|
|
|
#include <uvm/uvm_extern.h>
|
|
|
|
#include <sys/sysctl.h>
|
1994-08-24 23:13:39 +04:00
|
|
|
|
2000-02-27 20:30:10 +03:00
|
|
|
#if defined(__i386__)
|
1994-08-24 23:13:39 +04:00
|
|
|
#include <i386/include/reg.h>
|
2000-02-27 20:30:10 +03:00
|
|
|
#endif
|
1994-08-24 23:13:39 +04:00
|
|
|
|
|
|
|
#include <compat/ibcs2/ibcs2_types.h>
|
|
|
|
#include <compat/ibcs2/ibcs2_dirent.h>
|
|
|
|
#include <compat/ibcs2/ibcs2_fcntl.h>
|
1998-02-09 05:30:42 +03:00
|
|
|
#include <compat/ibcs2/ibcs2_mman.h>
|
1994-08-24 23:13:39 +04:00
|
|
|
#include <compat/ibcs2/ibcs2_time.h>
|
1995-03-14 18:12:17 +03:00
|
|
|
#include <compat/ibcs2/ibcs2_signal.h>
|
|
|
|
#include <compat/ibcs2/ibcs2_timeb.h>
|
1994-08-24 23:13:39 +04:00
|
|
|
#include <compat/ibcs2/ibcs2_unistd.h>
|
|
|
|
#include <compat/ibcs2/ibcs2_utsname.h>
|
1995-03-14 18:12:17 +03:00
|
|
|
#include <compat/ibcs2/ibcs2_util.h>
|
|
|
|
#include <compat/ibcs2/ibcs2_utime.h>
|
|
|
|
#include <compat/ibcs2/ibcs2_syscallargs.h>
|
1996-01-06 06:23:46 +03:00
|
|
|
#include <compat/ibcs2/ibcs2_sysi86.h>
|
2000-11-21 03:37:49 +03:00
|
|
|
#include <compat/ibcs2/ibcs2_exec.h>
|
1994-08-24 23:13:39 +04:00
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_ulimit(p, v, retval)
|
1994-08-24 23:13:39 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-08-24 23:13:39 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_ulimit_args /* {
|
|
|
|
syscallarg(int) cmd;
|
|
|
|
syscallarg(int) newlimit;
|
|
|
|
} */ *uap = v;
|
1996-05-03 21:05:16 +04:00
|
|
|
#ifdef notyet
|
1994-08-24 23:13:39 +04:00
|
|
|
int error;
|
|
|
|
struct rlimit rl;
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sys_setrlimit_args sra;
|
1996-05-03 21:05:16 +04:00
|
|
|
#endif
|
1995-03-14 18:12:17 +03:00
|
|
|
#define IBCS2_GETFSIZE 1
|
|
|
|
#define IBCS2_SETFSIZE 2
|
|
|
|
#define IBCS2_GETPSIZE 3
|
|
|
|
#define IBCS2_GETDTABLESIZE 4
|
1994-08-24 23:13:39 +04:00
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
switch (SCARG(uap, cmd)) {
|
1994-08-24 23:13:39 +04:00
|
|
|
case IBCS2_GETFSIZE:
|
|
|
|
*retval = p->p_rlimit[RLIMIT_FSIZE].rlim_cur;
|
|
|
|
return 0;
|
|
|
|
case IBCS2_SETFSIZE: /* XXX - fix this */
|
|
|
|
#ifdef notyet
|
1995-03-14 18:12:17 +03:00
|
|
|
rl.rlim_cur = SCARG(uap, newlimit);
|
1997-09-10 01:14:00 +04:00
|
|
|
SCARG(&sra, which) = RLIMIT_FSIZE;
|
|
|
|
SCARG(&sra, rlp) = &rl;
|
1994-08-24 23:13:39 +04:00
|
|
|
error = setrlimit(p, &sra, retval);
|
|
|
|
if (!error)
|
|
|
|
*retval = p->p_rlimit[RLIMIT_FSIZE].rlim_cur;
|
|
|
|
else
|
|
|
|
DPRINTF(("failed "));
|
|
|
|
return error;
|
|
|
|
#else
|
1995-03-14 18:12:17 +03:00
|
|
|
*retval = SCARG(uap, newlimit);
|
1994-08-24 23:13:39 +04:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
case IBCS2_GETPSIZE:
|
|
|
|
*retval = p->p_rlimit[RLIMIT_RSS].rlim_cur; /* XXX */
|
|
|
|
return 0;
|
1995-03-14 18:12:17 +03:00
|
|
|
case IBCS2_GETDTABLESIZE:
|
1997-09-10 01:14:00 +04:00
|
|
|
SCARG(uap, cmd) = IBCS2_SC_OPEN_MAX;
|
1995-10-07 09:25:19 +03:00
|
|
|
return ibcs2_sys_sysconf(p, uap, retval);
|
1994-08-24 23:13:39 +04:00
|
|
|
default:
|
|
|
|
return ENOSYS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_waitsys(p, v, retval)
|
1994-08-24 23:13:39 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-08-24 23:13:39 +04:00
|
|
|
{
|
2000-01-13 09:33:29 +03:00
|
|
|
#if defined(__i386__)
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_waitsys_args /* {
|
|
|
|
syscallarg(int) a1;
|
|
|
|
syscallarg(int) a2;
|
|
|
|
syscallarg(int) a3;
|
|
|
|
} */ *uap = v;
|
2000-01-13 09:33:29 +03:00
|
|
|
#endif
|
1996-05-03 21:05:16 +04:00
|
|
|
int error;
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sys_wait4_args w4;
|
1997-09-12 03:05:02 +04:00
|
|
|
caddr_t sg;
|
|
|
|
|
|
|
|
sg = stackgap_init(p->p_emul);
|
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
SCARG(&w4, rusage) = NULL;
|
1997-09-12 03:05:02 +04:00
|
|
|
SCARG(&w4, status) = stackgap_alloc(&sg, sizeof(int));
|
|
|
|
|
2000-01-10 06:16:25 +03:00
|
|
|
#if defined(__i386__)
|
|
|
|
#define WAITPID_EFLAGS 0x8c4 /* OF, SF, ZF, PF */
|
1995-05-01 23:33:17 +04:00
|
|
|
if ((p->p_md.md_regs->tf_eflags & WAITPID_EFLAGS) == WAITPID_EFLAGS) {
|
1994-08-24 23:13:39 +04:00
|
|
|
/* waitpid */
|
1995-03-14 18:12:17 +03:00
|
|
|
SCARG(&w4, pid) = SCARG(uap, a1);
|
|
|
|
SCARG(&w4, options) = SCARG(uap, a3);
|
1994-08-24 23:13:39 +04:00
|
|
|
} else {
|
2000-01-13 09:33:29 +03:00
|
|
|
#endif
|
1994-08-24 23:13:39 +04:00
|
|
|
/* wait */
|
1995-03-14 18:12:17 +03:00
|
|
|
SCARG(&w4, pid) = WAIT_ANY;
|
|
|
|
SCARG(&w4, options) = 0;
|
2000-01-13 09:33:29 +03:00
|
|
|
#if defined(__i386__)
|
1994-08-24 23:13:39 +04:00
|
|
|
}
|
2000-01-13 09:33:29 +03:00
|
|
|
#endif
|
1997-09-12 03:05:02 +04:00
|
|
|
|
1995-10-07 09:25:19 +03:00
|
|
|
if ((error = sys_wait4(p, &w4, retval)) != 0)
|
1995-03-14 18:12:17 +03:00
|
|
|
return error;
|
1997-09-12 03:05:02 +04:00
|
|
|
|
|
|
|
return copyin((caddr_t)SCARG(&w4, status), (caddr_t)&retval[1],
|
|
|
|
sizeof(int));
|
1994-08-24 23:13:39 +04:00
|
|
|
}
|
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_execv(p, v, retval)
|
1994-08-24 23:13:39 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-08-24 23:13:39 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_execv_args /* {
|
1999-02-09 23:21:18 +03:00
|
|
|
syscallarg(const char *) path;
|
1995-10-07 09:25:19 +03:00
|
|
|
syscallarg(char **) argp;
|
|
|
|
} */ *uap = v;
|
1996-09-03 07:12:17 +04:00
|
|
|
struct sys_execve_args ap;
|
|
|
|
caddr_t sg;
|
1995-03-14 18:12:17 +03:00
|
|
|
|
1996-09-03 07:12:17 +04:00
|
|
|
sg = stackgap_init(p->p_emul);
|
2000-12-01 15:28:30 +03:00
|
|
|
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) = NULL;
|
|
|
|
|
|
|
|
return sys_execve(p, &ap, retval);
|
1994-08-24 23:13:39 +04:00
|
|
|
}
|
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
int
|
1996-09-03 07:12:17 +04:00
|
|
|
ibcs2_sys_execve(p, v, retval)
|
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1996-09-03 07:12:17 +04:00
|
|
|
register_t *retval;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
1996-09-03 07:12:17 +04:00
|
|
|
struct ibcs2_sys_execve_args /* {
|
1999-02-09 23:21:18 +03:00
|
|
|
syscallarg(const char *) path;
|
1995-10-07 09:25:19 +03:00
|
|
|
syscallarg(char **) argp;
|
|
|
|
syscallarg(char **) envp;
|
|
|
|
} */ *uap = v;
|
1996-09-03 07:12:17 +04:00
|
|
|
struct sys_execve_args ap;
|
|
|
|
caddr_t sg;
|
|
|
|
|
|
|
|
sg = stackgap_init(p->p_emul);
|
2000-12-01 15:28:30 +03:00
|
|
|
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);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
1996-09-03 07:12:17 +04:00
|
|
|
return sys_execve(p, &ap, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
1994-08-24 23:13:39 +04:00
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_umount(p, v, retval)
|
1994-08-24 23:13:39 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-08-24 23:13:39 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_umount_args /* {
|
|
|
|
syscallarg(char *) name;
|
|
|
|
} */ *uap = v;
|
|
|
|
struct sys_unmount_args um;
|
1994-08-24 23:13:39 +04:00
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
SCARG(&um, path) = SCARG(uap, name);
|
|
|
|
SCARG(&um, flags) = 0;
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_unmount(p, &um, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
1994-08-24 23:13:39 +04:00
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_mount(p, v, retval)
|
1994-08-24 23:13:39 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-08-24 23:13:39 +04:00
|
|
|
{
|
1996-05-03 21:05:16 +04:00
|
|
|
#ifdef notyet
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_mount_args /* {
|
|
|
|
syscallarg(char *) special;
|
|
|
|
syscallarg(char *) dir;
|
|
|
|
syscallarg(int) flags;
|
|
|
|
syscallarg(int) fstype;
|
|
|
|
syscallarg(char *) data;
|
|
|
|
syscallarg(int) len;
|
|
|
|
} */ *uap = v;
|
1995-03-14 18:12:17 +03:00
|
|
|
int oflags = SCARG(uap, flags), nflags, error;
|
1994-08-24 23:13:39 +04:00
|
|
|
char fsname[MFSNAMELEN];
|
|
|
|
|
|
|
|
if (oflags & (IBCS2_MS_NOSUB | IBCS2_MS_SYS5))
|
|
|
|
return (EINVAL);
|
|
|
|
if ((oflags & IBCS2_MS_NEWTYPE) == 0)
|
|
|
|
return (EINVAL);
|
|
|
|
nflags = 0;
|
|
|
|
if (oflags & IBCS2_MS_RDONLY)
|
|
|
|
nflags |= MNT_RDONLY;
|
|
|
|
if (oflags & IBCS2_MS_NOSUID)
|
|
|
|
nflags |= MNT_NOSUID;
|
|
|
|
if (oflags & IBCS2_MS_REMOUNT)
|
|
|
|
nflags |= MNT_UPDATE;
|
1995-03-14 18:12:17 +03:00
|
|
|
SCARG(uap, flags) = nflags;
|
1994-08-24 23:13:39 +04:00
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
if (error = copyinstr((caddr_t)SCARG(uap, type), fsname, sizeof fsname,
|
1994-08-24 23:13:39 +04:00
|
|
|
(u_int *)0))
|
|
|
|
return (error);
|
|
|
|
|
1995-06-18 18:45:14 +04:00
|
|
|
if (strncmp(fsname, "4.2", sizeof fsname) == 0) {
|
1995-03-14 18:12:17 +03:00
|
|
|
SCARG(uap, type) = (caddr_t)STACK_ALLOC();
|
1995-11-08 01:27:21 +03:00
|
|
|
if (error = copyout("ffs", SCARG(uap, type), sizeof("ffs")))
|
1994-08-24 23:13:39 +04:00
|
|
|
return (error);
|
1995-06-18 18:45:14 +04:00
|
|
|
} else if (strncmp(fsname, "nfs", sizeof fsname) == 0) {
|
1994-08-24 23:13:39 +04:00
|
|
|
struct ibcs2_nfs_args sna;
|
|
|
|
struct sockaddr_in sain;
|
|
|
|
struct nfs_args na;
|
|
|
|
struct sockaddr sa;
|
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
if (error = copyin(SCARG(uap, data), &sna, sizeof sna))
|
1994-08-24 23:13:39 +04:00
|
|
|
return (error);
|
|
|
|
if (error = copyin(sna.addr, &sain, sizeof sain))
|
|
|
|
return (error);
|
1998-08-10 00:36:58 +04:00
|
|
|
memcpy(&sa, &sain, sizeof sa);
|
1994-08-24 23:13:39 +04:00
|
|
|
sa.sa_len = sizeof(sain);
|
1995-03-14 18:12:17 +03:00
|
|
|
SCARG(uap, data) = (caddr_t)STACK_ALLOC();
|
|
|
|
na.addr = (struct sockaddr *)((int)SCARG(uap, data) + sizeof na);
|
1994-08-24 23:13:39 +04:00
|
|
|
na.sotype = SOCK_DGRAM;
|
|
|
|
na.proto = IPPROTO_UDP;
|
|
|
|
na.fh = (nfsv2fh_t *)sna.fh;
|
|
|
|
na.flags = sna.flags;
|
|
|
|
na.wsize = sna.wsize;
|
|
|
|
na.rsize = sna.rsize;
|
|
|
|
na.timeo = sna.timeo;
|
|
|
|
na.retrans = sna.retrans;
|
|
|
|
na.hostname = sna.hostname;
|
|
|
|
|
|
|
|
if (error = copyout(&sa, na.addr, sizeof sa))
|
|
|
|
return (error);
|
1995-03-14 18:12:17 +03:00
|
|
|
if (error = copyout(&na, SCARG(uap, data), sizeof na))
|
1994-08-24 23:13:39 +04:00
|
|
|
return (error);
|
|
|
|
}
|
1995-10-07 09:25:19 +03:00
|
|
|
return (sys_mount(p, uap, retval));
|
1994-08-24 23:13:39 +04:00
|
|
|
#else
|
|
|
|
return EINVAL;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read iBCS2-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?
|
|
|
|
*/
|
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_getdents(p, v, retval)
|
1994-08-24 23:13:39 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-08-24 23:13:39 +04:00
|
|
|
{
|
2000-03-30 15:24:16 +04:00
|
|
|
struct ibcs2_sys_getdents_args /* {
|
1995-10-07 09:25:19 +03:00
|
|
|
syscallarg(int) fd;
|
|
|
|
syscallarg(char *) buf;
|
|
|
|
syscallarg(int) nbytes;
|
|
|
|
} */ *uap = v;
|
2000-03-30 15:24:16 +04:00
|
|
|
struct dirent *bdp;
|
1995-10-09 14:23:57 +03:00
|
|
|
struct vnode *vp;
|
|
|
|
caddr_t inp, buf; /* BSD-format */
|
|
|
|
int len, reclen; /* BSD-format */
|
|
|
|
caddr_t outp; /* iBCS2-format */
|
|
|
|
int resid, ibcs2_reclen;/* iBCS2-format */
|
1994-08-24 23:13:39 +04:00
|
|
|
struct file *fp;
|
|
|
|
struct uio auio;
|
|
|
|
struct iovec aiov;
|
|
|
|
struct ibcs2_dirent idb;
|
|
|
|
off_t off; /* true file offset */
|
|
|
|
int buflen, error, eofflag;
|
1998-03-03 16:44:48 +03:00
|
|
|
off_t *cookiebuf = NULL, *cookie;
|
1995-10-09 14:23:57 +03:00
|
|
|
int ncookies;
|
1994-08-24 23:13:39 +04:00
|
|
|
|
1999-05-06 00:01:01 +04:00
|
|
|
/* getvnode() will use the descriptor for us */
|
1995-03-14 18:12:17 +03:00
|
|
|
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
|
1994-08-24 23:13:39 +04:00
|
|
|
return (error);
|
1999-05-06 00:01:01 +04:00
|
|
|
if ((fp->f_flag & FREAD) == 0) {
|
|
|
|
error = EBADF;
|
|
|
|
goto out1;
|
|
|
|
}
|
1994-08-24 23:13:39 +04:00
|
|
|
vp = (struct vnode *)fp->f_data;
|
1999-05-06 00:01:01 +04:00
|
|
|
if (vp->v_type != VDIR) {
|
|
|
|
error = EINVAL;
|
|
|
|
goto out1;
|
|
|
|
}
|
1995-03-14 18:12:17 +03:00
|
|
|
buflen = min(MAXBSIZE, SCARG(uap, nbytes));
|
1994-08-24 23:13:39 +04:00
|
|
|
buf = malloc(buflen, M_TEMP, M_WAITOK);
|
1998-03-01 05:20:01 +03:00
|
|
|
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
1994-08-24 23:13:39 +04:00
|
|
|
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.
|
|
|
|
*/
|
1998-03-01 05:20:01 +03:00
|
|
|
error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &cookiebuf,
|
|
|
|
&ncookies);
|
1995-10-09 14:23:57 +03:00
|
|
|
if (error)
|
1994-08-24 23:13:39 +04:00
|
|
|
goto out;
|
|
|
|
inp = buf;
|
1995-03-14 18:12:17 +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)
|
1994-08-24 23:13:39 +04: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;
|
1994-08-24 23:13:39 +04:00
|
|
|
if (reclen & 3)
|
1997-10-10 05:42:21 +04:00
|
|
|
panic("ibcs2_getdents: bad reclen");
|
|
|
|
if ((*cookie >> 32) != 0) {
|
|
|
|
compat_offseterr(vp, "ibcs2_getdents");
|
|
|
|
error = EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
1995-10-09 14:23:57 +03:00
|
|
|
if (bdp->d_fileno == 0) {
|
1994-08-24 23:13:39 +04:00
|
|
|
inp += reclen; /* it is a hole; squish it out */
|
1997-08-04 13:48:07 +04:00
|
|
|
off = *cookie++;
|
1994-08-24 23:13:39 +04:00
|
|
|
continue;
|
|
|
|
}
|
1995-10-09 14:23:57 +03:00
|
|
|
ibcs2_reclen = IBCS2_RECLEN(&idb, bdp->d_namlen);
|
|
|
|
if (reclen > len || resid < ibcs2_reclen) {
|
1994-08-24 23:13:39 +04: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 the next */
|
1994-08-24 23:13:39 +04:00
|
|
|
/*
|
|
|
|
* Massage in place to make a iBCS2-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_ino = (ibcs2_ino_t)bdp->d_fileno;
|
1994-08-24 23:13:39 +04:00
|
|
|
idb.d_off = (ibcs2_off_t)off;
|
1995-10-09 14:23:57 +03:00
|
|
|
idb.d_reclen = (u_short)ibcs2_reclen;
|
|
|
|
strcpy(idb.d_name, bdp->d_name);
|
1996-09-03 06:44:14 +04:00
|
|
|
error = copyout(&idb, outp, ibcs2_reclen);
|
|
|
|
if (error)
|
1994-08-24 23:13:39 +04:00
|
|
|
goto out;
|
|
|
|
/* advance past this real entry */
|
|
|
|
inp += reclen;
|
1995-03-14 18:12:17 +03:00
|
|
|
/* advance output past iBCS2-shaped entry */
|
1995-10-09 14:23:57 +03:00
|
|
|
outp += ibcs2_reclen;
|
|
|
|
resid -= ibcs2_reclen;
|
1994-08-24 23:13:39 +04:00
|
|
|
}
|
1995-10-09 14:23:57 +03:00
|
|
|
|
1994-08-24 23:13:39 +04:00
|
|
|
/* if we squished out the whole block, try again */
|
1995-03-14 18:12:17 +03:00
|
|
|
if (outp == SCARG(uap, buf))
|
1994-08-24 23:13:39 +04:00
|
|
|
goto again;
|
1995-10-09 14:23:57 +03:00
|
|
|
fp->f_offset = off; /* update the vnode offset */
|
|
|
|
|
1994-08-24 23:13:39 +04:00
|
|
|
eof:
|
1995-03-14 18:12:17 +03:00
|
|
|
*retval = SCARG(uap, nbytes) - resid;
|
1994-08-24 23:13:39 +04:00
|
|
|
out:
|
1998-03-01 05:20:01 +03:00
|
|
|
VOP_UNLOCK(vp, 0);
|
1998-03-03 16:44:48 +03:00
|
|
|
if (cookiebuf)
|
|
|
|
free(cookiebuf, M_TEMP);
|
1994-08-24 23:13:39 +04:00
|
|
|
free(buf, M_TEMP);
|
1999-05-06 00:01:01 +04:00
|
|
|
out1:
|
|
|
|
FILE_UNUSE(fp, p);
|
1994-08-24 23:13:39 +04:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_read(p, v, retval)
|
1995-03-14 18:12:17 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-08-24 23:13:39 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_read_args /* {
|
|
|
|
syscallarg(int) fd;
|
|
|
|
syscallarg(char *) buf;
|
|
|
|
syscallarg(u_int) nbytes;
|
|
|
|
} */ *uap = v;
|
2000-03-30 15:24:16 +04:00
|
|
|
struct dirent *bdp;
|
1996-09-03 06:44:14 +04:00
|
|
|
struct vnode *vp;
|
|
|
|
caddr_t inp, buf; /* BSD-format */
|
|
|
|
int len, reclen; /* BSD-format */
|
|
|
|
caddr_t outp; /* iBCS2-format */
|
|
|
|
int resid, ibcs2_reclen;/* iBCS2-format */
|
1994-08-24 23:13:39 +04:00
|
|
|
struct file *fp;
|
1995-03-14 18:12:17 +03:00
|
|
|
struct uio auio;
|
|
|
|
struct iovec aiov;
|
|
|
|
struct ibcs2_direct {
|
|
|
|
ibcs2_ino_t ino;
|
|
|
|
char name[14];
|
|
|
|
} idb;
|
2000-08-12 02:19:29 +04:00
|
|
|
int buflen, error, eofflag;
|
|
|
|
size_t size;
|
1998-03-05 07:49:50 +03:00
|
|
|
off_t *cookiebuf = NULL, *cookie;
|
2000-08-12 02:19:29 +04:00
|
|
|
off_t off; /* true file offset */
|
1995-10-09 14:23:57 +03:00
|
|
|
int ncookies;
|
1994-08-24 23:13:39 +04:00
|
|
|
|
1999-05-06 00:01:01 +04:00
|
|
|
/* getvnode() will use the descriptor for us */
|
1996-05-03 21:05:16 +04:00
|
|
|
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) {
|
1995-03-14 18:12:17 +03:00
|
|
|
if (error == EINVAL)
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_read(p, uap, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
else
|
|
|
|
return error;
|
|
|
|
}
|
1999-05-06 00:01:01 +04:00
|
|
|
if ((fp->f_flag & FREAD) == 0) {
|
|
|
|
error = EBADF;
|
|
|
|
goto out1;
|
|
|
|
}
|
1994-08-24 23:13:39 +04:00
|
|
|
vp = (struct vnode *)fp->f_data;
|
1999-05-06 00:01:01 +04:00
|
|
|
if (vp->v_type != VDIR) {
|
|
|
|
FILE_UNUSE(fp, p);
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_read(p, uap, retval);
|
1999-05-06 00:01:01 +04:00
|
|
|
}
|
2000-08-24 01:11:47 +04:00
|
|
|
buflen = min(MAXBSIZE, max(DEV_BSIZE, SCARG(uap, nbytes)));
|
1995-03-14 18:12:17 +03:00
|
|
|
buf = malloc(buflen, M_TEMP, M_WAITOK);
|
1998-03-01 05:20:01 +03:00
|
|
|
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
1995-03-14 18:12:17 +03:00
|
|
|
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;
|
1995-10-09 14:23:57 +03:00
|
|
|
auio.uio_offset = off;
|
1995-03-14 18:12:17 +03:00
|
|
|
/*
|
|
|
|
* First we read into the malloc'ed buffer, then
|
|
|
|
* we massage it into user space, one record at a time.
|
|
|
|
*/
|
1998-03-01 05:20:01 +03:00
|
|
|
error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &cookiebuf,
|
|
|
|
&ncookies);
|
1996-09-03 06:44:14 +04:00
|
|
|
if (error)
|
1995-03-14 18:12:17 +03:00
|
|
|
goto out;
|
1996-09-03 06:44:14 +04:00
|
|
|
inp = buf;
|
1995-03-14 18:12:17 +03:00
|
|
|
outp = SCARG(uap, buf);
|
|
|
|
resid = SCARG(uap, nbytes);
|
2000-08-18 21:38:33 +04:00
|
|
|
if ((len = buflen - auio.uio_resid) == 0)
|
1995-03-14 18:12:17 +03:00
|
|
|
goto eof;
|
1995-10-09 14:23:57 +03:00
|
|
|
for (cookie = cookiebuf; len > 0 && resid > 0; len -= reclen) {
|
|
|
|
bdp = (struct dirent *)inp;
|
|
|
|
reclen = bdp->d_reclen;
|
1995-03-14 18:12:17 +03:00
|
|
|
if (reclen & 3)
|
2000-08-24 01:11:47 +04:00
|
|
|
panic("ibcs2_sys_read");
|
1996-09-03 06:44:14 +04:00
|
|
|
off = *cookie++; /* each entry points to the next */
|
1997-10-10 05:42:21 +04:00
|
|
|
if ((off >> 32) != 0) {
|
|
|
|
error = EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
1995-10-09 14:23:57 +03:00
|
|
|
if (bdp->d_fileno == 0) {
|
1995-03-14 18:12:17 +03:00
|
|
|
inp += reclen; /* it is a hole; squish it out */
|
|
|
|
continue;
|
|
|
|
}
|
1996-09-03 06:44:14 +04:00
|
|
|
ibcs2_reclen = 16;
|
|
|
|
if (reclen > len || resid < ibcs2_reclen) {
|
1995-03-14 18:12:17 +03:00
|
|
|
/* entry too big for buffer, so just stop */
|
|
|
|
outp++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Massage in place to make a iBCS2-shaped dirent (otherwise
|
|
|
|
* we have to worry about touching user memory outside of
|
|
|
|
* the copyout() call).
|
|
|
|
*
|
|
|
|
* TODO: if length(filename) > 14, then break filename into
|
|
|
|
* multiple entries and set inode = 0xffff except last
|
|
|
|
*/
|
1995-10-09 14:23:57 +03:00
|
|
|
idb.ino = (bdp->d_fileno > 0xfffe) ? 0xfffe : bdp->d_fileno;
|
|
|
|
(void)copystr(bdp->d_name, idb.name, 14, &size);
|
1998-08-10 00:36:58 +04:00
|
|
|
memset(idb.name + size, 0, 14 - size);
|
1996-09-03 06:44:14 +04:00
|
|
|
error = copyout(&idb, outp, ibcs2_reclen);
|
1996-05-03 21:05:16 +04:00
|
|
|
if (error)
|
1995-03-14 18:12:17 +03:00
|
|
|
goto out;
|
|
|
|
/* advance past this real entry */
|
|
|
|
inp += reclen;
|
|
|
|
/* advance output past iBCS2-shaped entry */
|
1996-09-03 06:44:14 +04:00
|
|
|
outp += ibcs2_reclen;
|
|
|
|
resid -= ibcs2_reclen;
|
1994-08-24 23:13:39 +04:00
|
|
|
}
|
1995-03-14 18:12:17 +03:00
|
|
|
/* if we squished out the whole block, try again */
|
|
|
|
if (outp == SCARG(uap, buf))
|
|
|
|
goto again;
|
|
|
|
fp->f_offset = off; /* update the vnode offset */
|
|
|
|
eof:
|
|
|
|
*retval = SCARG(uap, nbytes) - resid;
|
|
|
|
out:
|
1998-03-01 05:20:01 +03:00
|
|
|
VOP_UNLOCK(vp, 0);
|
1998-03-05 07:49:50 +03:00
|
|
|
if (cookiebuf)
|
|
|
|
free(cookiebuf, M_TEMP);
|
1995-03-14 18:12:17 +03:00
|
|
|
free(buf, M_TEMP);
|
2000-08-24 01:11:47 +04:00
|
|
|
out1:
|
1999-05-06 00:01:01 +04:00
|
|
|
FILE_UNUSE(fp, p);
|
1995-03-14 18:12:17 +03:00
|
|
|
return (error);
|
1994-08-24 23:13:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_mknod(p, v, retval)
|
1994-08-24 23:13:39 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-08-24 23:13:39 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_mknod_args /* {
|
1999-02-09 23:21:18 +03:00
|
|
|
syscallarg(const char *) path;
|
1995-10-07 09:25:19 +03:00
|
|
|
syscallarg(int) mode;
|
|
|
|
syscallarg(int) dev;
|
|
|
|
} */ *uap = v;
|
1995-06-25 00:18:53 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
1994-08-24 23:13:39 +04:00
|
|
|
|
2000-12-01 15:28:30 +03:00
|
|
|
CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
|
1995-03-14 18:12:17 +03:00
|
|
|
if (S_ISFIFO(SCARG(uap, mode))) {
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sys_mkfifo_args ap;
|
1995-03-14 18:12:17 +03:00
|
|
|
SCARG(&ap, path) = SCARG(uap, path);
|
|
|
|
SCARG(&ap, mode) = SCARG(uap, mode);
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_mkfifo(p, uap, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
} else {
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sys_mknod_args ap;
|
1995-03-14 18:12:17 +03:00
|
|
|
SCARG(&ap, path) = SCARG(uap, path);
|
|
|
|
SCARG(&ap, mode) = SCARG(uap, mode);
|
|
|
|
SCARG(&ap, dev) = SCARG(uap, dev);
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_mknod(p, &ap, retval);
|
1994-08-24 23:13:39 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_getgroups(p, v, retval)
|
1994-08-24 23:13:39 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-08-24 23:13:39 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_getgroups_args /* {
|
|
|
|
syscallarg(int) gidsetsize;
|
|
|
|
syscallarg(ibcs2_gid_t *) gidset;
|
|
|
|
} */ *uap = v;
|
1994-08-24 23:13:39 +04:00
|
|
|
int error, i;
|
2000-08-29 18:33:25 +04:00
|
|
|
ibcs2_gid_t iset[NGROUPS_MAX];
|
|
|
|
gid_t nset[NGROUPS_MAX];
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sys_getgroups_args sa;
|
2000-08-29 18:33:25 +04:00
|
|
|
int gidsetsize;
|
1995-06-25 00:18:53 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
2000-08-29 18:33:25 +04:00
|
|
|
gidsetsize = SCARG(uap, gidsetsize);
|
|
|
|
if (gidsetsize > NGROUPS_MAX)
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
SCARG(&sa, gidsetsize) = gidsetsize;
|
|
|
|
|
|
|
|
if (gidsetsize) {
|
1995-03-14 18:12:17 +03:00
|
|
|
SCARG(&sa, gidset) = stackgap_alloc(&sg, NGROUPS_MAX *
|
|
|
|
sizeof(gid_t *));
|
|
|
|
}
|
1996-05-03 21:05:16 +04:00
|
|
|
if ((error = sys_getgroups(p, &sa, retval)) != 0)
|
1994-08-24 23:13:39 +04:00
|
|
|
return error;
|
2000-08-29 18:33:25 +04:00
|
|
|
if (gidsetsize) {
|
|
|
|
gidsetsize = retval[0];
|
|
|
|
if (gidsetsize < 0)
|
|
|
|
gidsetsize = 0;
|
|
|
|
error = copyin((caddr_t)SCARG(&sa, gidset), (caddr_t)nset,
|
|
|
|
sizeof(gid_t) * gidsetsize);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
for (i = 0; i < gidsetsize; i++)
|
|
|
|
iset[i] = (ibcs2_gid_t)nset[i];
|
|
|
|
error = copyout((caddr_t)iset,
|
|
|
|
(caddr_t)SCARG(uap, gidset),
|
|
|
|
sizeof(ibcs2_gid_t) * retval[0]);
|
|
|
|
}
|
|
|
|
return error;
|
1994-08-24 23:13:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_setgroups(p, v, retval)
|
1994-08-24 23:13:39 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-08-24 23:13:39 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_setgroups_args /* {
|
|
|
|
syscallarg(int) gidsetsize;
|
|
|
|
syscallarg(ibcs2_gid_t *) gidset;
|
|
|
|
} */ *uap = v;
|
1994-08-24 23:13:39 +04:00
|
|
|
int error, i;
|
2000-08-29 18:33:25 +04:00
|
|
|
ibcs2_gid_t iset[NGROUPS_MAX];
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sys_setgroups_args sa;
|
2000-08-29 18:33:25 +04:00
|
|
|
gid_t gp[NGROUPS_MAX], *ngid;
|
1995-06-25 00:18:53 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
SCARG(&sa, gidsetsize) = SCARG(uap, gidsetsize);
|
2000-08-29 18:33:25 +04:00
|
|
|
if (SCARG(uap, gidsetsize) > NGROUPS_MAX)
|
|
|
|
return EINVAL;
|
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
if (SCARG(&sa, gidsetsize)) {
|
1996-05-03 21:05:16 +04:00
|
|
|
error = copyin((caddr_t)SCARG(uap, gidset), (caddr_t)iset,
|
2000-08-29 18:33:25 +04:00
|
|
|
sizeof(ibcs2_gid_t) * SCARG(uap, gidsetsize));
|
1996-05-03 21:05:16 +04:00
|
|
|
if (error)
|
1995-03-14 18:12:17 +03:00
|
|
|
return error;
|
|
|
|
}
|
1996-12-23 02:00:02 +03:00
|
|
|
for (i = 0; i < SCARG(&sa, gidsetsize); i++)
|
|
|
|
gp[i]= (gid_t)iset[i];
|
2000-08-29 18:33:25 +04:00
|
|
|
ngid = stackgap_alloc(&sg, NGROUPS_MAX * sizeof(gid_t));
|
|
|
|
error = copyout(gp, ngid, SCARG(&sa, gidsetsize) * sizeof(gid_t));
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
SCARG(&sa, gidset) = ngid;
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_setgroups(p, &sa, retval);
|
1994-08-24 23:13:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_setuid(p, v, retval)
|
1994-08-24 23:13:39 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-08-24 23:13:39 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_setuid_args /* {
|
|
|
|
syscallarg(int) uid;
|
|
|
|
} */ *uap = v;
|
|
|
|
struct sys_setuid_args sa;
|
1994-08-24 23:13:39 +04:00
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
SCARG(&sa, uid) = (uid_t)SCARG(uap, uid);
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_setuid(p, &sa, retval);
|
1994-08-24 23:13:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_setgid(p, v, retval)
|
1994-08-24 23:13:39 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-08-24 23:13:39 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_setgid_args /* {
|
|
|
|
syscallarg(int) gid;
|
|
|
|
} */ *uap = v;
|
|
|
|
struct sys_setgid_args sa;
|
1994-08-24 23:13:39 +04:00
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
SCARG(&sa, gid) = (gid_t)SCARG(uap, gid);
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_setgid(p, &sa, retval);
|
1994-08-24 23:13:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
xenix_sys_ftime(p, v, retval)
|
1994-08-24 23:13:39 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-08-24 23:13:39 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct xenix_sys_ftime_args /* {
|
|
|
|
syscallarg(struct xenix_timeb *) tp;
|
|
|
|
} */ *uap = v;
|
1994-08-24 23:13:39 +04:00
|
|
|
struct timeval tv;
|
1995-03-14 18:12:17 +03:00
|
|
|
struct xenix_timeb itb;
|
1994-08-24 23:13:39 +04:00
|
|
|
|
|
|
|
microtime(&tv);
|
|
|
|
itb.time = tv.tv_sec;
|
|
|
|
itb.millitm = (tv.tv_usec / 1000);
|
1997-01-15 04:28:28 +03:00
|
|
|
/* NetBSD has no kernel notion of timezone -- fake it. */
|
|
|
|
itb.timezone = 0;
|
|
|
|
itb.dstflag = 0;
|
1995-03-14 18:12:17 +03:00
|
|
|
return copyout((caddr_t)&itb, (caddr_t)SCARG(uap, tp), xenix_timeb_len);
|
1994-08-24 23:13:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_time(p, v, retval)
|
1994-08-24 23:13:39 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-08-24 23:13:39 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_time_args /* {
|
|
|
|
syscallarg(ibcs2_time_t *) tp;
|
|
|
|
} */ *uap = v;
|
1994-08-24 23:13:39 +04:00
|
|
|
struct timeval tv;
|
|
|
|
|
|
|
|
microtime(&tv);
|
|
|
|
*retval = tv.tv_sec;
|
2000-11-21 03:37:49 +03:00
|
|
|
if (p->p_emuldata == IBCS2_EXEC_XENIX && SCARG(uap, tp))
|
1995-03-14 18:12:17 +03:00
|
|
|
return copyout((caddr_t)&tv.tv_sec, (caddr_t)SCARG(uap, tp),
|
1994-08-24 23:13:39 +04:00
|
|
|
sizeof(ibcs2_time_t));
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_pathconf(p, v, retval)
|
1994-08-24 23:13:39 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-08-24 23:13:39 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_pathconf_args /* {
|
|
|
|
syscallarg(char *) path;
|
|
|
|
syscallarg(int) name;
|
|
|
|
} */ *uap = v;
|
1995-03-14 18:12:17 +03:00
|
|
|
SCARG(uap, name)++; /* iBCS2 _PC_* defines are offset by one */
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_pathconf(p, uap, retval);
|
1994-08-24 23:13:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_fpathconf(p, v, retval)
|
1994-08-24 23:13:39 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-08-24 23:13:39 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_fpathconf_args /* {
|
|
|
|
syscallarg(int) fd;
|
|
|
|
syscallarg(int) name;
|
|
|
|
} */ *uap = v;
|
1995-03-14 18:12:17 +03:00
|
|
|
SCARG(uap, name)++; /* iBCS2 _PC_* defines are offset by one */
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_fpathconf(p, uap, retval);
|
1994-08-24 23:13:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_sysconf(p, v, retval)
|
1994-08-24 23:13:39 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-08-24 23:13:39 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_sysconf_args /* {
|
|
|
|
syscallarg(int) name;
|
|
|
|
} */ *uap = v;
|
2000-08-12 02:19:29 +04:00
|
|
|
int mib[2], value, error;
|
|
|
|
size_t len;
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sys___sysctl_args sa;
|
|
|
|
struct sys_getrlimit_args ga;
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
switch(SCARG(uap, name)) {
|
1994-08-24 23:13:39 +04:00
|
|
|
case IBCS2_SC_ARG_MAX:
|
|
|
|
mib[1] = KERN_ARGMAX;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IBCS2_SC_CHILD_MAX:
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
1995-06-25 00:18:53 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
SCARG(&ga, which) = RLIMIT_NPROC;
|
|
|
|
SCARG(&ga, rlp) = stackgap_alloc(&sg, sizeof(struct rlimit *));
|
1996-05-03 21:05:16 +04:00
|
|
|
if ((error = sys_getrlimit(p, &ga, retval)) != 0)
|
1994-08-24 23:13:39 +04:00
|
|
|
return error;
|
1995-03-14 18:12:17 +03:00
|
|
|
*retval = SCARG(&ga, rlp)->rlim_cur;
|
1994-08-24 23:13:39 +04:00
|
|
|
return 0;
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
1994-08-24 23:13:39 +04:00
|
|
|
|
|
|
|
case IBCS2_SC_CLK_TCK:
|
|
|
|
*retval = hz;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case IBCS2_SC_NGROUPS_MAX:
|
|
|
|
mib[1] = KERN_NGROUPS;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IBCS2_SC_OPEN_MAX:
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
1995-06-25 00:18:53 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
SCARG(&ga, which) = RLIMIT_NOFILE;
|
|
|
|
SCARG(&ga, rlp) = stackgap_alloc(&sg, sizeof(struct rlimit *));
|
1996-05-03 21:05:16 +04:00
|
|
|
if ((error = sys_getrlimit(p, &ga, retval)) != 0)
|
1994-08-24 23:13:39 +04:00
|
|
|
return error;
|
1995-03-14 18:12:17 +03:00
|
|
|
*retval = SCARG(&ga, rlp)->rlim_cur;
|
1994-08-24 23:13:39 +04:00
|
|
|
return 0;
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
1994-08-24 23:13:39 +04:00
|
|
|
|
|
|
|
case IBCS2_SC_JOB_CONTROL:
|
|
|
|
mib[1] = KERN_JOB_CONTROL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IBCS2_SC_SAVED_IDS:
|
|
|
|
mib[1] = KERN_SAVED_IDS;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IBCS2_SC_VERSION:
|
|
|
|
mib[1] = KERN_POSIX1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IBCS2_SC_PASS_MAX:
|
|
|
|
*retval = 128; /* XXX - should we create PASS_MAX ? */
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case IBCS2_SC_XOPEN_VERSION:
|
|
|
|
*retval = 2; /* XXX: What should that be? */
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
mib[0] = CTL_KERN;
|
|
|
|
len = sizeof(value);
|
1995-03-14 18:12:17 +03:00
|
|
|
SCARG(&sa, name) = mib;
|
|
|
|
SCARG(&sa, namelen) = 2;
|
|
|
|
SCARG(&sa, old) = &value;
|
|
|
|
SCARG(&sa, oldlenp) = &len;
|
|
|
|
SCARG(&sa, new) = NULL;
|
|
|
|
SCARG(&sa, newlen) = 0;
|
1996-05-03 21:05:16 +04:00
|
|
|
if ((error = sys___sysctl(p, &sa, retval)) != 0)
|
1994-08-24 23:13:39 +04:00
|
|
|
return error;
|
|
|
|
*retval = value;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_alarm(p, v, retval)
|
1994-08-24 23:13:39 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-08-24 23:13:39 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_alarm_args /* {
|
|
|
|
syscallarg(unsigned) sec;
|
|
|
|
} */ *uap = v;
|
1994-08-24 23:13:39 +04:00
|
|
|
int error;
|
|
|
|
struct itimerval *itp, *oitp;
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sys_setitimer_args sa;
|
1995-06-25 00:18:53 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
1994-08-24 23:13:39 +04:00
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
itp = stackgap_alloc(&sg, sizeof(*itp));
|
|
|
|
oitp = stackgap_alloc(&sg, sizeof(*oitp));
|
1994-08-24 23:13:39 +04:00
|
|
|
timerclear(&itp->it_interval);
|
1995-03-14 18:12:17 +03:00
|
|
|
itp->it_value.tv_sec = SCARG(uap, sec);
|
1994-08-24 23:13:39 +04:00
|
|
|
itp->it_value.tv_usec = 0;
|
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
SCARG(&sa, which) = ITIMER_REAL;
|
|
|
|
SCARG(&sa, itv) = itp;
|
|
|
|
SCARG(&sa, oitv) = oitp;
|
1995-10-07 09:25:19 +03:00
|
|
|
error = sys_setitimer(p, &sa, retval);
|
1994-08-24 23:13:39 +04:00
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
if (oitp->it_value.tv_usec)
|
|
|
|
oitp->it_value.tv_sec++;
|
|
|
|
*retval = oitp->it_value.tv_sec;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_getmsg(p, v, retval)
|
1994-08-24 23:13:39 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-08-24 23:13:39 +04:00
|
|
|
{
|
1996-05-03 21:05:16 +04:00
|
|
|
#ifdef notyet
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_getmsg_args /* {
|
|
|
|
syscallarg(int) fd;
|
|
|
|
syscallarg(struct ibcs2_stropts *) ctl;
|
|
|
|
syscallarg(struct ibcs2_stropts *) dat;
|
|
|
|
syscallarg(int *) flags;
|
|
|
|
} */ *uap = v;
|
1996-05-03 21:05:16 +04:00
|
|
|
#endif
|
1995-09-20 02:19:01 +04:00
|
|
|
|
1994-08-24 23:13:39 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_putmsg(p, v, retval)
|
1994-08-24 23:13:39 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-08-24 23:13:39 +04:00
|
|
|
{
|
1996-05-03 21:05:16 +04:00
|
|
|
#ifdef notyet
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_putmsg_args /* {
|
|
|
|
syscallarg(int) fd;
|
|
|
|
syscallarg(struct ibcs2_stropts *) ctl;
|
|
|
|
syscallarg(struct ibcs2_stropts *) dat;
|
|
|
|
syscallarg(int) flags;
|
|
|
|
} */ *uap = v;
|
1996-05-03 21:05:16 +04:00
|
|
|
#endif
|
1995-09-20 02:19:01 +04:00
|
|
|
|
1994-08-24 23:13:39 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_times(p, v, retval)
|
1994-08-24 23:13:39 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-08-24 23:13:39 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_times_args /* {
|
|
|
|
syscallarg(struct tms *) tp;
|
|
|
|
} */ *uap = v;
|
1994-08-24 23:13:39 +04:00
|
|
|
int error;
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sys_getrusage_args ga;
|
1994-08-24 23:13:39 +04:00
|
|
|
struct tms tms;
|
|
|
|
struct timeval t;
|
1995-06-25 00:18:53 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
1995-03-14 18:12:17 +03:00
|
|
|
struct rusage *ru = stackgap_alloc(&sg, sizeof(*ru));
|
1994-08-24 23:13:39 +04:00
|
|
|
#define CONVTCK(r) (r.tv_sec * hz + r.tv_usec / (1000000 / hz))
|
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
SCARG(&ga, who) = RUSAGE_SELF;
|
|
|
|
SCARG(&ga, rusage) = ru;
|
1995-10-07 09:25:19 +03:00
|
|
|
error = sys_getrusage(p, &ga, retval);
|
1994-08-24 23:13:39 +04:00
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
tms.tms_utime = CONVTCK(ru->ru_utime);
|
|
|
|
tms.tms_stime = CONVTCK(ru->ru_stime);
|
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
SCARG(&ga, who) = RUSAGE_CHILDREN;
|
1995-10-07 09:25:19 +03:00
|
|
|
error = sys_getrusage(p, &ga, retval);
|
1994-08-24 23:13:39 +04:00
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
tms.tms_cutime = CONVTCK(ru->ru_utime);
|
|
|
|
tms.tms_cstime = CONVTCK(ru->ru_stime);
|
|
|
|
|
|
|
|
microtime(&t);
|
|
|
|
*retval = CONVTCK(t);
|
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
return copyout((caddr_t)&tms, (caddr_t)SCARG(uap, tp),
|
|
|
|
sizeof(struct tms));
|
1994-08-24 23:13:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_stime(p, v, retval)
|
1994-08-24 23:13:39 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-08-24 23:13:39 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_stime_args /* {
|
|
|
|
syscallarg(long *) timep;
|
|
|
|
} */ *uap = v;
|
1994-09-05 05:28:57 +04:00
|
|
|
int error;
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sys_settimeofday_args sa;
|
1995-06-25 00:18:53 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
1996-12-23 02:00:02 +03:00
|
|
|
struct timeval *tvp;
|
1995-03-14 18:12:17 +03:00
|
|
|
|
1996-12-23 02:00:02 +03:00
|
|
|
tvp = stackgap_alloc(&sg, sizeof(*SCARG(&sa, tv)));
|
1995-03-14 18:12:17 +03:00
|
|
|
SCARG(&sa, tzp) = NULL;
|
1996-05-03 21:05:16 +04:00
|
|
|
error = copyin((caddr_t)SCARG(uap, timep),
|
1996-12-23 02:00:02 +03:00
|
|
|
(void *)&tvp->tv_sec, sizeof(long));
|
1996-05-03 21:05:16 +04:00
|
|
|
if (error)
|
1994-09-05 05:28:57 +04:00
|
|
|
return error;
|
1996-12-23 02:00:02 +03:00
|
|
|
tvp->tv_usec = 0;
|
|
|
|
SCARG(&sa, tv) = tvp;
|
1996-05-03 21:05:16 +04:00
|
|
|
if ((error = sys_settimeofday(p, &sa, retval)) != 0)
|
1994-09-05 05:28:57 +04:00
|
|
|
return EPERM;
|
|
|
|
return 0;
|
1994-08-24 23:13:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_utime(p, v, retval)
|
1994-08-24 23:13:39 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-08-24 23:13:39 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_utime_args /* {
|
1999-02-09 23:21:18 +03:00
|
|
|
syscallarg(const char *) path;
|
1995-10-07 09:25:19 +03:00
|
|
|
syscallarg(struct ibcs2_utimbuf *) buf;
|
|
|
|
} */ *uap = v;
|
1994-09-05 05:28:57 +04:00
|
|
|
int error;
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sys_utimes_args sa;
|
1995-03-14 18:12:17 +03:00
|
|
|
struct timeval *tp;
|
1994-09-05 05:28:57 +04:00
|
|
|
|
2000-08-29 18:33:25 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
|
|
|
tp = stackgap_alloc(&sg, 2 * sizeof(struct timeval *));
|
2000-12-01 15:28:30 +03:00
|
|
|
CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
|
1995-03-14 18:12:17 +03:00
|
|
|
SCARG(&sa, path) = SCARG(uap, path);
|
|
|
|
if (SCARG(uap, buf)) {
|
1994-09-05 05:28:57 +04:00
|
|
|
struct ibcs2_utimbuf ubuf;
|
|
|
|
|
1996-05-03 21:05:16 +04:00
|
|
|
error = copyin((caddr_t)SCARG(uap, buf), (caddr_t)&ubuf,
|
|
|
|
sizeof(ubuf));
|
|
|
|
if (error)
|
1994-09-05 05:28:57 +04:00
|
|
|
return error;
|
1996-12-23 02:00:02 +03:00
|
|
|
tp[0].tv_sec = ubuf.actime;
|
|
|
|
tp[0].tv_usec = 0;
|
|
|
|
tp[1].tv_sec = ubuf.modtime;
|
|
|
|
tp[1].tv_usec = 0;
|
|
|
|
SCARG(&sa, tptr) = tp;
|
1994-09-05 05:28:57 +04:00
|
|
|
} else
|
1995-03-14 18:12:17 +03:00
|
|
|
SCARG(&sa, tptr) = NULL;
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_utimes(p, &sa, retval);
|
1994-08-24 23:13:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_nice(p, v, retval)
|
1994-08-24 23:13:39 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-08-24 23:13:39 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_nice_args /* {
|
|
|
|
syscallarg(int) incr;
|
|
|
|
} */ *uap = v;
|
1996-05-03 21:05:16 +04:00
|
|
|
int error;
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sys_setpriority_args sa;
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
SCARG(&sa, which) = PRIO_PROCESS;
|
|
|
|
SCARG(&sa, who) = 0;
|
1996-10-02 22:04:56 +04:00
|
|
|
SCARG(&sa, prio) = p->p_nice - NZERO + SCARG(uap, incr);
|
1996-05-03 21:05:16 +04:00
|
|
|
if ((error = sys_setpriority(p, &sa, retval)) != 0)
|
1994-09-05 05:28:57 +04:00
|
|
|
return EPERM;
|
1996-10-02 22:04:56 +04:00
|
|
|
*retval = p->p_nice - NZERO;
|
1994-09-05 05:28:57 +04:00
|
|
|
return 0;
|
1994-08-24 23:13:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* iBCS2 getpgrp, setpgrp, setsid, and setpgid
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_pgrpsys(p, v, retval)
|
1994-08-24 23:13:39 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-08-24 23:13:39 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_pgrpsys_args /* {
|
|
|
|
syscallarg(int) type;
|
|
|
|
syscallarg(caddr_t) dummy;
|
|
|
|
syscallarg(int) pid;
|
|
|
|
syscallarg(int) pgid;
|
|
|
|
} */ *uap = v;
|
1995-03-14 18:12:17 +03:00
|
|
|
switch (SCARG(uap, type)) {
|
1994-08-24 23:13:39 +04:00
|
|
|
case 0: /* getpgrp */
|
|
|
|
*retval = p->p_pgrp->pg_id;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case 1: /* setpgrp */
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sys_setpgid_args sa;
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
SCARG(&sa, pid) = 0;
|
|
|
|
SCARG(&sa, pgid) = 0;
|
1995-10-07 09:25:19 +03:00
|
|
|
sys_setpgid(p, &sa, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
*retval = p->p_pgrp->pg_id;
|
|
|
|
return 0;
|
|
|
|
}
|
1994-08-24 23:13:39 +04:00
|
|
|
|
|
|
|
case 2: /* setpgid */
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sys_setpgid_args sa;
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
SCARG(&sa, pid) = SCARG(uap, pid);
|
|
|
|
SCARG(&sa, pgid) = SCARG(uap, pgid);
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_setpgid(p, &sa, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
1994-08-24 23:13:39 +04:00
|
|
|
|
|
|
|
case 3: /* setsid */
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_setsid(p, NULL, retval);
|
1994-08-24 23:13:39 +04:00
|
|
|
|
|
|
|
default:
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1994-09-05 05:28:57 +04:00
|
|
|
/*
|
|
|
|
* XXX - need to check for nested calls
|
|
|
|
*/
|
|
|
|
|
1994-08-24 23:13:39 +04:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_plock(p, v, retval)
|
1994-08-24 23:13:39 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-08-24 23:13:39 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_plock_args /* {
|
|
|
|
syscallarg(int) cmd;
|
|
|
|
} */ *uap = v;
|
1994-09-05 05:28:57 +04:00
|
|
|
int error;
|
1995-03-14 18:12:17 +03:00
|
|
|
#define IBCS2_UNLOCK 0
|
|
|
|
#define IBCS2_PROCLOCK 1
|
|
|
|
#define IBCS2_TEXTLOCK 2
|
|
|
|
#define IBCS2_DATALOCK 4
|
|
|
|
|
1994-09-05 05:28:57 +04:00
|
|
|
|
1996-05-03 21:05:16 +04:00
|
|
|
if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
|
1994-09-05 05:28:57 +04:00
|
|
|
return EPERM;
|
1995-03-14 18:12:17 +03:00
|
|
|
switch(SCARG(uap, cmd)) {
|
1994-09-05 05:28:57 +04:00
|
|
|
case IBCS2_UNLOCK:
|
|
|
|
case IBCS2_PROCLOCK:
|
|
|
|
case IBCS2_TEXTLOCK:
|
|
|
|
case IBCS2_DATALOCK:
|
|
|
|
return 0; /* XXX - TODO */
|
|
|
|
}
|
|
|
|
return EINVAL;
|
1994-08-24 23:13:39 +04:00
|
|
|
}
|
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_uadmin(p, v, retval)
|
1995-03-14 18:12:17 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_uadmin_args /* {
|
|
|
|
syscallarg(int) cmd;
|
|
|
|
syscallarg(int) func;
|
|
|
|
syscallarg(caddr_t) data;
|
|
|
|
} */ *uap = v;
|
1995-09-20 02:19:01 +04:00
|
|
|
int error;
|
|
|
|
|
1994-09-05 05:28:57 +04:00
|
|
|
#define SCO_A_REBOOT 1
|
|
|
|
#define SCO_A_SHUTDOWN 2
|
|
|
|
#define SCO_A_REMOUNT 4
|
|
|
|
#define SCO_A_CLOCK 8
|
|
|
|
#define SCO_A_SETCONFIG 128
|
|
|
|
#define SCO_A_GETDEV 130
|
|
|
|
|
|
|
|
#define SCO_AD_HALT 0
|
|
|
|
#define SCO_AD_BOOT 1
|
|
|
|
#define SCO_AD_IBOOT 2
|
|
|
|
#define SCO_AD_PWRDOWN 3
|
|
|
|
#define SCO_AD_PWRNAP 4
|
|
|
|
|
|
|
|
#define SCO_AD_PANICBOOT 1
|
|
|
|
|
|
|
|
#define SCO_AD_GETBMAJ 0
|
|
|
|
#define SCO_AD_GETCMAJ 1
|
|
|
|
|
1995-09-20 02:19:01 +04:00
|
|
|
/* XXX: is this the right place for this call? */
|
1996-05-03 21:05:16 +04:00
|
|
|
if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
|
1995-09-20 02:19:01 +04:00
|
|
|
return (error);
|
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
switch(SCARG(uap, cmd)) {
|
1994-09-05 05:28:57 +04:00
|
|
|
case SCO_A_REBOOT:
|
|
|
|
case SCO_A_SHUTDOWN:
|
1995-03-14 18:12:17 +03:00
|
|
|
switch(SCARG(uap, func)) {
|
1994-09-05 05:28:57 +04:00
|
|
|
case SCO_AD_HALT:
|
|
|
|
case SCO_AD_PWRDOWN:
|
|
|
|
case SCO_AD_PWRNAP:
|
1997-03-27 02:44:27 +03:00
|
|
|
cpu_reboot(RB_HALT, NULL);
|
1994-09-05 05:28:57 +04:00
|
|
|
case SCO_AD_BOOT:
|
|
|
|
case SCO_AD_IBOOT:
|
1997-03-27 02:44:27 +03:00
|
|
|
cpu_reboot(RB_AUTOBOOT, NULL);
|
1994-09-05 05:28:57 +04:00
|
|
|
}
|
|
|
|
return EINVAL;
|
|
|
|
case SCO_A_REMOUNT:
|
|
|
|
case SCO_A_CLOCK:
|
|
|
|
case SCO_A_SETCONFIG:
|
|
|
|
return 0;
|
|
|
|
case SCO_A_GETDEV:
|
|
|
|
return EINVAL; /* XXX - TODO */
|
|
|
|
}
|
|
|
|
return EINVAL;
|
1994-08-24 23:13:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_sysfs(p, v, retval)
|
1994-08-24 23:13:39 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-08-24 23:13:39 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_sysfs_args /* {
|
|
|
|
syscallarg(int) cmd;
|
|
|
|
syscallarg(caddr_t) d1;
|
|
|
|
syscallarg(char *) buf;
|
|
|
|
} */ *uap = v;
|
1995-09-20 02:19:01 +04:00
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
#define IBCS2_GETFSIND 1
|
|
|
|
#define IBCS2_GETFSTYP 2
|
|
|
|
#define IBCS2_GETNFSTYP 3
|
|
|
|
|
|
|
|
switch(SCARG(uap, cmd)) {
|
1994-09-05 05:28:57 +04:00
|
|
|
case IBCS2_GETFSIND:
|
|
|
|
case IBCS2_GETFSTYP:
|
|
|
|
case IBCS2_GETNFSTYP:
|
2001-05-24 14:49:31 +04:00
|
|
|
break;
|
1994-09-05 05:28:57 +04:00
|
|
|
}
|
1994-08-24 23:13:39 +04:00
|
|
|
return EINVAL; /* XXX - TODO */
|
|
|
|
}
|
|
|
|
|
1994-09-05 05:28:57 +04:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
xenix_sys_rdchk(p, v, retval)
|
1994-09-05 05:28:57 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-09-05 05:28:57 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct xenix_sys_rdchk_args /* {
|
|
|
|
syscallarg(int) fd;
|
|
|
|
} */ *uap = v;
|
1994-09-05 05:28:57 +04:00
|
|
|
int error;
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sys_ioctl_args sa;
|
1995-06-25 00:18:53 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
SCARG(&sa, fd) = SCARG(uap, fd);
|
|
|
|
SCARG(&sa, com) = FIONREAD;
|
|
|
|
SCARG(&sa, data) = stackgap_alloc(&sg, sizeof(int));
|
1996-05-03 21:05:16 +04:00
|
|
|
if ((error = sys_ioctl(p, &sa, retval)) != 0)
|
1994-09-05 05:28:57 +04:00
|
|
|
return error;
|
1995-03-14 18:12:17 +03:00
|
|
|
*retval = (*((int*)SCARG(&sa, data))) ? 1 : 0;
|
1994-09-05 05:28:57 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
xenix_sys_chsize(p, v, retval)
|
1994-09-05 05:28:57 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-09-05 05:28:57 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct xenix_sys_chsize_args /* {
|
|
|
|
syscallarg(int) fd;
|
|
|
|
syscallarg(long) size;
|
|
|
|
} */ *uap = v;
|
|
|
|
struct sys_ftruncate_args sa;
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
SCARG(&sa, fd) = SCARG(uap, fd);
|
|
|
|
SCARG(&sa, pad) = 0;
|
|
|
|
SCARG(&sa, length) = SCARG(uap, size);
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_ftruncate(p, &sa, retval);
|
1994-09-05 05:28:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
xenix_sys_nap(p, v, retval)
|
1994-09-05 05:28:57 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1994-09-05 05:28:57 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct xenix_sys_nap_args /* {
|
1998-02-09 05:30:42 +03:00
|
|
|
syscallarg(long) millisec;
|
1995-10-07 09:25:19 +03:00
|
|
|
} */ *uap = v;
|
1998-02-09 05:30:42 +03:00
|
|
|
int error;
|
|
|
|
struct sys_nanosleep_args na;
|
|
|
|
struct timespec *rqtp;
|
|
|
|
struct timespec *rmtp;
|
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
1995-09-20 02:19:01 +04:00
|
|
|
|
1998-02-09 05:30:42 +03:00
|
|
|
rqtp = stackgap_alloc(&sg, sizeof(struct timespec));
|
|
|
|
rmtp = stackgap_alloc(&sg, sizeof(struct timespec));
|
|
|
|
rqtp->tv_sec = 0;
|
|
|
|
rqtp->tv_nsec = SCARG(uap, millisec) * 1000;
|
|
|
|
SCARG(&na, rqtp) = rqtp;
|
|
|
|
SCARG(&na, rmtp) = rmtp;
|
|
|
|
if ((error = sys_nanosleep(p, &na, retval)) != 0)
|
|
|
|
return error;
|
|
|
|
*retval = rmtp->tv_nsec / 1000;
|
|
|
|
return 0;
|
1994-09-05 05:28:57 +04:00
|
|
|
}
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_unlink(p, v, retval)
|
1995-03-14 18:12:17 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_unlink_args /* {
|
1999-02-09 23:21:18 +03:00
|
|
|
syscallarg(const char *) path;
|
1995-10-07 09:25:19 +03:00
|
|
|
} */ *uap = v;
|
1995-06-25 00:18:53 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
2000-12-01 15:28:30 +03:00
|
|
|
CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_unlink(p, uap, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_chdir(p, v, retval)
|
1995-03-14 18:12:17 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_chdir_args /* {
|
1999-02-09 23:21:18 +03:00
|
|
|
syscallarg(const char *) path;
|
1995-10-07 09:25:19 +03:00
|
|
|
} */ *uap = v;
|
1995-06-25 00:18:53 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
2000-12-01 15:28:30 +03:00
|
|
|
CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_chdir(p, uap, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_chmod(p, v, retval)
|
1995-03-14 18:12:17 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_chmod_args /* {
|
1999-02-09 23:21:18 +03:00
|
|
|
syscallarg(const char *) path;
|
1995-10-07 09:25:19 +03:00
|
|
|
syscallarg(int) mode;
|
|
|
|
} */ *uap = v;
|
1995-06-25 00:18:53 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
2000-12-01 15:28:30 +03:00
|
|
|
CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_chmod(p, uap, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_chown(p, v, retval)
|
1995-03-14 18:12:17 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_chown_args /* {
|
1999-02-09 23:21:18 +03:00
|
|
|
syscallarg(const char *) path;
|
1995-10-07 09:25:19 +03:00
|
|
|
syscallarg(int) uid;
|
|
|
|
syscallarg(int) gid;
|
|
|
|
} */ *uap = v;
|
1995-06-25 00:18:53 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
2000-12-01 15:28:30 +03:00
|
|
|
CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
|
1998-02-14 23:52:47 +03:00
|
|
|
return sys___posix_chown(p, uap, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_rmdir(p, v, retval)
|
1995-03-14 18:12:17 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_rmdir_args /* {
|
1999-02-09 23:21:18 +03:00
|
|
|
syscallarg(const char *) path;
|
1995-10-07 09:25:19 +03:00
|
|
|
} */ *uap = v;
|
1995-06-25 00:18:53 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
2000-12-01 15:28:30 +03:00
|
|
|
CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_rmdir(p, uap, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_mkdir(p, v, retval)
|
1995-03-14 18:12:17 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_mkdir_args /* {
|
1999-02-09 23:21:18 +03:00
|
|
|
syscallarg(const char *) path;
|
1995-10-07 09:25:19 +03:00
|
|
|
syscallarg(int) mode;
|
|
|
|
} */ *uap = v;
|
1995-06-25 00:18:53 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
2000-12-01 15:28:30 +03:00
|
|
|
CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_mkdir(p, uap, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_symlink(p, v, retval)
|
1995-03-14 18:12:17 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_symlink_args /* {
|
1999-02-09 23:21:18 +03:00
|
|
|
syscallarg(const char *) path;
|
|
|
|
syscallarg(const char *) link;
|
1995-10-07 09:25:19 +03:00
|
|
|
} */ *uap = v;
|
1995-06-25 00:18:53 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
2000-12-01 15:28:30 +03:00
|
|
|
CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
|
|
|
|
CHECK_ALT_CREAT(p, &sg, SCARG(uap, link));
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_symlink(p, uap, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_rename(p, v, retval)
|
1995-03-14 18:12:17 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_rename_args /* {
|
1999-02-09 23:21:18 +03:00
|
|
|
syscallarg(const char *) from;
|
|
|
|
syscallarg(const char *) to;
|
1995-10-07 09:25:19 +03:00
|
|
|
} */ *uap = v;
|
1995-06-25 00:18:53 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
2000-12-01 15:28:30 +03:00
|
|
|
CHECK_ALT_EXIST(p, &sg, SCARG(uap, from));
|
|
|
|
CHECK_ALT_CREAT(p, &sg, SCARG(uap, to));
|
1998-02-14 23:52:47 +03:00
|
|
|
return sys___posix_rename(p, uap, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_readlink(p, v, retval)
|
1995-03-14 18:12:17 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_readlink_args /* {
|
1999-02-09 23:21:18 +03:00
|
|
|
syscallarg(const char *) path;
|
1995-10-07 09:25:19 +03:00
|
|
|
syscallarg(char *) buf;
|
|
|
|
syscallarg(int) count;
|
|
|
|
} */ *uap = v;
|
1995-06-25 00:18:53 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
2001-01-22 23:08:03 +03:00
|
|
|
CHECK_ALT_SYMLINK(p, &sg, SCARG(uap, path));
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_readlink(p, uap, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
1996-01-06 06:23:46 +03:00
|
|
|
|
1998-02-09 05:30:42 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* mmap compat code borrowed from svr4/svr4_misc.c
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
|
|
|
ibcs2_sys_mmap(p, v, retval)
|
|
|
|
struct proc *p;
|
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct ibcs2_sys_mmap_args /* {
|
|
|
|
syscallarg(ibcs2_caddr_t) addr;
|
|
|
|
syscallarg(ibcs2_size_t) len;
|
|
|
|
syscallarg(int) prot;
|
|
|
|
syscallarg(int) flags;
|
|
|
|
syscallarg(int) fd;
|
|
|
|
syscallarg(ibcs2_off_t) off;
|
|
|
|
} */ *uap = v;
|
|
|
|
struct sys_mmap_args mm;
|
|
|
|
void *rp;
|
|
|
|
|
|
|
|
#define _MAP_NEW 0x80000000 /* XXX why? */
|
|
|
|
|
|
|
|
if (SCARG(uap, prot) & ~(PROT_READ | PROT_WRITE | PROT_EXEC))
|
|
|
|
return EINVAL;
|
|
|
|
if (SCARG(uap, len) == 0)
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
SCARG(&mm, prot) = SCARG(uap, prot);
|
|
|
|
SCARG(&mm, len) = SCARG(uap, len);
|
|
|
|
SCARG(&mm, flags) = SCARG(uap, flags) & ~_MAP_NEW;
|
|
|
|
SCARG(&mm, fd) = SCARG(uap, fd);
|
|
|
|
SCARG(&mm, addr) = SCARG(uap, addr);
|
|
|
|
SCARG(&mm, pos) = SCARG(uap, off);
|
|
|
|
|
2000-03-27 00:42:21 +04:00
|
|
|
rp = (void *) round_page((vaddr_t)p->p_vmspace->vm_daddr + MAXDSIZ);
|
1998-02-09 05:30:42 +03:00
|
|
|
if ((SCARG(&mm, flags) & MAP_FIXED) == 0 &&
|
|
|
|
SCARG(&mm, addr) != 0 && SCARG(&mm, addr) < rp)
|
|
|
|
SCARG(&mm, addr) = rp;
|
|
|
|
|
|
|
|
return sys_mmap(p, &mm, retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ibcs2_sys_memcntl(p, v, retval)
|
|
|
|
struct proc *p;
|
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct ibcs2_sys_memcntl_args /* {
|
|
|
|
syscallarg(ibcs2_caddr_t) addr;
|
|
|
|
syscallarg(ibcs2_size_t) len;
|
|
|
|
syscallarg(int) cmd;
|
|
|
|
syscallarg(ibcs2_caddr_t) arg;
|
|
|
|
syscallarg(int) attr;
|
|
|
|
syscallarg(int) mask;
|
|
|
|
} */ *uap = v;
|
|
|
|
|
|
|
|
switch (SCARG(uap, cmd)) {
|
|
|
|
case IBCS2_MC_SYNC:
|
|
|
|
{
|
|
|
|
struct sys___msync13_args msa;
|
|
|
|
|
|
|
|
SCARG(&msa, addr) = SCARG(uap, addr);
|
|
|
|
SCARG(&msa, len) = SCARG(uap, len);
|
|
|
|
SCARG(&msa, flags) = (int)SCARG(uap, arg);
|
|
|
|
|
|
|
|
return sys___msync13(p, &msa, retval);
|
|
|
|
}
|
|
|
|
#ifdef IBCS2_MC_ADVISE /* supported? */
|
|
|
|
case IBCS2_MC_ADVISE:
|
|
|
|
{
|
|
|
|
struct sys_madvise_args maa;
|
|
|
|
|
|
|
|
SCARG(&maa, addr) = SCARG(uap, addr);
|
|
|
|
SCARG(&maa, len) = SCARG(uap, len);
|
|
|
|
SCARG(&maa, behav) = (int)SCARG(uap, arg);
|
|
|
|
|
|
|
|
return sys_madvise(p, &maa, retval);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
case IBCS2_MC_LOCK:
|
|
|
|
case IBCS2_MC_UNLOCK:
|
|
|
|
case IBCS2_MC_LOCKAS:
|
|
|
|
case IBCS2_MC_UNLOCKAS:
|
|
|
|
return EOPNOTSUPP;
|
|
|
|
default:
|
|
|
|
return ENOSYS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ibcs2_sys_gettimeofday(p, v, retval)
|
|
|
|
struct proc *p;
|
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct ibcs2_sys_gettimeofday_args /* {
|
|
|
|
syscallarg(struct timeval *) tp;
|
|
|
|
} */ *uap = v;
|
|
|
|
|
|
|
|
if (SCARG(uap, tp)) {
|
|
|
|
struct timeval atv;
|
|
|
|
|
|
|
|
microtime(&atv);
|
|
|
|
return copyout(&atv, SCARG(uap, tp), sizeof (atv));
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ibcs2_sys_settimeofday(p, v, retval)
|
|
|
|
struct proc *p;
|
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct ibcs2_sys_settimeofday_args /* {
|
|
|
|
syscallarg(struct timeval *) tp;
|
|
|
|
} */ *uap = v;
|
|
|
|
struct sys_settimeofday_args ap;
|
|
|
|
|
|
|
|
SCARG(&ap, tv) = SCARG(uap, tp);
|
|
|
|
SCARG(&ap, tzp) = NULL;
|
|
|
|
return sys_settimeofday(p, &ap, retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ibcs2_sys_scoinfo(p, v, retval)
|
|
|
|
struct proc *p;
|
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct ibcs2_sys_scoinfo_args /* {
|
|
|
|
syscallarg(struct scoutsname *) bp;
|
|
|
|
syscallarg(int) len;
|
|
|
|
} */ *uap = v;
|
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
|
|
|
struct scoutsname *utsp = stackgap_alloc(&sg,
|
|
|
|
sizeof(struct scoutsname));
|
|
|
|
|
1998-08-10 00:36:58 +04:00
|
|
|
memset(utsp, 0, sizeof(struct scoutsname));
|
1998-02-09 05:30:42 +03:00
|
|
|
strncpy(utsp->sysname, ostype, 8);
|
|
|
|
strncpy(utsp->nodename, hostname, 8);
|
|
|
|
strncpy(utsp->release, osrelease, 15);
|
|
|
|
strncpy(utsp->kid, "kernel id 1", 19);
|
|
|
|
strncpy(utsp->machine, machine, 8);
|
|
|
|
strncpy(utsp->bustype, "pci", 8);
|
|
|
|
strncpy(utsp->serial, "1234", 9);
|
|
|
|
utsp->origin = 0;
|
|
|
|
utsp->oem = 0;
|
|
|
|
strncpy(utsp->nusers, "unlim", 8);
|
|
|
|
utsp->ncpu = 1;
|
|
|
|
|
|
|
|
return copyout((caddr_t)utsp, (caddr_t)SCARG(uap, bp),
|
|
|
|
sizeof(struct scoutsname));
|
|
|
|
}
|
|
|
|
|
|
|
|
#define X_LK_UNLCK 0
|
|
|
|
#define X_LK_LOCK 1
|
|
|
|
#define X_LK_NBLCK 20
|
|
|
|
#define X_LK_RLCK 3
|
|
|
|
#define X_LK_NBRLCK 4
|
|
|
|
#define X_LK_GETLK 5
|
|
|
|
#define X_LK_SETLK 6
|
|
|
|
#define X_LK_SETLKW 7
|
|
|
|
#define X_LK_TESTLK 8
|
|
|
|
|
|
|
|
int
|
|
|
|
xenix_sys_locking(p, v, retval)
|
|
|
|
struct proc *p;
|
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct xenix_sys_locking_args /* {
|
|
|
|
syscallarg(int) fd;
|
|
|
|
syscallarg(int) blk;
|
|
|
|
syscallarg(int) size;
|
|
|
|
} */ *uap = v;
|
1998-03-05 07:36:07 +03:00
|
|
|
struct sys_fcntl_args fa;
|
|
|
|
struct flock *flp;
|
|
|
|
struct filedesc *fdp = p->p_fd;
|
|
|
|
struct file *fp;
|
|
|
|
int cmd;
|
|
|
|
off_t off;
|
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
1998-02-09 05:30:42 +03:00
|
|
|
|
|
|
|
switch SCARG(uap, blk) {
|
1998-03-05 07:36:07 +03:00
|
|
|
case X_LK_GETLK:
|
|
|
|
case X_LK_SETLK:
|
|
|
|
case X_LK_SETLKW:
|
|
|
|
return ibcs2_sys_fcntl(p, v, retval);
|
|
|
|
}
|
|
|
|
|
2001-06-15 00:32:41 +04:00
|
|
|
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
|
1998-03-05 07:36:07 +03:00
|
|
|
return (EBADF);
|
|
|
|
off = fp->f_offset;
|
|
|
|
|
|
|
|
flp = stackgap_alloc(&sg, sizeof(*flp));
|
|
|
|
flp->l_start = off;
|
|
|
|
switch SCARG(uap, blk) {
|
|
|
|
case X_LK_UNLCK:
|
|
|
|
cmd = F_SETLK;
|
|
|
|
flp->l_type = F_UNLCK;
|
1998-02-09 05:30:42 +03:00
|
|
|
break;
|
1998-03-05 07:36:07 +03:00
|
|
|
case X_LK_LOCK:
|
|
|
|
cmd = F_SETLKW;
|
|
|
|
flp->l_type = F_WRLCK;
|
1998-02-09 05:30:42 +03:00
|
|
|
break;
|
1998-03-05 07:36:07 +03:00
|
|
|
case X_LK_NBRLCK:
|
|
|
|
cmd = F_SETLK;
|
|
|
|
flp->l_type = F_RDLCK;
|
1998-02-09 05:30:42 +03:00
|
|
|
break;
|
1998-03-05 07:36:07 +03:00
|
|
|
case X_LK_NBLCK:
|
|
|
|
cmd = F_SETLK;
|
|
|
|
flp->l_type = F_WRLCK;
|
1998-02-09 05:30:42 +03:00
|
|
|
break;
|
1998-03-05 07:36:07 +03:00
|
|
|
default:
|
1998-02-09 05:30:42 +03:00
|
|
|
return EINVAL;
|
|
|
|
}
|
1998-03-05 07:36:07 +03:00
|
|
|
flp->l_len = SCARG(uap, size);
|
|
|
|
flp->l_whence = SEEK_SET;
|
|
|
|
|
|
|
|
SCARG(&fa, fd) = SCARG(uap, fd);
|
|
|
|
SCARG(&fa, cmd) = cmd;
|
|
|
|
SCARG(&fa, arg) = (void *)flp;
|
1998-02-09 05:30:42 +03:00
|
|
|
|
1998-03-05 07:36:07 +03:00
|
|
|
return sys_fcntl(p, &fa, retval);
|
1998-02-09 05:30:42 +03:00
|
|
|
}
|