System Call

System Call

Post by Koal » Fri, 11 Jan 2002 21:49:18



Hi all,
    For my academic assignment I have to add a new system call in kernel
2.4.  My professor teach me that i have to add entry in Entry.S.  However, I
found that some
system call like shmget, shmat does not have entry in Entry.S.  Later I
browse the source code i found that most of system call are exported using
EXPORT_SYMBOL in ksyms.c.  In fact, what is the suitable method to make a
new system call?

Thanks
Koala

 
 
 

System Call

Post by Kasper Dupon » Fri, 11 Jan 2002 22:53:22



> Hi all,
>     For my academic assignment I have to add a new system call in kernel
> 2.4.  My professor teach me that i have to add entry in Entry.S.

That is true. The main risk is to pick a number that is actually
assigned for something else.

Quote:>  However, I
> found that some
> system call like shmget, shmat does not have entry in Entry.S.

True on most (perhaps all) architectures they are implemented
with a dispatcher named sys_ipc. So glibc calls sys_ipc with a
parameter stating which function should be called. Then sys_ipc
will call sys_shmget, sys_shmget, or whatever wanted.

Quote:>  Later I
> browse the source code i found that most of system call are exported using
> EXPORT_SYMBOL in ksyms.c.  In fact, what is the suitable method to make a
> new system call?

The exported symbols is something completely different. They
are used by kernel modules. A loaded kernel module containing
a driver or something else can call the exported functions.
But they cannot be called from userspace.

The appropriate way is to first consider if you want a syscall
or if there would be a better solution. If you are sure that a
syscall is the right solution start using some number large
enough to avoid assigned numbers. You can then start doing your
experiments. If you come up with something that is more than
just experimentel and can actually be used for something try to
get an official number assigned and if you actually get one
change your code to use this.

Another option would be to add your code to an existing
dispatcher, this is going to be slightly slower but it is for
sure easier to get an official number assigned in one of the
dispatchers than in the syscall table.

--
Kasper Dupont