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