SYSCALL_MODULE(9)
π SYSCALL_MODULE(9) π
okay bestie, gather round, because this is a Kernel Developer's Manual page and it's about the SYSCALL_MODULE macro β yes, the one that lets you declare a whole new syscall from inside a kernel module. main character energy fr fr π
β¨ NAME β¨
SYSCALL_MODULE β the syscall kernel module declaration macro. that's it, that's the vibe π
πΈ SYNOPSIS πΈ
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/module.h>
#include <sys/sysent.h>
SYSCALL_MODULE(name, int *offset, struct sysent *new_sysent,
modeventhand_t evh, void *arg);
π¦ DESCRIPTION π¦
so like. the SYSCALL_MODULE() macro declares a new syscall. that's the whole job. and when it expands, it gives you a kernel module declaration named sys/name. cute, right? β¨
here's the rest of the arguments this macro expects, no gatekeeping:
offsetβ a pointer to anintthat saves the offset instruct sysentwhere the syscall gets allocated. now listen: if the location thatoffsetpoints to holds a non 0 number, that number will be used if possible. but if it holds0, then a number will be assigned for you. lowkey generous πnew_sysentβ a pointer to a structure that specifies the function implementing the syscall, plus how many arguments that function needs (peep<sys/sysent.h>for that).evhβ a pointer to the kernel module event handler function, and it takesargas its argument. go readmodule(9)if you want the full tea π«argβ the argument that gets passed to the callback functions of theevhevent handler whenever it's called.
and here's a little bonus fact for you: the syscall number assigned to the module can be retrieved using the modstat(3) and modfind(3) library functions over in libc. also the MACRO SYSCALL_MODULE_HELPER() includes SYSCALL_MODULE() plus a whole bunch of its boilerplate code, so you don't have to hand-write all that π obsessed
π EXAMPLES π
if you want a minimal example of a syscall module, it's literally sitting right here:
/usr/share/examples/kld/syscall/module/syscall.c
go look at it, bestie, it's giving tutorial β¨
π SEE ALSO π
module(9)/usr/share/examples/kld/syscall/module/syscall.c
π AUTHORS π
this manual page was written by Alexander Langer <alex@FreeBSD.org>. iconic behavior, we stan π
ok that's the whole page, no cap, nothing skipped π
so this page came to you from the Debian edition of the manual, dated January 24, 2015, and it's filed under SYSCALL_MODULE(9). mwah, go write a syscall πβ¨π¦
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 2001 Alexander Langer
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms