.\" Copyright (C) 1996 Free Software Foundation, Inc. .\" This file is distributed according to the GNU General Public License. .\" See the file COPYING in the top level source directory for details. .\" .\" 2006-02-09, some reformatting by Luc Van Oostenryck; some .\" reformatting and rewordings by mtk .\" .\" Japanese Version Copyright (c) 2006 Akihiro MOTOKI all rights reserved. .\" Translated 2006-07-29, Akihiro MOTOKI .\" .TH INIT_MODULE 2 2006-02-09 "Linux" "Linux Programmer's Manual" .SH 名前 init_module \- ローダブルモジュールのエントリを初期化する .SH 書式 .nf .B #include .sp .BI "int init_module(const char *" name ", struct module *" image ); .fi .SH 説明 .BR init_module () は再配置されたモジュールイメージをカーネル空間にロードし、 そのモジュールの .I init 関数を実行する。 .PP モジュールイメージは先頭部分に module 構造体があり、その後ろに 適切なコードとデータが続く。 この module 構造体は以下のように定義されている: .PP .in +4n .nf 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 }; .fi .in .PP .I next と .I refs 以外の全てのポインタ要素はモジュール本体内部を指し、 カーネル空間での適切な値で初期化される (つまり、モジュールの残りの 部分で再配置される) ことが期待される。 .PP このシステムコールを使うには特権が必要である。 .SH 返り値 成功すると 0 を返す。エラーの場合 \-1 を返し、 .I errno を適切に設定する。 .SH エラー .TP .B EBUSY モジュールの初期化ルーチンが失敗した。 .TP .B EFAULT .I name や .I image がプログラムがアクセスできるアドレス空間の外部にある。 .TP .B EINVAL 一部の .I image スロットにおかしな値が入っている。または .I image\->name が元のモジュール名と一致していない。または、一部の .I image\->deps エントリがロードされたモジュールに対応していない。 または、他に同様の矛盾が起こっている。 .TP .B ENOENT その名前のモジュールが存在しない。 .TP .B EPERM 呼び出し元が特権 .RB ( CAP_SYS_MODULE ケーパビリティ) を持っていなかった。 .SH 準拠 .BR init_module () は Linux 固有である。 .SH 関連項目 .BR create_module (2), .BR delete_module (2), .BR query_module (2)