Skip to contentSkip to conversation

How to write System calls?

DISCUSSION Sureshkumar Kamalanathan 3 participants 3 messages Oct 29, 2001 – Oct 31, 2001

lore
Share & tools
lore
#0 lore raw

Hi All,
Good day!
I have 2.4.4 kernel. I have to write some system calls for
interaction with the kernel from the userland. Can any of you tell me where I can get the information regarding this?
I have the Linux Kernel Internals by Beck and others. But it gives
the procedure only for 2.2.x.
Moreover I need to implement these system calls as Loadable modules. Any pointers in this regard will be highly appreciated and I'll very
grateful!!

Thanks in advance,

Regards,
Suresh.

#1 lore raw

Hi,

First, I propose you to have a look on "Linux Kernel 2.4 Internals" from Tigran Aivazian. You can read it from the LDP at exact URL: http://www.linuxdoc.org/LDP/lki/index.html
In this, you'll probably see that syscalls are hardcoded (file arch/xxx/kernel/entry.S on your kernel tree).
This means, AFAIK, you cannot implements a syscall function in a module ;-)
One other way is using your modules to implements char drivers and use ioctl() as if it was yours syscalls. This method is generally recommended to users who wants to implement new sayscalls.

Am I wrong?

Regards,
Matthieu

Quoted 21 lines · Sureshkumar Kamalanathan

Hi All,
Good day!
I have 2.4.4 kernel. I have to write some system calls for
interaction with the kernel from the userland. Can any of you tell me where I can get the information regarding this?
I have the Linux Kernel Internals by Beck and others. But it gives
the procedure only for 2.2.x.
Moreover I need to implement these system calls as Loadable modules. Any pointers in this regard will be highly appreciated and I'll very
grateful!!

Thanks in advance,

Regards,
Suresh.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#2 lore raw
In reply to Sureshkumar Kamalanathan
Quoted 6 lines · Sureshkumar Kamalanathan

I have 2.4.4 kernel. I have to write some system calls for
interaction with the kernel from the userland. Can any of you tell me where I can get the information regarding this?
I have the Linux Kernel Internals by Beck and others. But it gives
the procedure only for 2.2.x.
Moreover I need to implement these system calls as Loadable modules.

Syscall entries are hard coded into the syscall table, usually in arch/$(ARCH)/entry.S.

There is no generic way to add a syscall that is serviced by a module. I know that the modutils HOWTO gives examples of syscalls in modules but that doc is out of date, on some architectures you have to adjust additional registers to make a remote function call. On those systems the syscall table works because the kernel is compiled with special flags, that will not work for modules. Also Linus has said that he does not want modules to be able to override syscalls.