載入helloworld模組

2021-04-13 01:19:40 字數 862 閱讀 7292

#include

#include

#if config_modversions==1

#define modversions

#include

#endif

#include

#include

#include

module_license ("gpl");

static int hello_init(void)

static void hello_exit(void)

module_init(hello_init);

module_exit(hello_exit); 

編譯命令:

gcc -wall -dmodule -d__kernel__ -dlinux -c -o helloworld.o helloworld.c -i /usr/src/linux-2.4/include/

其中 -i /usr/src/linux-2.4/include/ 是用來指定標頭檔案的路徑

產生helloworld.o

in**od hello.o

rmmod hello

執行這兩條命令後並沒有在終端輸出helloworld, goodbye cruel world!是因為printk輸出優先順序的問題,可以在終端下執行dmseg來檢視輸出!

在終端顯示的問題等以後看到此知識點後再解決!

曾經出現過的問題比較普遍,可以檢視以下兩個帖子!

編寫核心模組hello world

1 準備環境 mkdir src lkm example cd src lkm example 2 建立檔案 lkm example.c include include include module license gpl module author robert w.oliver ii modul...

Nginx 模組開發 Hello World

最近在研究如何利用 nginx 實現高效能閘道器,這裡記錄一下開發 nginx 擴充套件模組 hello world。wget tar zvxf nginx 1.13.10.tar.gz cd nginx 1.13.10編譯,安裝 nginx 到指定目錄 configure prefix home ...

Hello World 2 載入紋理

給地面新增紋理 背面的紋理 在前一節的基礎上,新增了有紋理的地面 輔助座標。在init 中加入 floor var geom new three.planegeometry 1000,1000,1,1 var floor new three.mesh geom,mat scene.add floor...