First move the kernel file to/usr/src/and unzip it.
Process Reference http://www.cnblogs.com/kavs/p/4607371.html
And then.. Start adding system calls:
sudo gedit/usr/src/linux-4.0.6/kernel/sys.c
Insert header file #include <linux/linkage.h>
1:
2:
3:* /
4:int sys_leemohello (char
5: printk (Kern_emerg"===this is Leemo's work ====="
6: printk (Kern_emerg"==2012221107110095 Leemo"
7:return
8: }
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
Compile kernel .... Process Reference http://www.cnblogs.com/kavs/p/4607371.html
Restart after compilation is complete.
Writing test Code
1, first build a folder mkdir Leemotest
2. Create the test code sudo gedit testleemohello.c type the code:
1: #include <stdio.h>
2:int main ()
3: {
4:int rs;
5:Char * buf="Leemo";
6: rs=syscall (359,BUF);
7: printf ("%d%s \ n", rs,buf);
8:if(rs==1) {
9: printf ("system call is success!\n");
Ten: }
One :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.
"Original" Linux adds system calls