KFILTER_REGISTER(9)
okay bestie, welcome to the KFILTER_REGISTER(9) page from the Kernel Developer's Manual β we're learning how to add or remove kernel event filters, and honestly? iconic behavior. π
β¨ NAME β¨
kfilter_register, kfilter_unregister β add or remove kernel event filters
πΈ SYNOPSIS πΈ
#include <sys/event.h>
int
kfilter_register(const char *name, struct filterops *filtops,
int *retfilter);
int
kfilter_unregister(const char *name);
π¦ DESCRIPTION π¦
so kfilter_register() is the function that adds a fresh new kernel event filter (a kfilter) to the system, so callers of kqueue(2) and kevent(2) can actually use it. name is the name of the new filter, and it must not already exist β no duplicate names, bestie. filtops is a pointer to a filterops structure that describes the filter operations. both name and filtops get copied into an internal data structure, and a new filter number gets allocated. If retfilter is not NULL, then the new filter number is returned in the address pointed at by retfilter. slay. π
kfilter_unregister() removes a kfilter named name that was previously registered with kfilter_register(). If a filter with the same name is later reregistered with kfilter_register(), it will get a different filter number β i.e., filter numbers are not recycled. no take-backs, no number reuse. π It is not possible to unregister the system filters (i.e., those that start with EVFILT_ and are documented in kqueue(2)). periodt.
okay, here's the filterops structure in all its glory β every field, every comment, no cap:
struct filterops {
int f_isfd; /* true if ident == filedescriptor */
int (*f_attach)(struct knote *kn);
/* called when knote is ADDed */
void (*f_detach)(struct knote *kn);
/* called when knote is DELETEd */
int (*f_event)(struct knote *kn, long hint);
/* called when event is triggered */
void (*f_touch)(struct knote *kn, struct kevent *kev, long hint);
/* called during registration and event
* processing to provide custom handling
* of event fflags and data
*/
};
If the filter operation is for a file descriptor, f_isfd should be non-zero; otherwise it should be zero. This controls where the kqueue(2) system stores the knotes for an object. highkey important, bestie. β
π RETURN VALUES π
kfilter_register()returns0on success,EINVALif there's an invalid argument, orEEXISTif the filter already exists.kfilter_unregister()returns0on success,EINVALif there's an invalid argument, orENOENTif the filter doesn't exist.
π SEE ALSO π
π HISTORY π
The kfilter_register() and kfilter_unregister() functions first appeared in NetBSD 2.0. vintage but make it cute. π«Ά
π AUTHORS π
The kfilter_register() and kfilter_unregister() functions were implemented by Luke Mewburn β¨lukem@NetBSD.orgβ©. thank you for your service, legend. π
and that's the whole page, bestie π«Ά β this one is from Debian, dated October 31, 2020, and it's filed under KFILTER_REGISTER(9). periodt π
π¦ where this page comes from
- nixpkgs unstable: netbsd-source 11.0
- Copyright (c) 2001, 2002 The NetBSD Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms