.TH init_module "" .SH NAME init_module - 初始化一條可加載模塊的記錄. .SH 總覽 .B #include .sp int init_module(const char *name, struct module *image); .SH 描述 init_module加載已被重定位的模塊映像到核心空間,並運行模塊的初始化函數. 模塊映像以module結構開始,緊跟著代碼和數據,module定義如下: struct module { unsigned long size_of_struct; /* module結構的大小 */ struct module *next; /*指向下一個module結構 */ const char *name; /* 模塊名字 */ unsigned long size; long usecount; /* 使用計數 */ unsigned long flags; /* 模塊當前狀態標誌 */ unsigned int nsyms; unsigned int ndeps; /* 正使用模塊的模塊個數 */ struct module_symbol *syms; struct module_ref *deps; struct module_ref *refs; int (*init)(void); /* 模塊的初始化函數指針 */ void (*cleanup)(void); /*模塊的清除函數指針 */ const struct exception_table_entry *ex_table_start; const struct exception_table_entry *ex_table_end; #ifdef __alpha__ unsigned long gp; #endif }; 除了next和refs外,所有的指針被期望指在模塊體內, 該系統調用只對超級使用者開放. .SH 返回值 成功時返回0,錯誤時返回 -1,errno被相應設置. .SH 錯誤 .TP EPERM 使用者不是超級使用者. .TP ENOENT name指定的模塊不存在. .TP EINVAL .TP EBUSY 模塊的初始化函數失敗. .TP EFAULT name或image越出了程式可訪問的地址空間. .SH "雷勇"