1 .\" Copyright (c) 2018 Conrad Meyer <cem@FreeBSD.org>
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 .Dt SYSCALL_HELPER_REGISTER 9
31 .Nm syscall_helper_register ,
32 .Nm syscall_helper_unregister
33 .Nd kernel syscall registration routines
38 .Fn syscall_helper_register "struct syscall_helper_data *sd" "int flags"
40 .Fn syscall_helper_unregister "struct syscall_helper_data *sd"
42 .Ss INITIALIZER MACROS
43 .Ft struct syscall_helper_data
44 .Fn SYSCALL_INIT_HELPER "syscallname"
45 .Ft struct syscall_helper_data
46 .Fn SYSCALL_INIT_HELPER_F "syscallname" "int flags"
48 .Ss COMPATIBILITY INITIALIZER MACROS
49 .Ft struct syscall_helper_data
50 .Fn SYSCALL_INIT_HELPER_COMPAT "syscallname"
51 .Ft struct syscall_helper_data
52 .Fn SYSCALL_INIT_HELPER_COMPAT_F "syscallname" "int flags"
56 .Fn syscall_helper_register
57 registers a system call.
58 This function takes the structure
59 .Va struct syscall_helper_data sd ,
60 which specifies the parameters for syscall registration:
62 .Bd -literal -offset indent -compact
63 struct syscall_helper_data {
64 struct sysent new_sysent;
65 struct sysent old_sysent;
71 The only valid flag for the
74 .Fn syscall_helper_register
77 This flag prevents the syscall from being unregistered.
80 Before use, the structure must be initialized with one of the
81 .Fn SYSCALL_INIT_HELPER*
83 In new code, syscall implementation functions shall be named
85 and the regular macros shall be used.
87 For legacy syscall functions named without "sys_" prefixes, the "COMPAT"
88 versions of the macros may be used.
90 The only valid flag for the
92 argument to the "F" variants of the initializer macros is
94 This flag indicates that the syscall is allowed in capability mode.
97 .Fn syscall_helper_unregister
98 unregisters a system call.
99 This function takes the same structure
100 .Va struct syscall_helper_data sd
101 that was previously initialized in the manner described above and used in a
102 successful invocation of
103 .Fn syscall_helper_register .
107 .Fn syscall_helper_register
109 .Fn syscall_helper_unregister
111 Otherwise, they will return an error.
115 .Fn syscall_helper_register
116 call will fail and the syscall will not be registered if:
121 argument contained a value other than
124 The specified syscall number,
126 .Dv ( SYS_syscallname ) ,
127 was outside of the valid range of system call numbers (zero through
128 .Dv SYS_MAXSYSCALL ) .
130 The system call table does not have any available slots.
132 The specified syscall number,
134 .Dv ( SYS_syscallname ) ,