xref: /netbsd/sys/compat/common/kern_event_100.c (revision 47cc1f20)
1 /*	$NetBSD: kern_event_100.c,v 1.1 2023/07/28 18:19:00 christos Exp $	*/
2 
3 /*-
4  * Copyright (c) 2023 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
28 #include <sys/cdefs.h>
29 __KERNEL_RCSID(0, "$NetBSD: kern_event_100.c,v 1.1 2023/07/28 18:19:00 christos Exp $");
30 
31 #if defined(_KERNEL_OPT)
32 #include "opt_compat_netbsd.h"
33 #endif
34 
35 #include <sys/param.h>
36 #include <sys/event.h>
37 #include <sys/syscall.h>
38 #include <sys/syscallvar.h>
39 #include <sys/syscallargs.h>
40 
41 #include <compat/common/compat_mod.h>
42 #include <compat/sys/event.h>
43 
44 static const struct syscall_package kern_event_100_syscalls[] = {
45 	{ SYS_compat_100___kevent50, 0,
46 	    (sy_call_t *)compat_100_sys___kevent50 },
47 	{ 0, 0, NULL },
48 };
49 
50 int
compat_100_sys___kevent50(struct lwp * l,const struct compat_100_sys___kevent50_args * uap,register_t * retval)51 compat_100_sys___kevent50(struct lwp *l,
52     const struct compat_100_sys___kevent50_args *uap,
53     register_t *retval)
54 {
55 	/* {
56 		syscallarg(int) fd;
57 		syscallarg(const struct kevent100 *) changelist;
58 		syscallarg(size_t) nchanges;
59 		syscallarg(struct kevent100 *) eventlist;
60 		syscallarg(size_t) nevents;
61 		syscallarg(const struct timespec *) timeout;
62 	} */
63 	static const struct kevent_ops compat_100_kevent_ops = {
64 		.keo_private = NULL,
65 		.keo_fetch_timeout = copyin,
66 		.keo_fetch_changes = compat_100___kevent50_fetch_changes,
67 		.keo_put_events = compat_100___kevent50_put_events,
68 	};
69 
70 	return kevent1(retval, SCARG(uap, fd),
71 	    (const struct kevent *)SCARG(uap, changelist), SCARG(uap, nchanges),
72 	    (struct kevent *)SCARG(uap, eventlist), SCARG(uap, nevents),
73 	    SCARG(uap, timeout), &compat_100_kevent_ops);
74 }
75 
76 int
kern_event_100_init(void)77 kern_event_100_init(void)
78 {
79 
80 	return syscall_establish(NULL, kern_event_100_syscalls);
81 }
82 
83 int
kern_event_100_fini(void)84 kern_event_100_fini(void)
85 {
86 
87 	return syscall_disestablish(NULL, kern_event_100_syscalls);
88 }
89