1. Download the kernel in Kernel. 2. Unzip the kernel cd/usr/srctar-jxvflinux-source-2.6.38.tar.bz2 to unzip the kernel to/us
1. Download the kernel
Download linux-2.6.38 at http://www.kernel.org,
You can select a stable version or a new test version, but you must download the Full source version.
2. decompress the kernel
Cd/usr/src
Tar-jxvf linux-source-2.6.38.tar.bz2
Decompress the kernel to/usr/src
3. modify files
A)/usr/src/linux-source-2.6.38/kernel/sys. c
You can right-click the administrator or
Getdit/usr/src/linux-source-2.6.38/kernel/sys. c
Add at the end of the file
Asmlinkage int sys_mycall (int number)
{
Printk ("This is my first system call !!! Hahahaha !! ");
Return number;
}
B)/usr/src/linux-source-2.6.38/arch/x86/kernel/syscall_table_32.S
You can right-click the administrator or
Gedit/usr/src/linux-source-2.6.38/arch/x86/kernel/syscall_table_32.S
Then add the value in the next row of the. long sys_XXXX column.
. Long sys_mycall
Remember that they are the first. long sys_XXXX
C)/usr/src/linux-source-2.6.38/arch/x86/include/asm/unistd_32.h
You can right-click the administrator or
Gedit/usr/src/linux-source-2.6.38/arch/x86/include/asm/unistd_32.h
Add several rows after a column # define _ NR_XXXX NNN
# Define _ NR_mycall 341
Note that the number following is followed by the rows above.
4. Compile the kernel
About the kernel compilation, I have already talked about in the previous article, I just do it according to the above, the following is the link of the article: "Ubuntu 10.10 successfully compiled Linux-2.6.38 kernel" http://www.linuxidc.com/Linux/2011-04/34080.htm
5. Restart
Restart Ubuntu. If you can access the system, it turns out that there is basically no problem.
Open terminal Input
Uname-r
Check the version number. If it is 2.6.38, you can feel at ease.
6. Check System calls
Try writing a function.
Use syscall (function number, parameter) in the main function to test the system call
For example
# Include
# Include
Main (){
Printf ("The number is % d \ n", syscall (341,100 ));
}
The following output is displayed: The number is 100
Compile and run the program, and then open the terminal input.
Sudo dmesg-c
Check whether the system call is successfully added to the last line:
If "This is my first system call !!! Hahahaha !! "
The system call is successfully added !!