Linux adds a system call to the approximate steps:
1. Download the kernel file and add your own calling function to the kernel source file.
2. Compile the kernel
3, verification.
Add your own function in the kernel source file
First move the kernel file to/usr/src/and unzip it.
Process Reference http://www.cnblogs.com/kavs/p/4607371.html
Here's how to start adding your own functions.
sudo gedit/usr/src/linux-4.0.6/kernel/sys.c
Insert header file #include <linux/linkage.h>
/* *leemo ' s own define task * /int Sys_leemohello (char * buf) {PRINTK (Kern_emerg "===this is Leemo's work ====="); PRINTK (Kern_emerg"==2012221107110095 leemo"1;}
sudo gedit/usr/src/linux-4.0.6/arch/x86/syscalls/syscall_32.tbl
Remember to increase the system number as above 359
sudo gedit/usr/src/linux-4.0.6/arch/x86/include/asm/syscalls.h
Second, compile the kernel
Compile kernel .... Process Reference http://www.cnblogs.com/kavs/p/4607371.html
Restart after compilation is complete.
Third, verification
Writing test Code
1, first build a folder mkdir Leemotest
2. Create the test code sudo gedit testleemohello.c type the code:
#include <stdio.h>IntMain () {IntRschar * buf="Leemo"359,buf); printf ( "%d%s \n" ,rs,buf); if (Rs==1 "system call is Success!\n" else printf ( "sorry,failed!\n "return 0
To compile the test code:
GCC Testleemohello.c-o Testleemohello
To run the test code:
./testleemohello
Results:
then enter DMESG
The call is complete.
Http://www.cnblogs.com/kavs/p/4607367.html
Linux adds system calls (RPM)