git: 61194e9852e6 - main - Add kqueue1() syscall
Date: Mon, 27 Mar 2023 23:39:32 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=61194e9852e641d1533cd04a5679d6042ff975d3 commit 61194e9852e641d1533cd04a5679d6042ff975d3 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2023-03-25 23:39:02 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2023-03-27 23:39:26 +0000 Add kqueue1() syscall It takes the flags argument. Immediate use is to provide the KQUEUE_CLOEXEC flag for kqueue(2). Reviewed by: emaste, jhb Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D39271 --- sys/kern/kern_event.c | 13 +++++++++++++ sys/kern/syscalls.master | 5 +++++ sys/sys/event.h | 3 +++ 3 files changed, 21 insertions(+) diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index f952a5f00340..0da4325ccd6a 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -1057,6 +1057,19 @@ sys_kqueue(struct thread *td, struct kqueue_args *uap) return (kern_kqueue(td, 0, NULL)); } +int +sys_kqueue1(struct thread *td, struct kqueue1_args *uap) +{ + int flags; + + if ((uap->flags & ~(KQUEUE_CLOEXEC)) != 0) + return (EINVAL); + flags = 0; + if ((uap->flags & KQUEUE_CLOEXEC) != 0) + flags |= O_CLOEXEC; + return (kern_kqueue(td, flags, NULL)); +} + static void kqueue_init(struct kqueue *kq) { diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master index c6dce5366219..52ae6bda5a16 100644 --- a/sys/kern/syscalls.master +++ b/sys/kern/syscalls.master @@ -3306,5 +3306,10 @@ u_int flags, ); } +583 AUE_KQUEUE STD|CAPENABLED { + int kqueue1( + u_int flags + ); + } ; vim: syntax=off diff --git a/sys/sys/event.h b/sys/sys/event.h index 1007b88828ae..e91ccbb31ae8 100644 --- a/sys/sys/event.h +++ b/sys/sys/event.h @@ -218,6 +218,9 @@ struct freebsd11_kevent32 { #define NOTE_NSECONDS 0x00000008 /* data is nanoseconds */ #define NOTE_ABSTIME 0x00000010 /* timeout is absolute */ +/* Flags for kqueue1(2) */ +#define KQUEUE_CLOEXEC 0x00000001 /* close on exec */ + struct knote; SLIST_HEAD(klist, knote); struct kqueue;