SYSCALL(9) BSD Kernel Developer's Manual SYSCALL(9)NAMEsyscall — system calls overview
DESCRIPTION
A system call is an explicit request to the kernel made via a software
interrupt by some program. For example, open() is a system call that is
used when access to a file stored in filesystem is needed. In this
sense, system calls provide the interface between a process and the oper‐
ating system.
The kernel implements system calls through a set of switch tables for
each emulation type. The list of currently supported system calls along
with their codes resides in sys/sys/syscall.h. This file, and a couple
others which will be examined later, are automatically generated and
should not be edited manually.
The first step in adding a new system call is to edit the
sys/kern/syscalls.master file. The “master” file is a text file consist‐
ing of a list of lines for each system call. Lines may be split by the
means of back slashing the end of the line. Each line is a set of fields
separated by whitespace:
number type namespace ...
Where:
number is the system call number;
namespace is one of POSIX, BSD, NOHIDE;
type is one of:
STD standard system call with full prototype and imple‐
mentation;
OBSOL obsolete, not included in the system;
UNIMPL unimplemented, not included in the system, place‐
holder only;
NODEF included, but don't define the syscall number;
NOARGS included, but don't define the syscall args struc‐
ture;
NOPROTO implemented elsewhere;
COMPAT a compatibility system call, only included if the
corresponding option is configured for the kernel.
The rest of the line for the STD, NODEF, NOARGS, and COMPAT types is:
{ pseudo-proto } [alias]
pseudo-proto is a C-like prototype used to generate the system call argu‐
ment list, and alias is an optional name alias for the call. The func‐
tion in the prototype has to be defined somewhere in the kernel sources
as it will be used as an entry point for the corresponding system call.
For other types the rest of the line is a comment.
To generate the header and code files from the “master” file, make sysent
has to be run from the directory containing the “master” file. Please
mind that the string sys_ is prepended to all system call names, but not
to the structures holding the arguments. So, if one has added the line:
503 STD BSD { int mycall(int x, int y); }
to the system call master file, the generated prototype would be:
int sys_mycall(struct mycall_args *uap);
It is customary to extract system call arguments with the SCARG(uap,
member) macro, which is defined in sys/sys/sysent.h file. Last, in order
to return a value to userland, the uap->sysmsg_result variable and
friends of it are used, as defined in sys/sys/sysmsg.h.
FILES
sys/kern/makesyscalls.sh a sh(1) script for generating C files out of
the syscall master file;
sys/kern/syscalls.conf a configuration file for the shell script
above;
sys/kern/syscalls.master master files describing names and numbers for
the system calls;
sys/kern/syscalls.c system call names lists;
sys/kern/init_sysent.c system call switch tables;
sys/sys/sysproto.h system call argument lists;
sys/sys/syscall.h system call numbers.
sys/emulation/linux/i386 Linux emulation system calls.
SEE ALSOktrace(2), syscall(2), SYSCALL_MODULE(9)HISTORY
The syscall section manual page appeared in DragonFly 2.3.
BSD May 25, 2009 BSD