實現乙個模組module用來進行字串的逆置

2021-07-25 19:24:45 字數 1011 閱讀 8351

**實現如下:

#include #include module_license("gpl");

module_author("weipeng jing");

module_description("hello world module");

module_alias("a ******st module");

static char * data="pang";

static char * data2=" ";

module_param(data,charp,s_irugo);

module_param(data2,charp,s_irugo);

static int hello_init()

for(i=len-1,j=0;i>=0;i--)

data2[j]='\0';

printk(kern_emerg"%d\n",len);

printk(kern_emerg"hello world!\n");

return 0;

}static void hello_exit()

module_init(hello_init);

module_exit(hello_exit);

實現步驟:1.make

2.insmod hello.ko

3.rmmod hello

即會輸出逆置後的字串

特別注意,在用兩個字元指標作為全域性變數時,一定要對其進行初始化,否則將會出現卡死的後果。

此**是在原有模組的**上進行修改的,只修改了源**,其他並未進行修改。在make clean之後,資料夾中一共有包括原始檔在內的四個檔案,分別是:hello.c    hello.ko.unsigned  makefile  modules.order(不可讀)。

!!!相信自己,相信知識。後經發現,如果.c檔案和makefile檔案一旦寫對,即可以實現出現所有的檔案,之所以一直不能出現所有的檔案,只是因為.c檔案沒有寫對。

利用模組模式(函式)構造乙個用來產生序列號的物件

序列號由字母字首和數字結尾組成 var serial maker function set seq function s create id function var seqer serial maker seqer.set prefix a seqer.set seq 1000 alert seq...

通過分層來體現 有乙個 或 用 來實現

使某個類的物件成為另乙個類的資料成員,從而實現將乙個類構築在另乙個類之上,這一過程稱為 分層 layering 例如 class address 某人居住之處 class phonenumber class person 本例中,person類被認為是置於string,address和phonenu...

JNI 同乙個Module生成多個so

終於解決困擾了我2天的問題!那叫乙個激動!最近做乙個專案,需要在同乙個模組中同時生成兩個so檔案,剛開始沒覺得怎麼樣,就在乙個cmakelists.txt檔案這麼寫入 cmake minimum required version 3.4.1 這是第乙個so add library a lib sha...