Subject: Re: How do I create a include-file to match my new syscall?
To: Espen Jorde; IFI; H97 <>
From: Guenther Grau <>
List: tech-kern
Date: 03/07/2000 15:54:05
Hi Espen,

"Espen Jorde; IFI; H97" wrote:
> Part of the work for my master thesis involves adding some system
> calls to the kernel.
> After some time I have figured out how to add my own system call. I
> have done this successfully with a 1.4.1 kernel.
> Now my problem is how to access syscalls from user-space. I can call
> them by using "syscall(<syscallnumber>, arguments)". But i would love
> to be able to do something like this:
> #include <foo.h>
> foo(i, j, k);
> Can anybody give me a hint on where I should look? Which directory
> should I put my .h file for it to compile correctly and end up in
> /usr/include. How should my .h file look. Any good examples?
> Any help is appreciated!

Well, you wrote _Any_ help, so here you go :-)
Not that I've done this myself, but I'd suggest looking
at some of the NetBSD libraries, which do make systemcalls.
I guess libc might be a good candidate, but probalby a lot
of the libraries do actual systemcalls.

My naive way to address this problem would be:

Implement function foo(int, int, int) in foo.c
which (probably) checks the parameters and then
does the actual syscall and returns the result
of the syscall.

Create a new library libbar.a or and
put the compiled foo.o into this library. Then
create <bar.h> file which contains the prototype
for foo(int, int, int).

Then change above program baz.c to

#include <bar.h>
foo(i, j, k);

main() {

cc -obaz baz.c -lfoo

This might be totally wrong, but that's how I thought it
might/could/would work. Anybody else, please feel free
to correct me.


P.S.: I changed the name of the lib/inlcude file to
bar, because libs usually contain more than just one