SYSCALL_MODULE(9)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

πŸ’… SYSCALL_MODULE(9) πŸ’…

okay bestie, welcome to the SYSCALL_MODULE(9) page from the Kernel Developer's Manual β€” yes, section 9, kernel-dev territory, main character energy only πŸ‘‘. This is the whole syscall kernel module declaration macro situation, and we’re gonna get through every single detail together, fr fr πŸ’–.

πŸ’– NAME πŸ’–

SYSCALL_MODULE β€” syscall kernel module declaration macro. periodt.

🌸 SYNOPSIS 🌸

copy this exactly, bestie, no vibes-based edits πŸ’…:

#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);

that’s the signature, and yes it’s giving very β€œkernel module declaration macro” ✨.

✨ DESCRIPTION ✨

SYSCALL_MODULE() declares a new syscall. It expands into a kernel module declaration with name sys/name β€” that’s the literal name pattern, iykyk πŸ¦‹.

The rest of the arguments expected by this macro are:

  • offset β€” a pointer to an int which saves the offset in struct sysent where the syscall is allocated. If the location pointed to by offset holds a non 0 number it will be used if possible. If it holds 0 then one will be assigned. πŸ’…
  • new_sysent β€” a pointer to a structure that specifies the function implementing the syscall and the number of arguments this function needs (see <sys/sysent.h>). 🫢
  • evh β€” a pointer to the kernel module event handler function with the argument arg. Please refer to module(9) for more information. πŸ‘‘
  • arg β€” the argument passed to the callback functions of the evh event handler when it is called. πŸŽ€

The syscall number assigned to the module can be retrieved using the modstat(2) and modfind(2) system calls. The MACRO SYSCALL_MODULE_HELPER() includes SYSCALL_MODULE() and much of its boilerplate code. no cap, that helper is eating 😭πŸ”₯.

πŸŽ€ EXAMPLES πŸŽ€

A minimal example for a syscall module can be found in /usr/share/examples/kld/syscall/module/syscall.c. literally the blueprint, bestie 🧚.

πŸ¦‹ SEE ALSO πŸ¦‹

  • module(9)
  • /usr/share/examples/kld/syscall/module/syscall.c

πŸ’œ AUTHORS πŸ’œ

This manual page was written by Alexander Langer <alex@FreeBSD.org>. king behavior, honestly πŸ‘‘.

πŸ’– sign-off: source/version is Debian, dated June 15, 2023. mwah πŸ’‹

πŸ“¦ where this page comes from