I want to implementing my own system call. (See below link)
http://www.tldp.org/HOWTO/html_single/Implement-Sys-Call-Linux-2.6-i386/
But adding new system call requires kernel compilation.
How to implement my own system call without recompiling the Linux kernel?
You can't. Without recompiling the kernel, all you can do is build and load kernel modules, and kernel modules cannot add new system calls.
The original definition of a system call is/was a system support (OS) function that is called by a trap of some kind rather than a "normal" function call. So by that definition, every system call requires a switch to kernel mode, as if it didn't it wouldn't be a system call (just a normal system library call).
For All Practical Purposes. In nearly all cases, you won't ever have to make direct system calls in your C programs. If you use assembly language, however, the need may arise.
Sure, you can.
In short, you'll need to patch the running kernel.
There are at least 2 ways to add a new syscall:
sys_call_table
and ia32_sys_call_table
) and patch system call limit check instruction (usally cmp
on x86) at any of the system call entries (system_call
, ia32_system_all
etc...)call
on x86) to point to table's copy and patch system call limit check instruction at any of the system call entries.See this anwers for details:
Implementing Linux System Call using LKM
How do 32-bit applications make system calls on 64-bit Linux?
:)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With