2.2 Kernel Module compilation

Source: Internet
Author: User

Kernel Module Compilation

20135206 at Jia Xin

?

Basic knowledge:

Module Constructors:

Initializes the function that is called when the kernel module is loaded by executing a insmod or modprobe instruction. The function prototype must be Module_init (), the function pointer inside the parentheses

Module destructor:

The function that is called when the rmmod instruction is executed to unload the module. Function prototype is module_exit ()

Module License Statement:

The function prototype is Module_license (), which tells the kernel which license the program uses, otherwise it will prompt the module to contaminate the kernel when it is loaded. The GPL is generally written.

Write a simple code first

Write makefile

Execute with Make

A lot of files appear after make

Loading modules

sudo insmod Printname.ko

Test module

DMESG See kernel information

Uninstalling the module

sudo rmmod printname

?

The next step is to write more complex code that implements the function of outputting the current process information and the ability to implement the read Process chain list, which shows only the output process

2.2 Kernel Module compilation

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.