From 29a332bce639b243a2a4eb50b04c3fabaca6fefb Mon Sep 17 00:00:00 2001 From: visa Date: Sun, 20 Aug 2023 15:17:53 +0000 Subject: [PATCH] Add syscall stub for kqueue1(2) This rides previous libc minor bump. Feedback and OK guenther@ --- lib/libc/Symbols.list | 2 ++ lib/libc/hidden/sys/event.h | 3 ++- lib/libc/sys/Makefile.inc | 4 ++-- lib/libc/sys/kqueue.2 | 39 ++++++++++++++++++++++++++++++++---- lib/libc/sys/pledge.2 | 5 +++-- lib/librthread/shlib_version | 2 +- 6 files changed, 45 insertions(+), 10 deletions(-) diff --git a/lib/libc/Symbols.list b/lib/libc/Symbols.list index b8f9b379a6a..f18c6baa0f5 100644 --- a/lib/libc/Symbols.list +++ b/lib/libc/Symbols.list @@ -121,6 +121,7 @@ _thread_sys_issetugid _thread_sys_kevent _thread_sys_kill _thread_sys_kqueue +_thread_sys_kqueue1 _thread_sys_ktrace _thread_sys_lchown _thread_sys_link @@ -322,6 +323,7 @@ issetugid kevent kill kqueue +kqueue1 ktrace lchown link diff --git a/lib/libc/hidden/sys/event.h b/lib/libc/hidden/sys/event.h index 7e129b8aab4..20a727ec683 100644 --- a/lib/libc/hidden/sys/event.h +++ b/lib/libc/hidden/sys/event.h @@ -1,4 +1,4 @@ -/* $OpenBSD: event.h,v 1.1 2023/05/18 16:11:09 guenther Exp $ */ +/* $OpenBSD: event.h,v 1.2 2023/08/20 15:17:53 visa Exp $ */ /* * Copyright (c) 2023 Philip Guenther * @@ -22,5 +22,6 @@ PROTO_NORMAL(kevent); PROTO_NORMAL(kqueue); +PROTO_NORMAL(kqueue1); #endif /* !_LIBC_SYS_EVENT_H_ */ diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc index 4d2e9b89f7d..f45b41ada0d 100644 --- a/lib/libc/sys/Makefile.inc +++ b/lib/libc/sys/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.173 2023/02/27 14:59:33 deraadt Exp $ +# $OpenBSD: Makefile.inc,v 1.174 2023/08/20 15:17:53 visa Exp $ # $NetBSD: Makefile.inc,v 1.35 1995/10/16 23:49:07 jtc Exp $ # @(#)Makefile.inc 8.1 (Berkeley) 6/17/93 @@ -73,7 +73,7 @@ ASM= __semctl.o __thrsigdivert.o \ getpriority.o getresgid.o getresuid.o \ getrlimit.o getrusage.o getsid.o getsockname.o \ getsockopt.o ioctl.o \ - kevent.o kill.o kqueue.o ktrace.o lchown.o \ + kevent.o kill.o kqueue.o kqueue1.o ktrace.o lchown.o \ link.o linkat.o listen.o lseek.o lstat.o \ madvise.o mimmutable.o minherit.o mkdir.o mkdirat.o mkfifo.o mkfifoat.o \ mknod.o mknodat.o mlock.o mlockall.o mmap.o mount.o mprotect.o \ diff --git a/lib/libc/sys/kqueue.2 b/lib/libc/sys/kqueue.2 index c4c13cca72f..0e187d5b1a2 100644 --- a/lib/libc/sys/kqueue.2 +++ b/lib/libc/sys/kqueue.2 @@ -1,4 +1,4 @@ -.\" $OpenBSD: kqueue.2,v 1.49 2023/08/13 10:23:26 jmc Exp $ +.\" $OpenBSD: kqueue.2,v 1.50 2023/08/20 15:17:53 visa Exp $ .\" .\" Copyright (c) 2000 Jonathan Lemon .\" All rights reserved. @@ -26,11 +26,12 @@ .\" .\" $FreeBSD: src/lib/libc/sys/kqueue.2,v 1.18 2001/02/14 08:48:35 guido Exp $ .\" -.Dd $Mdocdate: August 13 2023 $ +.Dd $Mdocdate: August 20 2023 $ .Dt KQUEUE 2 .Os .Sh NAME .Nm kqueue , +.Nm kqueue1 , .Nm kevent , .Nm EV_SET .Nd kernel event notification mechanism @@ -43,6 +44,12 @@ .Ft int .Fn kevent "int kq" "const struct kevent *changelist" "int nchanges" "struct kevent *eventlist" "int nevents" "const struct timespec *timeout" .Fn EV_SET "&kev" ident filter flags fflags data udata +.In sys/types.h +.In sys/event.h +.In sys/time.h +.In fcntl.h +.Ft int +.Fn kqueue1 "int flags" .Sh DESCRIPTION .Fn kqueue provides a generic method of notifying the user when an event @@ -78,6 +85,17 @@ The queue is not inherited by a child created with .Xr fork 2 . Similarly, kqueues cannot be passed across UNIX-domain sockets. .Pp +The +.Fn kqueue1 +function is identical to +.Fn kqueue +except that the close-on-exec flag on the new file descriptor +is determined by the +.Dv O_CLOEXEC flag +in the +.Fa flags +argument. +.Pp .Fn kevent is used to register events with the queue, and return any pending events to the user. @@ -545,7 +563,9 @@ contains the events which triggered the filter. .El .Sh RETURN VALUES .Fn kqueue -creates a new kernel event queue and returns a file descriptor. +and +.Fn kqueue1 +create a new kernel event queue and returns a file descriptor. If there was an error creating the kernel event queue, a value of -1 is returned and .Va errno @@ -577,7 +597,9 @@ returns 0. .Sh ERRORS The .Fn kqueue -function fails if: +and +.Fn kqueue1 +functions fail if: .Bl -tag -width Er .It Bq Er ENOMEM The kernel failed to allocate enough memory for the kernel queue. @@ -587,6 +609,15 @@ The per-process descriptor table is full. The system file table is full. .El .Pp +In addition, +.Fn kqueue1 +fails if: +.Bl -tag -width Er +.It Bq Er EINVAL +.Fa flags +is invalid. +.El +.Pp The .Fn kevent function fails if: diff --git a/lib/libc/sys/pledge.2 b/lib/libc/sys/pledge.2 index 5cca1fb17ce..18c01fded75 100644 --- a/lib/libc/sys/pledge.2 +++ b/lib/libc/sys/pledge.2 @@ -1,4 +1,4 @@ -.\" $OpenBSD: pledge.2,v 1.66 2023/06/02 17:44:29 cheloha Exp $ +.\" $OpenBSD: pledge.2,v 1.67 2023/08/20 15:17:53 visa Exp $ .\" .\" Copyright (c) 2015 Nicholas Marriott .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: June 2 2023 $ +.Dd $Mdocdate: August 20 2023 $ .Dt PLEDGE 2 .Os .Sh NAME @@ -198,6 +198,7 @@ As a result, all the expected functionalities of libc stdio work. .Xr issetugid 2 , .Xr kevent 2 , .Xr kqueue 2 , +.Xr kqueue1 2 , .Xr lseek 2 , .Xr madvise 2 , .Xr minherit 2 , diff --git a/lib/librthread/shlib_version b/lib/librthread/shlib_version index 54ef0c4cc0c..72e5894f74e 100644 --- a/lib/librthread/shlib_version +++ b/lib/librthread/shlib_version @@ -1,2 +1,2 @@ major=27 -minor=0 +minor=1 -- 2.20.1