OSDN Git Service

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