OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / man2 / query_module.2
1 .\" Copyright (C) 1996 Free Software Foundation, Inc.
2 .\"
3 .\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
4 .\" This file is distributed according to the GNU General Public License.
5 .\" %%%LICENSE_END
6 .\"
7 .\" 2006-02-09, some reformatting by Luc Van Oostenryck; some
8 .\" reformatting and rewordings by mtk
9 .\"
10 .TH QUERY_MODULE 2 2014-05-10 "Linux" "Linux Programmer's Manual"
11 .SH NAME
12 query_module \- query the kernel for various bits pertaining to modules
13 .SH SYNOPSIS
14 .nf
15 .B #include <linux/module.h>
16 .sp
17 .BI "int query_module(const char *" name ", int " which ", void *" buf ,
18 .BI "                 size_t " bufsize ", size_t *" ret );
19 .fi
20
21 .IR Note :
22 No declaration of this function is provided in glibc headers; see NOTES.
23 .SH DESCRIPTION
24 .IR Note :
25 This system call is present only in kernels before Linux 2.6.
26
27 .BR query_module ()
28 requests information from the kernel about loadable modules.
29 The returned information is placed in the buffer pointed to by
30 .IR buf .
31 The caller must specify the size of
32 .I buf
33 in
34 .IR bufsize .
35 The precise nature and format of the returned information
36 depend on the operation specified by
37 .IR which .
38 Some operations require
39 .I name
40 to identify a currently loaded module, some allow
41 .I name
42 to be NULL, indicating the kernel proper.
43
44 The following values can be specified for
45 .IR which :
46 .TP
47 .B 0
48 Returns success, if the kernel supports
49 .BR query_module ().
50 Used to probe for availability of the system call.
51 .TP
52 .B QM_MODULES
53 Returns the names of all loaded modules.
54 The returned buffer consists of a sequence of null-terminated strings;
55 .I ret
56 is set to the number of
57 modules.
58 .\" ret is set on ENOSPC
59 .TP
60 .B QM_DEPS
61 Returns the names of all modules used by the indicated module.
62 The returned buffer consists of a sequence of null-terminated strings;
63 .I ret
64 is set to the number of modules.
65 .\" ret is set on ENOSPC
66 .TP
67 .B QM_REFS
68 Returns the names of all modules using the indicated module.
69 This is the inverse of
70 .BR QM_DEPS .
71 The returned buffer consists of a sequence of null-terminated strings;
72 .I ret
73 is set to the number of modules.
74 .\" ret is set on ENOSPC
75 .TP
76 .B QM_SYMBOLS
77 Returns the symbols and values exported by the kernel or the indicated
78 module.
79 The returned buffer is an array of structures of the following form
80 .\" ret is set on ENOSPC
81 .in +4n
82 .nf
83
84 struct module_symbol {
85     unsigned long value;
86     unsigned long name;
87 };
88 .fi
89 .in
90 .IP
91 followed by null-terminated strings.
92 The value of
93 .I name
94 is the character offset of the string relative to the start of
95 .IR buf ;
96 .I ret
97 is set to the number of symbols.
98 .TP
99 .B QM_INFO
100 Returns miscellaneous information about the indicated module.
101 The output buffer format is:
102 .in +4n
103 .nf
104
105 struct module_info {
106     unsigned long address;
107     unsigned long size;
108     unsigned long flags;
109 };
110 .fi
111 .in
112 .IP
113 where
114 .I address
115 is the kernel address at which the module resides,
116 .I size
117 is the size of the module in bytes, and
118 .I flags
119 is a mask of
120 .BR MOD_RUNNING ,
121 .BR MOD_AUTOCLEAN ,
122 and so on, that indicates the current status of the module
123 (see the Linux kernel source file
124 .IR include/linux/module.h ).
125 .I ret
126 is set to the size of the
127 .I module_info
128 structure.
129 .SH RETURN VALUE
130 On success, zero is returned.
131 On error, \-1 is returned and
132 .I errno
133 is set appropriately.
134 .SH ERRORS
135 .TP
136 .B EFAULT
137 At least one of
138 .IR name ,
139 .IR buf ,
140 or
141 .I ret
142 was outside the program's accessible address space.
143 .TP
144 .B EINVAL
145 Invalid
146 .IR which ;
147 or
148 .I name
149 is NULL (indicating "the kernel"),
150 but this is not permitted with the specified value of
151 .IR which .
152 .\" Not permitted with QM_DEPS, QM_REFS, or QM_INFO.
153 .TP
154 .B ENOENT
155 No module by that
156 .I name
157 exists.
158 .TP
159 .B ENOSPC
160 The buffer size provided was too small.
161 .I ret
162 is set to the minimum size needed.
163 .TP
164 .B ENOSYS
165 .BR query_module ()
166 is not supported in this version of the kernel
167 (e.g., the kernel is version 2.6 or later).
168 .SH VERSIONS
169 This system call is present on Linux only up until kernel 2.4;
170 it was removed in Linux 2.6.
171 .\" Removed in Linux 2.5.48
172 .SH CONFORMING TO
173 .BR query_module ()
174 is Linux-specific.
175 .SH NOTES
176 Some of the information that was formerly available via
177 .BR query_module ()
178 can be obtained from
179 .IR /proc/modules ,
180 .IR /proc/kallsyms ,
181 and the files under the directory
182 .IR /sys/module .
183
184 The
185 .BR query_module ()
186 system call is not supported by glibc.
187 No declaration is provided in glibc headers, but,
188 through a quirk of history, glibc does export an ABI for this system call.
189 Therefore, in order to employ this system call,
190 it is sufficient to manually declare the interface in your code;
191 alternatively, you can invoke the system call using
192 .BR syscall (2).
193 .SH SEE ALSO
194 .BR create_module (2),
195 .BR delete_module (2),
196 .BR get_kernel_syms (2),
197 .BR init_module (2),
198 .BR lsmod (8),
199 .BR modinfo (8)
200 .SH COLOPHON
201 This page is part of release 3.79 of the Linux
202 .I man-pages
203 project.
204 A description of the project,
205 information about reporting bugs,
206 and the latest version of this page,
207 can be found at
208 \%http://www.kernel.org/doc/man\-pages/.