query_moduleのヘルプ・マニュアル
日本語 英語
query_module --help
man query_module
QUERY_MODULE(2) Linux Programmer’s Manual QUERY_MODULE(2)
名前
query_module - モジュールに関連する各種の情報をカーネルに問い合わせる
書式
#include
int query_module(const char *name, int which, void *buf,
size_t bufsize, size_t *ret);
説明
query_module() は、ローダブルモジュールに関する情報をカーネルに問い合わ
せる。情報は buf が指し示すバッファに格納されて返される。呼び出し 元 は
buf のサイズを bufsize に指定しなければならない。得られる情報の正確な意
味とフォーマットは、 which でどの操作を指定するかによって異なる。現在ロ
ー ドされているモジュールを特定するために name を必要とする操作があれば
、カーネル固有であることを示す NULL を指定できる操作もある。
which には以下の値を指定できる:
0 カーネルが query_module() をサポートしている場合、成功を返す。こ
のシステムコールが利用可能かを調べるために使われる。
QM_MODULES
ロードされている全てのモジュールの名前を返す。バッファには、NULL
終端された文字列が順に入る。返されるバッファ ret にはモジュー ル
の数が設定される。
QM_DEPS
指定されたモジュールが使用している全モジュールの名前を返す。バッ
ファには、NULL 終端された文字列が順に入る。返されるバッファ ret
にはモジュールの数が設定される。
QM_REFS
指定されたモジュールを使用している全モジュールの名前を返す。これ
は QM_DEPS と逆の機能である。バッファには、NULL 終端された文字列
が 順に入る。返されるバッファ ret にはモジュールの数が設定される
。
QM_SYMBOLS
カーネルまたは指定されたモジュールがエクスポートしているシンボル
と値を返す。バッファのデータは、以下の構造体の配列に NULL 終端さ
れた文字列が続く形となる。
struct module_symbol {
unsigned long value;
unsigned long name;
};
name の値は、 buf の先頭からの文字列までのオフセット文字数である
。 ret にはシンボルの数が設定される。
QM_INFO
指定されたモジュールに関する様々な情報を返す。出力バッファのフォ
ーマットは以下の形式となる:
struct module_info {
unsigned long address;
unsigned long size;
unsigned long flags;
};
address はそのモジュールが配置されているカーネル空間上のアドレス
、 size は そ の モ ジ ュ ールのバイト単位のサイズ、 flags は
MOD_RUNNING, MOD_AUTOCLEAN 等のマスクであり、そのモジュールの 現
在 の状態を示す (カーネルのソースファイル include/linux/module.h
を参照)。 ret には module_info 構造体のサイズが設定される。
返り値
成功の場合 0 が返される。エラーの場合 -1 が返され、 errno に適切な値 が
設定される。
エラー
EFAULT name, buf, ret の少なくとも一つが、プログラムがアクセスできるア
ドレス空間の外部であった。
EINVAL which が不正である。あるいは name が NULL だが (NULL は "カー ネ
ル" を示す)、 which で指定された値との組み合わせは許可されていな
い。
ENOENT name という名前のモジュールが存在しない。
ENOSPC 与えられたバッファの大きさが小さすぎる。 ret には最小限必要な バ
ッファのサイズが設定される。
ENOSYS query_module() はこのバージョンのカーネルではサポートされていな
い。
準拠
query_module() は Linux 固有である。
注意
このシステムコールが存在するのはカーネル 2.4 までの Linux だけである 。
Linux 2.6 では削除された。 query_module() で得られた情報のいくつかは、
/proc/modules, /proc/kallsyms, /sys/modules から取得できる。
関連項目
create_module(2), delete_module(2), get_kernel_syms(2), init_module(2)
Linux 2007-06-03 QUERY_MODULE(2)
QUERY_MODULE(2) Linux Programmer’s Manual QUERY_MODULE(2)
NAME
query_module - query the kernel for various bits pertaining to modules
SYNOPSIS
#include
int query_module(const char *name, int which, void *buf,
size_t bufsize, size_t *ret);
DESCRIPTION
query_module() requests information from the kernel about loadable mod-
ules. The returned information is placed in the buffer pointed to by
buf. The caller must specify the size of buf in bufsize. The precise
nature and format of the returned information depend on the operation
specified by which. Some operations require name to identify a cur-
rently loaded module, some allow name to be NULL, indicating the kernel
proper.
The following values can be specified for which:
0 Returns success, if the kernel supports query_module(). Used to
probe for availability of the system call.
QM_MODULES
Returns the names of all loaded modules. The returned buffer
consists of a sequence of null-terminated strings; ret is set to
the number of modules.
QM_DEPS
Returns the names of all modules used by the indicated module.
The returned buffer consists of a sequence of null-terminated
strings; ret is set to the number of modules.
QM_REFS
Returns the names of all modules using the indicated module.
This is the inverse of QM_DEPS. The returned buffer consists of
a sequence of null-terminated strings; ret is set to the number
of modules.
QM_SYMBOLS
Returns the symbols and values exported by the kernel or the
indicated module. The returned buffer is an array of structures
of the following form
struct module_symbol {
unsigned long value;
unsigned long name;
};
followed by null-terminated strings. The value of name is the
character offset of the string relative to the start of buf; ret
is set to the number of symbols.
QM_INFO
Returns miscellaneous information about the indicated module.
The output buffer format is:
struct module_info {
unsigned long address;
unsigned long size;
unsigned long flags;
};
where address is the kernel address at which the module resides,
size is the size of the module in bytes, and flags is a mask of
MOD_RUNNING, MOD_AUTOCLEAN, etc. that indicates the current sta-
tus of the module (see the kernel source file include/linux/mod-
ule.h). ret is set to the size of the module_info structure.
RETURN VALUE
On success, zero is returned. On error, -1 is returned and errno is
set appropriately.
ERRORS
EFAULT At least one of name, buf, or ret was outside the program’s
accessible address space.
EINVAL Invalid which; or name is NULL (indicating "the kernel"), but
this is not permitted with the specified value of which.
ENOENT No module by that name exists.
ENOSPC The buffer size provided was too small. ret is set to the mini-
mum size needed.
ENOSYS query_module() is not supported in this version of the kernel.
CONFORMING TO
query_module() is Linux-specific.
NOTES
This system call is only present on Linux up until kernel 2.4; it was
removed in Linux 2.6. Some of the information that was available via
query_module() can be obtained from /proc/modules, /proc/kallsyms, and
/sys/modules.
SEE ALSO
create_module(2), delete_module(2), get_kernel_syms(2), init_module(2)
COLOPHON
This page is part of release 3.22 of the Linux man-pages project. A
description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
Linux 2007-06-03 QUERY_MODULE(2)