Scroll to navigation

init_module() init_module()

NAME

init_module - 初始化一條可加載模塊的記錄.

總覽

#include <linux/module.h>

int init_module(const char *name, struct module *image);

描述

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外,所有的指針被期望指在模塊體內, 該系統調用只對超級用戶開放.

返回值

成功時返回0,錯誤時返回 -1,errno被相應設置.

錯誤

EPERM
用戶不是超級用戶.
ENOENT
name指定的模塊不存在.
EINVAL
EBUSY
模塊的初始化函數失敗.
EFAULT
name或image越出了程序可訪問的地址空間.

"雷勇" <nsinit@263.net>

本頁面中文版由中文 man 手冊頁計劃提供。
中文 man 手冊頁計劃:https://github.com/man-pages-zh/manpages-zh