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