1101099Srwatson/*	$NetBSD: linux_oldselect.c,v 1.59 2021/09/23 06:56:27 ryo Exp $	*/
2101099Srwatson
3115497Srwatson/*-
4101099Srwatson * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
5101099Srwatson * All rights reserved.
6101099Srwatson *
7101099Srwatson * This code is derived from software contributed to The NetBSD Foundation
8106393Srwatson * by Frank van der Linden and Eric Haszlakiewicz.
9106393Srwatson *
10106393Srwatson * Redistribution and use in source and binary forms, with or without
11106393Srwatson * modification, are permitted provided that the following conditions
12101099Srwatson * are met:
13101099Srwatson * 1. Redistributions of source code must retain the above copyright
14101099Srwatson *    notice, this list of conditions and the following disclaimer.
15101099Srwatson * 2. Redistributions in binary form must reproduce the above copyright
16101099Srwatson *    notice, this list of conditions and the following disclaimer in the
17101099Srwatson *    documentation and/or other materials provided with the distribution.
18101099Srwatson *
19101099Srwatson * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20101099Srwatson * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21101099Srwatson * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22101099Srwatson * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23101099Srwatson * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24101099Srwatson * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25101099Srwatson * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26101099Srwatson * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27101099Srwatson * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28101099Srwatson * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29101099Srwatson * POSSIBILITY OF SUCH DAMAGE.
30101099Srwatson */
31101099Srwatson
32101099Srwatson#include <sys/cdefs.h>
33101099Srwatson__KERNEL_RCSID(0, "$NetBSD: linux_oldselect.c,v 1.59 2021/09/23 06:56:27 ryo Exp $");
34101099Srwatson
35101099Srwatson#include <sys/param.h>
36101099Srwatson#include <sys/systm.h>
37101099Srwatson#include <sys/mount.h>
38101099Srwatson
39101099Srwatson#include <sys/sched.h>
40101099Srwatson#include <sys/syscallargs.h>
41101099Srwatson
42101099Srwatson#include <compat/linux/common/linux_types.h>
43101099Srwatson#include <compat/linux/common/linux_misc.h>
44101099Srwatson#include <compat/linux/common/linux_mmap.h>
45101099Srwatson#include <compat/linux/common/linux_signal.h>
46105988Srwatson#include <compat/linux/common/linux_oldselect.h>
47101099Srwatson
48101099Srwatson#include <compat/linux/linux_syscallargs.h>
49103183Sbde
50101099Srwatson/* Used on: arm, i386, m68k */
51101099Srwatson/* Not used on: aarch64, alpha, mips, ppc, sparc, sparc64 */
52115497Srwatson
53101099Srwatson/*
54101099Srwatson * Not sure why the arguments to this older version of select() were put
55101099Srwatson * into a structure, because there are 5, and that can all be handled
56105696Srwatson * in registers on the i386 like Linux wants to.
57101099Srwatson */
58101099Srwatsonint
59101099Srwatsonlinux_sys_oldselect(struct lwp *l, const struct linux_sys_oldselect_args *uap, register_t *retval)
60101099Srwatson{
61101099Srwatson	/* {
62101099Srwatson		syscallarg(struct linux_oldselect *) lsp;
63101099Srwatson	} */
64101099Srwatson	struct linux_oldselect ls;
65101099Srwatson	int error;
66101099Srwatson
67101099Srwatson	if ((error = copyin(SCARG(uap, lsp), &ls, sizeof(ls))))
68101099Srwatson		return error;
69101099Srwatson
70101099Srwatson	return linux_select1(l, retval, ls.nfds, ls.readfds, ls.writefds,
71101099Srwatson	    ls.exceptfds, ls.timeout);
72101099Srwatson}
73101099Srwatson
74101099Srwatson