SYSCALL_HELPER_UNREGISTER(9freebsd)
π SYSCALL_HELPER_REGISTER π β kernel syscall registration routines
okay bestie, welcome to the SYSCALL_HELPER_REGISTER(9) page, straight out of the Kernel Developer's Manual. this is the one where you learn how to slide a whole new system call into the kernel's little black book, and how to take it back out again. sit down, hydrate, let's go β¨
π NAME π
syscall_helper_register, syscall_helper_unregister β kernel syscall registration routines π«Ά
β¨ SYNOPSIS β¨
#include <sys/sysent.h>
int
syscall_helper_register(struct syscall_helper_data *sd, int flags);
int
syscall_helper_unregister(struct syscall_helper_data *sd);
πΈ INITIALIZER MACROS πΈ
struct syscall_helper_data
SYSCALL_INIT_HELPER(syscallname);
struct syscall_helper_data
SYSCALL_INIT_HELPER_F(syscallname, int flags);
π¦ COMPATIBILITY INITIALIZER MACROS π¦
struct syscall_helper_data
SYSCALL_INIT_HELPER_COMPAT(syscallname);
struct syscall_helper_data
SYSCALL_INIT_HELPER_COMPAT_F(syscallname, int flags);
π DESCRIPTION π
so, syscall_helper_register() registers a system call. periodt. it takes that struct syscall_helper_data sd and that struct is literally the blueprint β it tells the kernel everything it needs to know about your syscall registration:
struct syscall_helper_data {
struct sysent new_sysent;
struct sysent old_sysent;
int syscall_no;
int registered;
};
the only valid flag you can pass in the flags argument of syscall_helper_register() is SY_THR_STATIC. and bestie, listen β that flag prevents the syscall from being unregistered. it's giving permanent marker, not pencil π
before you even use the struct, you have to initialize it with one of the SYSCALL_INIT_HELPER*() macros. no skipping steps, no shortcuts. in new code, syscall implementation functions shall be named sys_syscallname() and you use the regular macros. that's the vibe. that's the standard. β¨
but if you're dealing with legacy syscall functions whose names don't have that "sys_" prefix, the "COMPAT" versions of the macros are there for you. iconic of them honestly.
and for the "F" variants of the initializer macros, the only valid flag in the flags argument is SYF_CAPENABLED. that flag means the syscall is allowed in capability mode. like, it gets a hall pass π
now for the other one: syscall_helper_unregister() unregisters a system call. it takes the same struct syscall_helper_data sd that you initialized the way described above and that was used in a successful invocation of syscall_helper_register(). same struct, no imposters π
π«Ά RETURN VALUES π«Ά
if everything goes right, syscall_helper_register() and syscall_helper_unregister() return 0. otherwise, they return an error. that's it, that's the whole thing π
π ERRORS π
the syscall_helper_register() call will fail and the syscall will not be registered if:
[EINVAL]β theflagsargument contained a value other thanSY_THR_STATIC. wrong flag, no entry, sorry babe π«[EINVAL]β the specified syscall number,sd.syscall_no(SYS_syscallname), was outside of the valid range of system call numbers (zerothroughSYS_MAXSYSCALL). out of bounds = out of luck.[ENFILE]β the system call table does not have any available slots. the club is full, the bouncer said no π[EEXIST]β the specified syscall number,sd.syscall_no(SYS_syscallname), was already in use. bestie that seat is taken π
π SEE ALSO π
SYSCALL_MODULE(9) β go read that one next, iykyk π
okay that's the whole page!! this beauty came to you from the Debian build, dated February 10, 2018, and it lives in section 9 as SYSCALL_HELPER_REGISTER(9). register responsibly, unregister even more responsibly, and don't you dare try to unregister something you flagged with SY_THR_STATIC ππβ¨
π¦ 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) 2018 Conrad Meyer <cem@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms