2010-04-24 03:05:40 +04:00
|
|
|
/* $NetBSD: netbsd32_compat_43.c,v 1.53 2010/04/23 23:05:40 joerg Exp $ */
|
1998-08-26 14:20:33 +04:00
|
|
|
|
|
|
|
/*
|
2001-08-25 19:06:02 +04:00
|
|
|
* Copyright (c) 1998, 2001 Matthew R. Green
|
1998-08-26 14:20:33 +04:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
1999-04-14 06:50:38 +04:00
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
1998-08-26 14:20:33 +04:00
|
|
|
* 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,
|
1999-04-14 06:50:38 +04:00
|
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
1998-08-26 14:20:33 +04:00
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2001-11-13 05:07:52 +03:00
|
|
|
#include <sys/cdefs.h>
|
2010-04-24 03:05:40 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_43.c,v 1.53 2010/04/23 23:05:40 joerg Exp $");
|
2001-11-13 05:07:52 +03:00
|
|
|
|
2001-05-30 15:37:21 +04:00
|
|
|
#if defined(_KERNEL_OPT)
|
2000-12-03 17:47:27 +03:00
|
|
|
#include "opt_compat_43.h"
|
|
|
|
#endif
|
|
|
|
|
1998-08-26 14:20:33 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/fcntl.h>
|
2007-04-30 18:05:47 +04:00
|
|
|
#include <sys/filedesc.h>
|
2007-06-30 19:31:49 +04:00
|
|
|
#include <sys/mbuf.h>
|
1998-08-26 14:20:33 +04:00
|
|
|
#include <sys/mount.h>
|
2007-04-30 18:05:47 +04:00
|
|
|
#include <sys/namei.h>
|
2005-09-24 19:42:58 +04:00
|
|
|
#include <sys/socket.h>
|
1998-08-26 14:20:33 +04:00
|
|
|
#include <sys/proc.h>
|
2007-06-30 19:31:49 +04:00
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/socketvar.h>
|
1998-08-26 14:20:33 +04:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/syscallargs.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/ucred.h>
|
2007-04-30 18:05:47 +04:00
|
|
|
#include <sys/vfs_syscalls.h>
|
2000-06-28 19:39:24 +04:00
|
|
|
#include <uvm/uvm_extern.h>
|
1998-08-26 14:20:33 +04:00
|
|
|
#include <sys/sysctl.h>
|
1998-08-29 21:01:14 +04:00
|
|
|
#include <sys/swap.h>
|
1998-08-26 14:20:33 +04:00
|
|
|
|
1999-03-25 19:22:49 +03:00
|
|
|
#include <compat/netbsd32/netbsd32.h>
|
|
|
|
#include <compat/netbsd32/netbsd32_syscallargs.h>
|
1998-08-26 14:20:33 +04:00
|
|
|
|
2005-09-13 07:23:09 +04:00
|
|
|
#include <compat/sys/stat.h>
|
|
|
|
#include <compat/sys/signal.h>
|
|
|
|
#include <compat/sys/signalvar.h>
|
2005-09-25 01:34:35 +04:00
|
|
|
#include <compat/sys/socket.h>
|
2005-09-13 07:23:09 +04:00
|
|
|
|
2007-12-21 02:02:38 +03:00
|
|
|
#define SYS_DEF(foo) struct foo##_args; \
|
|
|
|
int foo(struct lwp *, const struct foo##_args *, register_t *)
|
|
|
|
|
|
|
|
SYS_DEF(compat_43_netbsd32_sethostid);
|
|
|
|
SYS_DEF(compat_43_netbsd32_killpg);
|
|
|
|
SYS_DEF(compat_43_netbsd32_sigblock);
|
|
|
|
SYS_DEF(compat_43_netbsd32_sigblock);
|
|
|
|
SYS_DEF(compat_43_netbsd32_sigsetmask);
|
|
|
|
#undef SYS_DEF
|
1999-12-30 18:40:45 +03:00
|
|
|
|
2007-04-30 18:05:47 +04:00
|
|
|
static void
|
|
|
|
netbsd32_from_stat(const struct stat *sb, struct netbsd32_stat43 *sp32)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
|
|
|
|
2007-04-30 18:05:47 +04:00
|
|
|
sp32->st_dev = sb->st_dev;
|
|
|
|
sp32->st_ino = sb->st_ino;
|
|
|
|
sp32->st_mode = sb->st_mode;
|
|
|
|
sp32->st_nlink = sb->st_nlink;
|
|
|
|
sp32->st_uid = sb->st_uid;
|
|
|
|
sp32->st_gid = sb->st_gid;
|
|
|
|
sp32->st_rdev = sb->st_rdev;
|
|
|
|
sp32->st_size = sb->st_size < (quad_t)1 << 32 ? sb->st_size : -2;
|
|
|
|
sp32->st_atimespec.tv_sec = sb->st_atimespec.tv_sec;
|
|
|
|
sp32->st_atimespec.tv_nsec = sb->st_atimespec.tv_nsec;
|
|
|
|
sp32->st_mtimespec.tv_sec = sb->st_mtimespec.tv_sec;
|
|
|
|
sp32->st_mtimespec.tv_nsec = sb->st_mtimespec.tv_nsec;
|
|
|
|
sp32->st_ctimespec.tv_sec = sb->st_ctimespec.tv_sec;
|
|
|
|
sp32->st_ctimespec.tv_nsec = sb->st_ctimespec.tv_nsec;
|
|
|
|
sp32->st_blksize = sb->st_blksize;
|
|
|
|
sp32->st_blocks = sb->st_blocks;
|
|
|
|
sp32->st_flags = sb->st_flags;
|
|
|
|
sp32->st_gen = sb->st_gen;
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* file system syscalls */
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_43_netbsd32_ocreat(struct lwp *l, const struct compat_43_netbsd32_ocreat_args *uap, register_t *retval)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1999-03-25 19:22:49 +03:00
|
|
|
syscallarg(const netbsd32_charp) path;
|
1998-08-26 14:20:33 +04:00
|
|
|
syscallarg(mode_t) mode;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
1998-08-26 14:20:33 +04:00
|
|
|
struct sys_open_args ua;
|
|
|
|
|
1999-03-25 19:58:39 +03:00
|
|
|
NETBSD32TOP_UAP(path, const char);
|
|
|
|
NETBSD32TO64_UAP(mode);
|
1998-08-26 14:20:33 +04:00
|
|
|
SCARG(&ua, flags) = O_WRONLY | O_CREAT | O_TRUNC;
|
|
|
|
|
2003-01-18 11:28:25 +03:00
|
|
|
return (sys_open(l, &ua, retval));
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_43_netbsd32_olseek(struct lwp *l, const struct compat_43_netbsd32_olseek_args *uap, register_t *retval)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1998-08-26 14:20:33 +04:00
|
|
|
syscallarg(int) fd;
|
1999-03-25 19:22:49 +03:00
|
|
|
syscallarg(netbsd32_long) offset;
|
1998-08-26 14:20:33 +04:00
|
|
|
syscallarg(int) whence;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
1998-08-26 14:20:33 +04:00
|
|
|
struct sys_lseek_args ua;
|
|
|
|
|
|
|
|
SCARG(&ua, fd) = SCARG(uap, fd);
|
1999-03-25 19:58:39 +03:00
|
|
|
NETBSD32TOX_UAP(offset, long);
|
|
|
|
NETBSD32TO64_UAP(whence);
|
2008-01-27 00:01:23 +03:00
|
|
|
/* Maybe offsets > 2^32 should generate an error ? */
|
|
|
|
return sys_lseek(l, &ua, retval);
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_43_netbsd32_stat43(struct lwp *l, const struct compat_43_netbsd32_stat43_args *uap, register_t *retval)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1999-03-25 19:22:49 +03:00
|
|
|
syscallarg(const netbsd32_charp) path;
|
|
|
|
syscallarg(netbsd32_stat43p_t) ub;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
2007-04-30 18:05:47 +04:00
|
|
|
struct stat sb;
|
2001-02-02 16:06:48 +03:00
|
|
|
struct netbsd32_stat43 sb32;
|
2007-04-30 18:05:47 +04:00
|
|
|
int error;
|
|
|
|
|
2008-03-22 00:54:58 +03:00
|
|
|
error = do_sys_stat(SCARG_P32(uap, path), FOLLOW, &sb);
|
2007-04-30 18:05:47 +04:00
|
|
|
if (error == 0) {
|
|
|
|
netbsd32_from_stat(&sb, &sb32);
|
|
|
|
error = copyout(&sb32, SCARG_P32(uap, ub), sizeof(sb32));
|
|
|
|
}
|
|
|
|
return error;
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_43_netbsd32_lstat43(struct lwp *l, const struct compat_43_netbsd32_lstat43_args *uap, register_t *retval)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1999-03-25 19:22:49 +03:00
|
|
|
syscallarg(const netbsd32_charp) path;
|
|
|
|
syscallarg(netbsd32_stat43p_t) ub;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
2007-04-30 18:05:47 +04:00
|
|
|
struct stat sb;
|
2001-02-02 16:06:48 +03:00
|
|
|
struct netbsd32_stat43 sb32;
|
2007-04-30 18:05:47 +04:00
|
|
|
int error;
|
|
|
|
|
2008-03-22 00:54:58 +03:00
|
|
|
error = do_sys_stat(SCARG_P32(uap, path), NOFOLLOW, &sb);
|
2007-04-30 18:05:47 +04:00
|
|
|
if (error == 0) {
|
|
|
|
netbsd32_from_stat(&sb, &sb32);
|
|
|
|
error = copyout(&sb32, SCARG_P32(uap, ub), sizeof(sb32));
|
|
|
|
}
|
|
|
|
return error;
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_43_netbsd32_fstat43(struct lwp *l, const struct compat_43_netbsd32_fstat43_args *uap, register_t *retval)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1998-08-26 14:20:33 +04:00
|
|
|
syscallarg(int) fd;
|
1999-03-25 19:22:49 +03:00
|
|
|
syscallarg(netbsd32_stat43p_t) sb;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
2007-04-30 18:05:47 +04:00
|
|
|
struct stat sb;
|
2001-02-02 16:06:48 +03:00
|
|
|
struct netbsd32_stat43 sb32;
|
2007-04-30 18:05:47 +04:00
|
|
|
int error;
|
|
|
|
|
2008-03-22 00:54:58 +03:00
|
|
|
error = do_sys_fstat(SCARG(uap, fd), &sb);
|
2007-04-30 18:05:47 +04:00
|
|
|
if (error == 0) {
|
|
|
|
netbsd32_from_stat(&sb, &sb32);
|
|
|
|
error = copyout(&sb32, SCARG_P32(uap, sb), sizeof(sb32));
|
|
|
|
}
|
|
|
|
return error;
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_43_netbsd32_otruncate(struct lwp *l, const struct compat_43_netbsd32_otruncate_args *uap, register_t *retval)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1999-03-25 19:22:49 +03:00
|
|
|
syscallarg(const netbsd32_charp) path;
|
|
|
|
syscallarg(netbsd32_long) length;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
1998-08-26 14:20:33 +04:00
|
|
|
struct sys_truncate_args ua;
|
|
|
|
|
1999-03-25 19:58:39 +03:00
|
|
|
NETBSD32TOP_UAP(path, const char);
|
|
|
|
NETBSD32TO64_UAP(length);
|
2007-12-21 02:02:38 +03:00
|
|
|
return (sys_truncate(l, &ua, retval));
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_43_netbsd32_oftruncate(struct lwp *l, const struct compat_43_netbsd32_oftruncate_args *uap, register_t *retval)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1998-08-26 14:20:33 +04:00
|
|
|
syscallarg(int) fd;
|
1999-03-25 19:22:49 +03:00
|
|
|
syscallarg(netbsd32_long) length;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
1998-08-26 14:20:33 +04:00
|
|
|
struct sys_ftruncate_args ua;
|
|
|
|
|
1999-03-25 19:58:39 +03:00
|
|
|
NETBSD32TO64_UAP(fd);
|
|
|
|
NETBSD32TO64_UAP(length);
|
2003-01-18 11:28:25 +03:00
|
|
|
return (sys_ftruncate(l, &ua, retval));
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_43_netbsd32_ogetdirentries(struct lwp *l, const struct compat_43_netbsd32_ogetdirentries_args *uap, register_t *retval)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1998-08-26 14:20:33 +04:00
|
|
|
syscallarg(int) fd;
|
1999-03-25 19:22:49 +03:00
|
|
|
syscallarg(netbsd32_charp) buf;
|
1998-08-26 14:20:33 +04:00
|
|
|
syscallarg(u_int) count;
|
1999-03-25 19:22:49 +03:00
|
|
|
syscallarg(netbsd32_longp) basep;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
1998-08-26 14:20:33 +04:00
|
|
|
struct compat_43_sys_getdirentries_args ua;
|
|
|
|
|
1999-03-25 19:58:39 +03:00
|
|
|
NETBSD32TO64_UAP(fd);
|
|
|
|
NETBSD32TOP_UAP(buf, char);
|
|
|
|
NETBSD32TO64_UAP(count);
|
|
|
|
NETBSD32TOP_UAP(basep, long);
|
2003-01-18 11:28:25 +03:00
|
|
|
return (compat_43_sys_getdirentries(l, &ua, retval));
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* kernel syscalls */
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_43_netbsd32_ogetkerninfo(struct lwp *l, const struct compat_43_netbsd32_ogetkerninfo_args *uap, register_t *retval)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1998-08-26 14:20:33 +04:00
|
|
|
syscallarg(int) op;
|
1999-03-25 19:22:49 +03:00
|
|
|
syscallarg(netbsd32_charp) where;
|
|
|
|
syscallarg(netbsd32_intp) size;
|
1998-08-26 14:20:33 +04:00
|
|
|
syscallarg(int) arg;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
1998-08-26 14:20:33 +04:00
|
|
|
struct compat_43_sys_getkerninfo_args ua;
|
|
|
|
|
1999-03-25 19:58:39 +03:00
|
|
|
NETBSD32TO64_UAP(op);
|
|
|
|
NETBSD32TOP_UAP(where, char);
|
|
|
|
NETBSD32TOP_UAP(size, int);
|
|
|
|
NETBSD32TO64_UAP(arg);
|
2003-01-18 11:28:25 +03:00
|
|
|
return (compat_43_sys_getkerninfo(l, &ua, retval));
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_43_netbsd32_ogethostname(struct lwp *l, const struct compat_43_netbsd32_ogethostname_args *uap, register_t *retval)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1999-03-25 19:22:49 +03:00
|
|
|
syscallarg(netbsd32_charp) hostname;
|
1998-08-26 14:20:33 +04:00
|
|
|
syscallarg(u_int) len;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
Dynamic sysctl.
Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.
Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.
All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.
PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
2003-12-04 22:38:21 +03:00
|
|
|
int name[2];
|
1998-08-26 14:20:33 +04:00
|
|
|
size_t sz;
|
|
|
|
|
Dynamic sysctl.
Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.
Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.
All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.
PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
2003-12-04 22:38:21 +03:00
|
|
|
name[0] = CTL_KERN;
|
|
|
|
name[1] = KERN_HOSTNAME;
|
1998-08-26 14:20:33 +04:00
|
|
|
sz = SCARG(uap, len);
|
Dynamic sysctl.
Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.
Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.
All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.
PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
2003-12-04 22:38:21 +03:00
|
|
|
return (old_sysctl(&name[0], 2,
|
2007-03-19 00:38:32 +03:00
|
|
|
SCARG_P32(uap, hostname), &sz, 0, 0, l));
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_43_netbsd32_osethostname(struct lwp *l, const struct compat_43_netbsd32_osethostname_args *uap, register_t *retval)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1999-03-25 19:22:49 +03:00
|
|
|
syscallarg(netbsd32_charp) hostname;
|
1998-08-26 14:20:33 +04:00
|
|
|
syscallarg(u_int) len;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
Dynamic sysctl.
Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.
Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.
All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.
PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
2003-12-04 22:38:21 +03:00
|
|
|
int name[2];
|
|
|
|
|
|
|
|
name[0] = CTL_KERN;
|
|
|
|
name[1] = KERN_HOSTNAME;
|
2007-03-19 00:38:32 +03:00
|
|
|
return old_sysctl(&name[0], 2, 0, 0, (char *)SCARG_P32(uap,
|
|
|
|
hostname), SCARG(uap, len), l);
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
1998-10-01 18:27:56 +04:00
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_43_netbsd32_sethostid(struct lwp *l, const struct compat_43_netbsd32_sethostid_args *uap, register_t *retval)
|
1998-10-01 18:27:56 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1998-10-01 18:27:56 +04:00
|
|
|
syscallarg(int32_t) hostid;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
1998-10-01 18:27:56 +04:00
|
|
|
struct compat_43_sys_sethostid_args ua;
|
|
|
|
|
1999-03-25 19:58:39 +03:00
|
|
|
NETBSD32TO64_UAP(hostid);
|
2003-01-18 11:28:25 +03:00
|
|
|
return (compat_43_sys_sethostid(l, &ua, retval));
|
1998-10-01 18:27:56 +04:00
|
|
|
}
|
|
|
|
|
1998-08-26 14:20:33 +04:00
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_43_netbsd32_ogetrlimit(struct lwp *l, const struct compat_43_netbsd32_ogetrlimit_args *uap, register_t *retval)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1998-08-26 14:20:33 +04:00
|
|
|
syscallarg(int) which;
|
1999-03-25 19:22:49 +03:00
|
|
|
syscallarg(netbsd32_orlimitp_t) rlp;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
1998-08-26 14:20:33 +04:00
|
|
|
struct compat_43_sys_getrlimit_args ua;
|
|
|
|
|
1999-03-25 19:58:39 +03:00
|
|
|
NETBSD32TO64_UAP(which);
|
|
|
|
NETBSD32TOP_UAP(rlp, struct orlimit);
|
2003-01-18 11:28:25 +03:00
|
|
|
return (compat_43_sys_getrlimit(l, &ua, retval));
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_43_netbsd32_osetrlimit(struct lwp *l, const struct compat_43_netbsd32_osetrlimit_args *uap, register_t *retval)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1998-08-26 14:20:33 +04:00
|
|
|
syscallarg(int) which;
|
1999-03-25 19:22:49 +03:00
|
|
|
syscallarg(netbsd32_orlimitp_t) rlp;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
1998-08-26 14:20:33 +04:00
|
|
|
struct compat_43_sys_setrlimit_args ua;
|
|
|
|
|
1999-03-25 19:58:39 +03:00
|
|
|
NETBSD32TO64_UAP(which);
|
|
|
|
NETBSD32TOP_UAP(rlp, struct orlimit);
|
2003-01-18 11:28:25 +03:00
|
|
|
return (compat_43_sys_setrlimit(l, &ua, retval));
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
1998-10-01 18:27:56 +04:00
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_43_netbsd32_killpg(struct lwp *l, const struct compat_43_netbsd32_killpg_args *uap, register_t *retval)
|
1998-10-01 18:27:56 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1998-10-01 18:27:56 +04:00
|
|
|
syscallarg(int) pgid;
|
|
|
|
syscallarg(int) signum;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
1998-10-01 18:27:56 +04:00
|
|
|
struct compat_43_sys_killpg_args ua;
|
|
|
|
|
1999-03-25 19:58:39 +03:00
|
|
|
NETBSD32TO64_UAP(pgid);
|
|
|
|
NETBSD32TO64_UAP(signum);
|
2003-01-18 11:28:25 +03:00
|
|
|
return (compat_43_sys_killpg(l, &ua, retval));
|
1998-10-01 18:27:56 +04:00
|
|
|
}
|
|
|
|
|
1998-08-26 14:20:33 +04:00
|
|
|
/* virtual memory syscalls */
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_43_netbsd32_ommap(struct lwp *l, const struct compat_43_netbsd32_ommap_args *uap, register_t *retval)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
2009-01-30 16:01:36 +03:00
|
|
|
syscallarg(netbsd32_voidp) addr;
|
1999-03-25 19:22:49 +03:00
|
|
|
syscallarg(netbsd32_size_t) len;
|
1998-08-26 14:20:33 +04:00
|
|
|
syscallarg(int) prot;
|
|
|
|
syscallarg(int) flags;
|
|
|
|
syscallarg(int) fd;
|
1999-03-25 19:22:49 +03:00
|
|
|
syscallarg(netbsd32_long) pos;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
1998-08-26 14:20:33 +04:00
|
|
|
struct compat_43_sys_mmap_args ua;
|
|
|
|
|
2007-03-17 01:21:40 +03:00
|
|
|
NETBSD32TOP_UAP(addr, void *);
|
1999-03-25 19:58:39 +03:00
|
|
|
NETBSD32TOX_UAP(len, size_t);
|
|
|
|
NETBSD32TO64_UAP(prot);
|
|
|
|
NETBSD32TO64_UAP(flags);
|
|
|
|
NETBSD32TO64_UAP(fd);
|
|
|
|
NETBSD32TOX_UAP(pos, long);
|
2003-01-18 11:28:25 +03:00
|
|
|
return (compat_43_sys_mmap(l, &ua, retval));
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* network syscalls */
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_43_netbsd32_oaccept(struct lwp *l, const struct compat_43_netbsd32_oaccept_args *uap, register_t *retval)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1998-08-26 14:20:33 +04:00
|
|
|
syscallarg(int) s;
|
2009-01-30 16:01:36 +03:00
|
|
|
syscallarg(netbsd32_voidp) name;
|
1999-03-25 19:22:49 +03:00
|
|
|
syscallarg(netbsd32_intp) anamelen;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
1998-08-26 14:20:33 +04:00
|
|
|
struct compat_43_sys_accept_args ua;
|
|
|
|
|
1999-03-25 19:58:39 +03:00
|
|
|
NETBSD32TOX_UAP(s, int);
|
2007-03-17 01:21:40 +03:00
|
|
|
NETBSD32TOP_UAP(name, void *);
|
1999-03-25 19:58:39 +03:00
|
|
|
NETBSD32TOP_UAP(anamelen, int);
|
2003-01-18 11:28:25 +03:00
|
|
|
return (compat_43_sys_accept(l, &ua, retval));
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_43_netbsd32_osend(struct lwp *l, const struct compat_43_netbsd32_osend_args *uap, register_t *retval)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1998-08-26 14:20:33 +04:00
|
|
|
syscallarg(int) s;
|
2009-01-30 16:01:36 +03:00
|
|
|
syscallarg(netbsd32_voidp) buf;
|
1998-08-26 14:20:33 +04:00
|
|
|
syscallarg(int) len;
|
|
|
|
syscallarg(int) flags;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
1998-08-26 14:20:33 +04:00
|
|
|
struct compat_43_sys_send_args ua;
|
|
|
|
|
1999-03-25 19:58:39 +03:00
|
|
|
NETBSD32TO64_UAP(s);
|
2007-03-17 01:21:40 +03:00
|
|
|
NETBSD32TOP_UAP(buf, void *);
|
1999-03-25 19:58:39 +03:00
|
|
|
NETBSD32TO64_UAP(len);
|
|
|
|
NETBSD32TO64_UAP(flags);
|
2003-01-18 11:28:25 +03:00
|
|
|
return (compat_43_sys_send(l, &ua, retval));
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_43_netbsd32_orecv(struct lwp *l, const struct compat_43_netbsd32_orecv_args *uap, register_t *retval)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1998-08-26 14:20:33 +04:00
|
|
|
syscallarg(int) s;
|
2009-01-30 16:01:36 +03:00
|
|
|
syscallarg(netbsd32_voidp) buf;
|
1998-08-26 14:20:33 +04:00
|
|
|
syscallarg(int) len;
|
|
|
|
syscallarg(int) flags;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
1998-08-26 14:20:33 +04:00
|
|
|
struct compat_43_sys_recv_args ua;
|
|
|
|
|
1999-03-25 19:58:39 +03:00
|
|
|
NETBSD32TO64_UAP(s);
|
2007-03-17 01:21:40 +03:00
|
|
|
NETBSD32TOP_UAP(buf, void *);
|
1999-03-25 19:58:39 +03:00
|
|
|
NETBSD32TO64_UAP(len);
|
|
|
|
NETBSD32TO64_UAP(flags);
|
2003-01-18 11:28:25 +03:00
|
|
|
return (compat_43_sys_recv(l, &ua, retval));
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2007-06-30 19:31:49 +04:00
|
|
|
* This is a brutal clone of compat_43_sys_recvmsg().
|
1998-08-26 14:20:33 +04:00
|
|
|
*/
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_43_netbsd32_orecvmsg(struct lwp *l, const struct compat_43_netbsd32_orecvmsg_args *uap, register_t *retval)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1998-08-26 14:20:33 +04:00
|
|
|
syscallarg(int) s;
|
1999-03-25 19:22:49 +03:00
|
|
|
syscallarg(netbsd32_omsghdrp_t) msg;
|
1998-08-26 14:20:33 +04:00
|
|
|
syscallarg(int) flags;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
2007-06-30 19:31:49 +04:00
|
|
|
struct netbsd32_omsghdr omsg;
|
|
|
|
struct msghdr msg;
|
|
|
|
struct mbuf *from, *control;
|
|
|
|
struct iovec *iov, aiov[UIO_SMALLIOV];
|
|
|
|
int error;
|
2001-02-05 09:32:55 +03:00
|
|
|
|
2007-06-30 19:31:49 +04:00
|
|
|
error = copyin(SCARG_P32(uap, msg), &omsg, sizeof (struct omsghdr));
|
2001-02-05 09:32:55 +03:00
|
|
|
if (error)
|
|
|
|
return (error);
|
1998-08-26 14:20:33 +04:00
|
|
|
|
2007-06-30 19:31:49 +04:00
|
|
|
if (NETBSD32PTR64(omsg.msg_accrights) == NULL)
|
|
|
|
omsg.msg_accrightslen = 0;
|
|
|
|
/* it was this way in 4.4BSD */
|
|
|
|
if (omsg.msg_accrightslen > MLEN)
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
iov = netbsd32_get_iov(NETBSD32PTR64(omsg.msg_iov), omsg.msg_iovlen,
|
|
|
|
aiov, __arraycount(aiov));
|
|
|
|
if (iov == NULL)
|
|
|
|
return EFAULT;
|
|
|
|
|
|
|
|
msg.msg_name = NETBSD32PTR64(omsg.msg_name);
|
|
|
|
msg.msg_namelen = omsg.msg_namelen;
|
|
|
|
msg.msg_iovlen = omsg.msg_iovlen;
|
|
|
|
msg.msg_iov = iov;
|
|
|
|
msg.msg_flags = SCARG(uap, flags) & MSG_USERFLAGS;
|
|
|
|
|
|
|
|
error = do_sys_recvmsg(l, SCARG(uap, s), &msg, &from,
|
|
|
|
NETBSD32PTR64(omsg.msg_accrights) != NULL ? &control : NULL,
|
|
|
|
retval);
|
|
|
|
if (error != 0)
|
2010-04-23 19:19:19 +04:00
|
|
|
goto out;
|
2001-02-05 09:32:55 +03:00
|
|
|
|
2007-06-30 19:31:49 +04:00
|
|
|
/*
|
|
|
|
* If there is any control information and it's SCM_RIGHTS,
|
|
|
|
* pass it back to the program.
|
|
|
|
* XXX: maybe there can be more than one chunk of control data?
|
|
|
|
*/
|
|
|
|
if (NETBSD32PTR64(omsg.msg_accrights) != NULL && control != NULL) {
|
|
|
|
struct cmsghdr *cmsg = mtod(control, void *);
|
|
|
|
|
|
|
|
if (cmsg->cmsg_level == SOL_SOCKET
|
|
|
|
&& cmsg->cmsg_type == SCM_RIGHTS
|
|
|
|
&& cmsg->cmsg_len < omsg.msg_accrightslen
|
|
|
|
&& copyout(CMSG_DATA(cmsg),
|
|
|
|
NETBSD32PTR64(omsg.msg_accrights),
|
|
|
|
cmsg->cmsg_len) == 0) {
|
|
|
|
omsg.msg_accrightslen = cmsg->cmsg_len;
|
|
|
|
free_control_mbuf(l, control, control->m_next);
|
|
|
|
} else {
|
|
|
|
omsg.msg_accrightslen = 0;
|
|
|
|
free_control_mbuf(l, control, control);
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
omsg.msg_accrightslen = 0;
|
|
|
|
|
|
|
|
if (from != NULL)
|
|
|
|
/* convert from sockaddr sa_family to osockaddr one here */
|
|
|
|
mtod(from, struct osockaddr *)->sa_family =
|
|
|
|
mtod(from, struct sockaddr *)->sa_family;
|
|
|
|
|
|
|
|
error = copyout_sockname(NETBSD32PTR64(omsg.msg_name),
|
|
|
|
&omsg.msg_namelen, 0, from);
|
|
|
|
if (from != NULL)
|
|
|
|
m_free(from);
|
|
|
|
|
|
|
|
if (error != 0)
|
|
|
|
error = copyout(&omsg, SCARG_P32(uap, msg), sizeof(omsg));
|
2010-04-23 19:19:19 +04:00
|
|
|
out:
|
|
|
|
if (iov != aiov) {
|
2010-04-24 03:05:40 +04:00
|
|
|
kmem_free(iov, omsg.msg_iovlen * sizeof(*iov));
|
2010-04-23 19:19:19 +04:00
|
|
|
}
|
2007-06-30 19:31:49 +04:00
|
|
|
return error;
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_43_netbsd32_osendmsg(struct lwp *l, const struct compat_43_netbsd32_osendmsg_args *uap, register_t *retval)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1998-08-26 14:20:33 +04:00
|
|
|
syscallarg(int) s;
|
2009-01-30 16:01:36 +03:00
|
|
|
syscallarg(netbsd32_voidp) msg;
|
1998-08-26 14:20:33 +04:00
|
|
|
syscallarg(int) flags;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
2007-06-30 19:31:49 +04:00
|
|
|
struct iovec *iov, aiov[UIO_SMALLIOV];
|
|
|
|
struct netbsd32_omsghdr omsg;
|
|
|
|
struct msghdr msg;
|
|
|
|
struct mbuf *nam;
|
|
|
|
struct osockaddr *osa;
|
|
|
|
struct sockaddr *sa;
|
2010-04-23 19:19:19 +04:00
|
|
|
int error;
|
1998-08-26 14:20:33 +04:00
|
|
|
|
2007-06-30 19:31:49 +04:00
|
|
|
error = copyin(SCARG_P32(uap, msg), &omsg, sizeof (struct omsghdr));
|
|
|
|
if (error != 0)
|
2001-02-05 09:32:55 +03:00
|
|
|
return (error);
|
|
|
|
|
2007-06-30 19:31:49 +04:00
|
|
|
iov = netbsd32_get_iov(NETBSD32PTR64(omsg.msg_iov), omsg.msg_iovlen,
|
|
|
|
aiov, __arraycount(aiov));
|
|
|
|
if (iov == NULL)
|
|
|
|
return EFAULT;
|
|
|
|
|
|
|
|
msg.msg_iovlen = omsg.msg_iovlen;
|
|
|
|
msg.msg_iov = iov;
|
|
|
|
msg.msg_flags = MSG_NAMEMBUF;
|
|
|
|
|
|
|
|
error = sockargs(&nam, NETBSD32PTR64(omsg.msg_name), omsg.msg_namelen,
|
|
|
|
MT_SONAME);
|
|
|
|
if (error != 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
sa = mtod(nam, void *);
|
|
|
|
osa = mtod(nam, void *);
|
|
|
|
sa->sa_family = osa->sa_family;
|
|
|
|
sa->sa_len = omsg.msg_namelen;
|
|
|
|
|
|
|
|
msg.msg_name = nam;
|
|
|
|
msg.msg_namelen = omsg.msg_namelen;
|
|
|
|
error = compat43_set_accrights(&msg, NETBSD32PTR64(omsg.msg_accrights),
|
|
|
|
omsg.msg_accrightslen);
|
|
|
|
if (error != 0) {
|
|
|
|
m_free(nam);
|
|
|
|
goto out;
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
2007-06-30 19:31:49 +04:00
|
|
|
error = do_sys_sendmsg(l, SCARG(uap, s), &msg, SCARG(uap, flags), retval);
|
|
|
|
|
|
|
|
out:
|
|
|
|
if (iov != aiov)
|
2010-04-24 03:05:40 +04:00
|
|
|
kmem_free(iov, omsg.msg_iovlen * sizeof(*iov));
|
2007-06-30 19:31:49 +04:00
|
|
|
return (error);
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_43_netbsd32_orecvfrom(struct lwp *l, const struct compat_43_netbsd32_orecvfrom_args *uap, register_t *retval)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1998-08-26 14:20:33 +04:00
|
|
|
syscallarg(int) s;
|
2009-01-30 16:01:36 +03:00
|
|
|
syscallarg(netbsd32_voidp) buf;
|
1999-03-25 19:22:49 +03:00
|
|
|
syscallarg(netbsd32_size_t) len;
|
1998-08-26 14:20:33 +04:00
|
|
|
syscallarg(int) flags;
|
2009-01-30 16:01:36 +03:00
|
|
|
syscallarg(netbsd32_voidp) from;
|
1999-03-25 19:22:49 +03:00
|
|
|
syscallarg(netbsd32_intp) fromlenaddr;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
1998-08-26 14:20:33 +04:00
|
|
|
struct compat_43_sys_recvfrom_args ua;
|
|
|
|
|
1999-03-25 19:58:39 +03:00
|
|
|
NETBSD32TO64_UAP(s);
|
2007-03-17 01:21:40 +03:00
|
|
|
NETBSD32TOP_UAP(buf, void *);
|
1999-03-25 19:58:39 +03:00
|
|
|
NETBSD32TOX_UAP(len, size_t);
|
|
|
|
NETBSD32TO64_UAP(flags);
|
2007-03-17 01:21:40 +03:00
|
|
|
NETBSD32TOP_UAP(from, void *);
|
1999-03-25 19:58:39 +03:00
|
|
|
NETBSD32TOP_UAP(fromlenaddr, int);
|
2003-01-18 11:28:25 +03:00
|
|
|
return (compat_43_sys_recvfrom(l, &ua, retval));
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_43_netbsd32_ogetsockname(struct lwp *l, const struct compat_43_netbsd32_ogetsockname_args *uap, register_t *retval)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1998-08-26 14:20:33 +04:00
|
|
|
syscallarg(int) fdec;
|
2009-01-30 16:01:36 +03:00
|
|
|
syscallarg(netbsd32_voidp) asa;
|
1999-03-25 19:22:49 +03:00
|
|
|
syscallarg(netbsd32_intp) alen;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
1998-08-26 14:20:33 +04:00
|
|
|
struct compat_43_sys_getsockname_args ua;
|
|
|
|
|
1999-03-25 19:58:39 +03:00
|
|
|
NETBSD32TO64_UAP(fdec);
|
2007-03-17 01:21:40 +03:00
|
|
|
NETBSD32TOP_UAP(asa, void *);
|
|
|
|
NETBSD32TOP_UAP(alen, int *);
|
2003-01-18 11:28:25 +03:00
|
|
|
return (compat_43_sys_getsockname(l, &ua, retval));
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_43_netbsd32_ogetpeername(struct lwp *l, const struct compat_43_netbsd32_ogetpeername_args *uap, register_t *retval)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1998-08-26 14:20:33 +04:00
|
|
|
syscallarg(int) fdes;
|
2009-01-30 16:01:36 +03:00
|
|
|
syscallarg(netbsd32_voidp) asa;
|
1999-03-25 19:22:49 +03:00
|
|
|
syscallarg(netbsd32_intp) alen;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
1998-08-26 14:20:33 +04:00
|
|
|
struct compat_43_sys_getpeername_args ua;
|
|
|
|
|
1999-03-25 19:58:39 +03:00
|
|
|
NETBSD32TO64_UAP(fdes);
|
2007-03-17 01:21:40 +03:00
|
|
|
NETBSD32TOP_UAP(asa, void *);
|
|
|
|
NETBSD32TOP_UAP(alen, int *);
|
2003-01-18 11:28:25 +03:00
|
|
|
return (compat_43_sys_getpeername(l, &ua, retval));
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* signal syscalls */
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_43_netbsd32_osigvec(struct lwp *l, const struct compat_43_netbsd32_osigvec_args *uap, register_t *retval)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1998-08-26 14:20:33 +04:00
|
|
|
syscallarg(int) signum;
|
1999-03-25 19:22:49 +03:00
|
|
|
syscallarg(netbsd32_sigvecp_t) nsv;
|
|
|
|
syscallarg(netbsd32_sigvecp_t) osv;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
2001-02-05 09:32:55 +03:00
|
|
|
struct netbsd32_sigvec sv32;
|
2007-06-17 02:31:08 +04:00
|
|
|
struct sigaction nsa, osa;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
if (SCARG(uap, signum) >= 32)
|
|
|
|
return EINVAL;
|
1998-08-26 14:20:33 +04:00
|
|
|
|
2007-03-19 00:38:32 +03:00
|
|
|
if (SCARG_P32(uap, nsv)) {
|
|
|
|
error = copyin(SCARG_P32(uap, nsv), &sv32, sizeof(sv32));
|
2001-02-05 09:32:55 +03:00
|
|
|
if (error)
|
2007-06-17 02:31:08 +04:00
|
|
|
return error;
|
|
|
|
nsa.sa_handler = NETBSD32PTR64(sv32.sv_handler);
|
|
|
|
nsa.sa_mask.__bits[0] = sv32.sv_mask;
|
|
|
|
nsa.sa_mask.__bits[1] = 0;
|
|
|
|
nsa.sa_mask.__bits[2] = 0;
|
|
|
|
nsa.sa_mask.__bits[3] = 0;
|
|
|
|
nsa.sa_flags = sv32.sv_flags ^ SA_RESTART;
|
|
|
|
error = sigaction1(l, SCARG(uap, signum), &nsa, &osa, NULL, 0);
|
1998-08-26 14:20:33 +04:00
|
|
|
} else
|
2007-06-17 02:31:08 +04:00
|
|
|
error = sigaction1(l, SCARG(uap, signum), NULL, &osa, NULL, 0);
|
|
|
|
if (error)
|
|
|
|
return error;
|
1998-08-26 14:20:33 +04:00
|
|
|
|
2007-03-19 00:38:32 +03:00
|
|
|
if (SCARG_P32(uap, osv)) {
|
2007-06-17 02:31:08 +04:00
|
|
|
NETBSD32PTR32(sv32.sv_handler, osa.sa_handler);
|
|
|
|
sv32.sv_mask = osa.sa_mask.__bits[0];
|
|
|
|
sv32.sv_flags = osa.sa_flags ^ SA_RESTART;
|
2007-03-19 00:38:32 +03:00
|
|
|
error = copyout(&sv32, SCARG_P32(uap, osv), sizeof(sv32));
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
2007-06-17 02:31:08 +04:00
|
|
|
return error;
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
1998-10-01 18:27:56 +04:00
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_43_netbsd32_sigblock(struct lwp *l, const struct compat_43_netbsd32_sigblock_args *uap, register_t *retval)
|
1998-10-01 18:27:56 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1998-10-01 18:27:56 +04:00
|
|
|
syscallarg(int) mask;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
1998-10-01 18:27:56 +04:00
|
|
|
struct compat_43_sys_sigblock_args ua;
|
|
|
|
|
1999-03-25 19:58:39 +03:00
|
|
|
NETBSD32TO64_UAP(mask);
|
2003-01-18 11:28:25 +03:00
|
|
|
return (compat_43_sys_sigblock(l, &ua, retval));
|
1998-10-01 18:27:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_43_netbsd32_sigsetmask(struct lwp *l, const struct compat_43_netbsd32_sigsetmask_args *uap, register_t *retval)
|
1998-10-01 18:27:56 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1998-10-01 18:27:56 +04:00
|
|
|
syscallarg(int) mask;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
1998-10-01 18:27:56 +04:00
|
|
|
struct compat_43_sys_sigsetmask_args ua;
|
|
|
|
|
1999-03-25 19:58:39 +03:00
|
|
|
NETBSD32TO64_UAP(mask);
|
2003-01-18 11:28:25 +03:00
|
|
|
return (compat_43_sys_sigsetmask(l, &ua, retval));
|
1998-10-01 18:27:56 +04:00
|
|
|
}
|
|
|
|
|
1998-08-26 14:20:33 +04:00
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_43_netbsd32_osigstack(struct lwp *l, const struct compat_43_netbsd32_osigstack_args *uap, register_t *retval)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1999-03-25 19:22:49 +03:00
|
|
|
syscallarg(netbsd32_sigstackp_t) nss;
|
|
|
|
syscallarg(netbsd32_sigstackp_t) oss;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
2001-02-05 09:32:55 +03:00
|
|
|
struct netbsd32_sigstack ss32;
|
2007-06-17 02:31:08 +04:00
|
|
|
struct sigaltstack nsa, osa;
|
|
|
|
int error;
|
1998-08-26 14:20:33 +04:00
|
|
|
|
2007-03-19 00:38:32 +03:00
|
|
|
if (SCARG_P32(uap, nss)) {
|
|
|
|
error = copyin(SCARG_P32(uap, nss), &ss32, sizeof(ss32));
|
2001-02-05 09:32:55 +03:00
|
|
|
if (error)
|
2007-06-17 02:31:08 +04:00
|
|
|
return error;
|
|
|
|
nsa.ss_sp = NETBSD32PTR64(ss32.ss_sp);
|
|
|
|
nsa.ss_size = SIGSTKSZ; /* Use the recommended size */
|
|
|
|
nsa.ss_flags = ss32.ss_onstack ? SS_ONSTACK : 0;
|
|
|
|
error = sigaltstack1(l, &nsa, &osa);
|
1998-08-26 14:20:33 +04:00
|
|
|
} else
|
2007-06-17 02:31:08 +04:00
|
|
|
error = sigaltstack1(l, NULL, &osa);
|
|
|
|
if (error)
|
|
|
|
return error;
|
1998-08-26 14:20:33 +04:00
|
|
|
|
2007-03-19 00:38:32 +03:00
|
|
|
if (SCARG_P32(uap, oss)) {
|
2007-06-17 02:31:08 +04:00
|
|
|
NETBSD32PTR32(ss32.ss_sp, osa.ss_sp);
|
|
|
|
ss32.ss_onstack = (osa.ss_flags & SS_ONSTACK) != 0;
|
2007-03-19 00:38:32 +03:00
|
|
|
error = copyout(&ss32, SCARG_P32(uap, oss), sizeof(ss32));
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
2007-06-17 02:31:08 +04:00
|
|
|
return error;
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|