linux 載入hello模組

2021-06-02 19:14:16 字數 517 閱讀 5806

1、hello-1.c

/** hello-1.c - the ******st kernel module.

*/#include /* needed by all modules */

#include /* needed for kern_alert */

int init_module(void)

void cleanup_module(void)

2、makefile

obj-m := hello-1.o

3、編譯

make -c /lib/modules/2.6.27.5-117.fc10.i686/build m=/home/root/hello modules

4、載入模組

insmod ./hello-1.ko  

cat /proc/modules 檢視是否已經被載入

5、解除安裝模組

rmmod hello-1.ko 

cat   /var/log/messages  檢視日誌內容

Linux 2 6核心驅動之hello模組

終於開始在鍾愛的linux上學習寫驅動程式了。本來以為寫乙個hello模組是異常簡單的事情,結果折騰了幾天才編譯通過。首先為了測試安裝了虛擬機器 核心程式是很危險滴,我可不想讓自己的愛本頻繁崩潰 裝fedora17 fedora18的live版在虛擬機器上始終跑不起來 來回來去幾次也裝不上virtu...

繼續編寫簡單的linux模組 hello

1 通過包含linux sched.h標頭檔案 include可以使用下面的語句列印當前程序的程序 id 和命令名 printk kern info the process is s pid i n current comm,current pid hello.c include include i...

linux 核心模組載入 HelloWorld

1。建立hello目錄 mkdir hello 2。進入hello目錄 cd hello 3。編寫hello.c include include module license gpl static int hello init void static void hello exit void mod...