syscall to userland interface
Karl Dreger
k.dreger at yahoo.de
Fri May 10 19:31:27 UTC 2013
Hello,
I have been taking a look at a few syscalls in /usr/src/sys/kern/ and
always find that in their actuall c definition the function names are
preprended by a sys_. Take for example the fork system call which
is found in /usr/src/sys/kern/kern_fork.c
int
sys_fork(struct thread *td, struct fork_args *uap)
...
Now when I write a program from userland, that makes use of the
fork system call, then if call it as:
fork();
All the syscall are part of libc, which is usually defined in
/usr/src/lib/libc/
Since the system calls are already defined in the kernel sources, they
no longer need to be defined in /usr/src/lib/libc/. This is the reason
why one can only find the manpages and no c files in
/usr/src/lib/libc/sys?
At least this is how my thinking goes.
Now, when the syscalls in the kernel sources are all defined as sys_xxx
but are invoked as xxx and the c headers also show syscall prototypes
without any prepended sys. How does the actual user-, kernelland
move happen? In other words, why do I invoke fork() as fork() and
not as sys_fork()?
Or is there something that I missed?
Clarification on that point is highly welcome.
Thanks
More information about the freebsd-hackers
mailing list