init_module

Autres langues

Langue: ja

Autres versions - même langue

Version: 2006-02-09 (fedora - 25/11/07)

Autres sections - même nom

Section: 2 (Appels système)

名前

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

書式

 #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 固有である。

関連項目

create_module(2), delete_module(2), query_module(2)