Add a system to the Linux kernel to call the comparison between old and new kernels

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.