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