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