Imported upstream version 1.5
[manpages-zh.git] / raw / man2 / query_module.2
blobf8a78fa3456fd06f4e7dffccb059a02172076015
1 .\" Copyright (C) 1996 Free Software Foundation, Inc.
2 .\" This file is distributed according to the GNU General Public License.
3 .\" See the file COPYING in the top level source directory for details.
4 .\"
5 .TH QUERY_MODULE 2 "26 Dec 1996" "Linux 2.1.17" "Linux Module Support"
6 .SH NAME
7 query_module \- query the kernel for various bits pertaining to modules.
8 .SH SYNOPSIS
9 .nf
10 .B #include <linux/module.h>
11 .sp
12 \fBint query_module(const char *\fIname\fB, int \fIwhich\fB,
13 void *\fIbuf\fB, size_t \fIbufsize\fB, size_t *\fIret\fB);
14 .fi
15 .SH DESCRIPTION
16 .B query_module
17 requests information related to loadable modules from the kernel.  The
18 precise nature of the information and its format depends on the \fIwhich\fP
19 sub function.  Some functions require \fIname\fP to name a currently
20 loaded module, some allow \fIname\fP to be \fBNULL\fP indicating the
21 kernel proper.
23 .SS "VALUES OF WHICH"
24 .TP
25 .B 0
26 Always returns success.  Used to probe for the system call.
27 .TP
28 .B QM_MODULES
29 Returns the names of all loaded modules.  The output buffer format is
30 adjacent null-terminated strings; \fIret\fP is set to the number of
31 modules.
32 .TP
33 .B QM_DEPS
34 Returns the names of all modules used by the indicated module.  The
35 output buffer format is adjacent null-terminated strings; \fIret\fP is
36 set to the number of modules.
37 .TP
38 .B QM_REFS
39 Returns the names of all modules using the indicated module.  This is
40 the inverse of \fBQM_DEPS\fP.  The output buffer format is adjacent
41 null-terminated strings; \fIret\fP is set to the number of modules.
42 .TP
43 .B QM_SYMBOLS
44 Returns the symbols and values exported by the kernel or the indicated
45 module.  The buffer format is an array of:
46 .RS
47 .PP
48 .nf
49 struct module_symbol
51   unsigned long value;
52   unsigned long name;
54 .fi
55 .PP
56 followed by null-terminated strings.  The value of \fIname\fP is the
57 character offset of the string relative to the start of \fIbuf\fP;
58 \fIret\fP is set to the number of symbols.
59 .RE
60 .TP
61 .B QM_INFO
62 Returns miscellaneous information about the indicated module.  The output
63 buffer format is:
64 .RS
65 .PP
66 .nf
67 struct module_info
69   unsigned long address;
70   unsigned long size;
71   unsigned long flags;
73 .fi
74 .PP
75 where \fIaddress\fP is the kernel address at which the module resides,
76 \fIsize\fP is the size of the module in bytes, and \fIflags\fP is
77 a mask of \fBMOD_RUNNING\fP, \fBMOD_AUTOCLEAN\fP, et al that indicates
78 the current status of the module.  \fIret\fP is set to the size of
79 the \fBmodule_info\fP struct.
80 .RE
81 .SH "RETURN VALUE"
82 On success, zero is returned.  On error, \-1 is returned and \fIerrno\fP
83 is set appropriately.
84 .SH ERRORS
85 .TP
86 .B ENOENT
87 No module by that \fIname\fP exists.
88 .TP
89 .B EINVAL
90 Invalid \fIwhich\fP, or \fIname\fP indicates the kernel for an
91 inappropriate sub function.
92 .TP
93 .B ENOSPC
94 The buffer size provided was too small.  \fIret\fP is set to the
95 minimum size needed.
96 .TP
97 .B EFAULT
98 At least one of \fIname\fP, \fIbuf\fP, or \fIret\fP was
99 outside the program's accessible address space.
100 .SH "SEE ALSO
101 .BR create_module "(2), " init_module "(2), " delete_module "(2).