早期範例常將檔案名、主裝置號硬編碼於模組中,違背 Unix/Linux 靈活定製精神。核心模組可定義全域變數,insmod 自動填入對應值。
insmod
模組定義全域變數 str1、str2。編譯後以 insmod str1=xxx str2=yyy 載入。init_module 執行時,str1 指向 "xxx",str2 指向 "yyy"。
str1
str2
insmod str1=xxx str2=yyy
init_module
MODULE_PARM