Linux adds system calls

Source: Internet
Author: User

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)

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.