VOOZH about

URL: https://ja.manpages.org/init_module/2

⇱ man init_module (2): ローダブルモジュールのエントリを初期化する


init_module(2) ローダブルモジュールのエントリを初期化する

書式

#include <linux/module.h>


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

説明

init_module() は再配置されたモジュールイメージをカーネル空間にロードし、 そのモジュールの init 関数を実行する。

モジュールイメージは先頭部分に module 構造体があり、その後ろに 適切なコードとデータが続く。 この module 構造体は以下のように定義されている:

struct module {
 unsigned long size_of_struct;
 struct module *next;
 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
};

nextrefs 以外の全てのポインタ要素はモジュール本体内部を指し、 カーネル空間での適切な値で初期化される (つまり、モジュールの残りの 部分で再配置される) ことが期待される。

このシステムコールを使うには特権が必要である。

返り値

成功の場合 0 が返される。エラーの場合 -1 が返され、 errno に適切な値が設定される。

エラー

EBUSY
モジュールの初期化ルーチンが失敗した。
EFAULT
nameimage がプログラムがアクセスできるアドレス空間の外部にある。
EINVAL
一部の image スロットにおかしな値が入っている。または image->name が元のモジュール名と一致していない。または、一部の image->deps エントリがロードされたモジュールに対応していない。 または、他に同様の矛盾が起こっている。
ENOENT
その名前のモジュールが存在しない。
EPERM
呼び出し元が特権 (CAP_SYS_MODULE ケーパビリティ) を持っていなかった。

準拠

init_module() は Linux 固有である。

この文書について

この man ページは Linux man-pages プロジェクトのリリース 3.41 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man-pages/ に書かれている。