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