2.6 kernel
1> modify the linux-source-2.6.31/kernel/sys. c file and add the system response function at the end of the file. Function implementation: asmlinkage int sys_mycall (int number ){
Printk ("This is the first system call I added ");
Return number;
}
2> In linux-source-2.6.31/arch/x86/kernel/syscall_table_32.S Add:. long sys_mycall such as:. long sys_mycall/* 341 */
3> In the linux-2.6.31/arch/x86/include/asm/unistd_32.h add such as: # define _ NR_mycall serial number (such as 341), add the entry parameters of the system call (note: the sequence number of the entry parameter is defined sequentially. The sequence number is added based on the original maximum value + 1)
4> re-configure and compile the kernel.
Latest 3.x Kernel
1> Add new system call functions such as asmlinkage int sys_mycall (int number ){
Printk ("This is the first system call I added ");
Return number;
} 2> Find the unused 223 call under arch/x86/syscall_32.tbl and replace it with the call, for example, 223i386 mycallsys_mycall.
3> recompile
There is another method, because the 64-bit operating system is compatible with 32-bit, the following uses 64-bit
1> Step 1 above
2> locate System Call 313 under arch/x86/syscils/syscall_64.tbl, and add the 314 interrupt to it, for example, 314 common mycallsys_mycall3> re-compile.