Debian Codegraph @

upstream/debian-unstable/man2/query_module.2

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