Manpages

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 [AT] 263.net>

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