1QUERY_MODULE(2) Linux Programmer's Manual QUERY_MODULE(2)
2
3
4
6 query_module - query the kernel for various bits pertaining to modules
7
9 #include <linux/module.h>
10
11 int query_module(const char *name, int which, void *buf,
12 size_t bufsize, size_t *ret);
13
14 Note: There is no glibc wrapper for this system call; see NOTES.
15
17 Note: This system call is present only in kernels before Linux 2.6.
18
19 query_module() requests information from the kernel about loadable mod‐
20 ules. The returned information is placed in the buffer pointed to by
21 buf. The caller must specify the size of buf in bufsize. The precise
22 nature and format of the returned information depend on the operation
23 specified by which. Some operations require name to identify a cur‐
24 rently loaded module, some allow name to be NULL, indicating the kernel
25 proper.
26
27 The following values can be specified for which:
28
29 0 Returns success, if the kernel supports query_module(). Used to
30 probe for availability of the system call.
31
32 QM_MODULES
33 Returns the names of all loaded modules. The returned buffer
34 consists of a sequence of null-terminated strings; ret is set to
35 the number of modules.
36
37 QM_DEPS
38 Returns the names of all modules used by the indicated module.
39 The returned buffer consists of a sequence of null-terminated
40 strings; ret is set to the number of modules.
41
42 QM_REFS
43 Returns the names of all modules using the indicated module.
44 This is the inverse of QM_DEPS. The returned buffer consists of
45 a sequence of null-terminated strings; ret is set to the number
46 of modules.
47
48 QM_SYMBOLS
49 Returns the symbols and values exported by the kernel or the
50 indicated module. The returned buffer is an array of structures
51 of the following form
52
53 struct module_symbol {
54 unsigned long value;
55 unsigned long name;
56 };
57
58 followed by null-terminated strings. The value of name is the
59 character offset of the string relative to the start of buf; ret
60 is set to the number of symbols.
61
62 QM_INFO
63 Returns miscellaneous information about the indicated module.
64 The output buffer format is:
65
66 struct module_info {
67 unsigned long address;
68 unsigned long size;
69 unsigned long flags;
70 };
71
72 where address is the kernel address at which the module resides,
73 size is the size of the module in bytes, and flags is a mask of
74 MOD_RUNNING, MOD_AUTOCLEAN, etc., that indicates the current
75 status of the module (see the Linux kernel source file
76 include/linux/module.h). ret is set to the size of the mod‐
77 ule_info structure.
78
80 On success, zero is returned. On error, -1 is returned and errno is
81 set appropriately.
82
84 EFAULT At least one of name, buf, or ret was outside the program's
85 accessible address space.
86
87 EINVAL Invalid which; or name is NULL (indicating "the kernel"), but
88 this is not permitted with the specified value of which.
89
90 ENOENT No module by that name exists.
91
92 ENOSPC The buffer size provided was too small. ret is set to the mini‐
93 mum size needed.
94
95 ENOSYS query_module() is not supported in this version of the kernel
96 (e.g., the kernel is version 2.6 or later).
97
99 This system call is present on Linux only up until kernel 2.4; it was
100 removed in Linux 2.6.
101
103 query_module() is Linux-specific.
104
106 Some of the information that was formerly available via query_module()
107 can be obtained from /proc/modules, /proc/kallsyms, and the files under
108 the directory /sys/module.
109
110 Glibc does not provide a wrapper for this system call; in the unlikely
111 event that you need to use it on an old kernel, use syscall(2).
112
114 create_module(2), delete_module(2), get_kernel_syms(2), init_module(2),
115 lsmod(8), modinfo(8)
116
118 This page is part of release 3.53 of the Linux man-pages project. A
119 description of the project, and information about reporting bugs, can
120 be found at http://www.kernel.org/doc/man-pages/.
121
122
123
124Linux 2013-01-27 QUERY_MODULE(2)