Adding system calls to the Linux kernel comparison of old and new kernels

Source: Internet
Author: User

2.6 Cores
1> Modify the linux-source-2.6.31/kernel/sys.c file to add the system response function at the end of the file. The function is implemented as follows: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/added in Syscall_table_32.s:. Long Sys_mycallsuch as:. Long Sys_mycall/* 341 */
3> added in Linux-2.6.31/arch/x86/include/asm/unistd_32.hsuch as:#define __nr_mycall Sequence Number (for example, 341), add the entry parameters for the system call (note: The ordinal of the entry parameter is defined sequentially, and the added ordinal is based on the original maximum value +1)
4> Re-configure the build kernel to
latest 3. X Core
1> inAdd a new system call function at the end of the linux-3.8.4/kernel/sys.c filesuch as:asmlinkage int Sys_mycall (int number)  {
PRINTK ("This is the first system call I added");
return number;
 }2> found unused number No. 223 in ARCH/X86/SYSCALL_32.TBL and replaced it with the following:223 i386 mycallsys_mycall
3> can be re-compiled
There is another way, because 64-bit operating systems are 32-bit compatible, with 64-bit usage below
1> The first step with the above
2> found the system call number No. 313 under ARCH/X86/SYSCALLS/SYSCALL_64.TBL, and then added No. 314 to its own interrupt below.such as:314 common mycallsys_mycall 3> can be re-compiled
Transfer from www.360doc.com/content/13/0502/16/12139495_282464589.html

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.