use compat code from sys/compat/common

This commit is contained in:
pooka 2011-01-17 16:20:20 +00:00
parent 53c9307857
commit 46b3b0f6ce
3 changed files with 8 additions and 244 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.rumpkern,v 1.106 2011/01/06 11:22:55 pooka Exp $
# $NetBSD: Makefile.rumpkern,v 1.107 2011/01/17 16:20:20 pooka Exp $
#
.include "${RUMPTOP}/Makefile.rump"
@ -10,7 +10,8 @@ LIB= rump
${RUMPTOP}/../uvm \
${RUMPTOP}/../conf \
${RUMPTOP}/../dev \
${RUMPTOP}/../secmodel/suser
${RUMPTOP}/../secmodel/suser \
${RUMPTOP}/../compat/common
#
# Source modules, first the ones specifically implemented for librump.
@ -18,7 +19,6 @@ LIB= rump
SRCS= rump.c rumpcopy.c emul.c intr.c lwproc.c klock.c \
kobj_rename.c ltsleep.c memalloc.c scheduler.c \
signals.c sleepq.c threads.c vm.c
SRCS+= compat.c
# Multiprocessor or uniprocessor locking. TODO: select right
# locking at runtime.
@ -117,6 +117,9 @@ SRCS+= vnode_if.c
# sys/dev
SRCS+= clock_subr.c
# compat
SRCS+= kern_select_50.c
# Flip the comment to the other line if you want to use malloc(3)
# directly instead of the kernel allocators backed by malloc(3)/mmap(2).
# Libc malloc is a few percent faster, but doesn't emulate all kernel

View File

@ -1,119 +0,0 @@
/* $NetBSD: compat.c,v 1.2 2010/07/26 11:52:25 pooka Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Christos Zoulas.
*
* 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: compat.c,v 1.2 2010/07/26 11:52:25 pooka Exp $");
#include <sys/param.h>
#include <sys/kmem.h>
#include <sys/poll.h>
#include <sys/sched.h>
#include <sys/select.h>
#include <sys/syscallargs.h>
#include <sys/vnode.h>
#include <compat/sys/time.h>
#include <rump/rump.h>
#include <rump/rump_syscalls_compat.h>
#include <rump/rumpuser.h>
/* mostly from sys/compat/common/kern_time_50.c */
int
rump_sys_nb5_pollts(struct pollfd *fds, size_t nfds,
const struct timespec *tsarg, const void *sigset)
{
register_t retval;
struct timespec ats, *ts = NULL;
struct timespec50 ats50;
sigset_t amask, *mask = NULL;
int error;
rump_schedule();
if (tsarg) {
error = copyin(tsarg, &ats50, sizeof(ats50));
if (error)
return error;
timespec50_to_timespec(&ats50, &ats);
ts = &ats;
}
if (sigset) {
error = copyin(sigset, &amask, sizeof(amask));
if (error)
return error;
mask = &amask;
}
error = pollcommon(&retval, fds, nfds, ts, mask);
rump_unschedule();
if (error) {
rumpuser_seterrno(error);
retval = -1;
}
return retval;
}
int
rump_sys_nb5_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exfds,
struct timeval *timeout)
{
register_t retval;
struct timespec ats, *ts = NULL;
struct timeval50 atv50;
int error;
rump_schedule();
if (timeout) {
error = copyin(timeout, &atv50, sizeof(atv50));
if (error)
return error;
ats.tv_sec = atv50.tv_sec;
ats.tv_nsec = atv50.tv_usec * 1000;
ts = &ats;
}
error = selcommon(&retval, nfds, readfds, writefds, exfds, ts, NULL);
rump_unschedule();
if (error) {
rumpuser_seterrno(error);
retval = -1;
}
return retval;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: compat.c,v 1.8 2011/01/04 17:00:19 pooka Exp $ */
/* $NetBSD: compat.c,v 1.9 2011/01/17 16:20:20 pooka Exp $ */
/*
* Copyright (c) 2009 Antti Kantee. All Rights Reserved.
@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: compat.c,v 1.8 2011/01/04 17:00:19 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: compat.c,v 1.9 2011/01/17 16:20:20 pooka Exp $");
#include <sys/param.h>
#include <sys/kmem.h>
@ -80,126 +80,6 @@ struct vattr50 {
long va_spare; /* remain quad aligned */
};
int
rump_sys_nb5_stat(const char *path, struct stat *sb)
{
struct compat_50_sys___stat30_args args;
register_t retval = 0;
int error = 0;
SPARG(&args, path) = path;
SPARG(&args, ub) = (struct stat30 *)sb;
rump_schedule();
error = compat_50_sys___stat30(curlwp, &args, &retval);
if (error) {
retval = -1;
rumpuser_seterrno(error);
}
rump_unschedule();
return retval;
}
int
rump_sys_nb5_lstat(const char *path, struct stat *sb)
{
struct compat_50_sys___lstat30_args args;
register_t retval = 0;
int error = 0;
SPARG(&args, path) = path;
SPARG(&args, ub) = (struct stat30 *)sb;
rump_schedule();
error = compat_50_sys___lstat30(curlwp, &args, &retval);
if (error) {
retval = -1;
rumpuser_seterrno(error);
}
rump_unschedule();
return retval;
}
int
rump_sys_nb5_fstat(int fd, struct stat *sb)
{
struct compat_50_sys___fstat30_args args;
register_t retval = 0;
int error = 0;
SPARG(&args, fd) = fd;
SPARG(&args, sb) = (struct stat30 *)sb;
rump_schedule();
error = compat_50_sys___fstat30(curlwp, &args, &retval);
if (error) {
retval = -1;
rumpuser_seterrno(error);
}
rump_unschedule();
return retval;
}
int
rump_sys_nb5_utimes(const char *path, const struct timeval times[2])
{
struct compat_50_sys_utimes_args args;
register_t retval = 0;
int error = 0;
SPARG(&args, path) = path;
SPARG(&args, tptr) = (const struct timeval50 *)times;
rump_schedule();
error = compat_50_sys_utimes(curlwp, &args, &retval);
if (error) {
retval = -1;
rumpuser_seterrno(error);
}
rump_unschedule();
return retval;
}
int
rump_sys_nb5_lutimes(const char *path, const struct timeval times[2])
{
struct compat_50_sys_lutimes_args args;
register_t retval = 0;
int error = 0;
SPARG(&args, path) = path;
SPARG(&args, tptr) = (const struct timeval50 *)times;
rump_schedule();
error = compat_50_sys_lutimes(curlwp, &args, &retval);
if (error) {
retval = -1;
rumpuser_seterrno(error);
}
rump_unschedule();
return retval;
}
int
rump_sys_nb5_futimes(int fd, const struct timeval times[2])
{
struct compat_50_sys_futimes_args args;
register_t retval = 0;
int error = 0;
SPARG(&args, fd) = fd;
SPARG(&args, tptr) = (const struct timeval50 *)times;
rump_schedule();
error = compat_50_sys_futimes(curlwp, &args, &retval);
if (error) {
retval = -1;
rumpuser_seterrno(error);
}
rump_unschedule();
return retval;
}
/*
* XXX: types. But I don't want to start playing compat games in
* the userspace namespace too