Debian Codegraph @

upstream/debian-trixie/man2/query_module.2

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