Home | History | Annotate | Line # | Download | only in netbsd32
netbsd32_select.c revision 1.14.10.2
      1  1.14.10.2      yamt /*	$NetBSD: netbsd32_select.c,v 1.14.10.2 2010/03/11 15:03:18 yamt Exp $	*/
      2        1.1       mrg 
      3        1.1       mrg /*
      4        1.1       mrg  * Copyright (c) 1998, 2001 Matthew R. Green
      5        1.1       mrg  * All rights reserved.
      6        1.1       mrg  *
      7        1.1       mrg  * Redistribution and use in source and binary forms, with or without
      8        1.1       mrg  * modification, are permitted provided that the following conditions
      9        1.1       mrg  * are met:
     10        1.1       mrg  * 1. Redistributions of source code must retain the above copyright
     11        1.1       mrg  *    notice, this list of conditions and the following disclaimer.
     12        1.1       mrg  * 2. Redistributions in binary form must reproduce the above copyright
     13        1.1       mrg  *    notice, this list of conditions and the following disclaimer in the
     14        1.1       mrg  *    documentation and/or other materials provided with the distribution.
     15        1.1       mrg  *
     16        1.1       mrg  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17        1.1       mrg  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18        1.1       mrg  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19        1.1       mrg  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     20        1.1       mrg  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     21        1.1       mrg  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     22        1.1       mrg  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     23        1.1       mrg  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     24        1.1       mrg  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25        1.1       mrg  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26        1.1       mrg  * SUCH DAMAGE.
     27        1.1       mrg  */
     28        1.2     lukem 
     29        1.2     lukem #include <sys/cdefs.h>
     30  1.14.10.2      yamt __KERNEL_RCSID(0, "$NetBSD: netbsd32_select.c,v 1.14.10.2 2010/03/11 15:03:18 yamt Exp $");
     31        1.1       mrg 
     32        1.1       mrg #include <sys/param.h>
     33        1.1       mrg #include <sys/systm.h>
     34        1.1       mrg #include <sys/malloc.h>
     35        1.1       mrg #include <sys/mount.h>
     36        1.1       mrg #include <sys/time.h>
     37        1.1       mrg #include <sys/vnode.h>
     38        1.1       mrg #include <sys/file.h>
     39        1.1       mrg #include <sys/filedesc.h>
     40        1.7      cube #include <sys/poll.h>
     41        1.6      cube #include <sys/select.h>
     42        1.8  christos #include <sys/dirent.h>
     43        1.1       mrg 
     44        1.1       mrg #include <sys/proc.h>
     45        1.1       mrg 
     46        1.1       mrg #include <net/if.h>
     47        1.1       mrg 
     48        1.1       mrg #include <compat/netbsd32/netbsd32.h>
     49        1.1       mrg #include <compat/netbsd32/netbsd32_syscall.h>
     50        1.1       mrg #include <compat/netbsd32/netbsd32_syscallargs.h>
     51        1.1       mrg #include <compat/netbsd32/netbsd32_conv.h>
     52        1.1       mrg 
     53        1.1       mrg int
     54  1.14.10.2      yamt netbsd32___select50(struct lwp *l,
     55  1.14.10.2      yamt     const struct netbsd32___select50_args *uap, register_t *retval)
     56        1.1       mrg {
     57       1.14       dsl 	/* {
     58        1.1       mrg 		syscallarg(int) nd;
     59        1.1       mrg 		syscallarg(netbsd32_fd_setp_t) in;
     60        1.1       mrg 		syscallarg(netbsd32_fd_setp_t) ou;
     61        1.1       mrg 		syscallarg(netbsd32_fd_setp_t) ex;
     62        1.1       mrg 		syscallarg(netbsd32_timevalp_t) tv;
     63       1.14       dsl 	} */
     64        1.6      cube 	int error;
     65        1.1       mrg 	struct netbsd32_timeval tv32;
     66  1.14.10.1      yamt 	struct timespec ats, *ts = NULL;
     67        1.1       mrg 
     68       1.12       dsl 	if (SCARG_P32(uap, tv)) {
     69       1.12       dsl 		error = copyin(SCARG_P32(uap, tv), &tv32, sizeof(tv32));
     70       1.12       dsl 		if (error != 0)
     71        1.6      cube 			return error;
     72  1.14.10.1      yamt 		ats.tv_sec = tv32.tv_sec;
     73  1.14.10.1      yamt 		ats.tv_nsec = tv32.tv_usec * 1000;
     74  1.14.10.1      yamt 		ts = &ats;
     75        1.5  christos 	}
     76        1.6      cube 
     77  1.14.10.2      yamt 	return selcommon(retval, SCARG(uap, nd), SCARG_P32(uap, in),
     78  1.14.10.1      yamt 	    SCARG_P32(uap, ou), SCARG_P32(uap, ex), ts, NULL);
     79        1.1       mrg }
     80        1.7      cube 
     81        1.7      cube int
     82  1.14.10.2      yamt netbsd32___pselect50(struct lwp *l,
     83  1.14.10.2      yamt     const struct netbsd32___pselect50_args *uap, register_t *retval)
     84        1.7      cube {
     85       1.14       dsl 	/* {
     86        1.7      cube 		syscallarg(int) nd;
     87        1.7      cube 		syscallarg(netbsd32_fd_setp_t) in;
     88        1.7      cube 		syscallarg(netbsd32_fd_setp_t) ou;
     89        1.7      cube 		syscallarg(netbsd32_fd_setp_t) ex;
     90        1.7      cube 		syscallarg(const netbsd32_timespecp_t) ts;
     91        1.7      cube 		syscallarg(const netbsd32_sigsetp_t) mask;
     92       1.14       dsl 	} */
     93        1.7      cube 	int error;
     94        1.7      cube 	struct netbsd32_timespec ts32;
     95  1.14.10.1      yamt 	struct timespec ats, *ts = NULL;
     96        1.7      cube 	sigset_t amask, *mask = NULL;
     97        1.7      cube 
     98       1.12       dsl 	if (SCARG_P32(uap, ts)) {
     99       1.12       dsl 		error = copyin(SCARG_P32(uap, ts), &ts32, sizeof(ts32));
    100       1.12       dsl 		if (error != 0)
    101        1.7      cube 			return error;
    102  1.14.10.1      yamt 		netbsd32_to_timespec(&ts32, &ats);
    103  1.14.10.1      yamt 		ts = &ats;
    104        1.7      cube 	}
    105       1.12       dsl 	if (SCARG_P32(uap, mask)) {
    106       1.12       dsl 		error = copyin(SCARG_P32(uap, mask), &amask, sizeof(amask));
    107       1.12       dsl 		if (error != 0)
    108        1.7      cube 			return error;
    109        1.7      cube 		mask = &amask;
    110        1.7      cube 	}
    111        1.7      cube 
    112  1.14.10.2      yamt 	return selcommon(retval, SCARG(uap, nd), SCARG_P32(uap, in),
    113  1.14.10.1      yamt 	    SCARG_P32(uap, ou), SCARG_P32(uap, ex), ts, mask);
    114        1.7      cube }
    115        1.7      cube 
    116        1.7      cube int
    117  1.14.10.2      yamt netbsd32___pollts50(struct lwp *l, const struct netbsd32___pollts50_args *uap,
    118  1.14.10.2      yamt     register_t *retval)
    119        1.7      cube {
    120       1.14       dsl 	/* {
    121        1.7      cube 		syscallarg(struct netbsd32_pollfdp_t) fds;
    122        1.7      cube 		syscallarg(u_int) nfds;
    123        1.7      cube 		syscallarg(const netbsd32_timespecp_t) ts;
    124        1.7      cube 		syscallarg(const netbsd32_sigsetp_t) mask;
    125       1.14       dsl 	} */
    126        1.7      cube 	int error;
    127        1.7      cube 	struct netbsd32_timespec ts32;
    128  1.14.10.1      yamt 	struct timespec ats, *ts = NULL;
    129        1.7      cube 	sigset_t amask, *mask = NULL;
    130        1.7      cube 
    131       1.12       dsl 	if (SCARG_P32(uap, ts)) {
    132       1.12       dsl 		error = copyin(SCARG_P32(uap, ts), &ts32, sizeof(ts32));
    133       1.12       dsl 		if (error != 0)
    134        1.7      cube 			return error;
    135  1.14.10.1      yamt 		netbsd32_to_timespec(&ts32, &ats);
    136  1.14.10.1      yamt 		ts = &ats;
    137        1.7      cube 	}
    138       1.11       dsl 	if (NETBSD32PTR64( SCARG(uap, mask))) {
    139       1.12       dsl 		error = copyin(SCARG_P32(uap, mask), &amask, sizeof(amask));
    140       1.12       dsl 		if (error != 0)
    141        1.7      cube 			return error;
    142        1.7      cube 		mask = &amask;
    143        1.7      cube 	}
    144        1.7      cube 
    145  1.14.10.2      yamt 	return pollcommon(retval, SCARG_P32(uap, fds),
    146  1.14.10.1      yamt 	    SCARG(uap, nfds), ts, mask);
    147        1.7      cube }
    148