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